###################################################################
UPDATE: 17 Dec 2016
###################################################################

Vertex-data-to-labels for every MGH annot region

A new function, which can be accessed by a
shift-ctrl-left-click on the "W" button on the
"label:" line::

  write_val_annotedcols_vertices
  
writes a separate label file containing the
currently displayed vertex data for each region in
a currently loaded MGH annotation (e.g.,
HCP-MMP1).

Instead of entering a full label file name, a
label prefix, like:

  .../{lh,rh}-<infix>

should be entered in the "label:" entry, which
will generate a series of label files that look
like this (if infix is "TEST"):

  .../rh-TEST_R_V1_ROI.label
  .../rh-TEST_R_MST_ROI.label
  .../rh-TEST_R_V6_ROI.label
  .../rh-TEST_R_V2_ROI.label
  [etc]


Display histogram of surface data

A new tcl function:

  print_hist <0=curv,1=val,2=amp,3=ang,4=stat> <smoothsteps>

pops up histogram of current surface data (curv,
val, complex ampliltude, complex angle, or stat).
This requires that gnuplot is installed (in either
/usr/local/gnuplot or /opt/local/bin/gnuplot).

To run this from tksurfer, middle-click on the "h"
button in the upper right hand corner in tksurfer
to get a pop-up to select data type and adjust
parameters (a default left-click on "h" pops up
general tksurfer help, same as csurf: Help ->
tksurfer).


Fsaverage additions (fixed surfs, HCP annot) now in csurf

The fixed fsaverage inflated_avg surfaces and
flattenings, and the HCP parcellation as an .annot
file previously distributed in separate tarfiles:

  fsaverage-adds.tgz (fixed inflated_avg surfaces)
  fsaverage-labels.tgz (HCP parcellation)

are now included in the standard csurf
distribution in this internal subject directory:

  $CSURF_DIR/subjects/fsaverage-ADDITIONS

A new fixinflateavg bash script can be used to fix
the N/S poles on an average surface made outside
of csurf (normally this is automatically done if
an average surface made with CrossSess AVGSURF
button).


New tcl/C function: searchlightop_val2stat

This multithreaded function can perform three
different operations (more planned) using a
surface spotlight across the entire brain:

 searchlightop_val2stat <fillneartype:0-2> <crit> <op:0-2>

  fillneartype's:
    0: nearest n neighbors
    1: nearest up to area
    2: nearest up to radius

  criterion's:
    if fillneartype=0: number of vertices
    if fillneartype=1: area in mm^2
    if fillneartype=2: radius in mm

  operations's (on .val):
    op=0: average in searchlight ROIs
    op=1: count int IDs in ROIs
    op=2: get variance after subtr centID from neighID's

The result is put into the (invisible) .stat field
of each vertex.  To make the result visible, click
"S/V" swap the .stat and .val field, and then
adjust $colscale, $fslope, and $fmid to view the
result.

The first operation is a simple boxcar average
(N.B.: useful for very large kernels, but much
slower than nearest neighbor smoothing for small
kernels).

The second and third operations were written for
analyzing the local variance of unsupervised
clustering of gray matter DTi data.  Both expect
positive, ordered, integer cluster IDs.  Negative
vertex data is ignored.

The second operation counts the number of
different cluster IDs in each surface searchlight
ROI.

The third operation calculates the variance of
cluster IDs after first subtracting off the
cluster ID of the searchlight center.

This function is multi-threaded (8 threads) and
takes about 9 min to finish on a standard cortical
hemiphere surface on a 4-core i7 (the processor
fans will increase their speed).

It can be run by middle-clicking the SMOOTH button
after loading data into the .val field (e.g.,
using "R" on either the "val:" or "label:" lines).

An example tcl script for loading data, running
the function, displaying and saving the results,
and subtracting the results from two different
data sets (using the new C/tcl function,
subtr_valbak_from_val), is here:

  $CSURF_DIR/lib/tcl/zz-examples/searchlightdiff.tcl

That script expects two full-brain labels
containing positive integer cluster IDs ordered
by similarity, and displays differences in
cluster counts or cluster variance between
two different clusterings.

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

Direct manipulation of surface much improved on MacOSX 10.10+

Tested csurf on macOS Sierra 10.12.2

Better README.txt instructions on dealing with Mac GateKeeper

