BIDS root does not exist fMRIprep Singularity

Hi there,

been using fMRIprep on local clusters w/out problems and am now expanding to an HPC system on campus.
BIDS structure for a single subject has been created w/ heudiconv and validated.

I am trying to run the following command on the anats of a single subject:

singularity run --cleanenv -B /crash-work/fhopp/bids_nii/:/data /usr/local/fmriprep-1.5.0.simg\
    /data /data/derivatives/fmriprep\
    participant\
    --participant-label 01 -w /crash-work/fhopp/ --nthreads 16 --omp-nthreads 16 --mem_mb 10000 --anat-only --notrack --fs-no-reconall --fs-license-file /crash-work/fhopp/.fs_license.txt

Curioulsy, it appears that fMRIprep runs and can read the /data, as I get the following output:

This dataset appears to be BIDS compatible.

        Summary:                Available Tasks:                           Available Modalities: 
        98 Files, 3.03GB        TODO: full task name for exp               T1w                   
        1 - Subject             physiobase                                 T2w                   
        1 - Session             practise                                   dwi                   
                                TODO: full task name for physiobase        bold                  
                                TODO: full task name for practise          events                
                                exp                                        fieldmap              


	If you have any questions, please post on https://neurostars.org/tags/bids.

Making sure the input data is BIDS compliant (warnings can be ignored in most cases).
191107-18:10:11,472 nipype.workflow IMPORTANT:
	 
    Running fMRIPREP version 1.5.0:
      * BIDS dataset path: /data.
      * Participant list: ['01'].
      * Run identifier: 20191107-181009_5e7b185d-ec35-4ce8-92d9-6c810ba165c4.
    
191107-18:10:20,531 nipype.workflow IMPORTANT:
	 Works derived from this fMRIPrep execution should include the following boilerplate:


Results included in this manuscript come from preprocessing
performed using *fMRIPrep* 1.5.0
(@fmriprep1; @fmriprep2; RRID:SCR_016216),
which is based on *Nipype* 1.2.2
(@nipype1; @nipype2; RRID:SCR_002502).

However, I then get the following errors:

Captured warning (<class 'UserWarning'>): [Errno 2] No such file or directory.  joblib will operate in serial mode
/usr/local/miniconda/lib/python3.7/site-packages/sklearn/externals/joblib/_multiprocessing_helpers.py:28: UserWarning: [Errno 2] No such file or directory.  joblib will operate in serial mode
  warnings.warn('%s.  joblib will operate in serial mode' % (e,))
/usr/local/miniconda/lib/python3.7/site-packages/sklearn/externals/joblib/_multiprocessing_helpers.py:28: UserWarning: [Errno 2] No such file or directory.  joblib will operate in serial mode
  warnings.warn('%s.  joblib will operate in serial mode' % (e,))
fMRIPrep failed: [Errno 2] No such file or directory
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 136, in __init__
    mp_context = mp.context.get_context(
AttributeError: module 'multiprocessing.context' has no attribute 'get_context'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 407, in main
    fmriprep_wf.run(**plugin_settings)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/workflows.py", line 583, in run
    runner = plugin_mod(plugin_args=plugin_args)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 144, in __init__
    self.pool = ProcessPoolExecutor(max_workers=self.processors)
  File "/usr/local/miniconda/lib/python3.7/concurrent/futures/process.py", line 542, in __init__
    pending_work_items=self._pending_work_items)
  File "/usr/local/miniconda/lib/python3.7/concurrent/futures/process.py", line 158, in __init__
    super().__init__(max_size, ctx=ctx)
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/queues.py", line 42, in __init__
    self._rlock = ctx.Lock()
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/context.py", line 67, in Lock
    return Lock(ctx=self.get_context())
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/synchronize.py", line 162, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/synchronize.py", line 59, in __init__
    unlink_now)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/miniconda/bin/fmriprep", line 10, in <module>
    sys.exit(main())
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 483, in main
    subject_list, output_dir, work_dir, run_uuid, packagename='fmriprep')
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 431, in generate_reports
    for subject_label in subject_list
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 431, in <listcomp>
    for subject_label in subject_list
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 418, in run_reports
    subject_id=subject_label, packagename=packagename)
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 267, in __init__
    self._load_config(Path(config))
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 285, in _load_config
    self.index(settings['sections'])
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 294, in index
    self.layout = BIDSLayout(self.root, config='figures', validate=False)
  File "/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/layout.py", line 185, in __init__
    self._validate_root()
  File "/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/layout.py", line 318, in _validate_root
    raise ValueError("BIDS root does not exist: %s" % self.root)
ValueError: BIDS root does not exist: /crash-work/fhopp/reportlets/fmriprep/sub-01

