[Neuroimaging] Looping through 3D NIFTI Image: Help
Jose Rey López
jxrel at hotmail.com
Fri Jan 4 12:29:44 EST 2019
Using nilearn you could do:
niimage = nilearn.image.load_img(‘path’)
Voxels = niimage.get_data()
You get a numpy array, with Voxel[i,j,k] would allow you to access any voxel
Voxels[:,x,y] to acces a single line
Voxels[:,:,x] to access any slice
Or to iterate over all voxels
for i ....
for j ....
for k .....
Voxels[i,j,k]
On 4 Jan 2019, at 17:58, Arnav Lohe <arnavlohe15 at gmail.com<mailto:arnavlohe15 at gmail.com>> wrote:
Dear Neuroimaging List Members,
My name is Arnav Lohe, and I am a junior at Rutgers University working on a neuroimaging project. I want to write an original piece of code to calculate the total tissue volume in a (.nii) MRI image, and to do this I need to loop through the multidimensional array. The loop is what I do not know how to do. I tried triple indexing, I tried converting the .nii image into a numpy array, and got nowhere with my approaches. Does someone know how to loop through the individual voxels and extract the numerical information inside each one?
https://stackoverflow.com/questions/54031899/how-can-i-loop-through-3d-nifti-image-in-python
I have also posted this to StackOverflow, all additional relevant details should be there.
Sincerely,
Thanking you,
Arnav Lohe
_______________________________________________
Neuroimaging mailing list
Neuroimaging at python.org<mailto:Neuroimaging at python.org>
https://mail.python.org/mailman/listinfo/neuroimaging
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20190104/b2ce5433/attachment.html>
More information about the Neuroimaging
mailing list