[Neuroimaging] Find masked data voxel coordinates in the original Nifiti structure

Jingyi Wang jy_wang at ucsb.edu
Fri Nov 4 19:31:53 EDT 2022


Dear all,

I computed a vector that each element in the vector corresponding to each
voxel in my mask. I want to find out a way to put those values back to
Nifiti data structure in the original mask file space.

The total number of elements in the vector is exactly the same as the
number of voxels in my mask. I used "nib.load" from the nibabel package to
get the data for the whole brain time series. I load the mask file using
"image.load_img" from the nilearn package, then mask the whole brain time
series using "apply_mask" from the nilearn package. After masking, I got a
2D matrix with each column in the matrix corresponding to a voxel in the
mask region. Then I did some computations to this 2D matrix that reduced
this matrix into a vector, which the index of each element correlates with
the original 2D matrix column index.

I am trying to find whether there is a command that allows me to find the
coordinates in Nifiti structure data for each column (that corresponds to
the voxel) in the 2D matrix (that I got from "apply_mask").

I also tried the command "new_img_like", but failed as I don't know how to
find the element coordinates to the original 3D numpy array.

Thanks in advance!

Jingyi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/neuroimaging/attachments/20221104/272b7086/attachment.html>


More information about the Neuroimaging mailing list