I am not sure of the root cause of this problem (I am very new to singularity), but wonder whether it is a problem of binding to singularity (-B) or something else? Why does it tell me that BIDS root does not exist when it can read its content earlier? I must add that the IT person for HPC created the image, so – as of now – I cannot provide information on how the singularity image was created but if this is relevant info I will reach out.

Thanks in advance!!

hi and welcome @fhopp - this is probably the case because of an issue in bindings with your command - you are referencing /crash-work/fhopp when it doesn’t exist in the container. Could you try again with the following command?

singularity run --cleanenv -B /crash-work/fhopp/:/data /usr/local/fmriprep-1.5.0.simg \
/data/bids_nii /data/bids_nii/derivatives/fmriprep participant \
--participant-label 01 -w /data --nthreads 16 --omp-nthreads 16 --mem_mb 10000 --anat-only --notrack --fs-no-reconall --fs-license-file /data/.fs_license.txt

Thanks for the fast response. Unfortunately, this triggers the same error.
Command:

singularity run --cleanenv -B /crash-work/fhopp/:/data /usr/local/fmriprep-1.5.0.simg\
    /data/bids_nii /data/bids_nii/derivatives/fmriprep participant\
    --participant-label 01 -w /data --nthreads 16 --omp-nthreads 16 --mem_mb 10000 --anat-only --notrack --fs-no-reconall --fs-license-file /data/.fs_license.txt

Output:

This dataset appears to be BIDS compatible.

        Summary:                Available Tasks:                           Available Modalities: 
        98 Files, 3.03GB        TODO: full task name for exp               T1w                   
        1 - Subject             physiobase                                 T2w                   
        1 - Session             practise                                   dwi                   
                                TODO: full task name for physiobase        bold                  
                                TODO: full task name for practise          events                
                                exp                                        fieldmap              


	If you have any questions, please post on https://neurostars.org/tags/bids.

Making sure the input data is BIDS compliant (warnings can be ignored in most cases).
191108-08:52:32,464 nipype.workflow IMPORTANT:
	 
    Running fMRIPREP version 1.5.0:
      * BIDS dataset path: /data/bids_nii.
      * Participant list: ['01'].
      * Run identifier: 20191108-085230_dc45f0d4-ef27-4971-93bd-5835a1faef37.
    
191108-08:52:42,644 nipype.workflow IMPORTANT:
	 Works derived from this fMRIPrep execution should include the following boilerplate:


Results included in this manuscript come from preprocessing
performed using *fMRIPrep* 1.5.0
(@fmriprep1; @fmriprep2; RRID:SCR_016216),
which is based on *Nipype* 1.2.2
(@nipype1; @nipype2; RRID:SCR_002502).

Anatomical data preprocessing

: The T1-weighted (T1w) image was corrected for intensity non-uniformity (INU)
with `N4BiasFieldCorrection` [@n4], distributed with ANTs 2.2.0 [@ants, RRID:SCR_004757], and used as T1w-reference throughout the workflow.
The T1w-reference was then skull-stripped with a *Nipype* implementation of
the `antsBrainExtraction.sh` workflow (from ANTs), using OASIS30ANTs
as target template.
Brain tissue segmentation of cerebrospinal fluid (CSF),
white-matter (WM) and gray-matter (GM) was performed on
the brain-extracted T1w using `fast` [FSL 5.0.9, RRID:SCR_002823,
@fsl_fast].
Volume-based spatial normalization to one standard space (MNI152NLin2009cAsym) was performed through
nonlinear registration with `antsRegistration` (ANTs 2.2.0),
using brain-extracted versions of both T1w reference and the T1w template.
The following template was selected for spatial normalization:
*ICBM 152 Nonlinear Asymmetrical template version 2009c* [@mni152nlin2009casym, RRID:SCR_008796; TemplateFlow ID: MNI152NLin2009cAsym].

