Error running MRIQC with Singularity image on cluster

Hi all,

I’m trying to run MRIQC (v.0.14.2) on a cluster using a Singularity image. Here’s the command I sent MRIQC:

MRIQC=/home/groups/russpold/singularity_images/poldracklab_mriqc_0.14.2-2018-08-21-070e53b20a43.img
PROJECT_DIR=/scratch/groups/hyo/OPUS
BIDS_DIR=$PROJECT_DIR/BIDS_data
OUT_DIR=$BIDS_DIR/derivatives/mriqc
WORK_DIR=$PROJECT_DIR/work/mriqc
singularity run $MRIQC $BIDS_DIR $OUT_DIR participant \
    --participant-label sub-03 \
    -m T1w bold \
    -w $WORK_DIR -vvv

But I received this error:

2018-11-03 00:13:41,245 mriqc:IMPORTANT 
    Running MRIQC version 0.14.2:
      * BIDS dataset path: /scratch/groups/hyo/OPUS/BIDS_data.
      * Output folder: /scratch/groups/hyo/OPUS/BIDS_data/derivatives/mriqc.
      * Analysis levels: participant.
    
2018-11-03 00:13:41,246 mriqc:INFO Participant level started. Checking BIDS dataset...
2018-11-03 00:13:45,104 mriqc:CRITICAL MRIQC did not find any target image file under the given BIDS folder (/scratch/groups/hyo/OPUS/BIDS_data). Please ensure that the dataset is BIDS valid at http://incf.github.io/bids-validator/ .
2018-11-03 00:13:45,106 mriqc:WARNING The following BIDS entities were selected as filters: --participant-label sub-03, --modalities T1w bold. Please, check whether their combinations are possible.

I’m not sure that the issue is my data structure. I ran a relatively recent version of the BIDS validator (2018/5/19) on my dataset, and it spotted no problems, and I’ve managed to run fmriprep on these data with no issues. Based on previous threads, I tried binding /scratch (and other variations) using the -B flag, but I got the same error:

singularity -B /scratch/groups/hyo:/scratch/groups/hyo run $MRIQC $BIDS_DIR $OUT_DIR participant \
    --participant-label sub-03 \
    -m T1w bold \
    -w $WORK_DIR -vvv

2018-11-03 00:19:46,386 mriqc:IMPORTANT 
    Running MRIQC version 0.14.2:
      * BIDS dataset path: /scratch/groups/hyo/OPUS/BIDS_data.
      * Output folder: /scratch/groups/hyo/OPUS/BIDS_data/derivatives/mriqc.
      * Analysis levels: participant.
    
2018-11-03 00:19:46,386 mriqc:INFO Participant level started. Checking BIDS dataset...
2018-11-03 00:19:49,990 mriqc:CRITICAL MRIQC did not find any target image file under the given BIDS folder (/scratch/groups/hyo/OPUS/BIDS_data). Please ensure that the dataset is BIDS valid at http://incf.github.io/bids-validator/ .
2018-11-03 00:19:49,992 mriqc:WARNING The following BIDS entities were selected as filters: --participant-label sub-03, --modalities T1w bold. Please, check whether their combinations are possible.

Any advice? Thanks in advance!

I would run singularity shell and find out whether the data directory is visible from within the container (i.e. /scratch/groups/hyo/OPUS/BIDS_data has all sub-* under).

Thanks for the tip! I just tried this, and I can see all subject directories and image files from within the container. I still get the error, though. What would you suggest I try next?

Then, from within the container (i.e. using singularity exec) I would run mriqc:

ls /scratch/groups/hyo/OPUS/BIDS_data/sub-03/{anat,func}
mriqc /scratch/groups/hyo/OPUS/BIDS_data /scratch/groups/hyo/OPUS/BIDS_data/derivatives/mriqc --participant-label sub-03 -w /scratch/groups/hyo/OPUS/work/mriqc -vvv

Running ls within the container works:

singularity exec mriqc_0.14.2.img ls /scratch/groups/hyo/OPUS/BIDS_data/sub-03/anat
sub-03_T1w.nii.gz
singularity exec mriqc_0.14.2.img ls /scratch/groups/hyo/OPUS/BIDS_data/sub-03/func
sub-03_task-self_run-01_bold.json    sub-03_task-test_run-02_bold.json
sub-03_task-self_run-01_bold.nii.gz  sub-03_task-test_run-02_bold.nii.gz
sub-03_task-self_run-02_bold.json    sub-03_task-train_run-01_bold.json
sub-03_task-self_run-02_bold.nii.gz  sub-03_task-train_run-01_bold.nii.gz
sub-03_task-test_run-01_bold.json    sub-03_task-train_run-02_bold.json
sub-03_task-test_run-01_bold.nii.gz  sub-03_task-train_run-02_bold.nii.gz

