# How to find MNI coordinates of ROIs in Glasser atlas

I’m looking for the MNI coordinates of the centroid of each ROI in the Glasser360 atlas. I have the atlas in MNI space, glasser360MNI.nii.gz, from GitHub:

How can I find the MNI coordinate of each ROI?
Thanks,
Shane

In AFNI, you can use 3dCM to get the center of mass of a mask/region. There are a few options for what kind of center of mass to use. With no options, it is literally the center of mass, but that can actually be outside of the region itself (consider a donut—it’s center of mass is in the empty middle). Two other options are:

``````  -Icent :Compute Internal Center. For some shapes, the center can
lie outside the shape. This option finds the location
of the center of a voxel closest to the center of mass
It will be the same or similar to a center of mass
if the CM lies within the volume. It will lie necessarily
on an edge voxel if the CMass lies outside the volume

-Dcent :Compute Distance Center, i.e. the center of the voxel
that has the shortest average distance to all the other
voxels. This is much more computational expensive than
Cmass or Icent centers
``````

You can also use selectors to specify the ROI value of interest.

Therefore, for region #4, you could use perhaps:

``````3dCM -Icent glasser360MNI.nii.gz"<4>"
``````

The coordinates will be reported in RAI-DICOM notation by default, meaning that right/anterior/inferior locations are negative. You can change that, if you want, via the option:

`````` -rep_xyz_orient RRR :when reporting (x,y,z) coordinates, use the
specified RRR orientation (def: RAI).
NB: this does not apply when using '-local_ijk',
and will not change the orientation of the dset
when using '-set ..'.
``````

The ROI values in the region appear to go from [1, 360] with no gaps, so in tcsh, you could do this to store everything in a 4 column file (one column of ROI numbers and 3 cols of coords):

``````#!/bin/tcsh

# name output text file, and make it clean
set file_out = my_file.txt
printf "" > \${file_out}

# loop over all ROIs
foreach val ( `seq 1 1 360` )
set coords = `3dCM -Icent glasser360MNI.nii.gz"<\${val}>"`
echo "++ region \${val} -> \${coords}"

# record output in nicely aligned columns
printf "%3d %8.3f %8.3f %8.3f\n" \${val} \${coords[1]} \${coords[2]} \${coords[3]} >> \${file_out}
end
``````

–pt

Note, that because that glasser360MNI.nii.gz dataset has datatype float-64 for some reason, AFNI will whine a bit with something like:

``````** AFNI converts NIFTI_datatype=64 (FLOAT64) in file glass_neuro/glasser360/glasser360MNI.nii.gz to FLOAT32
``````

That isn’t a problem here because the max value is 360, and so it isn’t being truncated here or converted with data loss (no rounding even happens because it’s int, not float, valued).

If you wanted to, you could use nifti_tool to pre-convert the dataset to a more common datatype, such as float-32:

``````nifti_tool \
-copy_image \
-convert2dtype NIFTI_TYPE_FLOAT32 \
-infiles glasser360MNI.nii.gz \
-prefix glasser360MNI_float32.nii.gz
``````

… or in this case it could certainly be converted to an INT16 or something.

–pt

This worked perfectly, thank you!

Hi,
you can also use the following function in Nilearn:

Best,
Bertrand