Many internal operations of *fMRIPrep* use
*Nilearn* 0.5.2 [@nilearn, RRID:SCR_001362],
mostly within the functional processing workflow.
For more details of the pipeline, see [the section corresponding
to workflows in *fMRIPrep*'s documentation](https://fmriprep.readthedocs.io/en/latest/workflows.html "FMRIPrep's documentation").


### Copyright Waiver

The above boilerplate text was automatically generated by fMRIPrep
with the express intention that users should copy and paste this
text into their manuscripts *unchanged*.
It is released under the [CC0](https://creativecommons.org/publicdomain/zero/1.0/) license.

### References


Captured warning (<class 'UserWarning'>): [Errno 2] No such file or directory.  joblib will operate in serial mode
/usr/local/miniconda/lib/python3.7/site-packages/sklearn/externals/joblib/_multiprocessing_helpers.py:28: UserWarning: [Errno 2] No such file or directory.  joblib will operate in serial mode
  warnings.warn('%s.  joblib will operate in serial mode' % (e,))
/usr/local/miniconda/lib/python3.7/site-packages/sklearn/externals/joblib/_multiprocessing_helpers.py:28: UserWarning: [Errno 2] No such file or directory.  joblib will operate in serial mode
  warnings.warn('%s.  joblib will operate in serial mode' % (e,))
fMRIPrep failed: [Errno 2] No such file or directory
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 136, in __init__
    mp_context = mp.context.get_context(
AttributeError: module 'multiprocessing.context' has no attribute 'get_context'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 407, in main
    fmriprep_wf.run(**plugin_settings)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/workflows.py", line 583, in run
    runner = plugin_mod(plugin_args=plugin_args)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 144, in __init__
    self.pool = ProcessPoolExecutor(max_workers=self.processors)
  File "/usr/local/miniconda/lib/python3.7/concurrent/futures/process.py", line 542, in __init__
    pending_work_items=self._pending_work_items)
  File "/usr/local/miniconda/lib/python3.7/concurrent/futures/process.py", line 158, in __init__
    super().__init__(max_size, ctx=ctx)
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/queues.py", line 42, in __init__
    self._rlock = ctx.Lock()
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/context.py", line 67, in Lock
    return Lock(ctx=self.get_context())
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/synchronize.py", line 162, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/synchronize.py", line 59, in __init__
    unlink_now)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/miniconda/bin/fmriprep", line 10, in <module>
    sys.exit(main())
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 483, in main
    subject_list, output_dir, work_dir, run_uuid, packagename='fmriprep')
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 431, in generate_reports
    for subject_label in subject_list
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 431, in <listcomp>
    for subject_label in subject_list
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 418, in run_reports
    subject_id=subject_label, packagename=packagename)
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 267, in __init__
    self._load_config(Path(config))
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 285, in _load_config
    self.index(settings['sections'])
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/reports/core.py", line 294, in index
    self.layout = BIDSLayout(self.root, config='figures', validate=False)
  File "/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/layout.py", line 185, in __init__
    self._validate_root()
  File "/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/layout.py", line 318, in _validate_root
    raise ValueError("BIDS root does not exist: %s" % self.root)
ValueError: BIDS root does not exist: /data/reportlets/fmriprep/sub-01

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
<ipython-input-51-36a64582371f> in <module>
----> 1 get_ipython().run_cell_magic('bash', '', '\nsingularity run --cleanenv -B /crash-work/fhopp/:/data /usr/local/fmriprep-1.5.0.simg\\\n    /data/bids_nii /data/bids_nii/derivatives/fmriprep participant\\\n    --participant-label 01 -w /data --nthreads 16 --omp-nthreads 16 --mem_mb 10000 --anat-only --notrack --fs-no-reconall --fs-license-file /data/.fs_license.txt\n')

/crash-work/fhopp/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2357             with self.builtin_trap:
   2358                 args = (magic_arg_s, cell)
-> 2359                 result = fn(*args, **kwargs)
   2360             return result
   2361 

/crash-work/fhopp/anaconda3/lib/python3.7/site-packages/IPython/core/magics/script.py in named_script_magic(line, cell)
    140             else:
    141                 line = script
--> 142             return self.shebang(line, cell)
    143 
    144         # write a basic docstring:

</crash-work/fhopp/anaconda3/lib/python3.7/site-packages/decorator.py:decorator-gen-110> in shebang(self, line, cell)

/crash-work/fhopp/anaconda3/lib/python3.7/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

/crash-work/fhopp/anaconda3/lib/python3.7/site-packages/IPython/core/magics/script.py in shebang(self, line, cell)
    243             sys.stderr.flush()
    244         if args.raise_error and p.returncode!=0:
--> 245             raise CalledProcessError(p.returncode, cell, output=out, stderr=err)
    246 
    247     def _run_script(self, p, cell, to_close):

CalledProcessError: Command 'b'\nsingularity run --cleanenv -B /crash-work/fhopp/:/data /usr/local/fmriprep-1.5.0.simg\\\n    /data/bids_nii /data/bids_nii/derivatives/fmriprep participant\\\n    --participant-label 01 -w /data --nthreads 16 --omp-nthreads 16 --mem_mb 10000 --anat-only --notrack --fs-no-reconall --fs-license-file /data/.fs_license.txt\n'' returned non-zero exit status 1.

What version of singularity are you using? There may be a fix in an old fmriprep issue where the error log looks pretty familiar.

MANAGED BY INCF