cornerstonejs / cornerstone-nifti-image-loader

Nifti image loader module for cornerstone/ohif viewer
MIT License
56 stars 27 forks source link

RGB24 Niftis #14

Open tpenzkofer opened 4 years ago

tpenzkofer commented 4 years ago

Hi, thank you for this great implementation! I tried loading RGB24 (fused axial PET/CT) images using cornerstone-nifti-loader, but apparently the current loading mechanics do not support this image type (128), especially in

function niftiDatatypeCodeToTypedArray(nifti, datatypeCode) { var _typedArrayConstructo;

var typedArrayConstructorMap = (_typedArrayConstructo = {}, _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_UINT8, Uint8Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_UINT16, Uint16Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_UINT32, Uint32Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_INT8, Int8Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_INT16, Int16Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_INT32, Int32Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_FLOAT32, Float32Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_FLOAT64, Float64Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_RGB, Uint8Array), _defineProperty(_typedArrayConstructo, nifti.NIFTI1.TYPE_RGBA, Uint8Array), _typedArrayConstructo);

return typedArrayConstructorMap[datatypeCode]; }

nifti.NIFTI1.TYPE_RGB24 is not among the supported datatypes. Is there a way to have the loader support RGB24 (datatype=128) .nii files?

Thank you, T

tpenzkofer commented 4 years ago

update: added RGB24 as Uint8Array and reordered imageData from 24 bit RGB to 32 bit RGB , unfortunately the output now looks like this, any ideas how to adjust the slicing?

Screen Shot 2020-04-07 at 01 00 20

albagarrey commented 1 year ago

@tpenzkofer thanks for the reporting. Could you share how you converted RGB24 as Uint8Array and how you reordered imageData from 24 bit RGB to 32 bit RGB? Thanks a lot!