FreeSurfer

Software Category
Version
7.1.1, 6.0.0

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

Using FreeSurfer on RCC Resources

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

You need to define the SUBJECTS_DIR variable, as if you don't, you will get write permission errors due to FreeSurfer defaulting to the location it is installed in, which is not writable. Change YOURFSUID and /path/to/output in the SUBJECTS_DIR definition to your FSUID followed by the filepath where you want the output to go.

Once the FreeSurfer setup is complete, you can use FreeSurfer as shown in the documentation. For detailed usage information, refer to the official documentation. The official documentation also has a wealth of tutorials available.

 

Running FreeSurfer in 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. Below is a sample Slurm Script for the "recon-all" tool:

#!/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 modify find . -name "*.nii" such that the find command starts at the top level directory where your data is stored. You can also just use the cd command to change to that directory, then run the find command as it's written in the above example. You may also need to modify the last command to work for different tools. See the official documentation for more information on the tools that FreeSurfer contains.