Creating spherical ROI from MNI coordinates

Hi all,

I am conducting a resting state fMRI analysis. I preprocessed the data using fMRIprep and denoised the data using AFNI. I would like to create 264 spherical ROIs centered around the MNI coordinates provided by Power et al. (2011;

My preprocessed images are in MNI space (MNI152NLin6Asym) with 2x2x2 mm resolution. To create each ROI, I used the following code with 3dUndump:
3dUndump -prefix ${name}.nii.gz -master sub-001_task-rest_space-MNI152NLin6Asym_res-2_desc-preproc_bold.nii.gz -srad 5 -xyz -24.66 -97.84 -12.33

Can I use the MNI coordinates directly from the paper to create each spherical ROI (as done above)? Or do I need to do an intermediate step to transform the coordinates to my image space?

Thanks in advance,

Hi, Jenna-

I’m not quite sure I understand the question, about what transform might be needed?

The one thing to change would be that “-xyz” is not an option that should be followed by coordinates, but it is a flag, signifying:

-xyz         = Coordinates in the input file are (x,y,z)
                   spatial coordinates, in mm.  If neither
                   -ijk or -xyz is given, the default is -ijk.

The coordinates should be in a 3 column text file (or, a 4 column text file, if you want to provide a value for each ball, which I guess you would want since you have many coords?). So:

3dUndump -prefix ${name}.nii.gz -master sub-001_task-rest_space-MNI152NLin6Asym_res-2_desc-preproc_bold.nii.gz -srad 5 -xyz INFILE

… where INFILE contains your coord columns. The first 3 columns are your x, y and z coords; a fourth column would be interpreted as a value for that ROI, and a fifth column would be the radius of that ball (if they different, and then you wouldn’t include ‘-srad …’).

The one other thing you will likely want to consider is that, by default, the program will assume your coordinates are described with coordinate orientation matching the “-master …” dset. I am not sure how the authors describe their coordinates, but it might not match the dataset orientation. So you might also have to add a “-orient …” option to specify what the signs on the coordinates mean. Following the DICOM standard, AFNI interprets RAI as meaning that: a negative x value is on the right side (and a positive x on the left side), a negative y value is anterior, etc.


Hi Paul,

Thanks for the detailed response. For the xyz flag, I fed in one text file per ROI which had 3 columns corresponding to the x,y,z coordinates provided by Power. So, I believe this aligns with your suggestion.

Power’s readme file states the following, “All analyses were done in 3mm isotropic voxels in the “KY” atlas at Washington University, using the 4dfp format. The MNI is a linear transform into MNI152 space, as are the coordinates in the .xlsx. I don’t have a .nii of the 264 ROIs to distribute: your coordinates may differ, as may your resolution/sphere size. I tell people to create spherical ROIs at the coordinates, once transformed into your space to your satisfaction.” Given this information, can I use the MNI XYZ coordinates directly from the Power file with 3dundump to create ROIs in my data?

Given that my data has 2mm isotropic voxels compared to Power’s 3mm space, will this change the voxel coordinates (centers) at all?

The orientation was not provided in the manuscript but a supplementary file with data in MNI space suggests LPI data were used. My data is also in LPI orientation. Does using the -master flag read the orientation from my input dataset and use this to interpret the signs of the coordinates?


Hi, Jenna-

It wouldn’t surprise me if that paper’s coordinates were specified in LPI orientation. If there are meaningful names for each location, that might help verify that “left” has a negative x-value, for example. I wish more authors provided that useful nugget of information, though… These are the rules about the interpretation of the xyz coordinates:

-orient code = Specifies the coordinate order used by -xyz.
                   The code must be 3 letters, one each from the pairs
                   {R,L} {A,P} {I,S}.  The first letter gives the
                   orientation of the x-axis, the second the orientation
                   of the y-axis, the third the z-axis:
                     R = right-to-left         L = left-to-right
                     A = anterior-to-posterior P = posterior-to-anterior
                     I = inferior-to-superior  S = superior-to-inferior
                   If -orient isn't used, then the coordinate order of the
                   -master dataset is used to interpret (x,y,z) inputs.

I think I might still use “-orient LPI” explicitly, for stability, in case someone adapts your script elsewhere with a different template, or something.

The file you provide can have more than one row, which is what I would use, rather than many text files or many calls to the program.

I have never heard of that atlas, so I don’t really know what space it is in—it is slightly unclear to me what the final space is, but it is probably/hopefully the MNI152 space? The AFNI @SSwarper MNI template, MNI152_2009_template_SSW.nii.gz, is in MNI-152 space.

I believe the point of that paragraph is that users should make spheres around the specified locations on whatever grid they are using, to avoid having to regrid. Note that the output “spheres” may not look perfectly spherical or symmetric, because I might guess that the locations won’t sit exactly at the centroid of a voxel. So yes, using 3dUndump with those locations is likely the best/only want to go.

I guess many questions will be empirically by making the spheres, and visually verifying that they ~fill the brain template space. Hopefully ROI names can also verify the orientation information.


One point about the coordinates (one that I should probably fix so that this point doesn’t need to be made) is 3dUndump always reads in coordinates in the “master” dataset’s storage orientation. So if you want to use RAI coordinates, you can create a dataset in RAI storage orientation with “3dresample -orient RAI”; likewise, for LPI order, the most commonly used order in publications.

Thanks Paul and Daniel for your replies! They were very helpful.

Daniel - I just want to make sure I understand. Say you were going to use the master flag in 3dUndump as follows:

3dUndump -prefix ${name}.nii.gz -master sub-001_rest_bold.nii.gz -srad 5 -xyz INFILE

where the sub-001_rest_bold file had an RAI orientation but the coordinates were supplied from LPI orientation.

Considering that the orientation of the coordinates is interpreted by the orientation of the master dataset, does this mean that I would need to reorient (3dresample -orient LPI) my dataset prior to running 3dUndump?


That’s right. Resample the dataset to a temporary master dataset with the coordinate order you have. Only a single subbrick volume dataset is needed. You could reorder the coordinates too, but it’s easier this way.