I need to compute the pairwise distance between every combination of nodes on a Freesurfer surface. I would like to be able to get both the Euclidean distance and the distance along the mesh. I can get the Euclidean distance by loading the surface into Matlab and using the coordinates, but how can I get the distance along the mesh? I wrote a little wrapper for SurfDist that can probably do it, but that seems a bit slow for a problem of this scale.

Any suggestions? I would be happy to use an external Matlab toolbox, if that is the easiest.

I need to compute the pairwise distance between
every combination of nodes on a Freesurfer
surface. I would like to be able to get both the
Euclidean distance and the distance along the
mesh. I can get the Euclidean distance by loading
the surface into Matlab and using the coordinates,
but how can I get the distance along the mesh? I
wrote a little wrapper for SurfDist that can
probably do it, but that seems a bit slow for a
problem of this scale.

Any suggestions? I would be happy to use an
external Matlab toolbox, if that is the easiest.

You may also be interested in the surfing toolbox (https://github.com/nno/surfing - I am the main author). It contains the fast marching toolbox code and also some helper functions to read and write surfaces (surfing_read and surfing_write).

thanks for your response, and apologies for not responding sooner. I actually use your surfing toolbox a lot, so I am aware of the perform_fast_marching_mesh function. I was hoping there was an even quicker/easier, perhaps non-Matlab way of doing it.

thanks for your response, and apologies for not
responding sooner. I actually use your surfing
toolbox a lot, so I am aware of the
perform_fast_marching_mesh function. I was hoping
there was an even quicker/easier, perhaps
non-Matlab way of doing it.

When I try to run perform_fast_marching_mesh.m, at the call to perform_front_propagation_mesh, Matlab crashes with a Segmentation Violation error. The compile_mex function runs fine, but I do get a bunch of warnings. Have you got any experience with this problem? I get the same error regardless of what version of the Fast Marching Toolbox I use.

When I try to run perform_fast_marching_mesh.m, at
the call to perform_front_propagation_mesh, Matlab
crashes with a Segmentation Violation error. The
compile_mex function runs fine, but I do get a
bunch of warnings. Have you got any experience
with this problem? I get the same error regardless
of what version of the Fast Marching Toolbox I
use.

I have not encountered this myself. I also use OSX and have used all recent versions of it and don’t remember having issues with compiling. Not sure if it depends on which compiler yo are using.
If you want you can send me your email address and I would be happy to send you my compiled .mexmaci64 files for you to try.

For your application, would it be useful to limit the dyjkstra search to those pairs of nodes that are less than some geometric distance? Geometric distances are very fast to calculate, so if you were interested only in those nodes say some distance apart, then you could cut the number of more complex searches down. Then SurfDist could be more amenable for this.

The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.