###################################################################
UPDATE: 24 Jun 2016
###################################################################

Re-cut a label including only 'representative' vertices

When a label made by FILL is re-cut with a default
left-click on the "C" on the "label:" line --
e.g., in order to capture current surface data to
a label -- every vertex in the label is normally
included.  If the "C" button is instead
*ctrl*-left-clicked, the $hemi-UniqSampVtxs.label is
first read and consulted so that the recut label
only contains 'representative' vertices (a single
vertex for each sampled voxel that is nearest the
average of the vertices that sampled that voxel).

At re-cut time, since the resulting sparse label
will typically only contain a single vertex from
any given face, it cannot be displayed as a
continuous surface patch.  For this reason,
$pointsflag will be turned on to make the sparse
label visible immediately after the re-cut.  To
toggle $pointsflag off and on, middle-click the
MESH button.

Once the sparse label has been written, displaying
it with the "D" button will pad the single
vertices with their surrounding faces so it can be
seen (see the R-click for the ROI button for a
full explanation of why it has to be this way).


Write surface in format for 3D printer (.stl)

The "STL" button on the "outsurf:" line on larger
tksurfer F3 panel writes out the current
hemisphere surface in Stereolithography (.stl)
format (ASCII, all-positive octant, units=mm).
This makes a large file (50M).


Read/Write surface in Object File Format (.off)

The "OFF" button on the "outsurf:" line on larger
tksurfer F3 panel writes out the current surface
in the ASCII Object File Format (.off) for
importing into many other surface manipulation
programs (makes 10M file), Mathematica, etc.
Middle-click OFF writes out surface with current
colors appended to each face.  Shift-Middle-click
writes out surface with current colors appended to
vertices (first line of file in this case changes
to COFF instead of OFF).

The read_binary_surface function ("R" button on
"insurf:" line on F3 panel) now autodetects and
reads .off surfaces.


Surf-based false discovery rate (FDR) p-value correct

A middle-click on the "CS" (surfcluster) button
provides an alternate non-parametric FDR method of
correcting for multiple comparisons.  The
Benjamini/Hochberg (1995) method as introduced to
fMRI by Nichols estimates a corrected p-value to
use for a desired false discovery rate (FDR) as
follows:

  read F-stat onto surface
  calc p-val for each vertex (fcdf)
  sort p's in ascending order
  find highest p less than or equal to (i/N * q), where
      i = index of that p
      N = total num vertices
      q = desired probability

A middle-click on the "CS" button brings up a
popup with 4 adjustable parameters:

  smoothsteps       (e.g., 5)
  desired_FDR       (e.g., 0.05)
  noisedf           (e.g., 256-11=245)
  uniqsampvtxflag   (unticked: use every vtx)

Vertices with a value of 0.0 are excluded because
these are off the edge of the functional volume.

Any invisible vertices are also excluded, so
re-cut a label with "C" to restrict FDR
calculation to a label.

The corrected p-value is returned in a final
pop-up and written into the csurf log.

See the R-click help for the "CS" button for
additional details.


'Representative' sampling vertex for timecourses

The "T" button on the "label:" line (sample raw
timecourses) can now use the 'representative'
vertex mechanism (vertex closest to the average of
the vertices that sampled an individual voxel).
Tick "normdsampuniqvtxflag" in the "label:" popup.


ROI button can also fill between phase contours

Previously, the "ROI" button could floodfill a
connected surface region that has stat, complex
amplitude, or val above a requested threshold
value.  A fourth option was added to floodfill
between two phase contour lines.  The precendence
of operations is:

 (a) if mask on, use:          STAT > $sfthresh 
 (b) if truncphase, use:      COMPLEX PHASE within limits 
 (c) if complex data, use:   COMPLEX AMP > $fthresh 
 (d) if real data, use:         REAL AMP > $fthresh 

N.B.: the first matching condition wins and the
other criteria are ignored.  For example, to fill
an region in an overlay containing real data, the
"mask", "truncphase", and "cpx" ticks must all be
unticked.  The operations in more detail are:

 (a) compare .stat to $sfthresh
 (b) compare atan2(.val2,.val)/2Pi to $truncphasemin,max
 (c) compare hypot(.val,.val2) to $fthresh
 (d) compare .val to $fthresh
 
