find shortest distance to skull surface


I have a dataset of anatomical T1 images (and resting state) data from a transcranial magnetic stimulation (TMS) study. On each skull is affixed a fiducial marker positioned were the TMS stimulator was positioned. I am trying to do two things:

  1. find the distance from the cortical location targeted by TMS to the closest point on the skull, so I can calculate the difference between the actual TMS position and the to the closest point on the skull to the location of the targeted cortex.
  2. I also want to find the find the closest point on the cortical surface to the fiducial marker, so I can place a spherical ROI.

I have imported the structural data from freesurfer and used the @SUMA_Make_Spec_FS to bring it into afni. My thought was to use a spherical ROI that has a radius large enough to intersect the gray matter mask, and then search for the path that has the shortest euclidean distance between the voxel used for the center of the fiducial marker, and the intersection of the two masks. This seems pretty clunky and I was wondering if there is a way to "grow a sphere from a point (voxel), and find when it intersect with a mask, assuming they are in the same space.

Please excuse my ignorance and thanks for any help you can provide.


Your clunky way doesn’t look too bad to me, but I tend to like clunky (even better - “kludgey”). 3dLocalstat could be used using that volumetric approach. Another way to relate volumetric data to surfaces is with 3dVol2Surf or with the interactive plugin, Vol2surf. The plugin modifies what gets sent to suma to color the surface there. I recommend playing with the plugin to get a feel for the options and then automating this with the command line program.