nipreps / sdcflows

Susceptibility Distortion Correction (SDC) workflows for EPI MR schemes
https://www.nipreps.org/sdcflows
Apache License 2.0
32 stars 26 forks source link

Fmriprep gets confused by a `fieldmap` string in the acq-label #264

Open marcelzwiers opened 2 years ago

marcelzwiers commented 2 years ago

What happened?

I have BIDS valid data that consist (amongst others) of a fieldmap file named fmap/sub-003_ses-mri01_acq-fieldmap2p0iso68slices_run-1_magnitude1.nii.gz. If I run fmriprep I get this error message:

Process Process-2:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/sdcflows/fieldmaps.py", line 340, in __attrs_post_init__
    FieldmapFile(
  File "<attrs generated init sdcflows.fieldmaps.FieldmapFile>", line 11, in __init__
    __attr_validator_path(self, __attr_path, self.path)
  File "/opt/conda/lib/python3.8/site-packages/sdcflows/fieldmaps.py", line 203, in check_path
    raise FileNotFoundError(
FileNotFoundError: File path </project/3015089.01/deep-brain_EPI/bids_GEmap_mb3me2/sub-003/ses-mri01/fmap/sub-003_ses-mri01_acq-magnitude2p0iso68slices_run-1_magnitude1.nii.gz> does not exist, is a broken link, or it is not a file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/opt/conda/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/cli/workflow.py", line 118, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/workflows/base.py", line 85, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/workflows/base.py", line 324, in init_single_subject_wf
    fmap_estimators = find_estimators(
  File "/opt/conda/lib/python3.8/site-packages/sdcflows/utils/wrangler.py", line 281, in find_estimators
    e = fm.FieldmapEstimation(
  File "<attrs generated init sdcflows.fieldmaps.FieldmapEstimation>", line 7, in __init__
    self.__attrs_post_init__()
  File "/opt/conda/lib/python3.8/site-packages/sdcflows/fieldmaps.py", line 348, in __attrs_post_init__
    raise ValueError(
ValueError: A fieldmap or phase-difference estimation type was found, but an anatomical reference (magnitude1 file) is missing.

However, the error disappears and everything runs normally if I simply change/remove the fieldmap substring in the fmap filename (i.e. change the acq label), e.g. to fmap/sub-003_ses-mri01_acq-2p0iso68slices_run-1_magnitude1.nii.gz.

What command did you use?

unset PYTHONPATH; export PYTHONNOUSERSITE=1; singularity run --cleanenv /opt/fmriprep/21.0.1/fmriprep-21.0.1.simg bids_GEmap_mb3me2 bids_GEmap_mb3me2/derivatives/fmriprep participant -w \$TMPDIR --participant-label 003 --fs-license-file /opt_host/fmriprep/license.txt --mem_mb 20000 --omp-nthreads 2 --nthreads 2

What version of fMRIPrep are you running?

21.0.1

How are you running fMRIPrep?

Singularity

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

No response

Additional information / screenshots

No response

effigies commented 2 years ago

Looks like the issue is here:

https://github.com/nipreps/sdcflows/blob/a86c6e09d0473ab2cdb139ae434137d1ca037a76/sdcflows/fieldmaps.py#L339-L346

We should use more BIDS-aware filename munging, rather than relying on simple string matching and replacing.