###################################################################
UPDATE:  02 May 2026
###################################################################

-------------------------------------------------------------------
Summary:
  (1) find gradient reversals (curv, real-valued, phase)
  (2) export annot region IDs to label/wfile (copy_idnum_val)
  (3) new csurf menu item: add Preferences -> Upate Csurf
  (4) tksurfer: alt/cmd-z undo for accidental clear vertex marks
-------------------------------------------------------------------


-------------------------------------------
(1) find gradient reversals (curv, real-valued, phase data)
-------------------------------------------

There is a new 13th "Find Gradient Reversals"
button on the R-click popup for the tksurfer "GR"
(gradient) button.  It runs the C/tcl function,
find_gradient_reversals.  This requires that a
gradient (of .curv, real-valued data in .val, or
complex-valued phase data from .val and .val2) has
first been calculated and displayed using one of
the first 12 buttons on the "GR" right-click
popup.

For each vertex, the absolute angular difference
(lesser of CW and CCW angles) between the gradient
vector at the vertex and the gradient vectors at
each neighboring vertex are measured.  For each
angular difference that exceeds $mindiffphase, the
.pval field for that vertex is incremented by 1/n,
where n is the number of neighbors.  The
permissive default value of $mindiffphase is 0.1
(36deg) (0.5=180deg), which can be increased to
reduce noise in the reversal detection.

The calculated vertexwise .pval's are saved as a
wfile in the current scandir (or in the subject's
scripts dir for curv gradient reversals) as:

  gradrevprob_k-$hemi.w

The gradient reversals can be displayed in
two ways.  By default, $pvalborddotflag is ON
(ticked), which displays reversal vertices as cyan
dots (color adjustable in the the popup), with a
.pval threshold controlled by $dthresh (default
0.3).  Turn this up to reduce the number of dots
displayed (i.e., require a higher pval).

If $pvalborddotflag is unticked, there will be a
popup offering to swap .pval into the .val field
and display it using colscale 11 (BRy).

Here are some screenshots of using this function
on retinotopy and curvature data:

 https://pages.ucsd.edu/~msereno/csurf/screenshots/reversals-4polavg.jpg
 https://pages.ucsd.edu/~msereno/csurf/screenshots/reversals-curv+gradarrows.jpg


-------------------------------------------
(2) copy_idnum_val: export annot region IDs to label/wfile
-------------------------------------------

A new C/tcl function, copy_idnum_val, was added to
the R-click "S/V" (swap stat val) button bar.
After an MGH annotation file has been loaded and
displayed, this will copy the integer region ID
numbers to the .val field at each vertex.  This
allows writing out a labelfile OR a valfile as a
lightweight version of an annotation.

