This is a reduced procedure, not a complete reproduction of any
particular reference implementation. The full unfolding procedure
described in the literature integrates seven weighted energy terms against
a separate reference surface through a multi-resolution, multi-thousand
line optimization pipeline, which is out of scope for this package. Instead,
this implementation keeps the two dominant terms and integrates them with
the same momentum-based machinery mris_inflate uses:
- Distance term (
l_dist)
Restoring force pulling each vertex
back towards the input mesh's own original distances to its
neighbors.
- Area term (
l_area)
Repulsive force that acts only on
folded/negative-area faces, pushing their vertices apart - this is the
actual "unfolding" mechanism.
Both terms are integrated via momentum integration with gradient averaging
and a 1 mm per-step displacement cap, exactly as mris_inflate
does.
A further simplification: the reference procedure relaxes a freshly
spherical-projected surface against a separate, previously-loaded
white-matter reference surface for the distance term; since this function
takes a single mesh as input, the input mesh's own metric (captured before
projection) is used as the reference instead - the same convention
mris_inflate already uses, and the practical analogue (the
white-matter surface is normally what gets inflated to produce a typical
input to this kind of unfolding step).