# Distance between two sets of MNI coordinates

Hi experts,

Is there a function in AFNI to calculate the distance between two MNI coordinates in volumetric space (not surface)? For example, I’d like to calculate the distance between ROI 1 (-68.3,-41.41,-5.14) and ROI 2 (-60.48,-25.22,13.82).

Jenna

Hi, Jenna-

I am not aware of a tool to do this. The hardest part is picking a single point from each ROI (which is an extended volume, potentially of wildly weird shape) from which to calculate distance? I imagine center of mass or some kind of central point would be used, but consider how different distance might be interpreted, whether it was between two spheres or two octopuses with tenacles extended toward each other—what is the distance in the latter?

Once you do have a single point defined for each ROI A and B, the geometric distance would be the square root of the sum of squares across the components:
dist(A, B) = sqrt{ (A_i - B_i)^2 + (A_j - B_j)^2 + (A_k - B_k)^2 }

Note that with diffusion data 3dTrackID does have distance-measuring output, using the estimated bundle lengths (BL). You can control what it means to be a tract “between” ROIs, which exhibits some of the points noted above:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/FATCAT/Tracking.html#using-target-surfaces-to-control-tract-trimming

–pt

You may want to take a look at the script in this previous thread that includes an example ccalc command to include distance.