rii-mango / NIFTI-Reader-JS

A JavaScript NIfTI file format reader.
MIT License
136 stars 25 forks source link

Is it possible to get an specific slice of a NIFTI image? #9

Closed AlejandraM97 closed 1 year ago

AlejandraM97 commented 3 years ago

I would like to extract a 4d NIFTI image using NIFTI-Reader-JS so I could convert each slice into Base64. I have a 4D NIFTI Image with these dimensions in particular: Image Dimensions (1-8): 4, 216, 256, 10, 30, 1, 1, 1. I would like to extract this slice: [1,216,256,2,30] so I can iterate through 30 frames in order to convert each one into Base64. Is that possible?

Your help will be greatly appreciated, thanks very much in advance! Thanks, AlejandraM97

kmannislands commented 2 years ago

@AlejandraM97 seems the library doesn't consider this to be part of its scope. Beyond de-compressing the voxel data and reading the header, NIFTI-Reader-JS isn't particularly helpful here.

I think what you want is basically an ND Array in javascript to index into the slices without thinking much about the dimensions.

Unfortunately, the js ecosystem doesn't have a clear winner there like numpy in the python world, but there are options.

neurolabusc commented 1 year ago

As @kmannislands notes, this issue is out of scope for this library.

However, @znshje provides sample code for issue 18. See brain-tumor repository for an example.