###################################################################
UPDATE: 30 Jan 2016
###################################################################

-----------------------------------------------
New functions to read/write selections to labels
-----------------------------------------------

There are two new C/tcl functions accessible
from the "label:" line:

  read_label_to_select  (ctrl-left-D)
  write_selected_list_to_label  (ctrl-left-W)

The function, read_label_to_select, reads a label
and selects all the vertices in it as if each
vertex had been left-clicked.

The function, write_selected_list_to_label,
conversely, can write out a label from the
currently selected list.

Since the C/tcl function:

  select_uniqsamp_vertices

now *selects* the vertices it finds (it used to
just display them in cyan), the function
write_selected_list_to_label can be used to save
the unique vertices out as a label.  For
reference, select_uniqsamp_vertices does the
following: for each set of vertices that sample a
single voxel, find the vertex closest to their
average (this generates a representative set of
surface vertices, so that each 3D voxel is sampled
exactly once).

To try it out click "val:" to get "val3d:", read a
3D data set with "R", use "PAINT" to sample it to
the surface, and then "UNIQ" to run
select_uniqsamp_vertices.

If the data from a sparse label like this is read
back onto a cleared surface, use sparse smoothing
to fill in the gaps (select "sp", then SMOOTH,
which only allows undefined/zero vertices to
change).


-----------------------------------------------
Dilating FILL
-----------------------------------------------

Existing background

The "er" (eroding) tick next to FILL is by default
off so that repeated FILL's do not erode a label.

If this checkbox is left-clicked, an eroding FILL
will be done (useful for generating completely
non-overlapping labels -- see R-click help).

New functionality

If a non-default middle-click is done on the "er"
tickbox, a *dilating* FILL will instead be set up.
Each successive FILL will then *add* a rim of
additional vertices.  This can be used to
gradually grow the edges of an arbitrarily-shaped
label.

The dilating FILL respects/avoids any labels that
might have been displayed, and is cancelled or
overriden if eroding fill is selected.


-----------------------------------------------
New tksurfer funct to assemble labels into MGH annotation
-----------------------------------------------

There is a new tksurfer function to conveniently
assemble a set of individual csurf labels into a
single MGH annotation file.  If the "W" button is
*ctrl*-*middle*-clicked (instead of default
left-clicked), yet another alternate write label
function is called:

  write_mgh_annot

Ctrl-middle-clicking "W" makes a popup where an
MGH FreeSurfer Color Lookup Table (LUT) filename
can be entered.  Here is an example format of an
MGH FreeSurfer LUT file (empty lines or lines
starting with '#' are ignored).

#!ascii , CsurfColorLUT.txt (in $CSURF_DIR/lib/lut)
#-------------------------------------------------
#id    region(=labelinfix)  R      G      B      A
#-------------------------------------------------
 0     Unknown              0      0       0     0
 1     V1_lower             150    0      100    0
 2     V1_upper             150    0      120    0
14     V3_lower             0      50     200    0
15     VP_upper             0      50     220    0

Each region or structure name (except "Unknown")
must have a corresponding csurf dash-style label
(for current hemisphere) in the current subject's
label directory.  Using the example above for the
right hemisphere of subject, fsaverage, the
following label files must exist:

  $SUBJECTS_DIR/fsaverage/label/rh-V1_lower.label
  $SUBJECTS_DIR/fsaverage/label/rh-V1_upper.label
  $SUBJECTS_DIR/fsaverage/label/rh-V3_lower.label
  $SUBJECTS_DIR/fsaverage/label/rh-VP_upper.label

Select or enter an output file ending in *.annot
in the entry on the "label:" line.

Finally, click READY to assemble an MGH annotation
file containing these labels in these colors.
Vertices on the surface not included in any label
will be given structure name "Unknown" and will
always be displayed as completely transparent
(alpha=0).  The transparency of all other
structures is controlled by the "tran" entry at
the upper right.

Individual regions or all regions in an
annotation file can be used to extract
timecourses or stats from surface overlays.

If $annotbordflag is set to 1 (shift-middle
click the label tick), only the borders
of the annotations will be drawn.


-----------------------------------------------
Complex smoothing that ignores local phase diffs
-----------------------------------------------

Complex-valued smoothing (vector average) will
reduce the complex amplitude if data at
neighboring vertices have different phases.

To avoid this, a new smoothing option "cr"
(complex/real) is available in tksurfer on the
large F3 panel (or by middle-clicking "val" on the
regular panel).

The angle is derived from the vector average of
neighbors, but the amplitude is then replaced with
the real-valued average of neighboring complex
amplitudes.

This is most appropriate for data sets in which
the complex amplitude has been replaced by a
statistic -- e.g., _r,_i datasets, where complex
amplitude is sqrt(F).


-----------------------------------------------
tksurfer area/curv/lut/patch/val dropdowns update
-----------------------------------------------

The area, curv, lut, patch, and val filelist
dropdowns now update (pattern-match) appropriate
available files on every new click of the
dropdown, so any files written this session will
now appear without having to restart tksurfer
(previously only the case for label, tcl, and rgb
dropdowns).


-----------------------------------------------
tkmedit surf/im/roiup/valup/mskup/lut dropdowns update
-----------------------------------------------

The surf, im, im2, roiup, valup, mskup, and lut
filelist dropdowns now update (pattern match)
available files on every dropdown, so any files
written this session will now appear without
having to restart tkmedit.


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

Don't crash tksurfer if FSURF_DIR not defined.

Fix on Linux: File -> {Funct/Subj} NOTES

