Does this function plot_roi(img, cut_coords, title) transform the coordinates to be in the same space as image before plotting?

nilearn
fmri
nifti
python
#1

As far as i know affine matrix in niftii format describes the position of the image data in a reference space. lets say i need to mark coordinates for example (28, 42, 22). i should first transform this coordinate to be in the same domain space as the image. to do that we multiply the coordinate with affine matrix to get the new coordinates and the output was (31, 84, 47). my question is. does this function plot_roi(img, cut_coords, title) transform the coordinates before plotting? because as i can see this function take the image, coords and title.
this may be a dumb question but i really need an answer.
Thanks in advance

#2

Hi,

Your images need to be registered to MNI space to capitalize with the cut_coords argument.

If images are in MNI space, then simply give cut_coords=(28, 42, 22) does the job. You can tell what this image is briefly by giving it to title. title=“Your image description”

1 Like
#3

The affine matrix describes the image itself, it gives the position of each
voxel in some spatial referential, like MNI space:
affine.dot((i, j, k, 1)^T) = (x, y, z, 1)^T
it maps voxel indices to coordinates in millimeters.
you can find more details in this example:
https://nilearn.github.io/auto_examples/04_manipulating_images/plot_affine_transformation.html#sphx-glr-auto-examples-04-manipulating-images-plot-affine-transformation-py
If the coordinates are in the same space as the image, then you can just give
them to plot_roi to choose the slice, or to a nilearn display’s add_markers
function. If they are not in the same space, for example if the coordinates are
in MNI space and the image in a different space, you need to register the image
with a different tool before using nilearn (nilearn does not handle
preprocessing).

1 Like
#4

thanks for the answer one more question is there a way to know what space does the image fall in?

#5

do you mean to know if the image has been registered to MNI space?
you could plot it overlaid with the MNI template or MNI mask image available in nilearn.datasets to check if they are aligned.
If not, you will need to use a tool that can perform registration such as fmriprep

#6

If you use cut_coords=(0, 0, 0) and the position is at AC-PC line then the images are in MNI space. That’s one of simple way to know what space the images fall in.