Biowulf High Performance Computing at the NIH
Freesurfer on Biowulf

FreeSurfer is a set of automated tools for reconstruction of the brain's cortical surface from structural MRI data, and overlay of functional MRI data onto the reconstructed surface. It was developed at the Martinos Center for Biological Imaging at Harvard.

Important Notes

Interactive job
Interactive jobs should be used for debugging, graphics, or applications that cannot be run as batch jobs.

Allocate an interactive session and run the program. Sample session:

[user@biowulf]$ sinteractive
salloc.exe: Pending job allocation 46116226
salloc.exe: job 46116226 queued and waiting for resources
salloc.exe: job 46116226 has been allocated resources
salloc.exe: Granted job allocation 46116226
salloc.exe: Waiting for resource configuration
salloc.exe: Nodes cn3144 are ready for job

[user@cn3144 ~]$ module load freesurfer
[+] Loading Freesurfer 6.0.0 ...
[+] Bash users should now type: source $FREESURFER_HOME/
[+] Csh users should now type: source $FREESURFER_HOME/SetUpFreeSurfer.csh

[user@cn3144 ~]$ source $FREESURFER_HOME/
-------- freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0-2beb96c --------
Setting up environment for FreeSurfer/FS-FAST (and FSL)
FREESURFER_HOME   /usr/local/apps/freesurfer/6.0.0
FSFAST_HOME       /usr/local/apps/freesurfer/6.0.0/fsfast
SUBJECTS_DIR      /usr/local/apps/freesurfer/6.0.0/subjects
MNI_DIR           /usr/local/apps/freesurfer/6.0.0/mni

[user@cn3144 ~]$ tkmedit bert orig.mgz
Setting subject to bert
Reading 0 control points...
Reading 0 control points...
Reading /usr/local/freesurfer/lib/tcl/tkm_common.tcl
Reading /usr/local/freesurfer/lib/tcl/tkm_wrappers.tcl
Reading /usr/local/freesurfer/lib/tcl/fsgdfPlot.tcl
Reading /usr/local/freesurfer/lib/tcl/tkUtils.tcl

[user@cn3144 ~]$ exit
salloc.exe: Relinquishing job allocation 46116226
[user@biowulf ~]$

Batch job
Most jobs should be run as batch jobs.

Create a batch input file (e.g. For example:

set -e
module load freesurfer

cd /data/user/mydir
recon-all -subject hv1 -all

Submit this job using the Slurm sbatch command.

sbatch  [--mem=#]
Swarm of Jobs
A swarm of jobs is an easy way to submit a set of independent commands requiring identical resources.

For swarm jobs, it might be simplest to have the line

module load freesurfer/5.3.0 > /dev/null 2>&1 ; source $FREESURFER_HOME/
in your .bashrc file. Alternatively, you can add this line to each line in your swarm command file. <

Create a swarmfile (e.g. freesurfer.swarm). For example:

cd /data/$USER/mydir/; recon-all -subject hv1 -all
cd /data/$USER/mydir/; recon-all -subject hv2 -all
cd /data/$USER/mydir/; recon-all -subject hv3 -all

Submit this job using the swarm command.

swarm -f freesurfer.swarm [-t #] 
-g # Number of Gigabytes of memory required for each process (1 line in the swarm command file)