But running mriqc doesn’t:

singularity exec mriqc_0.14.2.img mriqc /scratch/groups/hyo/OPUS/BIDS_data /scratch/groups/hyo/OPUS/BIDS_data/derivatives/mriqc participant --participant-label sub-03 -w /scratch/groups/hyo/OPUS/work/mriqc -vvv
2018-11-05 16:55:24,909 mriqc:IMPORTANT 
    Running MRIQC version 0.14.2:
      * BIDS dataset path: /scratch/groups/hyo/OPUS/BIDS_data.
      * Output folder: /scratch/groups/hyo/OPUS/BIDS_data/derivatives/mriqc.
      * Analysis levels: participant.
    
2018-11-05 16:55:24,910 mriqc:INFO Participant level started. Checking BIDS dataset...
2018-11-05 16:55:30,046 mriqc:CRITICAL MRIQC did not find any target image file under the given BIDS folder (/scratch/groups/hyo/OPUS/BIDS_data). Please ensure that the dataset is BIDS valid at http://incf.github.io/bids-validator/ .
2018-11-05 16:55:30,048 mriqc:WARNING The following BIDS entities were selected as filters: --participant-label sub-03, --modalities T1w bold T2w. Please, check whether their combinations are possible.

Okay, sorry, can you give it a try without sub-?:

singularity -B /scratch/groups/hyo:/scratch/groups/hyo run \
    /home/groups/russpold/singularity_images/poldracklab_mriqc_0.14.2-2018-08-21-070e53b20a43.img \
    /scratch/groups/hyo/OPUS/BIDS_data \
    /scratch/groups/hyo/OPUS/BIDS_data/derivatives/mriqc \
    --participant-label 03 -w /scratch/groups/hyo/OPUS/work/mriqc -vvv
1 Like

That fixed it, thank you!

1 Like

Hi Oesteban,
I’m following along trying to resolve my error with mriqc using singularity and in my singularity ls does not show the subjects. What is the fix in this case? (I thought I manually bound my directory but it seems not to have worked?).

If you need me to provide further information/ error messages I’d be more than happy to add it. Any advice would be greatly appreciated (I’ve been stuck on this a long time).

(Just in case you are able to help I thought I’d pre-emptively share my command here. I’ve tried various iterations (e.g. most of my attempts have not used 2 -B arguments) but thought I’d share my most complete attempt here.
#!/bin/bash/
bids_root_dir= /home/kgeier/projects/rrg-brad/shared/users/rolsen/face_rep
subj=1002
nthreads=2
mem=10 #gb

export SINGULARITYENV_TEMPLATEFLOW_HOME=/home/kgeier/templateflow
unset PYTHONPATH
singularity run -B ${TEMPLATEFLOW_HOME:-$HOME/.cache/templateflow}:/home/kgeier/
templateflow -B HOME:/home/kgeier/ --cleanenv /home/kgeier/mriqc-0.15.1.simg /home/kgeier/projects/rrg -brad/shared/users/rolsen/face_rep /home/kgeier/projects/rrg-brad/shared/users/r olsen/face_rep/derivatives/mriqc/sub-{subj} participant --participant_label ${s
ubj} --n_proc $nthreads --hmc-fsl --correct-slice-timing --mem_gb $mem --float32
–ants-nthreads $nthreads -w bids_root_dir/derivatives/mriqc/sub-{subj}

Here’s an excerpt of the error I get :
Running MRIQC version 0.15.1:
* BIDS dataset path: /project/6019291/shared/users/rolsen/face_rep.
* Output folder: /project/6019291/shared/users/rolsen/face_rep/derivatives/mriqc/sub-1002.
* Analysis levels: participant.

Process Process-2:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.7/pathlib.py”, line 1241, in mkdir
self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: ‘/project/6019291/shared/users/rolsen/face_rep/derivatives/mriqc/sub-1002/logs’

OSError: [Errno 30] Read-only file system: ‘/project’

I think I’ve resolved the issue!
I’ll post what I got working below in case it helps others. It was an issue with proper binding as I suspected but my attempts to fix it weren’t correct :confused:

singularity run --cleanenv -B /home -B /scratch -B /project -B /project/6019291/shared/users/rolsen/face_rep/derivatives -B HOME:/home/kgeier /home/kgeier/mriqc-0.15.1.simg /home/kgeier/projects/rrg-brad/shared/users/rolsen/face_rep /home/kgeier/projects/rrg-brad/shared/users/rolsen/face_rep/derivatives/mriqc/sub-{subj} participant --participant_label ${subj} --n_proc $nthreads --hmc-fsl --correct-slice-timing --mem_gb $mem --float32 --ants-nthreads nthreads -w /home/kgeier/project/6019291/shared/users/rolsen/face_rep/derivatives/mriqc/sub-{subj}
(variable defined previously in script)