FreeSurfer

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 of an individual with a stereotaxic atlas
  • Statistical analysis of group morphometry differences

Usage

To run FreeSurfer, you simply need to add it to your path and run the setup script:

# For Version 6.0.0, run the following commands
export FREESURFER_HOME=/gpfs/research/software/freesurfer/freesurfer
source $FREESURFER_HOME/SetUpFreeSurfer.sh
export SUBJECTS_DIR=/gpfs/home/YOURFSUID/path/to/output

# For Version 7.1.1, run the following commands
export FREESURFER_HOME=/gpfs/research/software/freesurfer/freesurfer-7.1.1
source $FREESURFER_HOME/SetUpFreeSurfer.sh
export SUBJECTS_DIR=/gpfs/home/YOURFSUID/path/to/output

Change YOURFSUID and /path/to/output in the SUBJECTS_DIR definition to your FSUID followed by the filepath to where you want the output to go.  You will need to define this variable as if you don't, you will get write permission errors due to FreeSurfer defaulting to the location FreeSurfer is installed in which is not writable.  Once the FreeSurfer setup is complete, you can use FreeSurfer as shown in the documentation.  Please refer to the Documentation for more information. The official documentation also has a wealth of Tutorials available as well.

 

Parallelization using GNU Parallel

The primary method of running FreeSurfer in parallel is to use the GNU Parallel library.  Instructions on how to run commands in parallel can be found at this FreeSurfer Tutorial site.  An example of a possible SLURM Script for the "recon-all" tool is as follows:

#!/bin/bash
#SBATCH -J MyFreeSurferJob
#SBATCH -n 8
#SBATCH -N 1
#SBATCH -p backfill
#SBATCH -t 4:00:00

export FREESURFER_HOME=/gpfs/research/software/freesurfer/freesurfer-7.1.1
source $FREESURFER_HOME/SetUpFreeSurfer.sh
export SUBJECTS_DIR=/gpfs/home/YOURFSUID/path/to/output #CHANGE THIS AS DESCRIBED ABOVE!

find . -name "*.nii" | parallel --jobs 8 recon-all -s {.} -i {} -all -qcache

You may need to adjust the find . -name "*.nii" such that the find command starts at the top level directory where your data is stored. You can also just cd to that directory as well then run the find command as-is.  You may also need to adjust the last command to work for different tools.  See the documentation for more information on the tools FreeSurfer contains.

Version
7.1.1, 6.0.0
Software Category