-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh: add a
sbatch.slurm
submission file for SLURM and update sing…
…ularity
- Loading branch information
Showing
2 changed files
with
76 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
# | ||
#SBATCH -J fmriprep | ||
#SBATCH --time=48:00:00 | ||
#SBATCH -n 1 | ||
#SBATCH --cpus-per-task=16 | ||
#SBATCH --mem-per-cpu=4G | ||
#SBATCH -p normal,mygroup # Queue names you can submit to | ||
# Outputs ---------------------------------- | ||
#SBATCH -o log/%x-%A-%a.out | ||
#SBATCH -e log/%x-%A-%a.err | ||
#SBATCH --mail-user=%u@domain.tld | ||
#SBATCH --mail-type=ALL | ||
# ------------------------------------------ | ||
|
||
BIDS_DIR="$STUDY/data" | ||
DERIVS_DIR="derivatives/fmriprep-1.5.0" | ||
|
||
# Prepare some writeable bind-mount points. | ||
TEMPLATEFLOW_HOST_HOME=$HOME/.cache/templateflow | ||
FMRIPREP_HOST_CACHE=$HOME/.cache/fmriprep | ||
mkdir -p ${TEMPLATEFLOW_HOST_HOME} | ||
mkdir -p ${FMRIPREP_HOST_CACHE} | ||
|
||
# Prepare derivatives folder | ||
mkdir -p ${BIDS_DIR}/${DERIVS_DIR} | ||
|
||
# This trick will help you reuse freesurfer results across pipelines and fMRIPrep versions | ||
mkdir -p ${BIDS_DIR}/derivatives/freesurfer-6.0.1 | ||
if [ ! -d ${BIDS_DIR}/${DERIVS_DIR}/freesurfer ]; then | ||
ln -s ${BIDS_DIR}/derivatives/freesurfer-6.0.1 ${BIDS_DIR}/${DERIVS_DIR}/freesurfer | ||
fi | ||
|
||
# Make sure FS_LICENSE is defined in the container. | ||
export SINGULARITYENV_FS_LICENSE=$HOME/.freesurfer.txt | ||
|
||
# Designate a templateflow bind-mount point | ||
export SINGULARITYENV_TEMPLATEFLOW_HOME="/templateflow" | ||
SINGULARITY_CMD="singularity run --cleanenv -B $BIDS_DIR:/data -B ${TEMPLATEFLOW_HOST_HOME}:${SINGULARITYENV_TEMPLATEFLOW_HOME} -B $L_SCRATCH:/work $STUDY/images/poldracklab_fmriprep_1.5.0.simg" | ||
|
||
# Parse the participants.tsv file and extract one subject ID from the line corresponding to this SLURM task. | ||
subject=$( sed -n -E "$((${SLURM_ARRAY_TASK_ID} + 1))s/sub-(\S*)\>.*/\1/gp" ${BIDS_DIR}/participants.tsv ) | ||
|
||
# Remove IsRunning files from FreeSurfer | ||
find ${BIDS_DIR}/derivatives/freesurfer-6.0.1/sub-$subject/ -name "*IsRunning*" -type f -delete | ||
|
||
# Compose the command line | ||
cmd="${SINGULARITY_CMD} /data /data/${DERIVS_DIR} participant --participant-label $subject -w /work/ -vv --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --output-spaces MNI152NLin2009cAsym:res-2 anat fsnative fsaverage5 --use-aroma" | ||
|
||
# Setup done, run the command | ||
echo Running task ${SLURM_ARRAY_TASK_ID} | ||
echo Commandline: $cmd | ||
eval $cmd | ||
exitcode=$? | ||
|
||
# Output results to a table | ||
echo "sub-$subject ${SLURM_ARRAY_TASK_ID} $exitcode" \ | ||
>> ${SLURM_JOB_NAME}.${SLURM_ARRAY_JOB_ID}.tsv | ||
echo Finished tasks ${SLURM_ARRAY_TASK_ID} with exit code $exitcode | ||
exit $exitcode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters