# Distance between 2 coordinates via brain cortex

Dear AFNI expert

I want to estimate the distance between 2 coordinates (points, not ROI) on brain surface in MNI standard space, such as distance between hand area (-38 -29 54) in motor cortex and leg area (-2 -20 60) in motor cortex by passing through only grey matter, rather than direct shortest length.
Is there any way to estimate distance? Maybe using SUMA?

Thank you.

Neuro

Dear Neuro-

I think SurfDist is the program for you!

–pt

Thank you for comment. I checked SurfDist script, but I could not figure out how I should make command. I would like to measure distance between MNI coordinates (-38 -29 54) and (-2 -20 60) via grey natter in MNI brain. How should I write script? Could you give some example? Thank you for help.

Neuro

What surface(s) do you have, and what did you try as a command?

–pt

I tried
SurfDist -i_mni -38 -29 54, -2 -20 60
But, it did not work. How should I give MNI coordinates to measure distance? Thank you for help.

Neuro

Hi, Neuro-

You would first have to convert the coords to indices; the program to do that is:

``````
Surf2VolCoord -i std.60.lh.pial.gii -i std.60.rh.pial.gii -sv MNI152_2009_SurfVol.nii -qual LR -closest_nodes XYZ.1D

``````

where XYZ.1D is:

``````
-38 -29 54
-2 -20 60

``````

… which is assumed to be in DICOM (=RAI) coordinates. The output of that command is:

``````
11496R 1.730468
16730R 1.010598

``````

which tells you the index node number (e.g., “11496”), the letter of which surface it was (“R” here means the second surface, because it was the second letter of the “-qual …” argument), and the distance between my entered XYZ coordinate and the given index.

Then, you can put the node indices of interest into a text file in two columns, calling it say “nodelist.1D”:

``````
11496  16730

``````

and then calculate the distance between the points:

``````
SurfDist -i std.60.rh.pial.gii -input nodelist.1D -Euclidian

``````

… which produced thef ollowing output:

``````
#Internodal euclidian distance for surface std.60.rh.pial.gii
#A distance of -1 indicates an error of sorts.
#From   to     eDist.
11496  16730  37.23

``````

–pt

Thank you for reply. I acutually several reported coordinates in both Talairach space and MNI space from literatures. For example, -54 -6 26 in Talairach and -2 -20 60 in MNI space. How should I handle these coordinates in different space? Hopefully, I want to calculate distance among several coordinates in MNI space? Is there any good way to convert Talairach coordinates to MNI coordinate which is suitable for AFNI and SurfDist?
Thank you for help.

Neuro

Hi, Neuro-

It’s a bit hard for me to see what it would mean to calculate distances between locations in different spaces… I guess you have some ROI/location defined in one space, and another defined from another study in another space?

A few things to note; we have standard meshes for different standard spaces available, including MNI and Talairach-Tournoux:
https://afni.nimh.nih.gov/pub/dist/tgz/suma_MNI152_2009.tgz
https://afni.nimh.nih.gov/pub/dist/tgz/suma_MNI_N27.tgz
https://afni.nimh.nih.gov/pub/dist/tgz/suma_TT_N27.tgz

Once you find the node index associated with a coordinate location in one space, you can use that node index on any AFNI/SUMA-standardized mesh and it should refer to the same anatomical location in that brain-- that is what it means to be on a “standardized” mesh. This hsould provide you what you need:

• find the index for some locations in whatever coordinate space you want, and then
• calculate the distance between your desired index pairs on any of these standardized meshes, in your desired coordinate space.

Just make sure that you know what system your coordinates are defined in-- again, the default is DICOM (=RAI), but you can also flag to use other coord systems.

–pt

Dear Ptaylor

Thank you for comment.
For example, I have coordinate (-54 -6 26) in Talairach Space. I also have cooridinate (-2 -20 60) in MNI space.
How should I convert this coordinate to new coordinate in a “standardized” mesh to measure distance on Surface?

