Skip to content

FreeSurfer

A software package for the analysis and visualization of structural and functional neuroimaging data from cross-sectional or longitudinal studies.


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 need to add it to your path and run the setup script:

For 6.0.0, run the following commands:

1
2
3
$ 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:

1
2
3
$ 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

Note

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/path/to/output in the SUBJECTS_DIR to your FSUID followed by the file path where you want the output to go.

Once the FreeSurfer setup is complete, you can use FreeSurfer as shown in the documentation.

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

Then submit your script using the following command, replacing YOURSCRIPT with the name of your script file:

$ sbatch YOURSCRIPT.sh

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 is written in the above example. You may also need to modify the last command to work for different tools.