Biowulf High Performance Computing at the NIH
Fmriprep on Biowulf

Fmriprep is an fMRI data preprocessing pipeline that produces an output that can be submitted to a variety of group-level analyses, including task-based and resting-state fMRI, graph theoretical metrics, and surface or volume-based statistics. Some of the preprocessing steps performed by fmriprep include coregistration, normalization, unwarping, noise component extraction, segmentation, and skullstripping.

References:

Web site


IMPORTANT: (October 2020) The memory limit flags in fmriprep do not work as intended.
The flags mem, mem_mb, mem-mb that are used to select an upper bound for fmriprep memory processes do not work as intended. Therefore, if an fmriprep job exceeds its memory allocation, the job will hang and D processes will be generated in the compute node where the job is running. We are working on a solution to this but in the meantime we recommend carefully profiling memory consumption for a given type of dataset by running small-scale jobs, then gradually increasing the number of jobs when specific memory requirements have been established. Please get in touch with HPC staff if you need help with profiling memory requirements.

Documentation
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 input in bold):

[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 fmriprep

[user@cn3144 ~]$ fmriprep -h

[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. fmriprep.sh). For example:

#!/bin/bash
# sbatch --gres=lscratch:100 --mem=32g --cpus-per-task=48 --time=72:00:00 fmriprep.sh

set -o pipefail
set -e

function fail {
    echo "FAIL: $@" >&2
    exit 1  # signal failure
}

module load fmriprep 
fmriprep /data/user/BIDS-dataset/ds001 /data/user/BIDS-dataset/fmriprep.out.ds001 \
participant --participant_label sub-01 -w /lscratch/$SLURM_JOB_ID \
--notrack --nthreads $SLURM_CPUS_PER_TASK --use-aroma --mem_mb $SLURM_MEM_PER_NODE \
--stop-on-first-crash

Submit this job using the Slurm sbatch command.

sbatch [--gres=lscratch:#] [--cpus-per-task=#] [--mem=#] fmriprep.sh
Swarm of Jobs
A swarm of jobs is an easy way to submit a set of independent commands requiring identical resources.

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

export TMPDIR=/lscratch/$SLURM_JOB_ID; \
mkdir -p $TMPDIR/out; \
mkdir -p $TMPDIR/wrk; \
fmriprep /data/user/BIDS-dataset/ds001/ $TMPDIR/out \
participant --participant_label sub-01 -w $TMPDIR/wrk \
--use-aroma --notrack --nthreads $SLURM_CPUS_PER_TASK \
--mem_mb $SLURM_MEM_PER_NODE \
--stop-on-first-crash; \
mv $TMPDIR/out /data/user/BIDS-dataset/FMRIPREP.out.s001
export TMPDIR=/lscratch/$SLURM_JOB_ID; \
mkdir -p $TMPDIR/out; \
mkdir -p $TMPDIR/wrk; \
fmriprep /data/user/BIDS-dataset/ds001/ $TMPDIR/out \
participant --participant_label sub-02 -w $TMPDIR/wrk \
--use-aroma --notrack --nthreads $SLURM_CPUS_PER_TASK \
--mem_mb $SLURM_MEM_PER_NODE \
--stop-on-first-crash; \
mv $TMPDIR/out /data/user/BIDS-dataset/FMRIPREP.out.s002 

Submit this job using the swarm command.

swarm -f fmriprep.swarm [--gres=lscratch:#] [-g #] [-t #] --module fmriprep
where
-gres=lscratch:# Number of Gigabytes of local disk space allocated per process (1 line in the swarm command file)
-g # Number of Gigabytes of memory required for each process (1 line in the swarm command file)
-t # Number of threads/CPUs required for each process (1 line in the swarm command file).
--module fmriprep Loads the fmriprep module for each subjob in the swarm