Exercise: Running FreeSurfer jobs on the cluster

In this exercise we will construct a small script to run FreeSurfer’s recon-all, and use sbatch to submit this script to the cluster for execution.

Preparation

Move into the directory you’d like to work in and download the files prepared for the exercise using this command:

$ wget https://github.com/Donders-Institute/hpc-wiki-v2/raw/master/docs/cluster_howto/exercise_freesurfer/FSdata.tgz
$ tar -xvf FSdata.tgz
$ cd FSdata

Task 1: create the script

  1. Open a text editor and create the script called runFreesurfer.sh

    #!/bin/bash
    export SUBJECTS_DIR=$(pwd)
    recon-all -subjid FreeSurfer -i MP2RAGE.nii -all
    
  2. Set the script to be executable

  3. Load the freesurfer module

    $ module load freesurfer
    
  4. Submit the script to the cluster

    $ sbatch --time=00:10:00 --mem=1gb $PWD/runFreesurfer.sh
    
  5. Verify the job is running with qstat. You should see something like:

    $ squeue --me
    
         JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
      46540218     batch runFrees   honlee  R       2:19      1 dccn-c065
    
  6. Because we don’t really want to run the analysis but rather test a script, kill the job with scancel. For example:

    $ scancel 46540218