In truncphase case, the phase angle is modifed by
$revphaseflag, $invphaseflag, and $angle_offset
before truncation is applied (like "truncphase").

In all cases, this fill procedure also respects
(doesn't go past) cuts, and doesn't intrude on any
currently displayed labels.

Disconnected regions can be filled by marking
vertices by left-clicking them in more than one
region before clicking ROI.

-----------------------------------------------
Bug fixes, small changes
-----------------------------------------------

middle-click tksurfer val3d PAINT auto-smooths (using curr)

CLONE FUNCT now clones everything (was mk links)

HOWTO make single-vertex-wide are traverse label

ExtStats paint bug: uniqsampvtxs2labelflag => normdsampuniqvtxflag

Fix tkmedit swap bug with 3dmerge mask

##########################################################################
UPDATE: 24 Jun 2016
##########################################################################
--lib/help/tksurfer/{label_readcut,mesh}: HOWTO make/disp sparse uniqvtx labels
--tksurfer.tcl: middle-click MESH toggles pointsflag
--tksurfer.tcl: ctrl-left-click "C" recut label respecting normdsampuniqvtxflag
--tksurfer.c: read_label_cut_clearvals <0=label> respects normdsampuniqvtxflag
--csurf: paintmultibrik bug/typo: uniqsampvtxs2labelflag=>normdsampuniqvtxflag
--tkmedit.tcl: add surftmp to dropdown list
--tksurfer.tcl: add surftmp to dropdown list
--tksurfer.tcl: check selfintersectloaded (avoid ask clear selfintersect 2x)
--tksurfer.c: export/maintain selfintersectloaded
--lib/help/tksurfer/val_clust: doc cmdline tksurfer tcl script for FDR calc
--lib/help/tksurfer/dijk: document subject/session location output path label
--tksurfer.tcl: add hemi, cp Dijk subj scripts to sess scandir or subj labeldir
--lib/help/tksurfer/label: add how to make 1-vtx-wide line-label traverse
--imptest: *.off(gray,tricol/vtxcol)->geomview,Mathematica, *.stl->Mathematica
--tksurfer.tcl: mid-clk OFF => face colors, shift-mid-clk OFF => vertex colors
--tksurfer.c: write_stl_surface: face colors option, vtx col option: OFF=>COFF
--csurf: add new write .off and .stl help panels to All Help panel
--lib/help/tksurfer/outsurf{off,stl}_write: new helpfiles, add to mk0{.csh}
--tksurfer.tcl: add F3 panel OFF button to write .stl format surface (3D print)
--tksurfer.c: write_stl_surface writes .stl pos octant ASCII file
--tksurfer.tcl: add F3 panel OFF button to write .off format surface
--tksurfer.c: write_off_surface writes .off format file
--tksurfer.c: read_binary_surface autodetects/reads .off format file
--csurf: make/run no-window tksurfer script to calc cross-subj FDR (no uniqvtx)
--fourier.c: autoswap LSB input timeseries BRIK (already reads LSB fullfourier)
--csurf: fouriercmd: forcebrikMSB _h BRIK output (from apply clustermask)
--csurf: fouriercmd: forcebrikMSB fourier pre-smooth out (was smooth prob!)
--tkmedit.c: read_native_stat swaps LSB BRIK (was fail w/LSB 3dmerge mask)
--tkmedit.tcl: catch/fix statmask-disabling sfthresh=sfslope=0.0 (thr,sl,msk)
--tksurfer.tcl: catch/fix statmask-disabling sfthresh=sfslope=0.0 (thr,sl,msk)
--tkmedit.c: left-click also prints statmask value if loaded
--tk{medit,surfer}.tcl: warn sfthresh=sfslope=0.0 disables statmask
--tksurfer.tcl: add val,weight smooth type option on FDR pop-up
--tksurfer.tcl: new smooth type option on FDR pop-up
--tksurfer.tcl: if stats loaded, also smooth w/sparse,weighted (was just val)
--lib/help/tksurfer/val_clust: how to use the FDR popup, method
--tksurfer.tcl: FDR popup: smoothsteps, desired_FDR, noisedf, uniqsampvtxflag
--lib/tcl/{real,eccen,polar,twocond}-{views,flat}.tcl: after swap:set stat $val
--lib/help/tksurfer/label_read2val: doc new read_uniqsamp_vertices binding
--tksurfer.tcl: add ctrl-L-click "label:" line overload: read_uniqsamp_vertices
--tksurfer.tcl: fix Shift-Middle binding "RC"->"R" button (was overlap/ignore)
--tksurfer.c: fix alt/cmd-click on tk window w/focus in GLX window (like shift)
--tksurfer.c: fix all label-reading functions to ignore k out of bounds
--tksurfer.c: add/export read_uniqsamp_vertices (for paint.c-created label)
--tksurfer.c: add/export pval_FDR, find_FDR_from_pvals()
--tksurfer.c: add/export noisedf, pval_from_fourier_fstat()
--tksurfer.c: add NR fcdf() -- uses betainc(), loggam() and betacontfrac()
--tksurfer.c: draw_colscaledisk: top of scale resettable w/maxstatcolscale
--lib/help/tksurfer/val2rgb_write: doc req. low fthresh/sfthresh for write LUT
--lib/help/tksurfer/rect: document assumed input amps, no stat fade
--tksurfer.c: write_val2rgblut: assume hi stat to avoid fade (only amp in LUT)
--tksurfer.c: draw_colscaledisk: fix inset w/fmid=0 (was purp), hi stat no fade
--lib/help/tksurfer/{roi,script}: updates
--tksurfer.tcl: ROI does phasetrunc w/truncphase ON preced:stat/phase/cplx/real
--tksurfer.c: floodfill_marked_patch <PHAFILL=4>: fill between trunc limits
--tkmedit.tcl: make cursor big 2x after GOTO for changeplane (sameplane 2x OK)
--csurf: addrenderscan fix missing bak compat default for new uniqvtx var
--tksurfer.c: catch stale UQ after new paint
--lib/help/csurf/setupfunct: better uniqvox/uniqvtx explanation
--lib/help/tksurfer/nsamp_uniqvtx: new helpfile, add to mk0{.csh}
--csurf: add nsamp_uniqvtx to All Help
--csurf: normdsampuniqvtxflag forces normdsampuniqvoxflag (like tksurfer.c)
--csurf: rename uniqsamplabelflag -> normdsampuniqvtxflag, also pass to tksurfer
--tksurfer.tcl: uniqvtx tcourse pre-warn: req: native stat, paint, uniqsamp
--tksurfer.c: paintTODOflag: set on load/reload 3D
--tksurfer.c: normdsampuniqvtxflag requires (doesn't do) find_uniqsamp_vertices
--tksurfer.c: [one extra line of C => 150 lines of interface and help...]
--tksurfer.c: normdsampuniqvtxflag: sample tcourse continue if not uniqsamp vtx
--tksurfer.tcl: add ~/tmp/TmpTclScript.tcl to "tcl:" menu
--lib/help/tksurfer/val3d_paint: update for smooth overload
--tksurfer.tcl: mid-clk overload PAINT also smooths (curr parms) before redraw
--csurf: setting minvol (clustervol) to 0 skips 3D clustering (like 2D disable)
--csurf: change CLONE FUNCT to just cp everything (was mk links to big files)
--csurf: visually separate off options for PAINT on Setup Funct panel

##########################################################################
UPDATE: 27 May 2016
##########################################################################
--tksurfer.c: fix control-click on tk window w/focus in GLX window (like shift)
--lib/help/tksurfer/val3d_uniq: update for new binding
--tksurfer.tcl: middle-click UQ writes */$scandir/$hemi-UniqSampVtxs.label
--tksurfer.c: add/export write_uniqsamp_vertices (ignores usecurrcoordsflag)
...




