-------------------------------------------
tcl function: readupsampstats -- read upsamp stats
-------------------------------------------
keyboard equivalent: none

The "R" button reads stats that have already been
upsampled to 1x1x1mm resolution from file(s)
(variable=$upstatpatt) in entry to the left.
The stats may be real or complex, and possibly
3D-smoothed.  The files are read as one (real) or
two (complex) 256x256x256 float BRIK files.

For a single-subject session, this is typically
used to re-read saved smoothed upsampled data.

For a cross-session 3D average, this can be used
read an overlay file containing a cross-subject
average of upsampled data.

If the file in the entry contains an infix
indicating the data is complex (_r or _x), the
companion file for the imaginary component (_i or
_y) will also be read automatically.

Here is the tcl code for the "R" (read) button
function, which calls the tcl-linked-C-function,
read_regupsamp_stat:

# read real or complex upsampled stats
proc readupsampstats { } {
  global complexvalflag upstatpatt
  setfile upstatpatt [.mri.main.right.fi.val.e get]
  read_regupsamp_stat 0  ;# (0=real,1=imag,2=stat)
  if {$complexvalflag} {
    set infix [getstatbrikinfix $upstatpatt]
    if {$infix == "_r"} {
      set imaginfix "_i"
    } elseif {$infix == "_x"} {
      set imaginfix "_y"
    } else { return }
    set origupstatpatt $upstatpatt
    set stem \
      [string range $upstatpatt 0 \
        [expr [string length $upstatpatt] - 13]]
    setfile upstatpatt ${stem}${imaginfix}+orig.BRIK
    read_regupsamp_stat 1
    set upstatpatt $origupstatpatt
  }
}

