Running MRIQC with apptainer on Alliance Canada Cluster

Summary of what happened:

Hello!
I am trying to run mriqc on eventually a series of participants, but for now just one. I think I am having issues with binding my directories so that the container runs properly on the cluster. Has anybody done that? It should be pretty simple I think, somehow I havent got my way around it yet! I am assuming its a binding issue since the directory i have as input_dir is indeed valid, but it does not recognize when I run the slurm job.

Thanks in advance!

Command used (and if a helper script was used, a link to the helper script or the command generated):

#!/bin/bash
#SBATCH --job-name=test_MRIQC
#SBATCH --output=test_MRIQC_%a.out
#SBATCH --error=test_MRIQC_%a.err
#SBATCH --array=1
#SBATCH --time=6:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=16
#SBATCH --mem=64G
#SBATCH --mail-user=
#SBATCH --mail-type=BEGIN,FAIL,END

echo "Loading the necessary module..."
module load apptainer/1.3.5


if [ "$SLURM_ARRAY_TASK_ID" -ge 0 ] && [ "$SLURM_ARRAY_TASK_ID" -le 9 ]; then
  name="RGC90${SLURM_ARRAY_TASK_ID}"
else
  name="RGC9${SLURM_ARRAY_TASK_ID}"
fi

# Define paths
input_dir=${HOME}/projects/def-amichaud/share/GutBrain/data
output_dir=${HOME}/projects/def-amichaud/share/GutBrain/data/derivatives/mriqc
SCRATCH_DIR=${SCRATCH}/GutBrain/mriqc
CONTAINER_IMAGE=${HOME}/myimages/mriqc-24.0.2.sif

# export APPTAINER_BIND=${input_dir},${output_dir},${SCRATCH_DIR}

# Print the PID of the script
echo "Script PID: $$"

# Run MRIQC
apptainer run -C -B /${HOME}/projects/def-amichaud/share/GutBrain/data -W ${SCRATCH_DIR} \
     $CONTAINER_IMAGE \
     ${input_dir} ${output_dir} participant \
    --participant-label $name \
    --n_procs 16 \
    --mem_gb 60 \
    --work-dir $SCRATCH_DIR


echo "MRIQC processing complete."

Version:

mriqc-24.0.2

Environment (Docker, Singularity / Apptainer, custom installation):

apptainer/1.3.5 on Beluga (Alliance Canada HPC)

Data formatted according to a validatable standard? Please provide the output of the validator:

PASTE VALIDATOR OUTPUT HERE

I have not run the validator yet, but I successfully ran fmriprep on one subject, it so I am assuming its fine. fmriprep was easier since its already installed on the cluster.

Relevant log outputs (up to 20 lines):

usage: mriqc [-h] [--version] [-v] [--species {human,rat}]
             [--participant-label PARTICIPANT_LABEL [PARTICIPANT_LABEL ...]]
             [--bids-filter-file PATH] [--session-id [SESSION_ID ...]]
             [--run-id [RUN_ID ...]] [--task-id [TASK_ID ...]]
             [-m [{T1w,T2w,bold,dwi} ...]] [--dsname DSNAME]
             [--bids-database-dir PATH] [--bids-database-wipe]
             [--no-datalad-get] [--nprocs NPROCS]
             [--omp-nthreads OMP_NTHREADS] [--mem MEMORY_GB] [--testing] [-f]
             [--pdb] [-w WORK_DIR] [--verbose-reports] [--reports-only]
             [--write-graph] [--dry-run] [--resource-monitor]
             [--use-plugin USE_PLUGIN] [--crashfile-format {txt,pklz}]
             [--no-sub] [--email EMAIL] [--webapi-url WEBAPI_URL]
             [--webapi-port WEBAPI_PORT] [--upload-strict] [--notrack]
             [--ants-float] [--ants-settings ANTS_SETTINGS]
             [--min-dwi-length MIN_LEN_DWI] [--min-bold-length MIN_LEN_BOLD]
             [--fft-spikes-detector] [--fd_thres FD_THRES] [--deoblique]
             [--despike] [--start-idx START_IDX] [--stop-idx STOP_IDX]
             bids_dir output_dir {participant,group} [{participant,group} ...]
mriqc: error: Path does not exist: </home/pagag24/projects/def-amichaud/share/GutBrain/data>.
Loading the necessary module...
Script PID: 2453615
MRIQC processing complete.

Screenshots / relevant information:

Hi @pganon32 and welcome to neurostars!

As you can see from the documentation of apptainer run (apptainer run — Apptainer User Guide main documentation)

-c, --contain use minimal /dev and empty other directories (e.g. /tmp and $HOME) instead of sharing filesystems from your host
-C, --containall contain not only file systems, but also PID, IPC, and environment

using that flag will cause your $HOME dir to not exist in the container. You can try mounting your input dir to named directory in the container and passing that as MRIQC arguments, or try -e instead of -C to still have a clean environment, but successfully mount your home directory.

Also your scratch dir isn’t mounted in the container.

Best,
Steven

Ok thank you I will try that!

Patrick