gallantlab / pycortex

Pycortex is a python-based toolkit for surface visualization of fMRI data
https://gallantlab.github.io/pycortex
BSD 2-Clause "Simplified" License
579 stars 137 forks source link

compute sulcal depth #32

Open alexhuth opened 10 years ago

alexhuth commented 10 years ago

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.

alexhuth commented 10 years ago

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)