fMRIprep-docker incorrectly setting BIDS dataset dir?

Summary of what happened:

Running fMRIprep-docker on a test data set found in Downloads/fmriprep_data. Seems to be setting the data path to “/data/” rather than the actual path I have input?

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

fmriprep-docker "$HOME/Downloads/fmriprep_data/" 
"$HOME/Downloads/fmriprep_data/derivatives" 
--fs-license-file "$HOME/license.txt" participant 
--participant-label 01  --skip_bids_validation 

Version:

24.1.1

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

Docker

Relevant log outputs (up to 20 lines):

I notice that the BIDS dataset path is being set to /data instead of the specified path?

2025-03-04 12:23:51,462 [IMPORTANT] Building fMRIPrep's workflow:
           * BIDS dataset path: /data.
           * Participant list: ['01'].
           * Run identifier: 20250304-122337_aa5b0350-2699-488e-a84a-69d0908027a0.
           * Output spaces: MNI152NLin2009cAsym:res-native.
           * Pre-run FreeSurfer's SUBJECTS_DIR: /out/sourcedata/freesurfer.

Further down, showing the path doesnt exist:

  File "/opt/conda/envs/fmriprep/lib/python3.11/site-packages/fmriprep/utils/misc.py", line 57, in estimate_bold_mem_usage
    img = nb.load(bold_fname)
          ^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/fmriprep/lib/python3.11/site-packages/nibabel/loadsave.py", line 102, in load
    raise FileNotFoundError(f"No such file or no access: '{filename}'")
FileNotFoundError: No such file or no access: '/data/sub-01/func/sub-01_task-flanker_run-1_bold.nii.gz'

Screenshots / relevant information:


Hi @pmxtl3 and welcome to neurostars!

Fmriprep-docker is a wrapper around docker run that includes mounting your input directory to /data.

Best,
Steven

Hi @Steven, thank you for the swift response.

I apologise but I am not following, I’ve never used a container like Docker before so I am struggling with understanding!

If you paste the RUNNING section in here, people can answer your questions in more detail. The short story is that there will be something like:

-v $HOME/Downloads/fmriprep_data/:/data:ro

That maps the location from your host system into the /data location inside the container. When a program is run in the container, it will see the contents of $HOME/Downloads/fmriprep_data at /data. (The :ro indicates read-only.)

In principle, we could map -v $HOME/Downloads/fmriprep_data:$HOME/Downloads/fmriprep_data:ro, however if somehow the data directory being mapped overlaid something important in the container, there could be surprising and difficult-to-diagnose failures. It’s simpler to just use a known path inside the container.

Anyway, once you see the RUNNING: command, you can edit it however you like and run docker directly.

Apologies, I didn’t notice this section when looking at the error!

RUNNING: docker run --rm -e DOCKER_VERSION_8395080871=27.5.1 -it 
-v /Users/pmxtl3/license.txt:/opt/freesurfer/license.txt:ro 
-v /Users/pmxtl3/Downloads/fmriprep_data:/data:ro 
-v /Users/pmxtl3/Downloads/fmriprep_data/derivatives:/out 
-v /Users/pmxtl3:/scratch nipreps/fmriprep:24.1.1 
/data /out participant --participant-label 01 --skip-bids-validation 
--md-only-boilerplate --fs-no-reconall --nthreads 12 
--stop-on-first-crash --mem_mb 11000 -w /scratch 
--output-spaces MNI152NLin2009cAsym:res-2

I see the part you are talking about. Although I still don’t really understand why this isn’t working?

The error is fairly plain: The process inside the docker container cannot open the file. It could be a permissions error or a broken symlink. What happens when you run the following?

ls -l /Users/pmxtl3/Downloads/fmriprep_data/sub-01/func/
file /Users/pmxtl3/Downloads/fmriprep_data/sub-01/func/sub-01_task-flanker_run-1_bold.nii.gz

I would also try opening the file with some tool on your host system, such as mricron. If that all works, then there’s some issue that will only be apparent inside the container. To diagnose that, add --shell to your fmriprep-docker command to open a shell that will see the system the same way the fMRIPrep process does, and run the same checks:

ls -l /data/sub-01/func/
file /data/sub-01/func/sub-01_task-flanker_run-1_bold.nii.gz

I have only just started using bash/docker etc. which is why I am struggling to interpret these errors, so I appreciate your help.

It seems that it might be a broken symlink as you suggested:

pmxtl3@MACBOOK-C02FX062MD6P ~ % ls -l /Users/pmxtl3/Downloads/fmriprep_data/sub-01/func/
total 16
lrwxr-xr-x  1 pmxtl3  staff   142  3 Mar 09:51 sub-01_task-flanker_run-1_bold.nii.gz -> ../../.git/annex/objects/5m/w9/MD5E-s28061534--8e8c44ff53f9b5d46f2caae5916fa4ef.nii.gz/MD5E-s28061534--8e8c44ff53f9b5d46f2caae5916fa4ef.nii.gz
-rw-r--r--  1 pmxtl3  staff  1653  3 Mar 09:51 sub-01_task-flanker_run-1_events.tsv
lrwxr-xr-x  1 pmxtl3  staff   142  3 Mar 09:51 sub-01_task-flanker_run-2_bold.nii.gz -> ../../.git/annex/objects/2F/58/MD5E-s28143286--f0bcf782c3688e2cf7149b4665949484.nii.gz/MD5E-s28143286--f0bcf782c3688e2cf7149b4665949484.nii.gz
-rw-r--r--  1 pmxtl3  staff  1655  3 Mar 09:51 sub-01_task-flanker_run-2_events.tsv
(base) pmxtl3@MACBOOK-C02FX062MD6P ~ % file /Users/pmxtl3/Downloads/fmriprep_data/sub-01/func/sub-01_task-flanker_run-1_bold.nii.gz
/Users/pmxtl3/Downloads/fmriprep_data/sub-01/func/sub-01_task-flanker_run-1_bold.nii.gz: broken symbolic link to ../../.git/annex/objects/5m/w9/MD5E-s28061534--8e8c44ff53f9b5d46f2caae5916fa4ef.nii.gz/MD5E-s28061534--8e8c44ff53f9b5d46f2caae5916fa4ef.nii.gz

Okay, it looks like you have a DataLad dataset, but have not fetched the dataset contents yet. I don’t know if you’re using OpenNeuro data, but OpenNeuro Quickstart Guide: Accessing OpenNeuro datasets via DataLad — The DataLad Handbook has a good introduction that applies to most neuroimaging datasets you might retrieve with DataLad.

Thank you, I will give this a read!