------------------------------------------------
 The SessionsTools -> Import 3D Stats sets up
 to import statistical data set that have already
 been analyzed with AFNI (or SPM)
------------------------------------------------

Select Input Data Set

First select the input data set to extract and
convert.  The interface will crudely guess at the
StatType using the input file suffix:

  <stem>.img         => SPM
  <stem>.BRIK/HEAD   => AFNI-SINGLE
  <stem>.BRIK/HEAD   => AFNI-MULTI (BRICK_LABS)
  <stem>_%03d.bfloat => BFLOAT

After checking the configuration, then press
EXTRACT/CONVERT.  If this works without error,
press PAINT.

SPM Format

The SPM extraction requires that matlab
be installed (to extract the transformation
matrix) and has not been updated in a long time.
For now, convert to BRIK and use AFNI import.

AFNI BRIK Format

The tools for extracting and converting AFNI
files analyzed with 3dDeconvolve have been more
thoroughly tested.

If a BRIK contains no labels (BRICK_LABS field
in *.HEAD file) or only a single default label
('#0~), it will be treated as an AFNI-SINGLE
import, which allows the extraction of a single
subbrik ("Briks to Skip" selects which subbrik
to extract, if there are more than one).

An extra sub-panel appears when a BRIK containing
multiple labels is selected.  After pressing
the READ HEADER button in the sub-panel, you
should then be able to choose which sub-briks
to extract, which sub-briks to use as maskfiles,
and what the mask threshold should be.  You can
also run clustering and set the cluster radius
and volume.

Paint

Pressing PAINT, paints all the extracted
3D files onto the chosen cortical surface,
using the current vertex normal operation (same
operations as on Setup Align/Funct Scans panel,
for explanation, see Help for that panel).
You can then view all of the painted files later
on in the rendering panel:

  SessionTools -> View Functional Data

where there is a set of radiobuttons near the top
of the panel that allow the rendering of multiple
extracted sub-briks from a single scan directory.
The options are:

 one  -- render selected (single) vertex file
 last -- render all vertexfiles from last extract
 all  -- render all vertexfiles (except complex)

When the multiple-render options are clicked, 
the selected vertex file changes to "-multiple-".
The stems of the output rgb files in that case
are the same as the stems of the sub-briks.

BFLOAT

The bfloat format is a slice-based format with a
minimal header that is used internally by
FreeSurfer programs, and that can be easily be
generated by an external C program.  The filename
format for each slice file and header file is:

  <stem>_%03d.bfloat
  <stem>_%03d.hdr

The slice numbering is zero-based.  The first
slice is therefore:

  <stem>_000.bfloat
  <stem>_000.hdr

The bfloat file is a headerless string of floats
with x as the inner loop (x is the R->L direction
in tkregister when a default (identity matrix)
register.dat is loaded).  The hdr file is an
ASCII file that contains 4 strings:

  <xsize> <ysize> <numtimepoints> <other>

For example:

  64 64 1 0

Note that for binary compatibility across all
platforms, the bfloat files are stored in
SGI/Sun/Mac byte order.  All the FreeSurfer
programs automatically swap bytes on read and
write on Linux.  For this reason, if bfloat files
are generated by a simple C program in Linux
using fwrite(), you should swap the bytes as the
last step.  For example, you could run AFNI 4swap
on each bfloat after generating it.  The hdr
files are ASCII and therefore don't need to be
swapped.

