Point to ROI distance

Hello! I am wondering the best course of action to determine the shortest Euclidean distance from a 3d point to the nearest edge of an anatomical ROI. Thanks in advance!

3dDepthMap provides the distances - voxel center to voxel center. Given a single region, distance outside the region can be expressed as negative values with the -zeros_are_neg option. If you want to know where the closest point is in the region, that can be done with an extra couple steps.

Hi Daniel,

Thank you for the suggestion. There are a few things I'm a bit confused about with 3dDepthMap. I'm trying to find the distance from a point outside of an ROI to the nearest point on the boundary of the ROI. In terms of program usage, would the ROI be the mask or the input dataset? And how would I pass in my 3d point, does it need to be a dataset/which input argument is it?

Thank you!

Hi-

By default, the distance to the nearest ROI or mask edge is calculated everywhere in the input dataset, even in the zeros outside the mask/ROI.

For example, here is an example command calculating depth in and outside a brain mask:

3dDepthMap -input mask.auto.nii.gz -prefix DEPTH.nii.gz

So, if I underlay the brain mask and overlay the DEPTH.nii.gz dset and click somewhere outside the brainmask, you can see that there is nonzero distance value stored in the latter (in this case, 14.34 mm):

So, you can use 3dDepthmap to get the depth dataset, and then get the value anywhere at your point of interest, inside or outside the dataset.

--pt

Thank you so much for the clear explanation, this makes perfect sense.