FreeSurfer
A software package for the analysis and visualization of structural and functional neuroimaging data from cross-sectional or longitudinal studies.
FreeSurfer is a comprehensive software suite developed at Massachusetts General Hospital for the analysis and visualization of human brain MRI data. It is widely used in neuroimaging research for cortical surface reconstruction, brain segmentation, and morphometric analysis.
FreeSurfer provides a full processing stream for structural MRI data, including:
- Skull stripping, B1 bias field correction, and gray-white matter segmentation
- Reconstruction of cortical surface models (gray-white boundary surface and pial surface)
- Labeling of regions on the cortical surface, as well as subcortical brain structures
- Nonlinear registration of the cortical surface for an individual with a stereotaxic atlas
- Statistical analysis of group morphometry differences
Using FreeSurfer on RCC Resources#
Before running any FreeSurfer commands, you must load the appropriate module and initialize the FreeSurfer environment.
Load FreeSurfer#
For FreeSurfer 7.1.1:
For FreeSurfer 6.0.0:
Important
The SUBJECTS_DIR environment variable must be set to a writable directory. If this variable is not defined, FreeSurfer will attempt to write output to its installation directory,
which is not writable on RCC systems and will result in permission errors.
Example: Running FreeSurfer in Parallel#
The most common FreeSurfer workflow in parallel is the recon-all pipeline, which performs a full cortical and subcortical reconstruction from an MRI scan.
Step 1: Set Environment#
Step 2: Run recon-all#
This command:
- creates a subject directory named
sub-01insideSUBJECTS_DIR - imports the T1-weighted image
- runs the full FreeSurfer processing pipeline (
-all)
Output#
After completion, results will be stored in:
Key output subdirectories include:
mri/– volumetric data and segmentationssurf/– reconstructed cortical surfaceslabel/– anatomical labels and parcellationsstats/– quantitative morphometric statistics
Running FreeSurfer with Slurm (Recommended)#
Because recon-all is computationally intensive, it should be run as a Slurm batch job rather than on a login node.
Example Slurm Script (Single Subject)#
Submit the job with:
Running FreeSurfer in Parallel for Multiple Subjects#
For studies with multiple subjects, FreeSurfer workflows can be parallelized across subjects using GNU Parallel
Example Slurm Script (Multiple Subjects)#
Note
Adjust the number of parallel jobs (--jobs) to match the number of CPUs requested via #SBATCH -n.
Each recon-all instance is CPU- and memory-intensive.