cortex.freesurfer.SpringLayout

class cortex.freesurfer.SpringLayout(pts, polys, dpts=None, pins=None, stepsize=1, neighborhood=0)[source]

Relaxes a mesh’s vertex positions using a spring-force model, where each edge acts as a spring with its rest length set by the distance between the corresponding vertices in a (possibly different) reference mesh dpts.

Parameters:
ptsndarray

Initial vertex coordinates to relax.

polysndarray

Triangle faces defining the mesh’s edges/springs.

dptsndarray, optional

Vertex coordinates used to set each spring’s rest (target) length. Defaults to pts, i.e. the mesh starts at its own rest lengths.

pinsarray-like, optional

Indices of vertices that should remain fixed (not moved) during relaxation.

stepsizefloat, optional

Step size used to scale vertex movement at each iteration. Default 1.

neighborhoodint, optional

Number of times to expand each vertex’s neighbor set by one more hop, widening the set of springs attached to it. Default 0 (immediate mesh neighbors only).

__init__(pts, polys, dpts=None, pins=None, stepsize=1, neighborhood=0)[source]

Methods

__init__(pts, polys[, dpts, pins, stepsize, ...])

run([n])

step()

view_step()