-----------------------------------------
 The SubjectTools -> Inflate Surface Patch
 (hi-res) inflates (usually 3d) surface patch
-------------------------------------------

This takes a 3d surface patch as an input and
uses the function area_shrink() from tksurfer to
inflate it (Dale and Sereno, 1993).

The output of area_shrink() is similar, tho not
identical to that of mris_inflate.  Note that
mris_inflate which won't accept a cut surface.

The output can be used as a preprocessing stage
before further cutting the surface for difficult
flattenings (e.g., cerebellum).

To use this to inflate a full surface, first
write out a patch from a full surface without
making any cuts.

The output patch file will have "-inflated"
appended after the patch stem.  For example,
assuming we started with a patch made from
smoothwm:

  input -- lh.smoothwm.patch.3d

The output will be named:

  output -- lh.smoothwm-inflated.patch.3d

Each vertex is moved according to a geometry
preserving term that uniformly distributes
vertices in a tangential direction (tangential
vector sum -- strength set by $ws), a term that
reduces curvature (projection of neigbor-vector
sum onto vertex normal -- strength set by $wn),
and a term that reduces the directional log area
ratio (log area ratio is smoothed before use to
help unpack squished regions -- strength set by
$wa).

Since the curvature-reducing force will shrink
the surface, after each shrink cycle, the average
original area of the surface is restored
(normalize_area).  Since the default original
area ($hemi.area) calcuated by recon-all (based
on ($hemi.white) sets the area of vertices in the
cut medial wall to 0, these are first
recalculated/restored (initial pop-up).

These inflation parameters can be adjusted in
Preferences -> Expert Preferences -> InflateP
(defaults in parentheses):

  steps per cycle (15) 
  total cycles (tiffs) (100)
  dump tiff every cycle (0=OFF)
  weight tangential ($ws=0.5)
  weight normal/curv ($wn=0.5)
  weight logareaaratio ($wa=0.5)
  weight negar2norm ($wc=0.0) (def=OFF)
  bord mv uses nonbord nei ($bordneiflag, 1=def=ON)
  rm vtx w/no nonbord 2nd nei ($rmvtx2nonbordflag,def=ON)
  weight radial bord ($wt=0.5, $bordneiflag overrides)

The surface may contain holes.  Since the
tangential update component at a border vertex
will be biased inward, the movement of border
vertices is treated as a special case.

The default setting of $bordneiflag (1) moves
border vertices using the average of neighboring
non-border vertex movements.  If no neighboring
vertices are non-border, the average of second
order neighbor movements are used.  If no second
order neighbors are non-border, the vertex is
deleted from the patch if $rmvtx2nonbordflag is
set to 1 (default, else the vertex remains).

If $bordneiflag is 0, border vertices are moved
in a radial direction (strength set $wt).

Movie

To save tiffs of the inflation, set "dump tiff
every cycle" to 1.  To increase the number of
tiffs for the same inflation, reduce "steps per
cycle" and increase "total cycles".  The default
total number of steps is 1500 (100 cycles
multiplied by 15 steps per cycle).