Update tcl/tk 8.5.17 -> 8.5.18 (can't enter bare '-'/minus in 8.5.19)

New tksurfer funct: subtr_valbak_from_val(), result to .stat

##########################################################################
UPDATE: 17 Dec 2016
##########################################################################

--lib/help/tksurfer/smooth: explain mid-clk-SMOOTH for searchlightop_val2stat
--tksurfer.tcl: middle-click SMOOTH to get pop-up to run searchlightop_val2stat
--csurf: add hist button help panel to all-help index
--lib/help/tksurfer/hbutt,mk0{.csh}: new helpfile for "h" help button...
--tksurfer.tcl: mid-clk upper-right "h" makes run print_hist (histogram) pop-up
--tksurfer.c: print_hist(): adjustable smoothing, nbins 
--tksurfer.c: print_hist(): convert x-axis bin number to data value 
--dist: $CSURF_DIR/tiny/{NOTES.txt,tiny.c,tiny.tcl}: minimal C+tcltk test prog
--tksurfer.c: subtr_valbak_from_val prints sign test counts
--lib/tcl/zz-examples/searchlightdiff.tcl: another example script
--tksurfer.c: omit OpenGL calls from thread (crash if no tk yet, tho single OK)
--tksurfer.c: add/export subtr_valbak_from_val(), result to .stat
--tksurfer.c: multithread searchlightop_val2stat (~8x faster => 10min)
--tksurfer.c: searchlightop_val2stat: add variance after substr center operation
--tksurfer.c: searchlightop_val2stat: add count-diff-IDs-in-spotlight operation
--tksurfer.c: searchlight_val2stat (just avg) renamed: searchlightop_val2stat
--mk0{.csh}: tcl/tk: regress to 8.5.18: just '-' in entry OK
--mk0{.csh}: tcl/tk: found '-' in C-var float/int entry crashes 8.5.19 tk!
--tksurfer.tcl: default S/V explain panel only one time (others still always)
--lib/help/csurf/setupsphavg: document new loc FIX-POLES, fixinflatedavg script
--lib/help/tksurfer/{label_corr,val_read}: update formats, calcvert HOWTO
--csurf: fixinflatedavg: use $CSURF_DIR/subjects/fsaverage-ADDITIONS fixlabels
--mk0{.csh}: dist/inst: fsaverage-{adds,labels} -> subjects/fsaverage-ADDITIONS
--bin/noarch/fixinflatedavg: new bash script, add to mk0{.csh} dist/inst
--csurf: fixinflatedavg: fixed curv/sulc not being written out for AVGSURF 
--update to tcl/tk 8.5.19, mk0 {tcltktix,progs,insttmp,dist}
--mk0{.csh}: also include fsaverage-labels.tgz (HCP .annot) in dist
--tksurfer.c: do_one_glx_event 2x in eventloop: fix slow direct manip on 10.10+
--tksurfer.tcl: explicit bind ButtonRelease-1 b/c break won't work in -command
--tksurfer.tcl: block spaces in entered rgbnames: save_rgb_{checkfirst,named}
--lib/help/tksurfer/{label,label_corr,label_write,fill2area,fill2num,fill2rad}
--tksurfer.tcl: change write_spotlights => write_searchlights
--tksurfer.c: change var/funct names "spotlight" to "searchlight"
--tksurfer.c: add/export print_hist (curv/val/amp/ang/stat)
--tksurfer.c: add/export spotlightavg_val2stat -> slow (need multithread)
--tksurfer.tcl: create subject tmp dir if missing (For TmpTclScript.tcl)
--lib/help/tksurfer/{label,label_readcut,label_write,label_stat}: update,fix
--tksurfer.tcl: force: $hemi-<infix>: match hemi, no .label, dash, 1+ char infix
--tksurfer.tcl: 7th label "W" (shift-ctrl-R-clk): write_val_annotedcols_vertices
--tksurfer.tcl: mv 6th label "W" overload shift-ctrl-R-clk => shift-ctrl-M-clk
--tksurfer.c: force: $hemi-<infix>: match hemi, no .label, dash, 1+ char infix
--tksurfer.c: fix write_val_annotedcol_vertices label lines count
--tksurfer.c: add/export write_val_annotedcols_vertices => all annot regions

##########################################################################
UPDATE: 04 Oct 2016
##########################################################################

--lib/help/csurf/{csurf,rc-surfaces,rc-surface: update for GIFTI}
--lib/help/tksurfer/{clks,surf,val}: update for GIFTI
--lib/help/tksurfer/{clks,surf,val}: update for GIFTI
...




