Hi everyone, I am trying to extract the intensity (and the coordinates) values of a set of nifti images to a csv file. The first two columns of the csv file should be the coordinates while the third column should be the image intensity. I intend doing this jupyter notebook. Your kind guidance would be appreciated. Thanks.
Would you need this for every voxel in your image? If so, I suppose you can load your image into nilearn with nilearn.image.load_img, extract the intensities from the object (I believe the object you load with
load_img has a property
.data which would return the intensities), then the I,J,K of your index into the data matrix can be converted to an X,Y,Z of the image by multiplying the I,J,K by the voxel size dimensions (i.e., X position = J * voxel size in X dimension). Then add the end, you may have to center the X Y and Z values so that the origin is in the center.