fMRIPrep on HiPerGator - tannerjared/MRI_Guide GitHub Wiki
First, build an fMRIPrep container. In a HiPerGator Desktop session, go to Applications, then Terminal Emulator.
Then, in a location where you want to save the container (e.g., cd /blue/{group}/{gatorlink}/containers – that’s just an example, update to what matches your paths), run this:
export TMPDIR=$PWD
apptainer build fmriprep-25.0.0.sif docker://nipreps/fmriprep:25.0.0
That might take up to an hour to complete, but hopefully doesn’t give any errors.
Here is a sample script that should work. Update everything needed (accounts, paths to match where your data are, etc.). This also assumes you have some internet access. If not, you'll need to separately install templateflow into the desired location.
#!/bin/bash
#SBATCH --time=12:00:00
#SBATCH --job-name=sub-1001_fMRIPrep
#SBATCH --output=sub-1001_fMRIPrep_%j.log
#SBATCH --mem=32GB
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=16
#SBATCH --account=jjtanner
#SBATCH --qos=jjtanner-b
#SBATCH --mail-type=END,FAIL
#SBATCH [email protected]
pwd; hostname; date
# Define the path to the BIDS-formatted dataset
bids=/blue/jjtanner/shared/proact/dcm2bids
# Define the output directory for fMRIPrep's preprocessed data
out=/blue/jjtanner/shared/{study}/dcm2bids/derivatives/fmriprep
# Define a temporary working directory for intermediate files during processing
tmp=/blue/jjtanner/shared/{study}/dcm2bids/derivatives/tmp
# Specify the path to the FreeSurfer license file
FS_LICENSE=/apps/freesurfer/license/license.txt
# Set the TEMPLATEFLOW_HOME environment variable inside the Apptainer container
# This tells fMRIPrep where to find TemplateFlow templates within the container
export APPTAINERENV_TEMPLATEFLOW_HOME=/opt/templateflow
# Set the FS_LICENSE environment variable inside the Apptainer container
# This points to the FreeSurfer license file within the container
export APPTAINERENV_FS_LICENSE=$HOME/.freesurfer.txt
# Execute the Apptainer (formerly Singularity) container with a clean environment
apptainer run --cleanenv \
# Bind the BIDS dataset directory from the host to /in inside the container
--bind ${bids}:/in \
# Bind the output directory from the host to /out inside the container
--bind ${out}:/out \
# Bind the temporary working directory from the host to /tmp inside the container
--bind ${tmp}:/tmp \
# Bind the FreeSurfer license file from the host to its designated path inside the container
--bind ${FS_LICENSE}:${APPTAINERENV_FS_LICENSE} \
# Bind the TemplateFlow directory from the host to /opt/templateflow inside the container
--bind /blue/jjtanner/jjtanner/neurotools/templateflow:/opt/templateflow \
# Specify the path to the fMRIPrep Apptainer image
/blue/jjtanner/shared/containers/fmriprep-25.0.0.sif \
# Define the input directory for fMRIPrep (mounted as /in inside the container)
/in \
# Define the output directory for fMRIPrep's results (mounted as /out inside the container)
/out \
# Specify the analysis level; in this case, process individual subjects
participant \
# Target a specific participant by their label (e.g., sub-1001)
--participant-label sub-1001 \
# Allocate 16 CPU threads for parallel processing to enhance performance
--nthreads 16 \
# Set the working directory within the container to /tmp for intermediate files
-w /tmp \
# Allocate 16 threads for OpenMP parallel sections to optimize computational tasks
--omp-nthreads 16
date