
#################################################
#################################################
 This is the default (UCSD) template that appears
 when you select File -> Open Subject NOTES or
 File -> Open Functional NOTES for the first time
 in a subject or functional directory.  This
 template file is stored here:

   $CSURF_DIR/lib/help/csurf/defnotes

 Edit that file to setup site-specific NOTES.
 Also, each user can set up their own default
 NOTES file in:

   ~/.csurfnotes

 The subject- and session-specific (edited by
 user) versions of this file are stored here:

   $session/image/scripts/NOTES
   $subject/scripts/NOTES
#################################################
#################################################


=================================================
Minimal instructions for reconstructing a surface
=================================================
The latest tarball of the UCSD retinotopy-enabled
FreeSurfer (FreeSurfer0.8.tar.gz) is here:

  http://kamares.ucsd.edu/~sereno/csurf/tarballs 

First, decide where you are going to root your
tree of subjects and sessions, and then set these
environment variables to reflect this (the
directories must exist):

  setenv SUBJECTS_DIR /some/place/subjects
  setenv FUNCTIONALS_DIR /some/place/sessions

Now setup your path and start the csurf interface
(you can put the "source ..." line in your .cshrc
to do automatically):

  source \
    /mnt/raid1/sereno/local/etc/FreeSurfer.cshrc
  newdefs
  csurf

To make the highest-quality surface, it is best
to manually align and average two 1x1x1mm MPRAGE
or SPGR scans. To do this, the first step is to
make an new, empty subject (subject "marty" in
the following examples):

  File -> New Subject

Convert the DICOM files to BRIKs, force native
FreeSurfer byte order, make some subdirectories
in the mri/orig subdirectory of the newly made
blank subject, and copy the raw BRIK's into
them:

 cd /raw/s219027
 to3d -prefix spgr1 i*
 forceMSB spgr1+orig.BRIK
 mkdir $SUBJECTS_DIR/marty/mri/orig/spgr1
 cp spgr1+orig.* $SUBJECTS_DIR/marty/mri/orig/spgr1

 cd /raw/s219198
 to3d -prefix spgr2 i*
 forceMSB spgr2+orig.BRIK
 mkdir $SUBJECTS_DIR/marty/mri/orig/spgr2
 cp spgr2+orig.* $SUBJECTS_DIR/marty/mri/orig/spgr2

Now convert the two (or more) scans into the
native COR format and manually align them:

  SubjectTools -> Setup Structural Scans

  [select first scan subdir in list at left]
  Structural Scan Dir
  READ HEADER => check parameters are correct!
  Add "Flip" parameters if scan not coronal:
  -> Thornton sagittal -> coronal: -z y x
  -> fMRI center axial -> coronal: x -z y
  N.B: for fMRI center mp_anat3d scans, add:
    Other Options: -prescale 25

  [select second scan subdir in list at left]
  Structural Scan Dir
  READ HEADER
  Add "Flip" parameters if scan not coronal:
  -> Thornton sagittal -> coronal: -z  y  x
  -> Cent Varian axial -> coronal:  x -z  y
  -> Cent GE axial     -> coronal:  x -z -y

  N.B: for fMRI center mp_anat3d scans, add:
    Other Options: -prescale 25

A single 1x1x1 mm mp_anat3d scan can also be used
if you collect 256 slices (16 minutes) (N.B.:
because mp_anat3d is a volume protocol,
collecting more slices -- even slices outside the
brain -- actually improves the signal in the
central slices).

Finally, start up the manual align:

  CONVERT/AVERAGE 

When buttons turn purple in csurf, something is
going on in the background. If you want to kill
whatever is happening, click the purple button.

CONVERT/AVERAGE will convert the scans to COR
(optionally flipping) and eventually put up the
tkregister application which allows you to flip
back and forth between two 3D scans and align one
(the "MOVEABLE") to the other (the "TARGET").
When you are satisfied, then SAVEREG, and quit
the tkregister application. This will cause csurf
to average the two scans and put the result into
the mri/orig directory (viewable with by picking
the "orig" set of 3D images and hitting the
VOLUME button in csurf). If you only use one
scan, the register step will be skipped.

Now you can start up the 'big button'. This takes
about 4 hours to run on a modern Linux machine
(2GHz). It reconstructs the cortical hemispheres
of each hemisphere, unfolds each one, and then
makes a high quality estimate of the pial surface
and the gray/white matter surface.

  SubjectTools -> Process/Create/Fix/Final

When this finishes, take a look at the surfaces
using the SURFACE button in csurf. If things
don't look right, then edit the segmentation:

  SubjectTools -> Edit Segmentation
  SubjectTools -> Create Surface
  [possibly repeat above two if surface bad...]
  SubjectTools -> Fix/Final

Now you may want to make cuts in order to flatten
part of all of the each hemisphere:

  SubjectTools -> Make Full Surface Cuts

or

  SubjectTools -> Make Occip Surface Cuts

After doing this, then flatten both hemisphere
with:

  SubjectTools -> Flatten Surface

This takes about 4 hours per hemisphere (on the
same 2GHz machine).

==============================================
Minimal instructions for retinotopy analysis
==============================================

The cortical surface is typically reconstructed
from several MPRAGE or SPGR scans taken during a
"structural scan" session (above).

Then, on a number of subsequent "functional scan"
days, we collect an "alignment" scan in the same
plane as the set of "functional" scans (but with
higher resolution). The alignment scan is first
rotated into alignment with the original
structural scans from which the surface was made.
Then the registration matrix is copied (using the
interface) into the functional scan directories,
and touched up by directly comparing the
functional scans to the original high resolution
structural scan.

