Differences between revisions 1 and 45 (spanning 44 versions)
Revision 1 as of 2005-08-05 13:06:26
Size: 32960
Comment: first draft
Revision 45 as of 2015-11-06 15:04:02
Size: 36153
Editor: LeeTirrell
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## Note: This page was created with the CommandTemplate
##
## If you're modifying this page please take a look at the
## latest version of CommandTemplate to ensure that you're
## using the latest version of the CommandTemplate
##
## See HelpOnCommandTemplate for description of formatting

'''Index'''
[[TableOfContents]]
'''recon-all''' (See also ReconAllDevTable, OtherUsefulFlags and [[http://grahamwideman.com/gw/brain/fs/fsunderstanding2006/processvsdata2006.htm|ProcessVsFilesTable]])

'''Index''' <<TableOfContents>>
Line 14: Line 6:
recon-all - Performs all, or any part of, the FreeSurfer cortical reconstruction
process.
recon-all : Performs all, or any part of, the FreeSurfer cortical reconstruction process.
Line 18: Line 9:
recon-all -subjid subjid [Clustered Directive] ||recon-all ||-subjid subjid [Directive] ||
Line 21: Line 13:
== Required Argument ==
|| -subjid subjid || the subject data upon which to operate ||
Note: arguments are described in greater detail in the Description section (further below).

== Required Arguments ==
||-subjid subjid ||the subject data upon which to operate ||
||[Directive] ||one or more directives (see next) ||


== Specify input ==
||-i file.dcm ||single DICOM file from the T1 MRI series. If you have more than one T1, then use: -i file1.dcm -i file2.dcm ||
||-i file.nii||single NIFTI file from series||


== Fully-Automated Directive ==
||-all ||do everything, including subcortical segmentation ||
||-autorecon-all ||same as -all ||


== Manual-Intervention Workflow Directives ==
||-autorecon1 ||process steps 1-5 (see below) ||
||-autorecon2 ||process steps 6-23 ||
|| ||after autorecon2, check final surfaces: ||
|| ||a. if wm edit was required, then run -autorecon2-wm ||
|| ||b. if control points added, then run -autorecon2-cp ||
|| ||c. if edits made to correct pial, then run -autorecon2-pial ||
|| ||d. proceed to run -autorecon3 ||
||-autorecon2-cp ||process stages 12-23 (uses -f w/ mri_normalize, -keep w/ mri_seg) ||
||-autorecon2-wm ||process stages 15-23 ||
||-autorecon2-pial ||process stages 21-23 ||
||-autorecon3 ||process stages 24-31 ||
||-hemi ?h ||just do lh or rh (default is to do both) ||


 . Autorecon Processing Stages (see -autorecon# flags above):
  1. Motion Correction and Conform
  1. NU (Non-Uniform intensity normalization)
  1. Talairach transform computation
  1. Intensity Normalization 1
  1. Skull Strip

  1. EM Register (linear volumetric registration)
  1. CA Intensity Normalization
  1. CA Non-linear Volumetric Registration
  1. Remove Neck
  1. LTA with Skull
  1. CA Label (Volumetric Labeling, ie Aseg) and Statistics

  1. Intensity Normalization 2 (start here for control points)
  1. White matter segmentation
  1. Edit WM With ASeg
  1. Fill (start here for wm edits)
  1. Tessellation (begins per-hemisphere operations)
  1. Smooth1
  1. Inflate1
  1. QSphere
  1. Automatic Topology Fixer
  1. Final Surfs (start here for brain edits for pial surf)
  1. Smooth2
  1. Inflate2

  1. Spherical Mapping
  1. Spherical Registration
  1. Spherical Registration, Contralateral hemisphere
  1. Map average curvature to subject
  1. Cortical Parcellation - Desikan_Killiany and Christophe (Labeling)
  1. Cortical Parcellation Statistics
  1. Cortical Ribbon Mask
  1. Cortical Parcellation mapping to Aseg

== Step-wise Directives ==
See Description section.

== Expert Preferences ==
||-pons-crs C R S ||col, row, slice of seed point for pons, used in fill ||
||-cc-crs C R S ||col, row, slice of seed point for corpus callosum, used in fill ||
||-lh-crs C R S ||col, row, slice of seed point for left hemisphere, used in fill ||
||-rh-crs C R S ||col, row, slice of seed point for right hemisphere, used in fill ||
||-nofill ||do not use the automatic subcort seg to fill ||
||-custom-tal-atlas ||allows a custom talairach atlas to be used ||
||-watershed cmd ||control skull stripping/watershed program ||
||-wsless ||decrease watershed threshold (shrinks skull surface) ||
||-wsmore ||increase watershed threshold (expands skull surface) ||
||-wsatlas ||use atlas when skull stripping ||
||-wsthresh pct ||explicity set watershed threshold ||
||-wsseed C R S ||identify an index (C, R, S) point in the skull ||
||-nuiterations N ||set number of iterations for nu intensity correction (default is 2) ||
||-norm3diters niters ||number of 3d iterations for mri_normalize ||
||-normmaxgrad maxgrad ||max grad (-g) for mri_normalize. Default is 1. ||
||-cm ||conform COR volumes to the min voxel size ||
||-no-fix-with-ga ||do not use genetic algorithm when fixing topology ||
||-seg-wlo wlo ||set wlo value for mri_segment ||
||-seg-ghi ghi ||set ghi value for mri_segment ||
||-no-ca-align ||turn off -align with mri_ca_{register,label}. ||
||-deface ||deface subject, written to orig_defaced.mgz ||
||-expert file ||read-in expert options file ||


== Notification Files (Optional) ==
||-waitfor file ||wait for file to appear before beginning ||
||-notify file ||create this file after finishing ||


== Status and Log files (Optional) ==
||-log file ||default is $SUBJECTS_DIR/<your_subjectid>/scripts/recon-all.log ||
||-status file ||default is $SUBJECTS_DIR/<your_subjectid>/scripts/recon-all-status.log ||
||-noappend ||start new log and status files instead of appending ||


== Other Arguments (Optional) ==
||-sd subjectsdir ||specify subjects dir (default env SUBJECTS_DIR) ||
||-mail username ||mail user when done ||
||-umask umask ||set unix file permission mask (default 002) ||
||-grp groupid ||check that current group is alpha groupid ||
||-debug ||print out lots of info ||
||-dontrun ||do everthing but execute each command ||
||-version ||print version of this script and exit ||
||-help ||yea, like anybody's going to read this ||


= Description =
Performs all, or any part of, the FreeSurfer cortical reconstruction process. This help only gives some simple information. See also ReconAllDevTable.

Basic usages:

1. Subject dir does not exist:

 . recon-all -subject subjectname -i invol1 <-i invol2> -all

Creates analysis directory $SUBJECTS_DIR/subjectname, converts one or more input volumes to MGZ format in subjectname/mri/orig, and runs all processing steps.

2. Manual conversion into mgz:

 . mkdir -p $SUBJECTS_DIR/subjectname/mri/orig mri_convert invol1 $SUBJECTS_DIR/subjectname/mri/orig/001.mgz mri_convert invol2 $SUBJECTS_DIR/subjectname/mri/orig/002.mgz recon-all -subject subjectname -all

If no input volumes are given, then it is assumed that the subject directory has already been created and that the raw data already exists in MGZ format in subjid/mri/orig as XXX.mgz, where XXX is a 3-digit, zero-padded number.

3. Legacy Data

 . recon-all -subject subjectname -all -legacy

== Subject Identification String ==
{{{
-s subjectname
-sid subjectname
-subjid subjectname
-subject subjectname
}}}
'subjectname' is the FreeSurfer subject identification string which doubles as the name of the reconstruction root directory for this subject. This reconstruction should be referenced by this string for all FreeSurfer commands and in the register.dat matrix (for functional interfacing).

== Specifying Directives ==
Directives instruct recon-all which part(s) of the reconstruction stream to run. While it is possible to do everything in one shot (using the -all flag), there can be some benefits to customizing the stream. These benefits include stopping to perform manual editing as well as parallelization. Directives are either clustered or step-wise. Clustered directives are sets of steps that can be performed by specifying a single flag. A step-wise directive refers to a single step. Directives accumulate. A step can be removed from a cluster by adding -no<step> after the cluster flag. For example, specifying -all followed by -notalairach will perform all the reconstruction steps except talairaching. However, note that if -notalairach preceeded -all, talairaching would still be performed.
Line 25: Line 165:
|| -all || do everything ||
|| -stage1 || pre-manual editing (mc, tal, norm, strip, seg, stage2) ||
|| -stage2 || with manual editing (fill, tess, sm1, inf1) ||
|| -stage3 || runs the topology fixer (and stage2) ||
|| -stage4a || make final surfaces ||
|| -stage4b || spherical morph ||
|| -hemi ?h || just do lh or rh (default is to do both) ||
|| -subcortseg || automatic subcortical segmentation (aseg) ||

== Legacy Clustered Directives ==
|| -segment_subject || (same as stage1 without motion cor) ||
|| -inflate_subject || fill, tessellate, smooth1, inflate1 ||
|| -fix_subject || (qsphere, fix, smooth2, inflate2) ||
|| -morph || (sphere, surfreg, contrasurfreg, avgcurv, avglabels) ||
|| -make_final_surfaces || finalsurfs ||
{{{
-all
-autorecon-all
}}}
Perform all reconstruction steps, including subcortical segmentation.

{{{
-autorecon1
}}}
Motion correction through skull strip.

{{{
-autorecon2
}}}
Subcortical segmentation through make final surfaces.

{{{
-autorecon2-cp
}}}
Normalization2 through make final surfaces.

{{{
-autorecon2-wm
}}}
Fill through make final surfaces. Used after editing wm volume after running -autorecon2.

{{{
-autorecon2-pial
}}}
Makes final surfaces. Used after editing brain volume after running -autorecon2. The brain volume may be edited to fix problems with the pial surface.

{{{
-autorecon3
}}}
Spherical morph and automatic cortical parcellation.

{{{
-hemi hemisphere
}}}
Instruct recon-all to only operate on the specified hemisphere. Legal values are lh and rh. This can be used to run the surface-related steps in parallel.
Line 42: Line 207:
  See below Step-wise directives allow the user to implement a single step in the reconstruction process. See also STEP DESCRIPTION SUMMARIES below. They also allow users to include/exclude a step from a clustered DIRECTIVE. To include a step, use -step (eg, -skullstrip). To exclude a step, use -nostep (eg -noskullstrip).

Run times are approximate for an AMD Opteron 64bit 2.5GHz processor. The topology fixer processing time varies considerably depending on the complexity of the defects in need of fixing.
||-<no>motioncor ||< 5 min || ||
||-<no>nuintensitycor ||3 min || ||
||-<no>talairach ||1 min || ||
||-<no>normalization ||3 min || ||
||-<no>skullstrip ||1 min || ||
||-<no>gcareg ||8 min || ||
||-<no>canorm ||1 min || ||
||-<no>careg ||10 hours || ||
||-<no>rmneck ||3 min || ||
||-<no>skull-lta ||9 min || ||
||-<no>calabel ||30 min || ||
||-<no>normalization2 ||3 min || ||
||-<no>segmentation ||4 min || ||
||-<no>fill ||1 min || ||
||-<no>tessellate ||< 1 min ||per hemisphere ||
||-<no>smooth1 ||< 1 min ||per hemisphere ||
||-<no>inflate1 ||1 min ||per hemisphere ||
||-<no>qsphere ||16 min ||per hemisphere ||
||-<no>fix ||1-9 hours ||per hemisphere ||
||-<no>finalsurfs ||1-2 hours ||per hemisphere ||
||-<no>smooth2 ||< 1 min ||per hemisphere ||
||-<no>inflate2 ||2 min ||per hemisphere ||
||-<no>cortribbon ||< 1 min ||per hemisphere ||
||-<no>sphere ||1-2 hours ||per hemisphere ||
||-<no>surfreg ||1 hour ||per hemisphere ||
||-<no>contrasurfreg ||1 hour ||per hemisphere ||
||-<no>avgcurv ||< 1 min ||per hemisphere ||
||-<no>cortparc ||1 min ||per hemisphere ||
||-<no>parcstats ||< 1 min ||per hemisphere ||
||-<no>cortparc2 ||1 min ||per hemisphere ||
||-<no>parcstats2 ||< 1 min ||per hemisphere ||
||-<no>aparc2aseg ||1 min || ||
||-all ||20-40 hours ||both hemipheres ||


Line 45: Line 248:
|| -usecontrolpoints || use control points when intensity normalizing ||
|| -keepwmedits || keep edits to wm volume when segmenting ||
|| -pons-xyz X Y Z || XYZ of seed point for pons, used in fill ||
|| -cc-xyz X Y Z || XYZ of seed point for corpus callosum, used in fill ||
|| -lh-xyz X Y Z || XYZ of seed point for left hemisphere, used in fill ||
|| -rh-xyz X Y Z || XYZ of seed point for right hemisphere, used in fill ||
|| -fill-with-aseg || use the automatic subcort seg to fill ||
|| -watershed cmd || control skull stripping/watershed program ||
|| -wsless || decrease watershed threshold (shrinks skull surface) ||
|| -wsmore || increase watershed threshold (expands skull surface) ||
|| -wsatlas || use atlas when skull stripping ||
|| -wsthresh pct || explicity set watershed threshold ||
|| -wsseed C R S || identify an index (C, R, S) point in the skull ||
|| -nuiterations N || set number of iterations for nu intensity correction (default is 4) ||
|| -norm3diters niters || number of 3d iterations for mri_normalize ||
|| -cm || conform COR volumes to the min voxel size ||
|| -edit_wm_with_aseg || use automatic segmentation to edit WM volume ||
|| -no-fix-with-ga || do not use genetic algorithm when fixing topology ||

== Notification Files (Optional) ==
|| -waitfor file || wait for file to appear before beginning ||
|| -notify file || create this file after finishing ||

== Status and Log files (Optional) ==
|| -log file || default is scripts/recon-all.log ||
|| -status file || default is scripts/recon-all.status ||
|| -noappend || start new log and status files instead of appending ||

== Other Arguments (Optional) ==
|| -mgz || use compressed MGH format ||
|| -COR || use compressed MGH format ||
|| -disable-autoseg || disable automatic segmentation ||
|| -sd subjectsdir || specify subjects dir (default env SUBJECTS_DIR) ||
|| -gca gcafile || full path to gca file ||
|| -gca-tl gcatlfile || full path to gca temporal lobe file ||
|| -mail username || mail user when done ||
|| -umask umask || set unix file permission mask (default 002) ||
|| -grp groupid || check that current group is alpha groupid ||
|| -debug || print out lots of info ||
|| -dontrun || do everthing but execute each command ||
|| -version || print version of this script and exit ||
|| -help || yea, like anybody's going to read this ||

= Description =
Performs all, or any part of, the FreeSurfer cortical reconstruction process. It is assumed that the subject directory has already been created using mksubjdirs and that the raw data already exists in subjid/mri/orig, either in COR format or mgz. The format is automatically detected. To explicitly use COR, then add -COR. To explicitly use mgz, then add -mgz. When automatically detecting, looks for a COR volume in orig/XXX in COR format (XXX is a three-digit, zero-padded number). If that is not found, then looks for orig/XXX.mgz. See USING COMPRESSED MGH FORMAT (MGZ) below.

This help is not meant to be exhaustive documentation on FreeSurfer. For more information, see the references at the end or go to the FreeSurfer web site at http://surfer.nmr.mgh.harvard.edu. In particular, there is both a reconstruction guide and tutorial as well as manuals for tkmedit and tksurfer. The FreeSurfer mailing list can also be reached at freesurfer@nmr.mgh.harvard.edu.

= SUBJECT IDENTIFICATION STRING =
{{{
-subjid subjectid
}}}
This is the FreeSurfer subject identification string which doubles as
the name of the reconstruction root directory for this subject. This
reconstruction should be referenced by this string for all FreeSurfer
commands and in the register.dat matrix (for functional interfacing).

= SPECIFYING DIRECTIVES =
Directives instruct recon-all which part(s) of the reconstruction
stream to run. While it is possible to do everything in one shot
(using the -all flag), there can be some benefits to customizing the
stream. These benefits include stopping to perform manual editing as
well as parallelization. Directives are either clustered or step-wise.
Clustered directives are sets of steps that can be performed by
specifying a single flag. A step-wise directive refers to a single
step. Directives accumulate. For example, specifying -stage1 and
-stage3 will perform all the steps in both stage 1 and 2. A step can
be removed from a cluster by adding -no<step> after the cluster
flag. For example, specifying -all followed by -notalairach will
perform all the reconstruction steps except talairaching. However,
note that if -notalairach *preceeded* -all, talairaching would still
be performed.

= CLUSTERED DIRECTIVES =
{{{
-all
}}}
Perform all reconstruction steps.
{{{
-stage1
}}}
Perform all the stages prior to manually editing the wm volume. This
includes motion correction and averaging, talairaching, non-uniform
(nu) intensity correction, intensity normalization, skull stripping,
and white matter segmentation. It also runs stage2 so that users can
immediately start manual editing using the surface as a guide (stage2
usually only takes a few minutes). Runs the following steps:
motioncor, talairach, normalization, skullstrip, fill, tessellate,
smooth1, and inflate1. Approximate run time: 20 min.
{{{
-stage2
}}}
Run this stage after each manual edit. Cuts hemispheres from each
other and from the mid brain and fills each hemisphere in the volume
with a constant value, tesslates the surface, smooths, and inflates.
Runs the following steps: fill, tessellate, smooth1, and inflate1.
This stage is also run with stage1 and stage3. Approximate
run time: less than 5 min.
{{{
-stage3
}}}
Runs qsphere and automatic topology fixing. This will regeneate the
orig surface as well as the smoothwm surface, the inflated surface,
and the area, curv, and sulc files. Runs the following steps: fill,
tessellate, smooth1, inflate1, fix, euler, smooth2, inflate2. It is a
good idea to check the orig surface at this stage. It also runs stage2
just in case the user did not run it after manual editing (stage2
usually only takes a few minutes). Approximate run time: 1 hour per
hemisphere.
{{{
-stage4a
}}}
Creates the final surfaces (ie, white, pial, and thickness). Includes
the following step: finalsurfs. Can be run in parallel with -stage4b.
Approximate run time: 1.5 hour per hemisphere. Includes creating a mask
of the cortical ribbon (see -cortribbon) as ?h.ribbon.mgz.
{{{
-stage4b
}}}
Run spherical morph, which includes the following steps: sphere,
surfreg, contrasurfreg, avgcurv, avglabels. Can be run in parallel
with -stage4a. Approximate run time: 6.5 hours per hemisphere.
{{{
-hemi hemisphere
}}}
Instruct recon-all to only operate on the specified hemisphere. Legal
values are lh and rh. This can be used to run the surface-related
steps in parallel.
{{{
-autorecon1
}}}
Motion correction through skull strip
{{{
-autorecon2
}}}
Subcortical segmentation through make final surfaces
{{{
-autorecon2-cp
}}}
Normalization2 through make final surfaces. Implies -usecontrolpoints
and -keepwmedits. Used after adding control points after running
-autorecon2.
{{{
-autorecon2-wm
}}}
Fill through make final surfaces. Used after editing wm volume after running
-autorecon2.
{{{
-autorecon2-pial
}}}
Makes final surfaces. Used after editing brain volume after running
-autorecon2. The brain volume may be edited to fix problems with the
pial surface.
{{{
-autorecon3
}}}
Spherical morph and automatic cortical parcellation.

LEGACY CLUSTERED DIRECTIVES

Legacy clustered directives implement sets of steps associated with
scripts before the advent of recon-all.

STEP-WISE DIRECTIVES

Step-wise directives allow the user to implement a single step in the
reconstruction process. See also STEP DESCRIPTION SUMMARIES below.
They also allow users to include/exclude a step from a clustered
DIRECTIVE. To include a step, use -step (eg, -skillstrip). To exclude
a step, use -nostep (eg -noskullstrip). Run times are approximate for
Pentium III (Coppermine) 1GHz processor.

  -<no>motioncor < 5 min
  -<no>talairach 2 min
  -<no>nuintensitycor 12 min
  -<no>usenuintensitycor N/A
  -<no>normalization 5 min
  -<no>skullstrip 1 min
  -<no>normalization2 5 min
  -<no>segmentation 4 min
  -<no>gcareg 10 min
  -<no>fill 1 min
  -<no>tessellate 1 min per hemisphere
  -<no>smooth1 1 min per hemisphere
  -<no>inflate1 4 min per hemisphere
  -<no>qsphere 40 min per hemisphere
  -<no>fix 2 min per hemisphere
  -<no>euler 1 min per hemisphere
  -<no>smooth2 1 min per hemisphere
  -<no>inflate2 4 min per hemisphere
  -<no>finalsurfs 1.5 hours per hemisphere
  -<no>cortribbon 1 min per hemisphere
  -<no>sphere 3.0 hours per hemisphere
  -<no>surfreg 1.5 hours per hemisphere
  -<no>contrasurfreg 1.5 hours per hemisphere
  -<no>avgcurv 1 min per hemisphere
  -<no>avglabels 5 min per hemisphere
  -<no>cortparc 5 min per hemisphere
  -<no>parcstats 1 min per hemisphere
  -edit_wm_with_aseg

EXPERT PREFERENCES

-usecontrolpoints

Use control points during intensity normalization. They are used when
the inensity normalization fails because it cannot determine the
proper intensity for white matter. A control point is a manually selected
location in the volume that the user feels sure is inside white matter.
Control points are created using tkmedit. Inside tkmedit, enable
editing of control points with Tools->EditCtrlPts. Middle-clicking
will create a control point; right-clicking will delete a control
point. After creation, File->SaveControlPoints; this will create a
file called subjid/tmp/control.dat.

-keepwmedits

Keep edits manually made edits to the wm volume when segmenting the
brain volume (normally the segmentation step will just overwrite
the wm volume).

-pons-xyz X Y Z

Specify a seed point for the pons during the fill operation. This is
used to cut the brain stem from brain. By default, this point will be
determined automatically. It should only be specified if there is a
cut failure. To determine what this point should be, find the center
of the pons in the T1 volume (in tkmedit) and record the Talairach XYZ
values. If the talairach is not available, use the Volume RAS
Coordinates.

-cc-xyz X Y Z

Specify a seed point for the corpus callosum during the fill
operation. This is used to help separate the hemispheres. By default,
this point will be determined automatically. It should only be
specified if there is a cut failure. To determine what this point
should be, find the center of the corpus callosum in the T1 volume (in
tkmedit) and record the Talairach XYZ values. If the talairach is not
available, use the Volume RAS Coordinates.

-lh-xyz X Y Z

Specify a seed point for the left hemisphere during the fill
operation. This is used to help identify the left hemisphere. By
default, this point will be determined automatically. It should only
be specified if there is a cut failure. To determine what this point
should be, find a point in the white matter mass of the left
hemisphere in the T1 volume (in tkmedit) and record the Talairach XYZ
values. If the talairach is not available, use the Volume RAS
Coordinates. Remember that tkmedit displays the volume in radiological
convention (ie, left is right).

-rh-xyz X Y Z

Same as -lh-xyz but for the right hemisphere.

-fill-with-aseg

Fill subcortical structures based on results from automatic subcortical.
segmentation.
{{{
-pons-crs C R S
}}}
Specify a seed point for the pons during the fill operation. This is used to cut the brain stem from brain. By default, this point will be determined automatically. It should only be specified if there is a cut failure. To determine what this point should be, find the center of the pons in the T1 volume (in tkmedit) and record the column, row, and slice. Creates a file called scripts/seed-ponscrs.man.dat with the CRS.

{{{
-cc-crs C R S
}}}
Specify a seed point for the corpus callosum during the fill operation. This is used to help separate the hemispheres. By default, this point will be determined automatically. It should only be specified if there is a cut failure. To determine what this point should be, find the center of the CC in the T1 volume (in tkmedit) and record the column, row, and slice. Creates a file called scripts/seed-cccrs.man.dat with the CRS.

{{{
-lh-crs C R S
}}}
Specify a seed point for the left hemisphere during the fill operation. This is used to help identify the left hemisphere. By default, this point will be determined automatically. It should only be specified if there is a cut failure. To determine what this point should be, find a point in the white matter mass of the left hemisphere in the T1 volume (in tkmedit) and record the column, row, and slice. Creates a file called scripts/seed-cccrs.man.dat with the CRS. Remember that tkmedit displays the volume in radiological convention (ie, left is right).

{{{
-rh-crs C R S
}}}
Same as -lh-crs but for the right hemisphere. Creates a file called scripts/seed-rhcrs.man.dat with the CRS.

{{{
Line 308: Line 270:

This controls how the skull stripping will be performed. Legal values are
normal (the default), atlas, nowatershed, watershedonly, and watershedtemplate.
}}}
This controls how the skull stripping will be performed. Legal values are normal (the default), atlas, nowatershed, watershedonly, and watershedtemplate.

{{{
Line 313: Line 275:

Increase/decrease the preflooding height (threshold) when skull
stripping. -wsmore will expand the skull surface; -wsless will shrink
the skull surface. See also -wsthresh.
}}}
Increase/decrease the preflooding height (threshold) when skull stripping. -wsmore will expand the skull surface; -wsless will shrink the skull surface. See also -wsthresh.

{{{
Line 319: Line 280:
}}}
Line 322: Line 283:
{{{
Line 323: Line 285:

Supply a point in the volume that the user believes to be in the white
matter. By default, this point will be determined automatically. It
should only be specified if there is a strip failure. To determine
what this point should be, find a point in the white matter using
tkmedit and record the Volume Index values (NOT the XYZ coordinates).
}}}
Supply a point in the volume that the user believes to be in the white matter. By default, this point will be determined automatically. It should only be specified if there is a strip failure. To determine what this point should be, find a point in the white matter using tkmedit and record the Volume Index values (NOT the XYZ coordinates).

{{{
Line 331: Line 290:

Specify the full path to the gaussian classifier array (GCA) file
to be used with GCA registration and automatic subcortical
segmentation. Default is FREESURFER_HOME/average/talairach_mixed.gca.
This has no effect unless the GCA registration or subcortical
segmentation stages are to be performed.
}}}
Specify the full path to the gaussian classifier array (GCA) file to be used with GCA registration and automatic subcortical segmentation. Default is RB_all_2006-02-15.gca located in FREESURFER_HOME/average. This has no effect unless the GCA registration or subcortical segmentation stages are to be performed.

{{{
-gca-skull gcafile
}}}
Specify the full path to the gaussian classifier array (GCA) file to be used with registration with skull. Default is RB40_talairach_with_skull_2005-12-30.gca located in FREESURFER_HOME/average.

{{{
Line 339: Line 300:

Number of iterations in the non-uniform intensity correction. Default
is 4.
}}}
Number of iterations in the non-uniform intensity correction. Default is 4.

{{{
Line 344: Line 305:
}}}
Line 347: Line 308:
-edit_wm_with_aseg

Uses the results of the automatic subcortical segmentation to edit the
WM. Uses wm-init as the input volume. See also -subcortseg.

-no-fix-with-ga

Use genetic algorithm during automatic topology fixing (adds -ga
-keep 0 to the mris_fix_topology command line).

NOTIFICATION FILES

Notification files allow the user to cascade invocations to recon-all,
with one invocation waiting until another one terminates. This is done
by specifying a file that must exist before an invocation can precede
(-waitfor) and/or specifying a file that is created when an invocation
terminates (-notify). This type of interprocess communication can
allow users to parallelize the stream. If this is to be done, note
that each hemisphere can be run separately by specifying the -hemi
flag.

LOG AND STATUS FILES

By default, log and status files are created in subjid/scripts. The
log file contains all the output from all the programs that have been
run during the invocation to recon-all. The status file has a list of
all the programs that have been run and the time at which each
started. The log file is intended to be a record of what was done
whereas the status file allows the user to easily see where in the
stream a currently running process is. The log file should be sent
with all bug reports. By default, these files are called recon-all.log
and recon-all.status, but this can be changed with the -log and
-status options. By default, the log and status are appended to. New
log and status files can be forced with the -noappend flag.


OTHER ARGUMENTS
{{{
-normmaxgrad maxgrad
}}}
Passes "-g maxgrad" to mri_normalize. Max grad default is 1.

{{{
-noaseg
}}}
Skips subcortical segmentation steps (same as -nosubcortseg), and does not use aseg.mgz for inorm2, wm segmentation, or filling. Use this flag for brains that do not support usage of subcortical segmentation.

== Expert Options File ==
While the expert preferences flags supported by recon-all cover most of the instances where special flags need to be passed to a FreeSurfer binary, to allow passing an arbitrary flag to a binary, recon-all supports the reading of a user-created file containing special options to include in the command string (in addition to, not in place of). The file should contain as the first item the name of the command, and the items following it on rest of the line will be passed as the extra options. For example, if a file called expert.opts is created containing these lines:

{{{
mri_em_register -p .5
mris_fix_topology -s 100
}}}
then the option "-p .5" will be passed to mri_em_register, and "-s 100" will be passed to mris_fix_topology. The name of the expert options file is passed to recon-all with the -expert flag, eg.

{{{
recon-all -expert <full pathname>/expert.opts
}}}
Note: the full pathname to the file must be specified.

The following FreeSurfer binaries will accept an expert option:

 * [[talairach]]
 * [[mri_normalize]]
 * [[mri_watershed]]
 * [[mri_em_register]]
 * [[mri_ca_normalize]]
 * [[mri_ca_register]]
 * [[mri_remove_neck]]
 * [[mri_ca_label]]
 * [[mri_segstats]]
 * [[mri_mask]]
 * [[mri_segment]]
 * [[mri_edit_wm_with_aseg]]
 * [[mri_pretess]]
 * [[mri_fill]]
 * [[mri_tessellate]]
 * [[mris_smooth]]
 * [[mris_inflate]]
 * [[mris_sphere]]
 * [[mris_fix_topology]]
 * [[mris_make_surfaces]]
 * [[mris_surf2vol]]
 * [[mris_register]]
 * [[mrisp_paint]]
 * [[mris_ca_label]]
 * [[mris_anatomical_stats]]
 * [[mri_aparc2aseg]]

== Notification Files ==
Notification files allow the user to cascade invocations to recon-all, with one invocation waiting until another one terminates. This is done by specifying a file that must exist before an invocation can precede (-waitfor) and/or specifying a file that is created when an invocation terminates (-notify). This type of interprocess communication can allow users to parallelize the stream. If this is to be done, note that each hemisphere can be run separately by specifying the -hemi flag.

== Status and Log Files ==
By default, log and status files are created in subjid/scripts. The log file contains all the output from all the programs that have been run during the invocation to recon-all. The status file has a list of all the programs that have been run and the time at which each started. The log file is intended to be a record of what was done whereas the status file allows the user to easily see where in the stream a currently running process is. The log file should be sent with all bug reports. By default, these files are called recon-all.log and recon-all.status, but this can be changed with the -log and -status options. By default, the log and status are appended to. New log and status files can be forced with the -noappend flag.

== Other Arguments ==
{{{
Line 386: Line 370:

This allows the user to specify the root of the FreeSufer subjects
directory. If unspecified, the environment variable SUBJECTS_DIR
is used.
}}}
This allows the user to specify the root of the FreeSufer subjects directory. If unspecified, the environment variable $SUBJECTS_DIR is used.

{{{
Line 392: Line 375:
}}}
Line 395: Line 378:

STEP DESCRIPTION SUMMARIES

Motion Correction (-<no>motioncor)

When there are multiple source volumes, this step will correct for
small motions between them and then average them together. The input
are the COR volumes found in mri/orig/XXX (or mri/XXX.mgz with the
-mgz option). The output will be the orig COR volune in mri/orig (or
orig.mgz with the -mgz option). If no runs are found then it looks for
a volume in mri/orig (or mri/orig.mgz). If that volume is there, then
it is used in subsequent processes as if it was the motion corrected
volume. If no volume is found, then the process exits with errors. It
uses the MINC program minctracc (see Collins, et al, 1994) through a
FreeSurfer script called mri_motion_correct. Users must have the MINC
tools installed.

Talairach (-<no>talairach)

This computes the affine transform from the orig volume to the MNI305
atlas using the MINC program mritotal (see Collins, et al, 1994)
through a FreeSurfer script called talairach. Users must have the MINC
tools installed. Several of the downstream programs use talairach
coordinates as seed points. You can/should check how good the
talairach registration is using "tkregister2 --s subjid --fstal". You
must have a "talairach" subject in your SUBJECTS_DIR. tkregister2
allows you to compare the orig volume against the talairach volume
resampled into the orig space. If you modify the registration, it
will change the talairach.xfm file. Your edits will be overwritten
if you run recon-all without specifying -notalairach. Run
"tkregister2 --help" for more information.

Normalization (-<no>normalization)

Performs intensity normalization of the orig volume and places the
result in T1 (or T1.mgz). Attempts to correct for fluctuations in
intensity that would otherwise make intensity-based segmentation much
more difficult. Intensities for all voxels are scaled so that the mean
intensity of the white matter is 110. If there are problems with the
normalization, users can add control points. If -usenuintensitycor is
specified, then the input comes from the nu directory intead of orig
(to create this volume, run with -nuintensitycor). A file called
mri/T1/input-source is created indicating which input was used for
intensity normalization. See also Normalization2.

Skull Strip (-<no>skullstrip)

Removes the skull from mri/T1 and stores the result in mri/brain (or
mri/brain.mgz). Runs the mri_watershed program. If the strip fails,
users can specify seed points (-wsseed) or change the threshold
(-wsthresh, -wsmore, -wsless).

Normalization2 (-<no>normalization)

Performs a second intensity using only the brain volume as the input
(so that it has to be done after the skull strip). Intensity
normalization works better when the skull has been removed. Creates
a new T1 volume. It also creates a new brain volume by masking the
T1 with the original brain mask. Currently, this is not automatically
performed with Stage1 as this is experimental.

Segmentation -<no>segmentation

Attempts to separate white matter from everything else. The input is
mri/brain, and the output is mri/wm (or wm.mgz). Uses intensity,
neighborhood, and smoothness constraints. This is the volume that is
edited when manually fixing defects. Calls mri_segment. To keep
previous edits, run with -keepwmedits.

Cut/Fill -<no>fill

This creates the subcortical mass from which the orig surface is
created. The mid brain is cut from the cerebrum, and the hemispheres
are cut from each other. The left hemisphere is binarized to 255. The
right hemisphere is binarized to 127. The input is mri/wm and the
output is mri/filled (or filled.mgz). Calls mri_fill. If the cut
fails, then seed points can be supplied (-cc-xyz, -pons-xyz, -lh-xyz,
-rh-xyz). The actual points used for the cutting planes in the
corpus callosum and pons can be found in scripts/ponscc.cut.log.

Tessellation -<no>tessellate

This is the step where the orig surface (ie, surf/?h.orig) is created.
The surface is created by covering the filled hemisphere with
triangles. Runs mri_tessellate. The places where the points of the
triangles meet are called vertices. Note: the topology fixer will
over-write the orig surface.

Orig Surface Smoothing (-<no>smooth1, -<no>smooth2)

After tesselation, the orig surface is very jagged because each
triangle is on the edge of a voxel face and so are at right angles to
each other. The vertex positions are adjusted slightly here to reduce
the angle. This is only necessary for the inflation processes.
Creates surf/?h.smoothwm. Calls mris_smooth. Smooth1 is the step just
after tessellation, and smooth2 is the step just after topology
fixing.

Inflation (-<no>inflate1, -<no>inflate2)

Inflation of the surf/?h.smoothwm surface to create surf/?h.inflated.
The inflation attempts to minimize metric distortion so that distances
and areas are perserved (ie, the surface is not stretched). In this
sense, it is like inflating a paper bag and not a balloon. Inflate1
is the step just after tessellation, and inflate2 is the step just
after topology fixing. Calls mris_inflate. Creates ?h.inflated,
?h.sulc, ?h.curv, and ?h.area.

QSphere (-<no>qsphere)

This is the initial step of automatic topology fixing. It is a "quick"
spherical morph of the inflated surface designed to make the
topological defects show up clearly to the automatic topology fixer.
Calls mris_sphere. Creates surf/?h.qsphere.

Automatic Topology Fixer (-<no>fix)

Findes topological defects (ie, holes in a filled hemisphere) using
surf/?h.qsphere, and changes the orig surface (surf/?h.orig) to remove
the defects. Changes the number of vertices. All the defects will be
removed, but the user should check the orig surface in the volume to
make sure that it looks appropriate. Calls mris_fix_topology.
Overwrites surf/?h.orig.

Euler Number (-<no>euler)

Computes the euler number of the orig surface. If there are no
defects, the euler number will be 2 (0 holes). Creates
surf/?h.orig.euler, which is just a text file with the output
of mris_euler_number.

Final Surfaces (-<no>finalsurfs)

Creates the ?h.white and ?h.pial surfaces as well as the thickness
file (?h.thickness). The white surface is created by "nudging" the
orig surface so that it closely follows the white-gray intensity
gradient as found in the T1 volume. The pial surface is created by
expanding the white surface so that it closely follows the gray-CSF
intensity gradient as found in the T1 volume. Calls
mris_make_surfaces.

Cortical Ribbon Mask (-<no>cortribbon)

Creates binary volume masks of the cortical ribbon, ie, each voxel is
either a 1 or 0 depending upon whether it falls in the ribbon or not.
Saved as ?h.ribbon.mgz. Uses mgz regardless of whether the -mgz
option is used.

Spherical Inflation (-<no>sphere)

Inflates the orig surface into a sphere while minimizing metric
distortion. This step is necessary in order registrer the surface
to the spherical atlas. (also known as the spherical morph). Calls
mris_sphere. Creates surf/?h.sphere.

Ipsilateral Surface Registation (Spherical Morph) (-<no>surfreg)

Registers the orig surface to the spherical atlas through
surf/?h.sphere. The surfaces are first coarsely registered by aligning
the large scale folding patterns found in ?h.sulc and then fine tuned
using the small-scale patterns as in ?h.curv. Calls
mris_register. Creates surf/?h.sphere.reg.

Contralateral Surface Registation (Spherical Morph) (-<no>contasurfreg)

Same as ipsilateral but registers to the contralateral atlas. Creates
lh.rh.sphere.reg and rh.lh.sphere.reg.

Average Curvature (-<no>avgcurv)

Resamples the average curvature from the atlas to that of the subject.
Allows the user to display activity on the surface of an individual
with the folding pattern (ie, anatomy) of a group. Calls mrisp_paint.
Creates surf/?h.avg_curv.

Average Labels (-<no>avglabels)

This is obsolete because full surface parcellation is now done
automatically with -cortparc. This supplies all labels which can then
be checked to make sure that they ended up in the right place. It is
still possible to to use this flag, but it is turned off by default.
If you turn it on, make sure that you have an average7 subject.

Resamples several labels from the average7 subject onto the surface of
the subject. The labels are for the calcarine central, and superior
temporal sulci. The purpose of this is to help check how well the
registration performed. The user can view these labels in tksurfer by
loading them through the File->Label->Load. Creates
?h-calcarine_sulcus.label, ?h-central_sulcus.label, and
?h-superior_temporal_sulcus.label in the label directory.

Parcellation Statistics (-<no>parcstats)

Runs mris_anatomical_stats to create a summary table of cortical
parcellation statistics for each structure, including 1. structure
name 2. number of vertices 3. total surface area (mm^2) 4. total gray
matter volume (mm^3) 5. average cortical thickness (mm) 6. standard
error of cortical thicknessr (mm) 7. integrated rectified mean
curvature 8. integrated rectified Gaussian curvature 9. folding index
10. intrinsic curvature index. The file is saved in
scripts/?h.aparc.stats.

Automatic Subcortical Segmentation <-subcortseg>

This is done in four stages. (1) CGA linear registration
(-cgareg). This is an initial registration to a template. (2)
Canonical Normalization (-canorm), (3) Cannonical Registration
(-careg). (4) Subcortical labeling (-calabel). See also
-edit_wm_with_aseg.


MANUAL CHECKING AND EDITING OF SURFACES

To manually edit segmenation, run the following command (make sure
that your SUBJECTS_DIR environment variable is properly set).

  tkmedit subjid wm -aux T1

The surfaces can be loaded through the menu item
File->LoadMainSurface. To enable editing, set Tools->EditVoxels. It
may also be convenient to bring up the reconstruction toolbar with
View->ToolBars->Reconstruction. Alt-C toggles between the main (wm)
and auxiliary (T1) volumes. Middle clicking will set a voxel value to
255; left clicking will set a voxel value to 0. Only edit the wm
volume. When finished, File-SaveMainVolume.

To view the inflated surface simultaneosly with the volume, run the
following command from a different shell:

  tksurfer subjid lh inflated

To goto a point on the surface inside the volume, click on the point
and hit SavePoint (icon looks like a floppy disk), then, in tkmedit,
hit GotoSavedPoint (icon looks like an open file).

USING COMPRESSED MGH FORMAT (MGZ)

MGZ format can be used by specifying the -mgz flag. The MGH format is
a single-file format in which both pixel and meta data are stored.
Files in this format have a .mgh extension. This can be compressed
with gzip to give a compressed MGH format for which the extension is
.mgz. This can provide substantial savings on disk space, but it does
change the way that the data are stored. When COR format is used, an
entire directory must be dedicated to the volume, and the volume is
identified by the directory name (eg, mri/brain contains the
skull-stripped volume). When MGZ is used, the COR volume and directory
are replaced by a single file named directory.mgz (eg, brain.mgz).
When setting up the raw data in the subject directory, create MGZ
files with the names RRR.mgz in the mri directory, where RRR is the
3-digit, 0-padded run number (eg, 004.mgz). Do not use numbers over
100. Note that the input runs do not have to be conformed (ie, 256^3,
1mm isotropic). The input runs will be motion corrected and averaged
togther into rawavg.mgz which will then be conformed into orig.mgz.


FLATTENING

Flattening is not actually done in this script. This part just documents
how one would go about performing the flattening. First, load the subject
surface into tksurfer:

   tksurfer subjid lh inflated

Load the curvature through the File->Curvature->Load menu (load
lh.curv). This should show a green/red curvature pattern. Red = sulci.

Right click before making a cut; this will clear previous points. This
is needed because it will string together all the previous places you
have clicked to make the cut. To make a line cut, left click on a line
of points. Make the points fairly close together; if they are too far
appart, the cut fails. After making your line of points, execute the
cut by clicking on the Cut icon (scissors with an open triangle for a
line cut or scissors with a closed triangle for a closed cut). To make
a plane cut, left click on three points to define the plane, then left
click on the side to keep. Then hit the CutPlane icon.

Fill the patch. Left click in the part of the surface that you want to
form your patch. Then hit the Fill Uncut Area button (icon = filled
triangle). This will fill the patch with white. The non-patch area
will be unaccessible through the interface. Save the patch through
File->Patch->SaveAs. For whole cortex, save it to something like
lh.cort.patch.3d. For occipital patches, save it to lh.occip.patch.3d.

Cd into the subject surf directory and run

  mris_flatten -w N -distances Size Radius lh.patch.3d lh.patch.flat

where N instructs mris_flatten to write out an intermediate surface
every N interations. This is only useful for making movies; otherwise
set N=0. Size is maximum number of neighbors; Radius radius (mm) in
which to search for neighbors. In general, the more neighbors that are
taken into account, the less the metric distortion but the more
computationally intensive. Typical values are Size=12 for large
patches, and Size=20 for small patches. Radius is typically 7.
Note: flattening may take 12-24 hours to complete. The patch can be
viewed at any time by loading the subjects inflated surface, then
loading the patch through File->Patch->LoadPatch...


= Step Description Summaries =
== Motion Correction (-<no>motioncor) ==
When there are multiple source volumes, this step will correct for small motions between them and then average them together. The input are the volumes found in file(s) mri/orig/XXX.mgz. The output will be the volume mri/orig.mgz. If no runs are found, then it looks for a volume in mri/orig (or mri/orig.mgz). If that volume is there, then it is used in subsequent processes as if it was the motion corrected volume. If no volume is found, then the process exits with errors.

== NU Intensity Correction (-<no>nuintensitycor) ==
Non-parametric Non-uniform intensity Normalization (N3), corrects for intensity non-uniformity in MR data, making relatively few assumptions about the data. This runs the MINC tool 'nu_correct'. By default, four iterations of nu_correct are run. The flag -nuiterations specification of some other number of iterations.

== Talairach (-<no>talairach) ==
This computes the affine transform from the orig volume to the MNI305 atlas using the MINC program mritotal (see Collins, et al, 1994) through a FreeSurfer script called talairach. Several of the downstream programs use talairach coordinates as seed points. You can/should check how good the talairach registration is using {{{tkregister2 --s subjid --fstal}}}. tkregister2 allows you to compare the orig volume against the talairach volume resampled into the orig space. Run "tkregister2 --help" for more information. Creates the files mri/transform/talairach.auto.xfm and talairach.xfm.

== Normalization (-<no>normalization) ==
Performs intensity normalization of the orig volume and places the result in mri/T1.mgz. Attempts to correct for fluctuations in intensity that would otherwise make intensity-based segmentation much more difficult. Intensities for all voxels are scaled so that the mean intensity of the white matter is 110. If there are problems with the normalization, users can add control points. See also Normalization2.

== Skull Strip (-<no>skullstrip) ==
Removes the skull from mri/T1.mgz and stores the result in mri/brainmask.auto.mgz and mri/brainmask.mgz. Runs the mri_watershed program. If the strip fails, users can specify seed points (-wsseed) or change the threshold (-wsthresh, -wsmore, -wsless). The -autorecon1 stage ends here.

== Automatic Subcortical Segmentation (-<no>subcortseg) ==
This is done in six stages. (1) CGA linear registration (-gcareg). This is an initial registration to a template. (2) Canonical Normalization (-canorm), (3) Canonical Registration (-careg). (4) Neck removal (-rmneck), (5) Registration, w/skull (-skull-lta), and (6) Subcortical labeling (-calabel). The stages are listed next.

== EM (GCA) Registration (-<no>gcareg) ==
Computes transform to align the mri/nu.mgz volume to the default GCA atlas found in FREESURFER_HOME/average (see -gca flag for more info). Creates the file mri/transforms/talairach.lta. The -autorecon2 stage starts here.

== CA Normalize (-<no>canorm) ==
Further normalization, based on GCA model. Creates mri/norm.mgz.

== CA Register (-<no>careg) ==
Computes a nonlinear transform to align with GCA atlas. Creates the file mri/transform/talairach.m3z.

== Remove neck (-<no>rmneck) ==
The neck region is removed from the NU-corrected volume mri/nu.mgz. Makes use of transform computed from prior CA Register stage. Creates the file mri/nu_noneck.mgz.

== EM Registration, with Skull (-<no>skull-lta) ==
Computes transform to align volume mri/nu_noneck.mgz with GCA volume possessing the skull. Creates the file mri/transforms/talairach_with_skull.lta.

== CA Label (-<no>calabel) ==
Labels subcortical structures, based in GCA model. Creates the files mri/aseg.auto.mgz and mri/aseg.mgz.

== ASeg Stats (-<no>segstats) ==
Computes statistics on the segmented subcortical structures found in mri/aseg.mgz. Writes output to file stats/aseg.stats.

== Normalization2 (-<no>normalization) ==
Performs a second (major) intensity correction using only the brain volume as the input (so that it has to be done after the skull strip). Intensity normalization works better when the skull has been removed. Creates a new brain.mgz volume. The -autorecon2-cp stage begins here. If -noaseg flag is used, then aseg.mgz is not used by mri_normalize.

== WM Segmentation (-<no>segmentation) ==
Attempts to separate white matter from everything else. The input is mri/brain.mgz, and the output is mri/wm.mgz. Uses intensity, neighborhood, and smoothness constraints. This is the volume that is edited when manually fixing defects. Calls mri_segment, mri_edit_wm_with_aseg, and mri_pretess. To keep previous edits, run with -keepwmedits. If -noaseg is used, them mri_edit_wm_aseg is skipped.

== Cut/Fill (-<no>fill) ==
This creates the subcortical mass from which the orig surface is created. The mid brain is cut from the cerebrum, and the hemispheres are cut from each other. The left hemisphere is binarized to 255. The right hemisphere is binarized to 127. The input is mri/wm.mgz and the output is mri/filled.mgz. Calls mri_fill. If the cut fails, then seed points can be supplied (see -cc-crs, -pons-crs, -lh-crs, -rh-crs). The actual points used for the cutting planes in the corpus callosum and pons can be found in scripts/ponscc.cut.log. The stage -autorecon2-wm begins here. This is the last stage of volumetric processing. If -noaseg is used, then aseg.mgz is not used by mri_fill.

== Tessellation (-<no>tessellate) ==
This is the step where the orig surface (ie, surf/?h.orig.nofix) is created. The surface is created by covering the filled hemisphere with triangles. Runs mri_tessellate. The places where the points of the triangles meet are called vertices. Creates the file surf/?h.orig.nofix Note: the topology fixer will create the surface ?h.orig.

== Orig Surface Smoothing (-<no>smooth1, -<no>smooth2) ==
After tesselation, the orig surface is very jagged because each triangle is on the edge of a voxel face and so are at right angles to each other. The vertex positions are adjusted slightly here to reduce the angle. This is only necessary for the inflation processes. Creates surf/?h.smoothwm(.nofix). Calls mris_smooth. Smooth1 is the step just after tessellation, and smooth2 is the step just after topology fixing.

== Inflation (-<no>inflate1, -<no>inflate2) ==
Inflation of the surf/?h.smoothwm(.nofix) surface to create surf/?h.inflated. The inflation attempts to minimize metric distortion so that distances and areas are perserved (ie, the surface is not stretched). In this sense, it is like inflating a paper bag and not a balloon. Inflate1 is the step just after tessellation, and inflate2 is the step just after topology fixing. Calls mris_inflate. Creates ?h.inflated, ?h.sulc, ?h.curv, and ?h.area.

== QSphere (-<no>qsphere) ==
This is the initial step of automatic topology fixing. It is a quasi-homeomorphic spherical transformation of the inflated surface designed to localize topological defects for the subsequent automatic topology fixer. Calls mris_sphere. Creates surf/?h.qsphere.nofix.

== Automatic Topology Fixer (-<no>fix) ==
Finds topological defects (ie, holes in a filled hemisphere) using surf/?h.qsphere.nofix, and changes the orig surface (surf/?h.orig.nofix) to remove the defects. Changes the number of vertices. All the defects will be removed, but the user should check the orig surface in the volume to make sure that it looks appropriate. Calls mris_fix_topology. Creates surf/?h.orig (by iteratively fixing surf/?h.orig.nofix).

== Final Surfaces (-<no>finalsurfs) ==
Creates the ?h.white and ?h.pial surfaces as well as the thickness file (?h.thickness) and curvature file (?h.curv). The white surface is created by "nudging" the orig surface so that it closely follows the white-gray intensity gradient as found in the T1 volume. The pial surface is created by expanding the white surface so that it closely follows the gray-CSF intensity gradient as found in the T1 volume. Calls mris_make_surfaces.

== Cortical Ribbon Mask (-<no>cortribbon) ==
Creates binary volume masks of the cortical ribbon, ie, each voxel is either a 1 or 0 depending upon whether it falls in the ribbon or not. Saved as ?h.ribbon.mgz. Uses mgz regardless of whether the -mgz option is used. The -autorecon2 stage ends here.

== Spherical Inflation (-<no>sphere) ==
Inflates the orig surface into a sphere while minimizing metric distortion. This step is necessary in order to register the surface to the spherical atlas. (also known as the spherical morph). Calls mris_sphere. Creates surf/?h.sphere. The -autorecon3 stage begins here.

== Ipsilateral Surface Registation (Spherical Morph) (-<no>surfreg) ==
Registers the orig surface to the spherical atlas through surf/?h.sphere. The surfaces are first coarsely registered by aligning the large scale folding patterns found in ?h.sulc and then fine tuned using the small-scale patterns as in ?h.curv. Calls mris_register. Creates surf/?h.sphere.reg.

== Contralateral Surface Registation (Spherical Morph) (-<no>contasurfreg) ==
Same as ipsilateral but registers to the contralateral atlas. Creates lh.rh.sphere.reg and rh.lh.sphere.reg.

== Average Curvature (-<no>avgcurv) ==
Resamples the average curvature from the atlas to that of the subject. Allows the user to display activity on the surface of an individual with the folding pattern (ie, anatomy) of a group. Calls mrisp_paint. Creates surf/?h.avg_curv.

== Cortical Parcellation (-<no>cortparc, -<no>cortparc2) ==
Assigns a neuroanatomical label to each location on the cortical surface. Incorporates both geometric information derived from the cortical model (sulcus and curvature), and neuroanatomical convention. Calls mris_ca_label. -cortparc creates label/?h.aparc.annot, and -cortparc2 creates /label/?h.aparc.a2005s.annot.

== Parcellation Statistics (-<no>parcstats) ==
Runs mris_anatomical_stats to create a summary table of cortical parcellation statistics for each structure, including 1. structure name 2. number of vertices 3. total surface area (mm^2^) 4. total gray matter volume (mm^3^) 5. average cortical thickness (mm) 6. standard error of cortical thicknessr (mm) 7. integrated rectified mean curvature 8. integrated rectified Gaussian curvature 9. folding index 10. intrinsic curvature index. For -parcstats, the file is saved in stats/?h.aparc.stats. For -parcstats2, the file is saved in stats/?h.aparc.a2005s.stats.

= Other =
== Using T2 or FLAIR data to improve pial surfaces ==
Pial surfaces can be improved using the different contrast in T2 or FLAIR images. The original pial surfaces without T2/FLAIR data are saved as {{{?h.woT2.pial}}} or {{{?h.woFLAIR.pial}}}, and new {{{?h.pial}}} surfaces are created. One example where this is useful is when there is dura in the brainmask.mgz that isn't removed by skull stripping. The flags for these commands are:

|| -T2 <input T2 volume> or -FLAIR <input FLAIR volume> || specify the path to the T2 or FLAIR image to use (can be either a DICOM, MGH or NIFTI file) ||
|| -T2pial or -FLAIRpial || creates new pial surfaces using T2 or FLAIR images ||

An example of running a subject through Freesurfer with a T2 image is:
{{{
recon-all -subject subjectname -i /path/to/input_volume -T2 /path/to/T2_volume -T2pial -all
}}}

T2 or FLAIR images can also be used with Freesurfer subjects that have already been processed without them. Note that {{{autorecon3}}} should also be re-ran to compute statistics based on the new surfaces. For example:
{{{
recon-all -subject subjectname -T2 /path/to/T2_volume -T2pial -autorecon3
}}}


== Manual Checking and Editing of Surfaces ==
To manually edit segmenation, run the following command (make sure that your SUBJECTS_DIR environment variable is properly set).

{{{
tkmedit subjid wm.mgz -aux T1.mgz
}}}
The surfaces can be loaded through the menu item File->LoadMainSurface. To enable editing, set Tools->EditVoxels. It may also be convenient to bring up the reconstruction toolbar with View->ToolBars->Reconstruction. Alt-C toggles between the main (wm) and auxiliary (T1) volumes. Middle clicking will set a voxel value to 255; left clicking will set a voxel value to 0. Only edit the wm volume. When finished, File->SaveMainVolume.

To view the inflated surface simultaneosly with the volume, run the following command from a different shell:

{{{
tksurfer subjid lh inflated
}}}
To goto a point on the surface inside the volume, click on the point and hit SavePoint (icon looks like a floppy disk), then, in tkmedit, hit GotoSavedPoint (icon looks like an open file).

Be sure to see the tutorials found at FsTutorial.

== Verification of fsaverage ==
New to Freesurfer versions 5.2 and greater, recon-all will check if the fsaverage directory in SUBJECTS_DIR directory path corresponds to the 5.2 (or greater) version which contains several new files. If a previous version of fsaverage is detected which does not include these new files, then recon-all will delete the old fsaverage and create a new symlink. As a result, any files manually created by the user inside the fsaverage directory are potentially at risk of being deleted when upgrading Freesurfer versions.

== Using Compressed MGH Format (.mgz) ==
MGZ format can be used by specifying the -mgz flag. The MGH format is a single-file format in which both pixel and meta data are stored. Files in this format have a .mgh extension. This can be compressed with gzip to give a compressed MGH format for which the extension is .mgz. This can provide substantial savings on disk space, but it does change the way that the data are stored. When COR format is used, an entire directory must be dedicated to the volume, and the volume is identified by the directory name (eg, mri/brain contains the skull-stripped volume). When MGZ is used, the COR volume and directory are replaced by a single file named directory.mgz (eg, brain.mgz). When setting up the raw data in the subject directory, create MGZ files with the names RRR.mgz in the mri directory, where RRR is the 3-digit, 0-padded run number (eg, 004.mgz). Do not use numbers over 100. Note that the input runs do not have to be conformed (ie, 256^3^, 1mm isotropic). The input runs will be motion corrected and averaged togther into rawavg.mgz which will then be conformed into orig.mgz.

== Flattening ==
Flattening is not actually done in this script. This part just documents how one would go about performing the flattening. First, load the subject surface into tksurfer:

{{{
tksurfer subjid lh inflated
}}}
Load the curvature through the File->Curvature->Load menu (load lh.curv). This should show a green/red curvature pattern. Red = sulci.

Right click before making a cut; this will clear previous points. This is needed because it will string together all the previous places you have clicked to make the cut. To make a line cut, left click on a line of points. Make the points fairly close together; if they are too far appart, the cut fails. After making your line of points, execute the cut by clicking on the Cut icon (scissors with an open triangle for a line cut or scissors with a closed triangle for a closed cut). To make a plane cut, left click on three points to define the plane, then left click on the side to keep. Then hit the CutPlane icon. Fill the patch. Left click in the part of the surface that you want to form your patch. Then hit the Fill Uncut Area button (icon = filled triangle). This will fill the patch with white. The non-patch area will be unaccessible through the interface. Save the patch through File->Patch->SaveAs. For whole cortex, save it to something like lh.cort.patch.3d. For occipital patches, save it to lh.occip.patch.3d.

Cd into the subject surf directory and run:

{{{
mris_flatten -w N -distances Size Radius lh.patch.3d lh.patch.flat
}}}
where N instructs mris_flatten to write out an intermediate surface every N interations. This is only useful for making movies; otherwise set N=0. Size is maximum number of neighbors; Radius radius (mm) in which to search for neighbors. In general, the more neighbors that are taken into account, the less the metric distortion but the more computationally intensive. Typical values are Size=12 for large patches, and Size=20 for small patches. Radius is typically 7. Note: flattening may take 12-24 hours to complete. The patch can be viewed at any time by loading the subjects inflated surface, then loading the patch through File->Patch->LoadPatch...
Line 697: Line 525:
[1] Collins, DL, Neelin, P., Peters, TM, and Evans, AC. (1994)
Automatic 3D Inter-Subject Registration of MR Volumetric Data in
Standardized Talairach Space, Journal of Computer Assisted Tomography,
18(2) p192-205, 1994 PMID: 8126267; UI: 94172121

[2] Cortical Surface-Based Analysis I: Segmentation and Surface
Reconstruction Dale, A.M., Fischl, Bruce, Sereno, M.I.,
(1999). Cortical Surface-Based Analysis I: Segmentation and Surface
Reconstruction. NeuroImage 9(2):179-194

[3] Fischl, B.R., Sereno, M.I.,Dale, A. M. (1999) Cortical
Surface-Based Analysis II: Inflation, Flattening, and Surface-Based
Coordinate System. NeuroImage, 9, 195-207.

[4] Fischl, Bruce, Sereno, M.I., Tootell, R.B.H., and Dale, A.M.,
(1999). High-resolution inter-subject averaging and a coordinate
system for the cortical surface. Human Brain Mapping, 8(4): 272-284

[5] Fischl, Bruce, and Dale, A.M., (2000). Measuring the Thickness of
the Human Cerebral Cortex from Magnetic Resonance Images. Proceedings
of the National Academy of Sciences, 97:11044-11049.

[6] Fischl, Bruce, Liu, Arthur, and Dale, A.M., (2001). Automated
Manifold Surgery: Constructing Geometrically Accurate and
Topologically Correct Models of the Human Cerebral Cortex. IEEE
Transactions on Medical Imaging, 20(1):70-80

[7] Non-Uniform Intensity Correction.
http://www.bic.mni.mcgill.ca/software/N3/node6.html

[8] Fischl B, Salat DH, Busa E, Albert M, Dieterich M, Haselgrove C,
van der Kouwe A, Killiany R, Kennedy D, Klaveness S, Montillo A,
Makris N, Rosen B, Dale AM. Whole brain segmentation: automated
labeling of neuroanatomical structures in the human
brain. Neuron. 2002 Jan 31;33(3):341-55.

[9] Bruce Fischl, Andre van der Kouwe, Christophe Destrieux, Eric
Halgren, Florent Segonne, David H. Salat, Evelina Busa, Larry
J. Seidman, Jill Goldstein, David Kennedy, Verne Caviness, Nikos
Makris, Bruce Rosen, and Anders M. Dale. Automatically Parcellating
the Human Cerebral Cortex. Cerebral Cortex January 2004; 14:11-22.
[1] Collins, DL, Neelin, P., Peters, TM, and Evans, AC. (1994) Automatic 3D Inter-Subject Registration of MR Volumetric Data in Standardized Talairach Space, Journal of Computer Assisted Tomography, 18(2) p192-205, 1994 PMID: 8126267; UI: 94172121

[2] Cortical Surface-Based Analysis I: Segmentation and Surface Reconstruction Dale, A.M., Fischl, Bruce, Sereno, M.I., (1999). Cortical Surface-Based Analysis I: Segmentation and Surface Reconstruction. NeuroImage 9(2):179-194

[3] Fischl, B.R., Sereno, M.I.,Dale, A. M. (1999) Cortical Surface-Based Analysis II: Inflation, Flattening, and Surface-Based Coordinate System. NeuroImage, 9, 195-207.

[4] Fischl, Bruce, Sereno, M.I., Tootell, R.B.H., and Dale, A.M., (1999). High-resolution inter-subject averaging and a coordinate system for the cortical surface. Human Brain Mapping, 8(4): 272-284

[5] Fischl, Bruce, and Dale, A.M., (2000). Measuring the Thickness of the Human Cerebral Cortex from Magnetic Resonance Images. Proceedings of the National Academy of Sciences, 97:11044-11049.

[6] Fischl, Bruce, Liu, Arthur, and Dale, A.M., (2001). Automated Manifold Surgery: Constructing Geometrically Accurate and Topologically Correct Models of the Human Cerebral Cortex. IEEE Transactions on Medical Imaging, 20(1):70-80

[7] Non-Uniform Intensity Correction. http://www.bic.mni.mcgill.ca/software/N3/node6.html

[8] Fischl B, Salat DH, Busa E, Albert M, Dieterich M, Haselgrove C, van der Kouwe A, Killiany R, Kennedy D, Klaveness S, Montillo A, Makris N, Rosen B, Dale AM. Whole brain segmentation: automated labeling of neuroanatomical structures in the human brain. Neuron. 2002 Jan 31;33(3):341-55.

[9] Bruce Fischl, Andre van der Kouwe, Christophe Destrieux, Eric Halgren, Florent Segonne, David H. Salat, Evelina Busa, Larry J. Seidman, Jill Goldstein, David Kennedy, Verne Caviness, Nikos Makris, Bruce Rosen, and Anders M. Dale. Automatically Parcellating the Human Cerebral Cortex. Cerebral Cortex January 2004; 14:11-22.
Line 740: Line 544:
Report bugs to <analysis-bugs@nmr.mgh.harvard.edu> Report bugs to < freesurfer@nmr.mgh.harvard.edu > See also: BugReporting
Line 743: Line 547:
Send email to freesurfer@nmr.mgh.harvard.edu. Also see http://surfer.nmr.mgh.harvard.edu. In particular, there is both a reconstruction guide and tutorial as well as manuals for tkmedit and
tksurfer.
Send email to freesurfer@nmr.mgh.harvard.edu . Also see http://surfer.nmr.mgh.harvard.edu. In particular, there is both a reconstruction guide and tutorial as well as manuals for tkmedit and tksurfer.

recon-all (See also ReconAllDevTable, OtherUsefulFlags and ProcessVsFilesTable)

Index

Contents

  1. Name
  2. Synopsis
  3. Arguments
    1. Required Arguments
    2. Specify input
    3. Fully-Automated Directive
    4. Manual-Intervention Workflow Directives
    5. Step-wise Directives
    6. Expert Preferences
    7. Notification Files (Optional)
    8. Status and Log files (Optional)
    9. Other Arguments (Optional)
  4. Description
    1. Subject Identification String
    2. Specifying Directives
    3. Clustered Directives
    4. Step-wise Directives
    5. Expert Preferences
    6. Expert Options File
    7. Notification Files
    8. Status and Log Files
    9. Other Arguments
  5. Step Description Summaries
    1. Motion Correction (-<no>motioncor)
    2. NU Intensity Correction (-<no>nuintensitycor)
    3. Talairach (-<no>talairach)
    4. Normalization (-<no>normalization)
    5. Skull Strip (-<no>skullstrip)
    6. Automatic Subcortical Segmentation (-<no>subcortseg)
    7. EM (GCA) Registration (-<no>gcareg)
    8. CA Normalize (-<no>canorm)
    9. CA Register (-<no>careg)
    10. Remove neck (-<no>rmneck)
    11. EM Registration, with Skull (-<no>skull-lta)
    12. CA Label (-<no>calabel)
    13. ASeg Stats (-<no>segstats)
    14. Normalization2 (-<no>normalization)
    15. WM Segmentation (-<no>segmentation)
    16. Cut/Fill (-<no>fill)
    17. Tessellation (-<no>tessellate)
    18. Orig Surface Smoothing (-<no>smooth1, -<no>smooth2)
    19. Inflation (-<no>inflate1, -<no>inflate2)
    20. QSphere (-<no>qsphere)
    21. Automatic Topology Fixer (-<no>fix)
    22. Final Surfaces (-<no>finalsurfs)
    23. Cortical Ribbon Mask (-<no>cortribbon)
    24. Spherical Inflation (-<no>sphere)
    25. Ipsilateral Surface Registation (Spherical Morph) (-<no>surfreg)
    26. Contralateral Surface Registation (Spherical Morph) (-<no>contasurfreg)
    27. Average Curvature (-<no>avgcurv)
    28. Cortical Parcellation (-<no>cortparc, -<no>cortparc2)
    29. Parcellation Statistics (-<no>parcstats)
  6. Other
    1. Using T2 or FLAIR data to improve pial surfaces
    2. Manual Checking and Editing of Surfaces
    3. Verification of fsaverage
    4. Using Compressed MGH Format (.mgz)
    5. Flattening
  7. References
  8. Reporting Bugs
  9. Additional Help

Name

recon-all : Performs all, or any part of, the FreeSurfer cortical reconstruction process.

Synopsis

recon-all

-subjid subjid [Directive]

Arguments

Note: arguments are described in greater detail in the Description section (further below).

Required Arguments

-subjid subjid

the subject data upon which to operate

[Directive]

one or more directives (see next)

Specify input

-i file.dcm

single DICOM file from the T1 MRI series. If you have more than one T1, then use: -i file1.dcm -i file2.dcm

-i file.nii

single NIFTI file from series

Fully-Automated Directive

-all

do everything, including subcortical segmentation

-autorecon-all

same as -all

Manual-Intervention Workflow Directives

-autorecon1

process steps 1-5 (see below)

-autorecon2

process steps 6-23

after autorecon2, check final surfaces:

a. if wm edit was required, then run -autorecon2-wm

b. if control points added, then run -autorecon2-cp

c. if edits made to correct pial, then run -autorecon2-pial

d. proceed to run -autorecon3

-autorecon2-cp

process stages 12-23 (uses -f w/ mri_normalize, -keep w/ mri_seg)

-autorecon2-wm

process stages 15-23

-autorecon2-pial

process stages 21-23

-autorecon3

process stages 24-31

-hemi ?h

just do lh or rh (default is to do both)

  • Autorecon Processing Stages (see -autorecon# flags above):
    1. Motion Correction and Conform
    2. NU (Non-Uniform intensity normalization)
    3. Talairach transform computation
    4. Intensity Normalization 1
    5. Skull Strip
    6. EM Register (linear volumetric registration)
    7. CA Intensity Normalization
    8. CA Non-linear Volumetric Registration
    9. Remove Neck
    10. LTA with Skull
    11. CA Label (Volumetric Labeling, ie Aseg) and Statistics
    12. Intensity Normalization 2 (start here for control points)
    13. White matter segmentation
    14. Edit WM With ASeg
    15. Fill (start here for wm edits)
    16. Tessellation (begins per-hemisphere operations)
    17. Smooth1
    18. Inflate1
    19. QSphere
    20. Automatic Topology Fixer
    21. Final Surfs (start here for brain edits for pial surf)
    22. Smooth2
    23. Inflate2
    24. Spherical Mapping
    25. Spherical Registration
    26. Spherical Registration, Contralateral hemisphere
    27. Map average curvature to subject
    28. Cortical Parcellation - Desikan_Killiany and Christophe (Labeling)
    29. Cortical Parcellation Statistics
    30. Cortical Ribbon Mask
    31. Cortical Parcellation mapping to Aseg

Step-wise Directives

See Description section.

Expert Preferences

-pons-crs C R S

col, row, slice of seed point for pons, used in fill

-cc-crs C R S

col, row, slice of seed point for corpus callosum, used in fill

-lh-crs C R S

col, row, slice of seed point for left hemisphere, used in fill

-rh-crs C R S

col, row, slice of seed point for right hemisphere, used in fill

-nofill

do not use the automatic subcort seg to fill

-custom-tal-atlas

allows a custom talairach atlas to be used

-watershed cmd

control skull stripping/watershed program

-wsless

decrease watershed threshold (shrinks skull surface)

-wsmore

increase watershed threshold (expands skull surface)

-wsatlas

use atlas when skull stripping

-wsthresh pct

explicity set watershed threshold

-wsseed C R S

identify an index (C, R, S) point in the skull

-nuiterations N

set number of iterations for nu intensity correction (default is 2)

-norm3diters niters

number of 3d iterations for mri_normalize

-normmaxgrad maxgrad

max grad (-g) for mri_normalize. Default is 1.

-cm

conform COR volumes to the min voxel size

-no-fix-with-ga

do not use genetic algorithm when fixing topology

-seg-wlo wlo

set wlo value for mri_segment

-seg-ghi ghi

set ghi value for mri_segment

-no-ca-align

turn off -align with mri_ca_{register,label}.

-deface

deface subject, written to orig_defaced.mgz

-expert file

read-in expert options file

Notification Files (Optional)

-waitfor file

wait for file to appear before beginning

-notify file

create this file after finishing

Status and Log files (Optional)

-log file

default is $SUBJECTS_DIR/<your_subjectid>/scripts/recon-all.log

-status file

default is $SUBJECTS_DIR/<your_subjectid>/scripts/recon-all-status.log

-noappend

start new log and status files instead of appending

Other Arguments (Optional)

-sd subjectsdir

specify subjects dir (default env SUBJECTS_DIR)

-mail username

mail user when done

-umask umask

set unix file permission mask (default 002)

-grp groupid

check that current group is alpha groupid

-debug

print out lots of info

-dontrun

do everthing but execute each command

-version

print version of this script and exit

-help

yea, like anybody's going to read this

Description

Performs all, or any part of, the FreeSurfer cortical reconstruction process. This help only gives some simple information. See also ReconAllDevTable.

Basic usages:

1. Subject dir does not exist:

  • recon-all -subject subjectname -i invol1 <-i invol2> -all

Creates analysis directory $SUBJECTS_DIR/subjectname, converts one or more input volumes to MGZ format in subjectname/mri/orig, and runs all processing steps.

2. Manual conversion into mgz:

  • mkdir -p $SUBJECTS_DIR/subjectname/mri/orig mri_convert invol1 $SUBJECTS_DIR/subjectname/mri/orig/001.mgz mri_convert invol2 $SUBJECTS_DIR/subjectname/mri/orig/002.mgz recon-all -subject subjectname -all

If no input volumes are given, then it is assumed that the subject directory has already been created and that the raw data already exists in MGZ format in subjid/mri/orig as XXX.mgz, where XXX is a 3-digit, zero-padded number.

3. Legacy Data

  • recon-all -subject subjectname -all -legacy

Subject Identification String

-s subjectname
-sid subjectname
-subjid subjectname
-subject subjectname

'subjectname' is the FreeSurfer subject identification string which doubles as the name of the reconstruction root directory for this subject. This reconstruction should be referenced by this string for all FreeSurfer commands and in the register.dat matrix (for functional interfacing).

Specifying Directives

Directives instruct recon-all which part(s) of the reconstruction stream to run. While it is possible to do everything in one shot (using the -all flag), there can be some benefits to customizing the stream. These benefits include stopping to perform manual editing as well as parallelization. Directives are either clustered or step-wise. Clustered directives are sets of steps that can be performed by specifying a single flag. A step-wise directive refers to a single step. Directives accumulate. A step can be removed from a cluster by adding -no<step> after the cluster flag. For example, specifying -all followed by -notalairach will perform all the reconstruction steps except talairaching. However, note that if -notalairach preceeded -all, talairaching would still be performed.

Clustered Directives

-all
-autorecon-all

Perform all reconstruction steps, including subcortical segmentation.

-autorecon1

Motion correction through skull strip.

-autorecon2

Subcortical segmentation through make final surfaces.

-autorecon2-cp

Normalization2 through make final surfaces.

-autorecon2-wm

Fill through make final surfaces. Used after editing wm volume after running -autorecon2.

-autorecon2-pial

Makes final surfaces. Used after editing brain volume after running -autorecon2. The brain volume may be edited to fix problems with the pial surface.

-autorecon3

Spherical morph and automatic cortical parcellation.

-hemi hemisphere

Instruct recon-all to only operate on the specified hemisphere. Legal values are lh and rh. This can be used to run the surface-related steps in parallel.

Step-wise Directives

Step-wise directives allow the user to implement a single step in the reconstruction process. See also STEP DESCRIPTION SUMMARIES below. They also allow users to include/exclude a step from a clustered DIRECTIVE. To include a step, use -step (eg, -skullstrip). To exclude a step, use -nostep (eg -noskullstrip).

Run times are approximate for an AMD Opteron 64bit 2.5GHz processor. The topology fixer processing time varies considerably depending on the complexity of the defects in need of fixing.

-<no>motioncor

< 5 min

-<no>nuintensitycor

3 min

-<no>talairach

1 min

-<no>normalization

3 min

-<no>skullstrip

1 min

-<no>gcareg

8 min

-<no>canorm

1 min

-<no>careg

10 hours

-<no>rmneck

3 min

-<no>skull-lta

9 min

-<no>calabel

30 min

-<no>normalization2

3 min

-<no>segmentation

4 min

-<no>fill

1 min

-<no>tessellate

< 1 min

per hemisphere

-<no>smooth1

< 1 min

per hemisphere

-<no>inflate1

1 min

per hemisphere

-<no>qsphere

16 min

per hemisphere

-<no>fix

1-9 hours

per hemisphere

-<no>finalsurfs

1-2 hours

per hemisphere

-<no>smooth2

< 1 min

per hemisphere

-<no>inflate2

2 min

per hemisphere

-<no>cortribbon

< 1 min

per hemisphere

-<no>sphere

1-2 hours

per hemisphere

-<no>surfreg

1 hour

per hemisphere

-<no>contrasurfreg

1 hour

per hemisphere

-<no>avgcurv

< 1 min

per hemisphere

-<no>cortparc

1 min

per hemisphere

-<no>parcstats

< 1 min

per hemisphere

-<no>cortparc2

1 min

per hemisphere

-<no>parcstats2

< 1 min

per hemisphere

-<no>aparc2aseg

1 min

-all

20-40 hours

both hemipheres

Expert Preferences

-pons-crs C R S

Specify a seed point for the pons during the fill operation. This is used to cut the brain stem from brain. By default, this point will be determined automatically. It should only be specified if there is a cut failure. To determine what this point should be, find the center of the pons in the T1 volume (in tkmedit) and record the column, row, and slice. Creates a file called scripts/seed-ponscrs.man.dat with the CRS.

-cc-crs C R S

Specify a seed point for the corpus callosum during the fill operation. This is used to help separate the hemispheres. By default, this point will be determined automatically. It should only be specified if there is a cut failure. To determine what this point should be, find the center of the CC in the T1 volume (in tkmedit) and record the column, row, and slice. Creates a file called scripts/seed-cccrs.man.dat with the CRS.

-lh-crs C R S

Specify a seed point for the left hemisphere during the fill operation. This is used to help identify the left hemisphere. By default, this point will be determined automatically. It should only be specified if there is a cut failure. To determine what this point should be, find a point in the white matter mass of the left hemisphere in the T1 volume (in tkmedit) and record the column, row, and slice. Creates a file called scripts/seed-cccrs.man.dat with the CRS. Remember that tkmedit displays the volume in radiological convention (ie, left is right).

-rh-crs C R S

Same as -lh-crs but for the right hemisphere. Creates a file called scripts/seed-rhcrs.man.dat with the CRS.

-watershed cmd

This controls how the skull stripping will be performed. Legal values are normal (the default), atlas, nowatershed, watershedonly, and watershedtemplate.

-wsmore/-wsless

Increase/decrease the preflooding height (threshold) when skull stripping. -wsmore will expand the skull surface; -wsless will shrink the skull surface. See also -wsthresh.

-wsthresh pctheight

Explicitly set the preflooding height when skull stripping.

-wsseed R C S

Supply a point in the volume that the user believes to be in the white matter. By default, this point will be determined automatically. It should only be specified if there is a strip failure. To determine what this point should be, find a point in the white matter using tkmedit and record the Volume Index values (NOT the XYZ coordinates).

-gca gcafile

Specify the full path to the gaussian classifier array (GCA) file to be used with GCA registration and automatic subcortical segmentation. Default is RB_all_2006-02-15.gca located in FREESURFER_HOME/average. This has no effect unless the GCA registration or subcortical segmentation stages are to be performed.

-gca-skull gcafile

Specify the full path to the gaussian classifier array (GCA) file to be used with registration with skull. Default is RB40_talairach_with_skull_2005-12-30.gca located in FREESURFER_HOME/average.

-nuiterations

Number of iterations in the non-uniform intensity correction. Default is 4.

-norm3diters niters

Use niters 3d normalization iterations (passes as -n to mri_normalize).

-normmaxgrad maxgrad

Passes "-g maxgrad" to mri_normalize. Max grad default is 1.

-noaseg

Skips subcortical segmentation steps (same as -nosubcortseg), and does not use aseg.mgz for inorm2, wm segmentation, or filling. Use this flag for brains that do not support usage of subcortical segmentation.

Expert Options File

While the expert preferences flags supported by recon-all cover most of the instances where special flags need to be passed to a FreeSurfer binary, to allow passing an arbitrary flag to a binary, recon-all supports the reading of a user-created file containing special options to include in the command string (in addition to, not in place of). The file should contain as the first item the name of the command, and the items following it on rest of the line will be passed as the extra options. For example, if a file called expert.opts is created containing these lines:

mri_em_register -p .5
mris_fix_topology -s 100

then the option "-p .5" will be passed to mri_em_register, and "-s 100" will be passed to mris_fix_topology. The name of the expert options file is passed to recon-all with the -expert flag, eg.

recon-all -expert <full pathname>/expert.opts

Note: the full pathname to the file must be specified.

The following FreeSurfer binaries will accept an expert option:

Notification Files

Notification files allow the user to cascade invocations to recon-all, with one invocation waiting until another one terminates. This is done by specifying a file that must exist before an invocation can precede (-waitfor) and/or specifying a file that is created when an invocation terminates (-notify). This type of interprocess communication can allow users to parallelize the stream. If this is to be done, note that each hemisphere can be run separately by specifying the -hemi flag.

Status and Log Files

By default, log and status files are created in subjid/scripts. The log file contains all the output from all the programs that have been run during the invocation to recon-all. The status file has a list of all the programs that have been run and the time at which each started. The log file is intended to be a record of what was done whereas the status file allows the user to easily see where in the stream a currently running process is. The log file should be sent with all bug reports. By default, these files are called recon-all.log and recon-all.status, but this can be changed with the -log and -status options. By default, the log and status are appended to. New log and status files can be forced with the -noappend flag.

Other Arguments

-sd subjectsdir

This allows the user to specify the root of the FreeSufer subjects directory. If unspecified, the environment variable $SUBJECTS_DIR is used.

-mail username

Send email to username when the process terminates.

Step Description Summaries

Motion Correction (-<no>motioncor)

When there are multiple source volumes, this step will correct for small motions between them and then average them together. The input are the volumes found in file(s) mri/orig/XXX.mgz. The output will be the volume mri/orig.mgz. If no runs are found, then it looks for a volume in mri/orig (or mri/orig.mgz). If that volume is there, then it is used in subsequent processes as if it was the motion corrected volume. If no volume is found, then the process exits with errors.

NU Intensity Correction (-<no>nuintensitycor)

Non-parametric Non-uniform intensity Normalization (N3), corrects for intensity non-uniformity in MR data, making relatively few assumptions about the data. This runs the MINC tool 'nu_correct'. By default, four iterations of nu_correct are run. The flag -nuiterations specification of some other number of iterations.

Talairach (-<no>talairach)

This computes the affine transform from the orig volume to the MNI305 atlas using the MINC program mritotal (see Collins, et al, 1994) through a FreeSurfer script called talairach. Several of the downstream programs use talairach coordinates as seed points. You can/should check how good the talairach registration is using tkregister2 --s subjid --fstal. tkregister2 allows you to compare the orig volume against the talairach volume resampled into the orig space. Run "tkregister2 --help" for more information. Creates the files mri/transform/talairach.auto.xfm and talairach.xfm.

Normalization (-<no>normalization)

Performs intensity normalization of the orig volume and places the result in mri/T1.mgz. Attempts to correct for fluctuations in intensity that would otherwise make intensity-based segmentation much more difficult. Intensities for all voxels are scaled so that the mean intensity of the white matter is 110. If there are problems with the normalization, users can add control points. See also Normalization2.

Skull Strip (-<no>skullstrip)

Removes the skull from mri/T1.mgz and stores the result in mri/brainmask.auto.mgz and mri/brainmask.mgz. Runs the mri_watershed program. If the strip fails, users can specify seed points (-wsseed) or change the threshold (-wsthresh, -wsmore, -wsless). The -autorecon1 stage ends here.

Automatic Subcortical Segmentation (-<no>subcortseg)

This is done in six stages. (1) CGA linear registration (-gcareg). This is an initial registration to a template. (2) Canonical Normalization (-canorm), (3) Canonical Registration (-careg). (4) Neck removal (-rmneck), (5) Registration, w/skull (-skull-lta), and (6) Subcortical labeling (-calabel). The stages are listed next.

EM (GCA) Registration (-<no>gcareg)

Computes transform to align the mri/nu.mgz volume to the default GCA atlas found in FREESURFER_HOME/average (see -gca flag for more info). Creates the file mri/transforms/talairach.lta. The -autorecon2 stage starts here.

CA Normalize (-<no>canorm)

Further normalization, based on GCA model. Creates mri/norm.mgz.

CA Register (-<no>careg)

Computes a nonlinear transform to align with GCA atlas. Creates the file mri/transform/talairach.m3z.

Remove neck (-<no>rmneck)

The neck region is removed from the NU-corrected volume mri/nu.mgz. Makes use of transform computed from prior CA Register stage. Creates the file mri/nu_noneck.mgz.

EM Registration, with Skull (-<no>skull-lta)

Computes transform to align volume mri/nu_noneck.mgz with GCA volume possessing the skull. Creates the file mri/transforms/talairach_with_skull.lta.

CA Label (-<no>calabel)

Labels subcortical structures, based in GCA model. Creates the files mri/aseg.auto.mgz and mri/aseg.mgz.

ASeg Stats (-<no>segstats)

Computes statistics on the segmented subcortical structures found in mri/aseg.mgz. Writes output to file stats/aseg.stats.

Normalization2 (-<no>normalization)

Performs a second (major) intensity correction using only the brain volume as the input (so that it has to be done after the skull strip). Intensity normalization works better when the skull has been removed. Creates a new brain.mgz volume. The -autorecon2-cp stage begins here. If -noaseg flag is used, then aseg.mgz is not used by mri_normalize.

WM Segmentation (-<no>segmentation)

Attempts to separate white matter from everything else. The input is mri/brain.mgz, and the output is mri/wm.mgz. Uses intensity, neighborhood, and smoothness constraints. This is the volume that is edited when manually fixing defects. Calls mri_segment, mri_edit_wm_with_aseg, and mri_pretess. To keep previous edits, run with -keepwmedits. If -noaseg is used, them mri_edit_wm_aseg is skipped.

Cut/Fill (-<no>fill)

This creates the subcortical mass from which the orig surface is created. The mid brain is cut from the cerebrum, and the hemispheres are cut from each other. The left hemisphere is binarized to 255. The right hemisphere is binarized to 127. The input is mri/wm.mgz and the output is mri/filled.mgz. Calls mri_fill. If the cut fails, then seed points can be supplied (see -cc-crs, -pons-crs, -lh-crs, -rh-crs). The actual points used for the cutting planes in the corpus callosum and pons can be found in scripts/ponscc.cut.log. The stage -autorecon2-wm begins here. This is the last stage of volumetric processing. If -noaseg is used, then aseg.mgz is not used by mri_fill.

Tessellation (-<no>tessellate)

This is the step where the orig surface (ie, surf/?h.orig.nofix) is created. The surface is created by covering the filled hemisphere with triangles. Runs mri_tessellate. The places where the points of the triangles meet are called vertices. Creates the file surf/?h.orig.nofix Note: the topology fixer will create the surface ?h.orig.

Orig Surface Smoothing (-<no>smooth1, -<no>smooth2)

After tesselation, the orig surface is very jagged because each triangle is on the edge of a voxel face and so are at right angles to each other. The vertex positions are adjusted slightly here to reduce the angle. This is only necessary for the inflation processes. Creates surf/?h.smoothwm(.nofix). Calls mris_smooth. Smooth1 is the step just after tessellation, and smooth2 is the step just after topology fixing.

Inflation (-<no>inflate1, -<no>inflate2)

Inflation of the surf/?h.smoothwm(.nofix) surface to create surf/?h.inflated. The inflation attempts to minimize metric distortion so that distances and areas are perserved (ie, the surface is not stretched). In this sense, it is like inflating a paper bag and not a balloon. Inflate1 is the step just after tessellation, and inflate2 is the step just after topology fixing. Calls mris_inflate. Creates ?h.inflated, ?h.sulc, ?h.curv, and ?h.area.

QSphere (-<no>qsphere)

This is the initial step of automatic topology fixing. It is a quasi-homeomorphic spherical transformation of the inflated surface designed to localize topological defects for the subsequent automatic topology fixer. Calls mris_sphere. Creates surf/?h.qsphere.nofix.

Automatic Topology Fixer (-<no>fix)

Finds topological defects (ie, holes in a filled hemisphere) using surf/?h.qsphere.nofix, and changes the orig surface (surf/?h.orig.nofix) to remove the defects. Changes the number of vertices. All the defects will be removed, but the user should check the orig surface in the volume to make sure that it looks appropriate. Calls mris_fix_topology. Creates surf/?h.orig (by iteratively fixing surf/?h.orig.nofix).

Final Surfaces (-<no>finalsurfs)

Creates the ?h.white and ?h.pial surfaces as well as the thickness file (?h.thickness) and curvature file (?h.curv). The white surface is created by "nudging" the orig surface so that it closely follows the white-gray intensity gradient as found in the T1 volume. The pial surface is created by expanding the white surface so that it closely follows the gray-CSF intensity gradient as found in the T1 volume. Calls mris_make_surfaces.

Cortical Ribbon Mask (-<no>cortribbon)

Creates binary volume masks of the cortical ribbon, ie, each voxel is either a 1 or 0 depending upon whether it falls in the ribbon or not. Saved as ?h.ribbon.mgz. Uses mgz regardless of whether the -mgz option is used. The -autorecon2 stage ends here.

Spherical Inflation (-<no>sphere)

Inflates the orig surface into a sphere while minimizing metric distortion. This step is necessary in order to register the surface to the spherical atlas. (also known as the spherical morph). Calls mris_sphere. Creates surf/?h.sphere. The -autorecon3 stage begins here.

Ipsilateral Surface Registation (Spherical Morph) (-<no>surfreg)

Registers the orig surface to the spherical atlas through surf/?h.sphere. The surfaces are first coarsely registered by aligning the large scale folding patterns found in ?h.sulc and then fine tuned using the small-scale patterns as in ?h.curv. Calls mris_register. Creates surf/?h.sphere.reg.

Contralateral Surface Registation (Spherical Morph) (-<no>contasurfreg)

Same as ipsilateral but registers to the contralateral atlas. Creates lh.rh.sphere.reg and rh.lh.sphere.reg.

Average Curvature (-<no>avgcurv)

Resamples the average curvature from the atlas to that of the subject. Allows the user to display activity on the surface of an individual with the folding pattern (ie, anatomy) of a group. Calls mrisp_paint. Creates surf/?h.avg_curv.

Cortical Parcellation (-<no>cortparc, -<no>cortparc2)

Assigns a neuroanatomical label to each location on the cortical surface. Incorporates both geometric information derived from the cortical model (sulcus and curvature), and neuroanatomical convention. Calls mris_ca_label. -cortparc creates label/?h.aparc.annot, and -cortparc2 creates /label/?h.aparc.a2005s.annot.

Parcellation Statistics (-<no>parcstats)

Runs mris_anatomical_stats to create a summary table of cortical parcellation statistics for each structure, including 1. structure name 2. number of vertices 3. total surface area (mm2) 4. total gray matter volume (mm3) 5. average cortical thickness (mm) 6. standard error of cortical thicknessr (mm) 7. integrated rectified mean curvature 8. integrated rectified Gaussian curvature 9. folding index 10. intrinsic curvature index. For -parcstats, the file is saved in stats/?h.aparc.stats. For -parcstats2, the file is saved in stats/?h.aparc.a2005s.stats.

Other

Using T2 or FLAIR data to improve pial surfaces

Pial surfaces can be improved using the different contrast in T2 or FLAIR images. The original pial surfaces without T2/FLAIR data are saved as ?h.woT2.pial or ?h.woFLAIR.pial, and new ?h.pial surfaces are created. One example where this is useful is when there is dura in the brainmask.mgz that isn't removed by skull stripping. The flags for these commands are:

-T2 <input T2 volume> or -FLAIR <input FLAIR volume>

specify the path to the T2 or FLAIR image to use (can be either a DICOM, MGH or NIFTI file)

-T2pial or -FLAIRpial

creates new pial surfaces using T2 or FLAIR images

An example of running a subject through Freesurfer with a T2 image is:

recon-all -subject subjectname -i /path/to/input_volume -T2 /path/to/T2_volume -T2pial -all

T2 or FLAIR images can also be used with Freesurfer subjects that have already been processed without them. Note that autorecon3 should also be re-ran to compute statistics based on the new surfaces. For example:

recon-all -subject subjectname -T2 /path/to/T2_volume -T2pial -autorecon3

Manual Checking and Editing of Surfaces

To manually edit segmenation, run the following command (make sure that your SUBJECTS_DIR environment variable is properly set).

tkmedit subjid wm.mgz -aux T1.mgz

The surfaces can be loaded through the menu item File->LoadMainSurface. To enable editing, set Tools->EditVoxels. It may also be convenient to bring up the reconstruction toolbar with View->ToolBars->Reconstruction. Alt-C toggles between the main (wm) and auxiliary (T1) volumes. Middle clicking will set a voxel value to 255; left clicking will set a voxel value to 0. Only edit the wm volume. When finished, File->SaveMainVolume.

To view the inflated surface simultaneosly with the volume, run the following command from a different shell:

tksurfer subjid lh inflated

To goto a point on the surface inside the volume, click on the point and hit SavePoint (icon looks like a floppy disk), then, in tkmedit, hit GotoSavedPoint (icon looks like an open file).

Be sure to see the tutorials found at FsTutorial.

Verification of fsaverage

New to Freesurfer versions 5.2 and greater, recon-all will check if the fsaverage directory in SUBJECTS_DIR directory path corresponds to the 5.2 (or greater) version which contains several new files. If a previous version of fsaverage is detected which does not include these new files, then recon-all will delete the old fsaverage and create a new symlink. As a result, any files manually created by the user inside the fsaverage directory are potentially at risk of being deleted when upgrading Freesurfer versions.

Using Compressed MGH Format (.mgz)

MGZ format can be used by specifying the -mgz flag. The MGH format is a single-file format in which both pixel and meta data are stored. Files in this format have a .mgh extension. This can be compressed with gzip to give a compressed MGH format for which the extension is .mgz. This can provide substantial savings on disk space, but it does change the way that the data are stored. When COR format is used, an entire directory must be dedicated to the volume, and the volume is identified by the directory name (eg, mri/brain contains the skull-stripped volume). When MGZ is used, the COR volume and directory are replaced by a single file named directory.mgz (eg, brain.mgz). When setting up the raw data in the subject directory, create MGZ files with the names RRR.mgz in the mri directory, where RRR is the 3-digit, 0-padded run number (eg, 004.mgz). Do not use numbers over 100. Note that the input runs do not have to be conformed (ie, 2563, 1mm isotropic). The input runs will be motion corrected and averaged togther into rawavg.mgz which will then be conformed into orig.mgz.

Flattening

Flattening is not actually done in this script. This part just documents how one would go about performing the flattening. First, load the subject surface into tksurfer:

tksurfer subjid lh inflated

Load the curvature through the File->Curvature->Load menu (load lh.curv). This should show a green/red curvature pattern. Red = sulci.

Right click before making a cut; this will clear previous points. This is needed because it will string together all the previous places you have clicked to make the cut. To make a line cut, left click on a line of points. Make the points fairly close together; if they are too far appart, the cut fails. After making your line of points, execute the cut by clicking on the Cut icon (scissors with an open triangle for a line cut or scissors with a closed triangle for a closed cut). To make a plane cut, left click on three points to define the plane, then left click on the side to keep. Then hit the CutPlane icon. Fill the patch. Left click in the part of the surface that you want to form your patch. Then hit the Fill Uncut Area button (icon = filled triangle). This will fill the patch with white. The non-patch area will be unaccessible through the interface. Save the patch through File->Patch->SaveAs. For whole cortex, save it to something like lh.cort.patch.3d. For occipital patches, save it to lh.occip.patch.3d.

Cd into the subject surf directory and run:

mris_flatten -w N -distances Size Radius lh.patch.3d lh.patch.flat

where N instructs mris_flatten to write out an intermediate surface every N interations. This is only useful for making movies; otherwise set N=0. Size is maximum number of neighbors; Radius radius (mm) in which to search for neighbors. In general, the more neighbors that are taken into account, the less the metric distortion but the more computationally intensive. Typical values are Size=12 for large patches, and Size=20 for small patches. Radius is typically 7. Note: flattening may take 12-24 hours to complete. The patch can be viewed at any time by loading the subjects inflated surface, then loading the patch through File->Patch->LoadPatch...

References

[1] Collins, DL, Neelin, P., Peters, TM, and Evans, AC. (1994) Automatic 3D Inter-Subject Registration of MR Volumetric Data in Standardized Talairach Space, Journal of Computer Assisted Tomography, 18(2) p192-205, 1994 PMID: 8126267; UI: 94172121

[2] Cortical Surface-Based Analysis I: Segmentation and Surface Reconstruction Dale, A.M., Fischl, Bruce, Sereno, M.I., (1999). Cortical Surface-Based Analysis I: Segmentation and Surface Reconstruction. NeuroImage 9(2):179-194

[3] Fischl, B.R., Sereno, M.I.,Dale, A. M. (1999) Cortical Surface-Based Analysis II: Inflation, Flattening, and Surface-Based Coordinate System. NeuroImage, 9, 195-207.

[4] Fischl, Bruce, Sereno, M.I., Tootell, R.B.H., and Dale, A.M., (1999). High-resolution inter-subject averaging and a coordinate system for the cortical surface. Human Brain Mapping, 8(4): 272-284

[5] Fischl, Bruce, and Dale, A.M., (2000). Measuring the Thickness of the Human Cerebral Cortex from Magnetic Resonance Images. Proceedings of the National Academy of Sciences, 97:11044-11049.

[6] Fischl, Bruce, Liu, Arthur, and Dale, A.M., (2001). Automated Manifold Surgery: Constructing Geometrically Accurate and Topologically Correct Models of the Human Cerebral Cortex. IEEE Transactions on Medical Imaging, 20(1):70-80

[7] Non-Uniform Intensity Correction. http://www.bic.mni.mcgill.ca/software/N3/node6.html

[8] Fischl B, Salat DH, Busa E, Albert M, Dieterich M, Haselgrove C, van der Kouwe A, Killiany R, Kennedy D, Klaveness S, Montillo A, Makris N, Rosen B, Dale AM. Whole brain segmentation: automated labeling of neuroanatomical structures in the human brain. Neuron. 2002 Jan 31;33(3):341-55.

[9] Bruce Fischl, Andre van der Kouwe, Christophe Destrieux, Eric Halgren, Florent Segonne, David H. Salat, Evelina Busa, Larry J. Seidman, Jill Goldstein, David Kennedy, Verne Caviness, Nikos Makris, Bruce Rosen, and Anders M. Dale. Automatically Parcellating the Human Cerebral Cortex. Cerebral Cortex January 2004; 14:11-22.

Reporting Bugs

Report bugs to < freesurfer@nmr.mgh.harvard.edu > See also: BugReporting

Additional Help

Send email to freesurfer@nmr.mgh.harvard.edu . Also see http://surfer.nmr.mgh.harvard.edu. In particular, there is both a reconstruction guide and tutorial as well as manuals for tkmedit and tksurfer.

recon-all (last edited 2017-12-08 18:23:09 by MorganFogarty)