###################################################################
UPDATE:  24 Mar 2022
###################################################################

----------------------------------------------
New visual/auditory/somato fsaverage parcellation
----------------------------------------------

A new csurf parcellation (from Sereno, Sood, and
Huang, 2022) is included in this distribution:

  $CSURF_DIR/subjects/fsaverage-ADDITIONS/rh-CsurfMaps1.annot
  $CSURF_DIR/subjects/fsaverage-ADDITIONS/lh-CsurfMaps1.annot

It has also been converted to a GIFTI label file:

  $CSURF_DIR/subjects/fsaverage-ADDITIONS/rh-CsurfMaps1.label.gii
  $CSURF_DIR/subjects/fsaverage-ADDITIONS/lh-CsurfMaps1.label.gii

Both file types are compatible with csurf and MGH
FreeSurfer (and GIFTI with HCP utilities).

The parcellation contains 117 areas in each
hemisphere, which accounts for about 47% of the
total neocortical surface area.

For details, see Sereno, Sood, and Huang (2022),
Frontiers in Neuroscience (in press).

----------------------------------------------
Script example vertex cols assembly, render hi-res
----------------------------------------------

A new example tcl script shows how to assemble
vertex color files from different modalities
(different color scales on same image), and how
to render higher-than-screen-resolution images
off-screen:

  $CSURF_DIR/lib/tcl/zz-examples/assemble-render-maps.tcl

----------------------------------------------
Pop-ups for overloaded buttons and tickboxes
----------------------------------------------

Most of the buttons on the "label:" and "val:"
lines have acquired waaay too many overloads
(click plus key(s) combinations) for alternate
actions.

A R-click help on eight of these now also makes
a pop-up with verbosely labelled buttons to
individually control all the alternate actions.

These include the "D", "C", "CLR", "R", and "W"
buttons on the "label:" line, the "S/V" and "W"
buttons on the "val:" line, and the "GR" button
on the "fs:" line (for displaying gradient
arrows).

A R-click help on the leftmost tickbox on the
"label:" line already puts up a popup to control
multiple label flags more conveniently.  Similar
popups have been added to the R-click help for the
the tickbox to the left of the "fs:" line (for
controlling gradients display), and the tick at
the bottom of the middle left "phc" box (for
controlling arrows, normals, and points display).

----------------------------------------------
tksurfer write_mgh_annot output more compatible
----------------------------------------------

Csurf tksurfer write_mgh_annot originally
followed the spec for annot file format here:

  https://surfer.nmr.mgh.harvard.edu/fswiki/LabelsClutsAnnotationFiles

Although csurf tksurfer read_mgh_annot can accept
an *.annot file containing non-sequential region
idnums, these files will crash mris_convert and
may not be read properly by freeview, which use
similar utils/colortable.c functions.  Therefore,
the idnums in the *.annot output files now
generated by tksurfer write_mgh_annot are
re-numbered sequentially.

A second workaround to avoid mris_convert crashes
and freeview fail-to-reads is that the maximum
region idnum field in the output *.annot is
incremented by 1 over the actual value (tksurfer
read_mgh_annot accepts either incremented or
actual max idnum).

This makes it possible to convert csurf-generated
annotation files to GIFTI with mris_convert, and
to display them in freeview.

Sorry for not doing more thorough compatibility
testing earlier.

----------------------------------------------
read_gifti_to_annot
----------------------------------------------

A new C/tcl function, read_gifti_to_annot, was
added to read GIFTI files that contain a
FreeSurfer annotation. These xml files contain a
FreeSurfer color table followed by a region
number for each vertex.

Any available *.gii files are now loaded into the
"label:" line entry dropdown, and "D" will
automatically display them.

So far, only tested on the *.gii output of
mris_convert.

----------------------------------------------
labeled_cut_clearvals <0=label,1=hole>
-------------------------------------------

A new C/tcl function, labeled_cut_clearval works
like the existing read_label_cut_clearval, but
uses currently displayed label(s) to cut a label
(or cut a hole out) instead of reading a label
file to do these things.

This can be used, for example, to mask
activations in preparation for making a vertex
color label.

-------------------------------------------
currcol_to_vtxcol
-------------------------------------------