This makes it possible to collect a large amount
of data on single subjects. Here is an example of
how to collect data on mapping visual areas.
Source code and binaries for the "mapper"
retinotopy stimulus program is available here:

  http://kamares.ucsd.edu/~sereno/stim/IRIX
  http://kamares.ucsd.edu/~sereno/stim/MacOSX
  http://kamares.ucsd.edu/~sereno/stim/Linux
  http://kamares.ucsd.edu/~sereno/stim/src

First start up csurf again:

  newdefs
  csurf

Then make a new blank functional session
directory:

  File -> New Functional

This will query you for a subject name (and a
reconstructed surface) that belongs to the person
from which this functional data was collected. It
has to already exist. For the following example,
the functional session is given a name that sorts
chronologically (year/month/day/initials):

  020930MS

Make subdirectories for each functional scan as
well as the alignment scan in a session:

  cd $FUNCTIONALS_DIR/020930MS/image
  mkdir polar eccen mprage

Copy the raw mprage and functional BRIK's and
HEAD's into those directories and run "flipbrik"
on each functional BRIK like this:

  cp /raw/data/mp_anat3d_01+orig.BRIK mprage
  cp /raw/data/mp_anat3d_01+orig.HEAD mprage
  [don't run flipbrik]

  cp /raw/data/spep_#001+orig.BRIK polar
  cp /raw/data/spep_#001+orig.HEAD polar
  flipbrik \
    polar/spep_#001+orig polar/spep_#001+orig

  cp /raw/data/spep_#002+orig.BRIK eccen
  cp /raw/data/spep_#002+orig.HEAD eccen
  flipbrik \
    eccen/spep_#002+orig eccen/spep_#002+orig

Flipbrik changes the internal ordering of the
data in the AFNI BRIK (and updates the HEAD) so
that x rather than y is the fastest changing
index.

Next, strip off the first three time points
(initial blips-off phase correction acquisition
plus first two non-steady-state TR's):

  cd $FUNCTIONALS_DIR/020930MS/polar
  3dTcat -prefix polar spep_#001+orig'[2..$]'

  cd $FUNCTIONALS_DIR/020930MS/eccen
  3dTcat -prefix eccen spep_#002+orig'[2..$]'

Now open the first panel in the
SessionTools set:

  SessionTools -> Setup Align/Funct Scans

select the alignment scan from the list at the
left at the left and declare the scan to be an
alignment scan by hitting the "Align Scan Dir"
button at the top of the panel.

Now configure the alignment scan:

  read header with READ HEADER button
  enter Block Center Offset
  fix anything that looks incorrect

and then rotate and translate it into alignment
with the original scans the surface was made
from:

  ALIGN=>SUBJ (starts tkregister to align ALIGN
                scan to SUBJECT scan)

When you are done with the manual alignment, hit
SAVEREG on tkregister and quit the tkregister
application.

Now configure all of the functional scans by
selecting each one at the left, and declaring
them to be a "Funct Scan Dir", and filling in the
form:

  READ HEADER
  optionally run AFNI motion correction, 3dvolreg
  (select targ scan, targ TR in scan, hit "ALL")
  select alignment scan from the "Same-Plane
    Structural Dir:" combobox
  enter Block Center Offset
  enter distance to search for data perpendicular
    to each vertex (be reasonable)

Now go back to the Align Scan directory and copy
the transformation matrix into all the functional
directories (automatically accounting for the
difference in voxel size) with:

  COPY ALIGN TO ALL FUNCTS

Be sure to verify that the actual transformation
to be performed by PAINT is a good one by
selecting a functional directory and checking the
alignment with:

  FUNCT=>SUBJ (starts tkregister to align FUNCT
                 scan to SUBJECT scan)

To fix a y-shear in the functional image, rotate
30 deg, shrink (scale-down) y, un-rotate 30 deg,
un-shrink (scale-up) y (shrink/un-shrink x for
x-shear). You can copy your refined registration
to all the other currently configured functionals
with:

  CP TO OTHERS

Now, run the Fourier analysis:

  SessionTools -> Calculate 3D Fourier Stats

  enter the number of stimulus cycles (e.g., 8)
  choose eccen or polar phase encode type
    (presets color scales, analysis scripts)
  do the analysis: FOURIER button
  paint the data on the "orig" surface: PAINT

Optionally calculate field sign:

  SessionTools -> Calculate Visual Fieldsign

Open the rendering panel:

  SessionTools -> View Functional Data

  select scan dir to render from list at left
  select surface or patch from "surface:"
    or "patch:" comboboxes
  hit SURFACE-STATS button

If you redo your registration, you need to
re-paint and re-render everything.  If you want
to redo your registration and then re-paint and
re-render, run:

  SessionTools -> Run Batch Process

select Run All Paint Surfaces and Run All
Rendering Panels, and hit Start.  This will open
all the panels of currently configured scans, run
the PAINT button in each one, and then run the
SURFACE-STATS button in each one. In addition, it
will save bitmaps for any folded or flat views
you have configured on View Functional Data
panels.

The Help -> ... menu items have more detailed
information for all the extra panels. You can
never leave too many ASCII notes in:

  File -> Open Subject NOTES
    (in $subject/scripts/NOTES)

  File -> Open Functional NOTES
    (in $session/image/scripts/NOTES)

:-}

marty

