pycortex
pycortex copied to clipboard
compute sulcal depth
We should be able to compute sulcal depth from the surfaces without relying on freesurfer. This is the only surface property that we are still relying on freesurfer for.
Ugh freesurfer computes it based on the inflation process, that's not gonna work for us. But we can compute a reasonable facsimile just by taking the distance to the convex hull. This is ridiculously simple, and looks pretty good:
import scipy.spatial
import cortex
pts, polys = cortex.db.surfs.getSurf("S1", "fiducial", "left")
lsurf = cortex.polyutils.Surface(pts, polys)
# Find convex hull
lsurf_tess = scipy.spatial.Delaunay(lsurf.pts)
lsurf_hullpts = np.unique(lsurf_tess.convex_hull)
# Find euclidean distance from each vertex to closest vertex in convex hull
kdt = scipy.spatial.cKDTree(lsurf.pts[lsurf_hullpts])
dist,idx = kdt.query(lsurf.pts)