Copy the current color at each visible vertex (as
controlled by current settings of colscale, etc)
to the fixed vertex color "paint" fields
(.vr/.vg/.vb).  This can be used to assemble
illustrations containing data that uses different
color scales.

To save the vertex colors as a file, use
ctrl-R-click W on the "label:" line (tcl/C
function: write_vtxcol_label).

Be sure to start with a clean vtxcol slate by
middle-click-CLR on the "label:" line, else any
previously copied vtxcols will be included in
final .cols file.

Also, if you want to assemble multiple vtxcol's,
be sure a label has been re-cut so the whole
surface won't be saved to the vtxcol label.

This can also be done in one step by converting a
standard label directly to a vertex color label
using middle-click W on "label:" line (tcl/C
function: label_to_vtxcol_label).


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

re-cut label now clears vertex marks (fix stray add/cut with PTS)

popups for overloaded buttons now left of main panel, help above

various vtxcol ("paint") upgrades

mid-clk-R on "rgb:" line displays all saved tiffs

recognize arm64, tmp classify as x86_64

new ROI fill types: stat AND real/hypot

compute_gradient/compute_surfgrad -> also respects sfthresh if statmask

fixed truncated ic6.tri

allow back out of more operations on "label:" and "val:" lines

ROI can do AND of stat and complexamp

restored/fixed mac_appnap_hack for 10.14, 10.15

non-eroding fill for adjacent 1 vertex overlap

popup to control pointsize

new popups for too-overloaded buttons

better bail-out for write buttons 

don't mess with env var LANG! (borks xterm from xterm on some mac 10.15)

fix transparent mpeg_play on CentOS 7



##########################################################################
UPDATE: 24 Mar 2022
##########################################################################