The x,y,z coordinates in the labelfile can be
'original' (from $hemi.orig), or can be Talairach
(MNI 305 or MNI 152, as selected by |la|cu|
buttons at the upper left, prior to writing
the file.

This was used to add 8 lightweight 'annotation'
files (labelfiles, valfiles):

 {rh,lh}-CsurfMaps1_MNI152.label
 {rh,lh}-CsurfMaps1_MNI305.label
 CsurfMaps1_newcurv-{rh,lh}.w
 CsurfMaps1_old3byte-{rh,lh}.w

to both the csurf download site and the fsaverage
and fsaverage-ADDITIONS tarfiles:

  https://pages.ucsd.edu/~msereno/csurf:
    fsaverage-labels/CsurfMaps1-parcellation/simple-annot/*
    fsaverage.tgz              # full, updated
    fsaverage-ADDITIONS.tgz    # just additions, updated


-------------------------------------------
(3) Add Preferences -> Update Csurf
-------------------------------------------

There is a new csurf menu item to auto-run the
'update-csurf' shell script from the csurf
interface itself.  It moves the existing install
aside to a dated directory.  You have to
quit/restart csurf to get the new version.

The old, moved-aside install directory and the
new tarfile can/should be deleted to save space
afterward.

-------------------------------------------
(4) tksurfer: alt/cmd-z undo for accidental clear vertex marks
-------------------------------------------

An alt/cmd-z in the surface display window
restores vertex marks accidentally cleared with a
R-click.  This is useful when making difficult
cuts on complexly shaped surfaces for flattening
(e.g., cerebellum :-} ).



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

Rm'd Apr2026 vtx range chk on deref'd selected ptr that broke 1st tksurfer GOTO

Better layout of fieldsign and find retin borders panel

tksurfer.c: add compute_laplacian (curv, real, complex phase)

tksurfer.c: write_label_hdr() includes Talairach 152 vs. 305, normd{frac}samp

new opt cancels separate overlay fade into 2 sulc/gyrus grays above fthresh


##########################################################################
UPDATE: 02 May 2026
##########################################################################

   [newrelease 260502]
--lib/help/tksurfer/{save,goto}_pnt: update
--tksurfer.c: sensibly rename: *vindex -> *selectedptr (in 2 functs below)
--tksurfer.c: same fix as below for (script-only) select_talairach_point
   [tmprelease 260429]
--tksurfer.c: funct below passed &selected(def=-1) so deref rngchk brks 1stcall
--tksurfer.c: rm bad select_orig_vertex_coords err chk *vindex - broke 1st GOTO
--tksurfer.tcl: bind toggle nobicurvfadeoverfthresh mid-clk F3 panel "cv" radio
   [tmprelease 260426]
--tksurfer.tcl: cut_{line,vertices},uncut_connected_vertices: warn no selected
--lib/help/tksurfer/curv_tick: update
--tksurfer.tcl: bind toggle nobicurvfadeoverfthresh mid-clk "[ ] curv" tickbox
--tksurfer.c: add/exp nobicurvfadeoverfthresh:no diff fade to sulc/gyr > fthresh
   [tmprelease 260412]
--tksurfer.tcl: disp-annot,chng-annotbordflag reselect_selected_list:select->top
--tksurfer.c: finally fix undo logic! select_vertex w/select=-1 restarts baklist
--tksurfer.c: back out: draw_curs 3x for all b/c weird offset select problem?
--tksurfer.c: reselect_selected_list: draw last-in-list curs 2x extra fix fail?
--lib/help/tksurfe/clks: update, undo
--tksurfer.c: glxwin 'cmd-z' restores prev selected list & redisplays
--tksurfer.c; add restore_selected_list()
--tksurfer.c: clear_vertex_marks_list saves prev (if not already clr:2Rclk help)
--tksurfer.c: glxwin 'd' key does reselect_selected_list to see over annot
--tksurfer.c: add/export reselect_selected_list()
   [tmprelease 260108]
--csurf: warn {SUBJECTS,FUNCTIONALS}_DIR autoset to inside csurf (by FS Env)
--update-csurf: non-verbose untar if "ggo" to not clog csurf.log
--csurf: updatecsurfcmd: find moved-aside name before run update-csurf
--csurf: check csurf install/update dir writable
--csurf: add un-quarantine commands to final updatecsurfcmd popup
    [tmprelease 260104]
--update-csurf: echo pwd/install dir!
--update-csurf: Mac warns run xattr (new tar), don't autodo b/c req's passwd
--csurf: Preferences->Update Csurf:setupupdatecsurf,updatecsurfcmd: update-csurf
--update-csurf: add "ggo" for don't-ask install
    [tmprelease 260101]
--8 file/label lightweight 'annots' (8M) added to fsaverage/fsaverage-ADDITIONS
 {rh,lh}-CsurfMaps1_MNI152.label
 {rh,lh}-CsurfMaps1_MNI305.label
 CsurfMaps1_newcurv-{rh,lh}.w
 CsurfMaps1_old3byte-{rh,lh}.w
--tksurfer.c: write_label_hdr() includes Talairach 152 vs. 305, normd{frac}samp
--lib/help/tksurfer/val_{lab,write}: update
--tksurfer.tcl: mid-click "val;" makes allverticesflag,val2newcurfflag popup
--tksurfer.tcl: left-click "label:" auto-pops up label_label help
--lib/help/tksurfer/swapstatval: update
--tksurfer.tcl: add copy_idnum_val to S/V (swap stat val) button bar
--tksurfer.c: add/export copy_idnum_val (for writing annot-like wfile/label)
--lib/help/tksurfer/comp_grad: doc hidden compute_laplacian <0,1,2> funct
--tksurfer.c: scale_brain() updates tcl-exported glxzoomfact (not yet used)
--tksurfer.c: trunc pval dots w/fthresh (not fully general for all mod flags)
--tksurfer.tcl: rm 3 Calc Laplacian (includelaplacian=0),leave procs,tksurfer.c
--tksurfer.tcl add 3 Calc Laplacian buttons, comp_disp_laplace proc
--tksurfer.c: add/export compute_laplacian (curv,val,phase) -> valbak
--wrappers.tcl: allow "whitespace" (use proc null), added into GR gradient menu
--tksurfer.tcl: findgradrevctrls help: non-existent findgradrev -> comp_grad
    [tmprelease 251126]
--lib/help/tksurfer/{gradfsarrows,comp_grad}: updates
--tksurfer.tcl: add flipRHpolararrowsflag to FIELDSIGN and GRADIENT ARR
--tksurfer.tcl: do_gradrev: find_grad..,write pval wfile, borddots/val display
--tksurfer.c: add/export pvalborddotflag/dthresh to view .pval above thr as dots
--tksurfer.c: find_gradient_reversals: get same ang from 2D/3D grads dot prod
--lib/help/tksurfer/gradfsarrows: update stale hotkeys, regularize
--tksurfer.tcl: don't trunc lg early-area curv gradients (curv avg flatter/OK)
--tksurfer.c: find_gradient_reversals: replace w/new neighbors-only version
--tksurfer.c: add/export find_gradient_reversals (similar to find_retin_borders)
--tksurfer.tcl: findgradrevctrls popup to run find_gradient_reversals
--tksurfer.tcl: calc gradient reversals make-popup-button to GR button R-click
--lib/help/csurf/setupfield: respect reordered parms
--csurf: Setup Calculate Fieldsign, Borders: dividers, better var description
--lib/help/tksurfer/comp_grad: fix avggradvecbak{3d}flag->reggradvecbak{3d}flag


##########################################################################
UPDATE: 17 Sep 2025
##########################################################################
    [tmprelease 250917]
--lib/help/tksurfer/gradfsarrows: update
--tksurfer.c: bugfix: compute_{gradient,surfgrad} unset valbaks_cart2polarflag
--tksurfer.tcl: do_grad2col bugfixes: accept 3D surfgrad, blk reggrad, colscale
--lib/help/tksurfer/comp_grad: update
--tksurfer.c: add/export flipRHpolararrowsflag (def=1) for draw_arrows{2,3}d
--tksurfer.tcl: add 6 brainregion avg gradient buttons to GR gradient buttonbar
--tksurfer.tcl: add reggradvecbak{3d}flags to FIELDSIGN and GRADIENT ARROWS ppup
--tksurfer.c: draw_arrows{2d,3d}() can also just draw brainregion[i].avgvtx k's
--tksurfer.c: add/exp reggradvecbakflag,reggradvecbak3dflag,reggradvecloadedflag
--tksurfer.c: add/export compute_brainregion_avggrads
--mk0: insttmp finally puts tardate also into all-help
    [tmprelease 250829]
--lib/help/tkurfer/label_toggle: document dthreshfact, reason for it
--tksurfer.tcl: add $dthreshfact hack to LABEL CONTROLS popup
--lib/help/*/*: shorten lines for AllHelp (48 vs. 50 wide to reduce white space)
--lib/help/tksurfer: update 18 helpfiles: incl buttonbar buttontext for search!
--tksurfer.tcl: labelR_val: better error/help if trying to read .cols file
--tksurfer.tcl: listcmd_tcl: don't dup dropdown scripts csurf start from subjdir
--lib/tcl/zz-examples/assemble-render-maps.tcl: dthreshfact anti-labelflash hack
--tksurfer.c export dthreshfact->tcl: desperate hack fix flashy labels w/script
    [tmprelease 250810]
--csurf: add Expert Preferences->Views alt font, pass -fontfile to tksurfer
    [tmprelease 250810]
--csurf: add Expert Preferences->Views alt font, pass -fontfile to tksurfer
    [tmprelease 250808]
--mk0: 04f: combine separate but dependent freetype,ftgl compiles to "libftgl"
--tksurfer.c: add opt -fontfile for diff .ttf font put into $CSURF_DIR/lib/fonts
--tksurfer.c: 1 cm label same col as scalebar, tweak bar thick, font size/pos
--tksurfer.c: separate draw_areanames dthresh (depth) inflated vs. folded surf
    [tmprelease 250804]
--tksurfer.c: fix linux compiler cast warnings
--mk0: 04e: add freetype, ftgl for static tksurfer compile
--tksurfer.c: new fast draw_areanames: cmp testpnt depth w/glReadPixels readback
    [tmprelease 250802]
--tksurfer.c: draw_areanames: test neigh to 6th order to fix sloppy re-select
--tksurfer Makefile: LIB_PATH mv X11 after freetype/ftgl to get static freetype
--lib/help/tksurfer/{label_write: update
--tksurfer.tcl: "Write Region Centers" butt R-clk "W" on "label:" line buttbar
--tksurfer.c: draw_areanames: add brightness cue to reduce edge flashing
--tksurfer.c: draw_areanames: hacky/slow/working select_vertex occlusion test
--mk0: dist/insttmp: copy luxisb.ttf to $CSURF_DIR/lib/fonts
--tksurfer.c: add write_annot_region_centers (scriptsdir:AnnotRegionCenters.txt)
--lib/help/tksurfer/{label_toggle,meshr/g/b,label_read}: update
--tksurfer.c: fix scalebar label scaling/placement
--tksurfer.tcl: if vars exist, add $areanamesflag, annot-warn to LABEL CONTROLS
--tksurfer.c:   newvars: export: fontname,areanamesflag, intern: FTFont
--tksurfer.c:   newfunc: export:draw_areanames intern:initfont,drawstr_centonvec
--tksurfer.c:   #include FTGL/ftgl.h, #define FTGLFONT to included luxisb.ttf
--tksurfer.c: add ifdef'd __cplusplus FTGL font code below (req's g++) 3 above:
--tksurfer.c: add find_regionvtx_nearest_avg, always do (fast) in read_mgh_annot
--tksurfer.c: add vec2glxwinpix so to use glBitmap (vs. glRasterPos) for FTGL
--tksurfer Makefile: logic so just changing CMPL to g++ fixes libs/includes
...