I know that Surf2VolCoord has option such as -LPI. Should I use -LPI for MNI coordinate? How about coordinate in Talairach space?
Thank you for help.

Neuro

The previous message in the thread had links for the SUMA surfaces of both TT_N27 (Talairach space) and MNI space brains, so that would suit your needs.

What commands did you try so far?

–pt

Dear Ptaylor

I did
Surf2VolCoord -i std.60.lh.pial.gii -i std.60.rh.pial.gii -sv MNI152_2009_SurfVol.nii -qual LR -closest_node ‘-38 -29 54’
11496R 1.730468

MNI coordinate ‘-38 -29 54’ is actually located in left hemisphere. But, Surf2VolCoord said 11496R, meaning right hemisphere.

I converted several coordinates by Surf2VolCoord like above. But, it said all opposite hemisphere in comparison to true hemisphere.
What is the problem?
Thank you for help.

Neuro

Hi, Neuro-

This is a confusing point, and a good one to be cautious about in both analysis and report results. Namely, there are multiple coordinate notations in neuroimaging, and the sign is not enough for any (x, y, z) coordinate location to specify “left” or “right” for x, etc.

There are 2 main coordinate conventions: RAI (DICOM) and LPI (often called “SPM” coordinates because they use that). In AFNI, by default, we use the RAI/DICOM convention, so that: negative x coords are to the R, negative y coords are to the A, and negative z coords are to the I; positive x coords are to the L, etc.

So, whenever you are specifying a coordinate value, you need to also provide which coord system you are using: RAI or LPI (or something else). In AFNI, typically if nothing else is specified, you are in RAI coords (unless you have set an env variable to be otherwise). This seems to address your issue at present.

Note that in reporting in a paper, it would be more clear/helpful to the reader to point to “(47R, 13P, 7S)” than to “(-47, 13, 7) in RAI coordinates”.

Note also that other software might deal differently with coordinate systems and reporting (sigh), so it is always good to be explicit as possible.

–pt

Dear Ptaylor

Thank you for reply. I added -LPI in my script. It indicated reasonable side of hemisphere.

I have 2 coordinates, and one is in TT space and the other is in MNI space.

For example,

I did
Surf2VolCoord -i std.60.lh.pial.gii -i std.60.rh.pial.gii -sv TT_N27_SurfVol.nii -LPI -qual LR -closest_node ‘48 -4 47’
13020R 1.585939
and
Surf2VolCoord -i std.60.lh.pial.gii -i std.60.rh.pial.gii -sv MNI152_2009_SurfVol.nii -LPI -qual LR -closest_node ‘35 -26 59’
14278R 0.921334

Then, I went to suma_MNI152_2009 folder.

I did

SurfDist -i std.60.rh.pial.gii -input nodelist.1D -Euclidian
#Internodal euclidian distance for surface std.60.rh.pial.gii
#A distance of -1 indicates an error of sorts.
#From to eDist.
13020 14278 36.99

So, does this mean distance between 2 coordinates in MNI brain surface?

I want to visualize what distance SurfDist actually measures. So, should I add “-node_path_do PATH_D”? I actually did, but I could not see it.

Thank you for help.

Neuro

Hi, Neuro-

The parts preceding your SurfDist command seem correct.

Re. the SurfDist command:

• “-i std.60.rh.pial.gii” does, indeed, specify the surface on which your node indices will be located.
• why do you want “-Euclidian”? That would be the distance between the two points as a straight line not constrained to the surface. From previous questions, I would assume you want “-Graph” (or, just not putting either of these options, because “-Graph” is the default)?
• the previous point probably relates to why nothing shows up with outputting a path, because you have not estimated distance along a path.

So, I ran (where “nodelist.1D” just contains “13020 14278”, which I believe are your two node indices of interest):

``````
SurfDist -i std.60.rh.pial.gii -input nodelist.1D -node_path_do PATH_DO

``````

… which produced the following text output:

``````
#Internodal distance along graph of surface std.60.rh.pial.gii
#A distance of -1 indicates an error of sorts.
#From   to     gDist.
13020  14278  55.87

