USAGE: recon-all Required Arguments: -subjid subjid Clustered Directives: -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) 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 Step-wise Directives See -help Expert Preferences -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 -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) 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) -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 $Id: recon-all-nmr,v 1.26 2003/07/18 18:48:34 greve Exp $ 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/XXX in COR format (XXX is a three-digit, zero-padded number). 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 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. -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. 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. -motioncor < 5 min -talairach 2 min -nuintensitycor 12 min -usenuintensitycor N/A -normalization 5 min -skullstrip 1 min -segmentation 4 min -fill 1 min -tessellate 1 min per hemisphere -smooth1 1 min per hemisphere -inflate1 4 min per hemisphere -qsphere 40 min per hemisphere -fix 2 min per hemisphere -euler 1 min per hemisphere -smooth2 1 min per hemisphere -inflate2 4 min per hemisphere -finalsurfs 1.5 hours per hemisphere -sphere 3.0 hours per hemisphere -surfreg 1.5 hours per hemisphere -contrasurfreg 1.5 hours per hemisphere -avgcurv 1 min per hemisphere -avglabels 5 min per hemisphere 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. -watershed cmd This controls how the skull stripping will be performed. Legal values are normal (the default), 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). -nuiterations Number of iterations in the non-uniform intensity correction. Default is 4. 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 -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 (-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. The output will be the orig COR volune (in mri/orig). If no runs are found in mri/orig/XXX, then it looks for a volume in mri/orig. 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 (-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. Normalization (-normalization) Performs intensity normalization of the orig volume and places the result in T1. 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. Skull Strip (-skullstrip) Removes the skull from mri/T1 and stores the result in mri/brain. Runs the mri_watershed program. If the strip fails, users can specify seed points (-wsseed) or change the threshold (-wsthresh, -wsmore, -wsless). Segmentation -segmentation Attempts to separate white matter from everything else. The input is mri/brain, and the output is mri/wm. 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 -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. Calls mri_fill. If the cut fails, then seed points can be supplied (-cc-xyz, -pons-xyz, -lh-xyz, -rh-xyz). Tessellation -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 (-smooth1, -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 (-inflate1, -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 (-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 (-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 (-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 (-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. Spherical Inflation (-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) (-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) (-contasurfreg) Same as ipsilateral but registers to the contralateral atlas. Creates lh.rh.sphere.reg and rh.lh.sphere.reg. Average Curvature (-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 (-avglabels) 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. 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). 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... GETTING 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. 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] Dale, A. M., Fischl, B.R., Sereno, M.I. (1998) Cortical Surface-Based Analysis I: Segmentation and Surface Reconstruction. em NeuroImage. [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, B.R., Sereno, Tootell, R.B.H. M.I.,Dale, A. M. (20??) High-Resolution Inter-Subject Averaging and a Coordinate System for the Cortical Surface. [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