cortex.polyutils.Surface.geodesic_distance

Surface.geodesic_distance(verts, m=1.0, fem=False)[source]

Minimum mesh geodesic distance (in mm) from each vertex in surface to any vertex in the collection verts.

Geodesic distance is estimated using heat-based method (see ‘Geodesics in Heat’, Crane et al, 2012). Diffusion of heat along the mesh is simulated and then used to infer geodesic distance. The duration of the simulation is controlled by the parameter m. Larger values of m will smooth & regularize the distance computation. Smaller values of m will roughen and will usually increase error in the distance computation. The default value of 1.0 is probably pretty good.

This function caches some data (sparse LU factorizations of the laplace-beltrami operator and the weighted adjacency matrix), so it will be much faster on subsequent runs.

The time taken by this function is independent of the number of vertices in verts.

Parameters
verts1D array-like of ints

Set of vertices to compute distance from. This function returns the shortest distance to any of these vertices from every vertex in the surface.

mfloat, optional

Reverse Euler step length. The optimal value is likely between 0.5 and 1.5. Default is 1.0, which should be fine for most cases.

fembool, optional

Whether to use Finite Element Method lumped mass matrix. Wasn’t used in Crane 2012 paper. Doesn’t seem to help any.

Returns
1D ndarray, shape (total_verts,)

Geodesic distance (in mm) from each vertex in the surface to the closest vertex in verts.