``````

→ note how the distance along the surface is longer than the Euclidean distance, which makes sense-- dist_euclidean has to be less than or equal to the dist_alongsurf.

I could then view the PATH* as follows:

``````
suma -onestate -i std.60.rh.pial.gii -sv MNI152_2009_SurfVol.nii &
DriveSuma -com viewer_cont -load_do PATH_DO.1D.do

``````

Note: are you sure you want to use the pial surface for calculating distance? That is the “outer” GM boundary; it can be fine, but you have to choose whether you want the grey-white boundary, or the pial.

–pt

Dear Ptaylor

Thank you for reply.
I just want to make sure that 13020 comes from TT space and 14278 comes from MNI space. Can I use 13020 and 14278 in the same SurfDist script? Are 13020 and 14278 already in same space?

Thank you for your clarification.
I actually want to measure distance of abnormal protein propagation pathway from one grey matter area to the other grey matter area possibly via adjacent neural fibers.
So, I guess that distance via grey-white boundary is close to my expected propagation pathway. I am happy to have your recommendation if you know more suitable model.
In any case, how should I modify SurfDist script?
Thank you for your help.

Neuro

Hi, Neuro-

I understand that question-- the important point to note is that the std.* meshes in SUMA are named that way because they are standardized: that is, the std.60.* meshes across subjects all have the same number of nodes, and a node of a particular index should correspond to the same physiological location (plus/minus some registration error) across all the subjects. The same is true of the std.141.* meshes, just with a higher number of nodes per brain. The std.60.* meshes correspond roughly to a typical spacing of EPI volumetric data, and the std.141.* meshes correspond roughly to a similar spacing of typical anatomical volumes.

You have used different templates to identify node locations, sure, but each of those meshes were standard, std.60* meshes, so the same node location should be identifiable. And therefore, you can take those node indices to any other std.60.* mesh and talk about it equivalently.

Hope that helps.

–pt

Dear Ptaylor

Thank you for your clarification.
I need high spatial resolution to discuss distance of 2 points such as 0.1mm order. Do you know how much resltuion std.60 and std.141 has? Approximate number would be fine.

In addiiton, I actually want to measure distance of abnormal protein propagation pathway from one grey matter area to the other grey matter area possibly via adjacent neural fibers.
So, I guess that distance via grey-white boundary is close to my expected propagation pathway. I am happy to have your recommendation if you know more suitable model.
In any case, how should I modify SurfDist script?

Thank you for your help.

Neuro

Hi, Neuro-

The std.60* has a resolution typical of EPI data (~3mm edges) and the std.141* has resolution typical of anatomical data (~1mm edges). Again, these are quite approximate and not constant. So, you could repeat the above steps wtih std.141* surfs instead of std.60 ones—note that you can’t mix the resolutions of the surfaces in different steps here!

… However, regarding the distance scale that you would like to resolve: umm, did you acquire your data at a super-high resolution? Most anatomical vols put into FS are acquired with a voxel size of about 1 mm isotropic voxels; maaaaybe some folks get 0.75 mm isotropic or slightly higher. And voxel size determines the minimal possible scale of distances you could measure, under ideal circumstances—note that all MRI has noise, and all algorithms are imperfect, sooo, I don’t see how distances that are an order of magnitude (about 10 times) smaller than acquired voxel size could be resolved.

For the grey-white boundary, you might want the WM surface (std..white.gii) or the smoothed version of that (std..smoothwm.gii) instead of std.*.pial.gii; the numbers for either of those WM surfs will be quite similar.

–pt

Dear Ptyalor

Thank you for your reply. My coordinates come from the previous literature by using task-based fMRI. So, original resolution should be std.60*. I calculated the distance by using std.141*, just in case.

By the way, what is the unit for gDist. Is that mm in standard space?
Thank you for help.

Nuro

Hi, Neuro-

Unless otherwise specified, all distances in AFNI-land are in units of ‘mm’.

And those millimeters are measuring out a distance on whatever mesh you are using.

–pt