Pulling ICA network from nifit file on nibabel

I have a nifti file with the following colormap.

0 NONE 0 0 0 0
1 7Networks_1 120 18 134 0
2 7Networks_2 70 130 180 0
3 7Networks_3 0 118 14 0
4 7Networks_4 196 58 250 0
5 7Networks_5 220 248 164 0
6 7Networks_6 230 148 34 0
7 7Networks_7 205 62 78 0

Once I load the file with nibabel.load() then get_fdata() how can I pull the MNI coordinate of a voxel with one of those values?

you can go from voxel indices to millimeters by multiplying by the inverse of the image affine matrix


Thank you I am not trying to go from MNI to millimeters and I understand how to transform between them I am trying to get separate networks out so I want the set of voxels considered to be a part of each of these networks as a list or array.

In this case since ICA components are continuous maps you need to threshold them and identify connected components in the thresholded maps. you can do it easily using nilearn.regions.RegionExtractor:
see these examples: https://nilearn.github.io/auto_examples/03_connectivity/plot_extract_regions_dictlearning_maps.html and https://nilearn.github.io/auto_examples/04_manipulating_images/plot_extract_rois_smith_atlas.html

1 Like

What if I don’t have an image affine? I have a set of real mri coordinates and a set of MNI coordinates can I calculate the affine from that data to go to mm space?

As far as I know the registration of the MRI image to the MNI template is not necessarily affine?