The angle_offset value required to cancel a 1sec
hemodynamic delay added to View Functional Data
and Fourier panels

Fix Recon-all panel 'file not found bug' if accidentally
ADD SCAN more lines than needed

Preferences -> Small Screen works again for SURFACE button

Earlier warning for wrong render type (indiv vs.
cross-subject)

Fix "load2surf" tick for interactive shrink

Put back 100ms delay to block runaway updates from
fast clicks in slider trough in Linux

##########################################################################
### UPDATE: 30 Jan 2016
--tksurfer.tcl: Linux:100ms delay block runaway updates w/fast slidertrough clks
--lib/help/tksurfer/label_write: update for write_mgh_annot
--tksurfer.tcl: ctrl-mid-clk label "W" assemble ColorLUT csurf labels to .annot
--tksurfer.c: default $lulabel/ulfname now $CSURF_DIR/lib/lut/CsurfColorLUT.txt
--tksurfer.c: write_mgh_annot:assemble MGHcolorLUT csurf label infixes -> .annot
--csurf: R-click help for the "h" button
--csurf: add new complex/real smoothing to all-help panel
--mk0{.csh}: add new helpfile to dist
--lib/help/tksurfer/{smooth_cpxreal,smooth}: new helpfile, update existing
--tksurfer.tcl; new "cr" (complex/real) smoothing F3 (or mid-clk F2 "val")
--tksurfer.c: add/exp smooth_complexang_realamp (repl smoothed amp w/real avg)
--bin/noarch/tiff2mpg: add tiling option (if ImageMagick montage on path)
--lib/help/tksurfer/erode: document dilatingfillflag
--tksurfer.tcl: overload erode FILL: mid-clk => dilate FILL (erode cancels)
--tksurfer.c: add/export dilatingfillflag to floodfill_marked_patch
--csurf: load2surf bug (forgot to global inflatedext2)
--tksurfer.tcl: copy global/startup C/tcl functions/vars into comments
--tkmedit.tcl: copy global/startup C/tcl functions/vars into comments
--mk0{.csh}: fix broken cp to src of pre-compiled linux libjpeg
--tkmedit.tcl: localize all help bindings (easier to rearrange)
--tkmedit.tcl: add listcmd to "lut:" combo (for luts written interactively)
--tkmedit.tcl: add listcmd to "mskup:" combo (interactive write upsamp mskBRIK)
--tkmedit.tcl: add listcmd to "valup:" combo (interactive write upsamp valBRIK)
--tkmedit.tcl: add listcmd to "roiup:" combo (for ROIs written interactively)
--tkmedit.tcl: add combo w/listcmd to "im2:" (for vols written interactively)
--tkmedit.tcl: add combo w/listcmd to "im:" (for vols written interactively)
--tkmedit.tcl: add combo w/listcmd to "surf:" w/surfs for both hemis, curr first
--csurf: below makes Preferences->SmallScreen work again for SURFACE button
--csurf: SURFACE/surfercmd env=>opts:late csurftclenv read broke openwin configs
--csurf: earlier warn wrong rendertype (View Funct/SphAvg Data menu before set)
--csurf: squish padx RIGHT LEFT BOTH for freakishly large Fedora Helv 14
--wrappers.tcl: foundbywhich: strip to tail in string match else not found Mac
--csurf: fix reconall ADD/DEL file not found bug: unset mghinprawscanfiles(last)
--tkmedit.tcl: add Mac app nap hack
--lib/help/tksurfer/val_bi, lib/help/csurf/setuprender: better "bi" scale doc
--csurf: add angle_offset for 1sec delay to View Functional Data
--csurf: Fourier panel calculates angle_offset for 1sec delay
--lib/help/csurf/setuprawavg: improve description of reversing time
--csurf: block/explain non-integer Stim Cycles Per Scan
--csurf: block/explain non-integer Num TRs to timeshift
--csurf: stop "Now, locate single sub..." message from wrapping on "functional"
--tksurfer.tcl: don't crash interface if FSURF_DIR not def'd, just rm Dijk butt
--tksurfer.c: malloc marked[] to vertexcnt of surface
--wrappers.tcl: mk foundbywhich work w/compound path (fix File->NOTES linux bug)
--lib/help/tksurfer/label_{read,write}: update additional overloadings
--tksurfer.tcl: ctrl-left-D on "label:" line => read_label_to_select
--tksurfer.tcl: ctrl-left-W on "label:" line => write_selected_list_to_label
--tksurfer.c: add/export read_label_to_select
--tksurfer.c: select_uniqsamp_vertices now marks, too
--tksurfer.c: increase marklist 1K->150K, mark_vertex flag to skip log print
--tksurfer.c: add/export write_selected_list_to_label
--Makefile: tk{sur,med,reg,str},nmovie,wheel: Mac-only: add /opt/X11/{incl,lib}
--tksurfer.tcl: add listcmd to "area:" combo so open dropdown updates files
--tksurfer.tcl: add listcmd to "curv:" combo so open dropdown updates files
--tksurfer.tcl: add listcmd to "lut:" combo so open dropdown updates files
--tksurfer.tcl: add listcmd to "patch:" combo so open dropdown updates files
--tksurfer.tcl: add listcmd to "val:" combo so open dropdown updates files

### UPDATE: 30 Dec 2015
--multiclust.cpp: marty: allow .mgh/.vtk input/output (parallel to surfclust)
--multiclust.cpp: extern global recurscnt/maxusedrecurscnt (decl:surflib.h)
...




