Exercise: Running FreeSurfer jobs on the cluster

In this exercise we will construct a small script to run FreeSurfer’s recon-all, and use qsub 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 (an example of version 5.3)

    $ module unload freesurfer
    $ module load freesurfer/5.3
    
  4. Submit the script to the cluster

    $ echo "cd $PWD; ./runFreesurfer.sh" | qsub -l walltime=00:10:00,mem=1GB
    
  5. Verify the job is running with qstat. You should see something like:

    $ qstat 11173851
    Job ID                    Name             User            Time Use S Queue
    +----------------------- ---------------- --------------- -------- - -----
    11173851.dccn-l029         STDIN            dansha                 0 Q long
    
  6. Because we don’t really want to run the analysis but rather test a script, kill the job with qdel. For example:

    $ qdel 11173851