#!/bin/bash #SBATCH -J fmriprep #SBATCH --time=10:00:00 #SBATCH -n 1 #SBATCH --account=ctb-villens #SBATCH --cpus-per-task=3 #SBATCH --mem-per-cpu=4G #SBATCH --mail-user=**** #SBATCH --mail-type=FAIL #SBATCH --mail-type=REQUEUE #SBATCH --mail-type=ALL # Load singularity module SINGULARITY_IMG="/project/ctb-villens/quarantine/Core/fmriprep/22.0.0/fmriprep-22.0.0.simg" module load VilleneuveLab module load singularity/3.8 # Allocate your input and output directories, and allocate local scratch as the working directory WORK_DIR=$(mktemp -d -p "${SLURM_TMPDIR}" work_dir-XXXX) || exit 1 echo "working directory is $work_dir"/project/ctb-villens/dataset/PreventAD_2019-2020/mri/bids/ # Define path for TSV file STUDY="/home/javan/scratch/multi_prep/test/script/me/version" # Designate the location of your templateflow templates export SINGULARITYENV_TEMPLATEFLOW_HOME=/project/ctb-villens/javan/templateflow TEMPLATEFLOW_HOME="/project/ctb-villens/javan/templateflow" export SINGULARITYENV_FS_LICENSE=/project/ctb-villens/quarantine/Core/freesurfer/6.0.0/license.txt FS_LICENSE="/project/ctb-villens/quarantine/Core/freesurfer/6.0.0/license.txt" #Parse the participants.tsv file and extract one subject ID from the line corresponding to this SLURM task # The $((${SLURM_ARRAY_TASK_ID} + 1)) section is responsible for scipping the first line of the participant tsv file SUBJECT=$( sed -n -E "$((${SLURM_ARRAY_TASK_ID} + 1))s/sub-(\S*)\>.*/\1/gp" ${STUDY}/participants_all_NAV2_id.tsv ) BOLDPATH=$( sed -n -E "$((${SLURM_ARRAY_TASK_ID} + 1))s/sub-(\S*)\>.*/\1/gp" ${STUDY}/participants_all_NAV2_ses.tsv ) # Build your command to tell singularity to run fmriprep, ensuring it binds to your template directory, your scratch folder SINGULARITY_CMD="singularity run --cleanenv \ -B ${TEMPLATEFLOW_HOME}:${SINGULARITYENV_TEMPLATEFLOW_HOME} \ -B ${FS_LICENSE}:${SINGULARITYENV_FS_LICENSE} \ -B /project/ctb-villens/dataset/PreventAD_2019-2020/mri/bids/sub-${SUBJECT}/ses-${BOLDPATH}/:/source_bids:ro \ -B /home/javan/scratch/multi_prep/test/derivatives_me:/out \ -B "${WORK_DIR}":/work \ ${SINGULARITY_IMG} \ /source_bids /out \ participant --participant-label ${SUBJECT} \ -w /work -vv --nthreads ${SLURM_CPUS_PER_TASK} \ --mem_mb $((${SLURM_MEM_PER_CPU}*${SLURM_CPUS_PER_TASK}-256)) \ --fs-license-file ${FS_LICENSE} \ --skip_bids_validation \ --output-spaces MNI152NLin2009cAsym:res-2 MNI152NLin2009cAsym anat \ --fs-no-reconall --notrack" # Setup done, run the command echo Running task ${SLURM_ARRAY_TASK_ID} echo Commandline: ${SINGULARITY_CMD} eval ${SINGULARITY_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