###################################################################
UPDATE: 21 Jun 2017
###################################################################

Can dump .val's just from borders of displayed labels

If $annotbordflag is ON (shift-middle-click the
far left tick on the "label:" line), then the
functions that dump current surface data .val's
from a displayed annotation (one or more single
labels displayed with "D", or one or all MGH
annotations also displayed with "D") will only
dump the border vertices of each label:

regular labels:

  -------------------------------------------
  shift-middle-click "label:" line "W":
    write_val_annoted_vertices
  -------------------------------------------

MGH annotations:

  -------------------------------------------
  shift-left-click "label:" line "W":
    write_val_annotedcol_vertices <r> <g> <b>
  -------------------------------------------
  shift-ctrl-left-click "label:" line "W":
    write_val_annotedcols_vertices
  -------------------------------------------


Count neighbors of each annotation area (tksurfer)

The number of other annotation areas bordering
each area in the annotation can be counted with:

  -------------------------------------------
  ctrl-middle-click "label:" line "D"
    count_mgh_annot_neigh2stat
  -------------------------------------------

The integer result is stored vertexwise in the
.stat field (overwrite warning if .stat loaded),
and also written by annotation field to an ASCII
table in subject's scripts dir:

  AnnotRegionsNeighborCounts.txt

which also includes the IDnums of the neighboring
areas for each area.  Requires that an MGH
annotation file has first been loaded.


Spherical Gaussian hand normalization (tkmedit)

An option was added (middle-click the tkmedit F3
panel "sph" tick) to hand normalize a spherical
region around a point using a Gaussian-like curve
(instead of the default linear ramp).  Pixels at
the center are multipled by $ffrac0, with that
factor falling off to no-change at a radius of
$lim0.  The FWHM of the Gaussian is: 0.36198 *
$ffrac0.


Transfer previous wm edits to a new wm (tkmedit)

In the course of a manual reconstruction, after
already having edited a white matter (wm) data
set, you may want to go back and make additional
local hand-normalization steps in order to
regenerate the wm data set (e.g., using local
spherical Gaussian: "sph" tick in F3 panel), but
without losing the extensive edits made so far.

A new function, im2wmedits_to_im(), was added to
tkmedit to do this and bound to the COMPARE
button.  Copy the previously edited wm.mgz file to
a different name (e.g., wm-old.mgz), remake
wm.mgz, load old wm-old.mgz as the second image
set with the "R" button on the "im2:" entry, and
finally do shift-middle-COMPARE.  This will copy
only previously edited pixels (pix=1, pix=255) to
the wm.mgz in the editable buffer.  This can then
be saved in the usual fashion (SAVEIMGS button).
To summarize:

  (0) already did many edits on wm.mgz
  (1) copy prev edited wm.mgz aside to wm-old.mgz
  (2) hand normalize, remake wm.mgz, load it
  (3) load wm-old.mgz into "im2:" w/"R"
  (4) shift-middle-COMPARE
  (5) SAVE IMGS


Flip from CORONAL view popup (tkmedit)

An new overload was added to the CORONAL button,
middle-click-CORONAL.  This first forces view to
CORONAL, then pops up a panel that allows
performing one of the 48 different possible 3D
transposes on the data in the editable buffer
using the C/tcl function: flip_corview_xyz.
Among (many) other things, this can mirror-image
the data set.


New standard script: searchlightdiff.tcl (tksurfer)

The script, searchlightdiff.tcl, has been added to
the set of standard scripts.  Running it
interactively from the "tcl:" dropdown in csurf
first generates a pop-up to adjust parameters.
Clicking "RUN SCRIPT" first runs full-hemisphere
searchlight operation on two sets of
full-hemisphere, real-valued data:

  Searchlight operations:

    0 -> average of searchlight data
    1 -> count num classes (assumes integer data)
    2 -> variance of searchlight data

and writes out the results as two labels.  These
multithreaded operations take about 10
min/hemisphere on an Intel i7.

Then, the first searchlight result is then
subtracted from the second searchlight result and
saved as a third label.

The size, ${num,sqmm,mm}, of the approximately
geodesic surface searchlight circles can be
specified by vertex count, area, radius, or by
neighbor order (1=immediate neighbors, 2=also
include neighbors of neighbors, etc):

  Searchlight size ($fillneartype):

    0 -> num vertices
    1 -> area (in mm^2)
    2 -> radius (in mm)
    3 -> neighbor order (1-6)

The first three searchlight types use the C/tcl
function, searchlightop_val2stat (multi-threaded),
while the fourth type uses the new C/tcl function,
neighop_val2stat (similar result for similar
vertex count, goes up to 6th-order neighbors,
which is 127 vertices on fsaverage).

Adjustable parameters can be hard-coded in the
script in order to run it non-interactively from
the command line as a tksurfer tcl script.

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

Fix accidentally disabled PF, PFGAU buttons tkmedit (broken Apr 2016!)

Fix off-edge array access on click Unknown region (white)
  with MGH annotation loaded

fix crashing second malloc/free in searchlightop_val2stat_th() thread

more info in double-middle-click annotation region pop-up

fix error in GR error popups

##########################################################################
UPDATE: 21 Jun 2017
##########################################################################
--tksurfer.c: count_mgh_annot_neigh2stat() also prints neigh IDnums to outfile
--tkmedit.tcl: before flip, if not CORONAL, warn/force CORONAL/center
--tkmedit.c: ptype errors, un-global/clean-up impt,ipt,jpt
--tkmedit.c: goto_point_coords->goto_point_zcoords, unzoomed: goto_point_coords
--csurf: add tkmedit CORONAL/SAGITTAL/HORIZONTAL to all help window
--lib/help/tkmedit/{hbutt,coronal,sagittal,horizontal}: new help, update mk0*
--tkmedit.tcl: overload "CORONAL" butt (mid-click) with flip_corview_xyz popup
--tksurfer.tcl: fix GR button error popup bug, manually bind avoids dup L-*-clk
--lib/help/csurf/csurf: more script help, document csurf tclenv mechanism
--lib/help/tksurfer/label: update
--lib/help/tksurfer/label_read: update
--tksurfer.tcl: count_mgh_annot_neigh2stat: ctrl-mid-clk-D, warn no-annot/.stat
--tksurfer.tcl: bind ctrl-middle-click-D to count_mgh_annot_neigh2stat
--tksurfer.c: add/export count_mgh_annot_neigh2stat(), write scriptsdir file
--tksurfer.c: annot2brainregionindex() (localizes above)
--tksurfer.c: catch off-edge on double-middle-click popup annot region/color
--tksurfer.c: do_one_glx_event: double-mid-clk also pops up D'd plain label col
--lib/help/tksurfer/label: another doc of double-mid-click popup annot name/col
--tksurfer.c: neighop_val2stat(): add 6th order (still useable: ~3min)
--searchlightdiff.tcl: also support neighop_val2stat (fillneartype=3)
--tksurfer.c: neighop_val2stat() for 1st-5th order neigh (req'd same alloc fix)
--tksurfer.c: count_neigh_ids2stat() for 1st to 5th order neigh (req'd samefix)
--mk0{.csh}: add searchlightdiff.tcl to standard scripts
--lib/tcl/searchlightdiff.tcl: new standard lib script
--tksurfer.c: fix free(hist) crash in searchlightop_val2stat_th() w/simple alloc
--tksurfer.c: searchlightop_val2stat_th(): if (SLOPCNT) -> if (optype==SLOPCNT)
--tksurfer.c: write_val_annoted_vertices: fix write all bug, resp annotbordflag
--lib/help/tkmedit/smoothstats: update to mk alt options parallel
--lib/help/tkmedit/{compare,wmtrunc,wmfilterstd,wmfiltergau}: update,mkparallel
--tkmedit.tcl: overload "COMPARE" button (shift-mid-click) with im2wmedits_to_im
--tkmedit.c: im2wmedits_to_im(): apply im2 WM_EDITED_OFF=1,WM_EDITED_ON=255 ->im
--lib/help/tkmedit/wmtrunc: make apply trunc, tclfunct help parallel to PF{GAU}
--tksurfer.c: print AnnotStruct: catch off-edge array access if Unknown region
--lib/help/tksurfer/label_read2val: explain complex, funct name typo shift-mid
--lib/help/tkmedit/sphnorm: doc Gaussian spherical option for $sphnormflag
--tkmedit.tcl: M-clk overload "sph" tick w/$gaussnormflag autoset $sphnormflag
--tkmedit.c: if gaussnormflag (and sphnormflag), linear->Gaussian profile
--tkmedit.tcl: better log commands for hand normalize, regular and sphere norm
--tksurfer.tcl: write_val_annoted{col,cols}_vertices: warn if $annotbordflag ON
--tksurfer.c: write_val_annoted_vertices: fix write all bug, resp annotbordflag
--tkmedit.tcl: fix run_wmfilter non-combo entry get (PF,PFGAU disabled Apr2016)
--lib/help/tksurfer/label_write: update
--tksurfer.c: write_val_annotedcol{s}_vertices respect annotbordflag

##########################################################################
PREVIOUS UPDATE: 20 Mar 2017
##########################################################################
--lib/tcl/movie360.tcl: can use ffmpeg to make mp4 directly (if on $path)
--lib/tcl/tksurfer/scripts: doc annot2roi.tcl
--lib/tcl/annot2roi.tcl: new script: samp fsavg annot to sing sub, get 3D ROIs
--tksurfer.c: single quote rm,>> args in system() calls (sure wildcard block)
--lib/tcl/tksurfer/label_read: doc all-in-one ROI BRIK
--tksurfer.c: insert_idnum() can accumulate merged all-in-one ROI BRIK
--tksurfer.c: write_annotcols_timecourses_stats() makes all-in-one ROI BRIK
--bin/noarch/fsavgannot2subj: sh one-liner to samp fsaverage annot to sing sub
--lib/help/csurf/setupfield, lib/tcl/borders.tcl: better doc
--tksurfer.c: write_annotcol{s}_timecourses_stats puts idnums into mask BRIKs
--tksurfer.c: print annot region IDnum (not just annot name) to log on select
--lib/help/tksurfer/label: update because couldn't find label->3DROI ("D")
...