--csurf: list other brik2cor options on setup struct panel
--csurf: setup structs: 3-way opt (cancel, use, don't use) if no -zeropixwidth
--csurf: double-clk setupscans upper-left "Session:" label for current location
--csurf: block check scandir callback from set iscandir if aspect equals struct
--csurf: double-clk setupscan panel raises csurf only from bottom buttons frame
--csurf: Setup Structural Scans auto-converts *.nii (AFNI 3dcopy)
--lib/help/tksurfer/read_im{2,3}: example set infile names
--lib/help/tksurfer/col1col2: new helpfile, add to mk0{.csh}
--tksurfer.tcl: helpwins for F3 panel col1,col2 for "bi" scale
--lib/help/tksurfer/val2rgb_{read,write}: explicit example set in/out filename
--wrappers.tcl: controls,buttonbar: mv panel right of tk b/c far left tkmedit
--wrappers.tcl: controls,buttonbar: mv panel below GL if F3 b/c tksurfer F3 top
--lib/help/tksurfer/outsurf{NULL,asc,glb,obj,off,stl,vtk}_write: update
--wrappers.tcl: helpwin: mv less right for narrow tksurfer F3, small tkmedit GL
--csurf: all-help panel: separate read/write (SurfaceR,SurfaceW), c2lab to Label
--tksurfer.tcl,mk0: rename helpfile: hemisurf->insurf_read, bind F3 insurf "R"
--tkmedit.c: nudge startup GLX glxwinx0 back to right (for left Mac dock)
--tkmedit.tcl: SAVEIMGS ignores post-startup $inoutim change (write 1st read-in)
--lib/help/tksurfer/{patch,curv,area}_{read,write,mask,cut}: explicit set file
    [tmprelease: 220220]
--tksurfer.c: rm unused fname arg from corr_over_annotcol
--lib/help/tksurfer/label_{read,readcut,clear,write,timecourses,stat,corr}: e.g.
--lib/help/tksurfer/val_{read,clust,write}: explicit example set in/out filename
--lib/help/tksurfer/script_phasemovie: document how to deal with wrap
--csurf: movie panel plays mpgdir mp4/m4v's w/QuickTimePlayer (mac), vlc (lnx)
--tksurfer.tcl: 2D/3D gradient arrows respect annotmaskflag just show unmasked
--tksurfer.tcl: ctrl-right-R,W bind update vclabel so confirm msg not stale
--tksurfer.tcl: ctrl-right-R,W bind: fix forgot to read curr entry to label!
--lib/help/tksurfer/label: update with *.cols, *.cols format
    [tmprelease: 220115]
--lib/help/tksurfer/{label,label_read,annot}: update
--add to dist: dist/fsaverage-ADDITIONS/surf/?h.cortex2a.patch.flat, mk tarfile
--add to dist: dist/fsaverage-ADDITIONS/surf/?h.cortex2a.patch.flat, mk tarfile
--mris_convert --annot ../label/{rh,lh}-CsurfMaps1.annot ../surf/{rh,lh}.white \
   ../label/{rh,lh}-CsurfMaps1.gii (FreeSurfer5.3) => dist/fsaverage-ADDITIONS
--tksurfer.c: skip do all glx events if offscreen: resizes win to max onscreen!
--lib/help/tksurfer/label_read: update
--tksurfer.tcl: final overload of D button: currcol_to_vtxcol
--tksurfer.c: add/export currcol_to_vtxcol(): only visible vertices are copied
--tksurfer.tcl: writevtxcols checks no vtxcols loaded, wrong suff
--csurf: double-click on render panel raises small main (no way from tksurfer..)
--tksurfer.c: clear_annot() also clears .annotbord
--tksurfer.c: add arg: clear_vertex_marks_list(reportlog=1): no log intern use
--csurf: showlogs raises main csurf window (helps w/many csurf's)
--tksurfer.c: select_vertex miss selected to -1; all selected users now check
--tksurfer.c: read_label_cut_clearvals -> clear_vertex_marks_list: fix weird PTS
--tksurfer.tcl: bind cmd/alt-z to UNDO cut butt, R-click help on 2 more popups
--wrappers.tcl: add thin space for buttonbar, helpwin lower
--tksurfer.tcl: fix auto-run default scripts (after cmd->bind so can use break)
    [tmprelease: 211229]
--csurf: add appnap startup hack b/c ugly startup
--tkmedit.tcl: increase appnap hack to 2000 msec
--lib/help/tksurfer/label_readcut: update
--tksurfer.tcl: allow bail on re-run startup script
--tksurfer.tcl: add labeled_cut_clearval to "label:" line "C", buttonbar popup
--tksurfer.c: add/export labeled_cut_clearvals(), cf. read_label_cut_clearvals
--tksurfer.tcl: remove buttonbar popup delay (wrappers.tcl now moves it aside)
--wrappers.tcl: position buttonbar,controls left of tk, helpwin up/right on GLX
    [tmprelease: 211220]
--lib/help/tksurfer/label_read: update
--tksurfer.tcl: 3rd vers DISPLAY SUBSET/MASK OVERLAY popup for vtxcol subset
--tksurfer.c: pick idnums/annotmaskflag works w/vtxcol overlays (was:annot,val)
--lib/help/tksurfer/{label,label_read}: update
--tksurfer.tcl: "label:" entry/dropdown also loads *.gii's, "D" displays
--tksurfer.c: add/export read_gifti_to_annot() (only test: mris_convert output)
    [tmprelease: 211202]
--tksurfer.tcl: accept $hemi-<name>.label format for csurf annot files
--tksurfer.tcl: lut2annotcrtsl/do_lut2annot: global combovar update hacked cbx's
    [tmprelease 211120]
--tksurfer.c: read_mgh_annot(): more err check
--tksurfer.c: write_mgh_annot(): workaround mris_convert crash: idmax++,renumber
--tksurfer.tcl: buttonbars pop/re-create corresponding help, shortcuts incl butt
--wrappers.tcl: optional arg to buttonbar to bind helpfile
    [tmprelease 210923]
--tk{surfer,medit}.tcl: increase Mac uncover redraw hack delay to 2000 msec
--tksurfer.tcl: {read,write}vtxcols,labeltovtxcol cleanup, better vtxcol warn
--tksurfer.tcl: readvtxcols accepts *.col in addition to autoconverted *.label
--lib/help/tksurfer/{label_write,angle_offset,rgb_write,rgb_write2}: updated
--tksurfer.tcl: final overload for "label:" line "W": write_vtxcol_label
--tksurfer.c: add/export write_vtxcol_label: curr vtxcols AND visible
--tksurfer.tcl: dup write_mgh_annot comment-in/out: {exclude,include}_following
--tksurfer.tcl: fix nagging vtxcolflag=ON popup -> once only per new read
--tksurfer.tcl: fix logging for vtxcol labels
--tksurfer.c: add/export read_label_to_setvalval2 <valconst> <val2const>
--tksurfer.c: read_label_cut_clearvals(CUTNOCLR):fix recursive non-eroding hack
--tksurfer.tcl: warn hidden label for ROI button (similar to FILL)
--tksurfer.tcl: remaining file not found popups for "label:" line "D" and "R"
--tksurfer.c: label_to_vtxcol_label: use curr loaded stat (1.0 was desaturated)
    [tmprelease 210911]
--getonearch{.csh}: recognize proc=arm64, tmp classify as x86_64
--tksurfer.tcl: buttonbar for "label:" line "R" button R-click help
--tksurfer.tcl: buttonbar for "label:" line "CLR" button R-click help
--lib/help/tksurfer/comp_grad: update
--tksurfer.c: compute_gradient/compute_surfgrad: mask arrs w/sfthresh if statmsk
--tksurfer.tcl: dup arrowscale/arrowline in gradient popup (unlabeld fs tick)
--tksurfer.c: inplane rot: ctrl-arr -> shift-ctrl-arr b/c 10.15 ctrl-arr=maxmize
--tksurfer.tcl: write_mgh_annot: reverse Skip/ShowOverlap, so <Ret> skips
--lib/help/tksurfer/{label_clear,label_write}: updated
--tksurfer.c: read_mgh_colorlut() respects "### {include,exclude}_following"
--tksurfer.tcl: ctrl-middle-click on CLR does clear_annot_with_col mesh rgb
--tksurfer.c: add/export clear_annot_with_col(r,g,b)
--tksurfer.c: restore_ripflags SWAP_CURR_OLD, SAVCURR_MKORIG now don't unmark
--lib/help/tksurfer/{roi,statmaskamp}: update
--tksurfer.tcl: ROI: ctrl-mid-clk overload statANDrealflag mask tick (radio-ize)
--tksurfer.tcl: ROI: if real+stat, force choice between stat vs. stat AND real
--tksurfer.tcl: ROI: if cmplx+stat, force choice between stat vs. stat AND hypot
--tksurfer.c: new filltype=STREFILL: real>fthresh AND stat>sfthresh
--tksurfer.tcl: hack: fix Return in arrowscale in popup bound to arr->col butt!
    [tmprelease]
--tksurfer.tcl: CLR single label now reads current combo entry, not found err
--lib/help/tksurfer/{roi,statmaskamp}: fix confusing typos!
--ima2brik: better checking for -di2sub option
    [tmprelease]
--stripairPD.tcl: new standard lib/tcl script, add to mk0{.csh} dist
--tkstrip.c: def outim tmp->tmp.mgz, action5,6 set dfrac before init_surf_to_im
--tkstrip.c: add action=6: shrink on inim, read/peel orig.mgz, outim tmp.mgz
    [tmprelease 210731]
--lib/bem/ic6.tri: fix truncated file
--tkstrip.c: read_geometry crash from reading truncated *.tri file
--tkmedit.tcl: increase appnap xterm 300->800 msec (same as tksurfer.tcl)
--csurf: procs using mri_surf2surf, check/blk '#' in {FUNCTIONALS,SUBJECTS}_DIR
    [tmprelease 210722]
--tksurfer.tcl: middle-click-R on "rgb:" line shows all tiffs in nmovie
--tksurfer.tcl: FILL warn eroding/non-eroding fill
--tksurfer.c: !erodingfillflag retains FILL-like 1-vtx overlap label hole/add
--csurf: reinstate macos 10.{14,15) mac_appnap_hack=1
--tksurfer.tcl: inc appnap_hack delay 500->800 msec (works 10.15)
--lib/help/tksurfer/{roi,statmaskamp}: update
--tksurfer.tcl: middle-click overload statANDhypotflag to mask tick
--tksurfer.tcl: fix weird bug by always destroy/remake labeltickctrlswin
--tksurfer.c: new filltype=STHYFILL: hypot>fthresh AND stat>sfthresh
--tksurfer.tcl: allow back out of "label:" line CLR's
--tksurfer.tcl: redrawbutton warns vtxcolflag on
--lib/help/tksurfer/angle_cycles: ref linrampphase2vtxcol doc angle_offset
--tksurfer.tcl: allow back out of "val:" line CLR's
--lib/help/tksurfer/label_clear: update
--tksurfer.tcl: overload for "label:" line "CLR": read_label_to_clear_annot
--tksurfer.c: add/export read_label_to_clear_annot()
--tksurfer.tcl: add pointsize, mesh/rgb to labeltick controls win
--tksurfer.tcl: extra labeltick ctrlswin button RESTORE ANNOT BORD undo PRUNE
--tksurfer.c: annotborddotflag uses pointsize/meshrgb to adj annot dot bord
--tksurfer.c: export find_annot_borders()
    [tmprelease 210708]
--tksurfer.tcl: buttonbar for "label:" line "D" R-clk help (disp,conv3d,mak,etc)
--tksurfer.tcl: allow escape from all S/V button actions
--tksurfer.tcl: buttonbar for "val:" line "S/V" butt R-clk help (various swaps)
--tksurfer{.c,.tcl}: confirm toggle bigcursorflag GLX and tk
--tksurfer.c: bigcursorflag makes write_selected_list_to_label save neighbors
--csurf: Preferences -> Cover/Uncover Speedup Hack (mac_appnap_hack) if Mac
--tksurfer.tcl: controls for 4-overloaded unlabeled "fs:" tickbox (grad arrows)
--tksurfer.tcl: buttonbar "fs:" "GR" button Rclk-help (calc gradient arrows)
    [tmprelease 210627]
--mk0{.csh}: distinct inst date (README.txt, csurf help), dist date (src file)
--dist/patch/mpeg_play-2.3/util32.c: linux maxdepth -> 24bit to fix transparent
--FreeSurferEnv.{sh,csh}: rm change LANG (broke start xterm from xterm mac10.15)
--tksurfer.c,tcl: rename write_annotcol_to_label -> write_annotedcol_autoname
--tksurfer.tcl: allow bail from all "label:" line writes
--tksurfer.tcl: allow bail from all "val:" line writes
--tksurfer.tcl: buttonbar "val:" "W" butt Rclk-help (vals,FT2amp,sphims)
--tksurfer.tcl: buttonbar "label:" "W" butt Rclk-help (label,vtxcol,annot,etc)
--tksurfer.tcl: write_mgh_annot: restore overlay if skip count overlap
--wrappers.tcl: allow mult buttonbar's uniq'ed by 1st cmd proc (raise existing)
--lib/help/tksurfer/arrownorm: update
--tksurfer.tcl: add pointsize, pointsflag to ARROWS/NORMALS/POINTS controls
--tksurfer.c: export pointsize
--tksurfer.tcl: buttonbar "label:" "C" butt Rclk-help (recut,hole,add,recutuniq)
--wrappers.tcl: optional title for buttonbar
--csurf: Setup Sphavg help: open correct help rather than just warn


##########################################################################
UPDATE: 14 Jun 2021
##########################################################################

--lib/help/tksurfer/{label_write,label_write_annot}
--tksurfer.tcl: write_mgh_annot: allow mk annot w/label files missing (C now OK)
--tksurfer.c: write_mgh_annot: report/ignore missing label files
--csurf: fix wasn't passing -softtruncphaseflag to tksurfer in Render panel
--tksurfer.tcl: fix stale hard/soft truncphase message
--tksurfer.c: read_mgh_colorlut bail on duplicated color
--tksurfer.tcl: alt mid-click-GOTO finds opposite hemi point
--tksurfer.c: select_opphemi_vertex_coordinates: find fsaverage pnt other hemi
--tksurfer.c: add intern flag (norm/opp) to select_orig_vertex_coordinates
--tksurfer.c: write_mgh_annot: cnt vtxs for region popups (like read_mgh_annot)
--tksurfer.tcl: write_mgh_annot: gather/report all missing label files
--tksurfer.tcl: searchlight correlation popup tells label vs. annot region
--tksurfer.tcl: write_mgh_annot: also chk dup cols
--csurf: NormSearch def now frac=0.8 (paint/paintmulti chk for thickness file)
...

