How to include fieldmap related distortion correction in qsiprep dwi preprocessing

Summary of what happened:

Hello! I am using fieldmap data for susceptibility distortion correction (SDC) in DWI preprocessing with QSIPrep. Although my input BIDS data includes a /fmap directory, the processing pipeline doesn’t seem to apply fieldmap-based SDC. Could there be an issue with my input data or the corresponding JSON files? Below is an example of what my input data looks like.
image

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

singularity run --cleanenv -e -B /XXX/for_test/qsiprep_out:/out -B /XXX/for_test/qsiprep_work:/work -B /XXX/for_test/BIDS:/data:ro -B /XX/freesurfer/freesurfer:/opt/freesurfer --env FS_LICENSE=/opt/freesurfer/license.txt /XX/qsiprep/qsiprep.sif /data /out participant --fs-license-file /opt/freesurfer/license.txt --work-dir /work --recon-spec mrtrix_multishell_msmt_noACT --output-resolution 2.0 --skip_bids_validation --nthreads 32 --skip-odf-report --skip-anat-based-spatial-normalization

PASTE CODE HERE

Version:

v0.21.5

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

singularity

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

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

PASTE LOG OUTPUT HERE

Screenshots / relevant information:


Hi @Shanbin_Zhang,

How are you associating the fmaps with the dwi image? The IntendedFor or B0FieldSource/Identifier method? (See it explained here: Fmriprep 23.2.0 didn't do sesceptibility distortion correction - #4 by Steven)

Best,
Steven

It’s seems that I forgot to add the “IntendedFor” key in “sub-941s6580y2_ses-baseline_fmap_phasediff.json”. Qsiprep could find the fieldmap files after I added it, but it ran into a new problem:

240926-10:19:10,272 nipype.workflow INFO:
         Running with omp_nthreads=8, nthreads=32
240926-10:19:10,272 nipype.workflow IMPORTANT:
         
    Running qsiprep version 0.21.5.dev0+g36b93fe.d20240504:
      * BIDS dataset path: /data.
      * Participant list: ['941s6580y2'].
      * Run identifier: 20240926-101909_13763836-a10e-4ffb-86b7-1d121429f304.
    
240926-10:19:10,567 nipype.workflow INFO:
         Combining all dwi files within each available session:
240926-10:19:10,567 nipype.workflow INFO:
                - 1 scans in session baseline
240926-10:19:10,584 nipype.workflow INFO:
         [{'dwi_series': ['/data/sub-941s6580y2/ses-baseline/dwi/sub-941s6580y2_ses-baseline_dwi.nii'], 'fieldmap_info': {'phasediff': '/data/sub-941s6580y2/ses-baseline/fmap/sub-941s6580y2_ses-baseline_fmap_phasediff.nii', 'magnitude1': '/data/sub-941s6580y2/ses-baseline/fmap/sub-941s6580y2_ses-baseline_fmap_magnitude1.nii', 'suffix': 'phasediff', 'magnitude2': '/data/sub-941s6580y2/ses-baseline/fmap/sub-941s6580y2_ses-baseline_fmap_magnitude2.nii'}, 'dwi_series_pedir': 'j', 'concatenated_bids_name': 'sub-941s6580y2_ses-baseline'}]
240926-10:19:10,597 nipype.workflow IMPORTANT:
         Creating dwi processing workflow "dwi_preproc_ses_baseline_wf" to produce output sub-941s6580y2_ses-baseline (1.26 GB / 137 DWIs). Memory resampled/largemem=2.03/2.36 GB.
240926-10:19:10,599 nipype.workflow INFO:
         Automatically using 5, 5, 5 window for dwidenoise
240926-10:19:10,692 nipype.workflow INFO:
         Using 8 threads in eddy
240926-10:19:10,707 nipype.workflow INFO:
         Computing fieldmap directly from phasediff
Process Process-2:
Traceback (most recent call last):
  File "/opt/conda/envs/qsiprep/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/conda/envs/qsiprep/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/cli/run.py", line 1091, in build_qsiprep_workflow
    retval["workflow"] = init_qsiprep_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/base.py", line 237, in init_qsiprep_wf
    single_subject_wf = init_single_subject_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/base.py", line 748, in init_single_subject_wf
    dwi_preproc_wf = init_dwi_preproc_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/dwi/base.py", line 406, in init_dwi_preproc_wf
    hmc_wf = init_fsl_hmc_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/dwi/fsl.py", line 422, in init_fsl_hmc_wf
    b0_sdc_wf = init_sdc_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/fieldmap/base.py", line 244, in init_sdc_wf
    sdc_unwarp_wf = init_sdc_unwarp_wf(
  File "/opt/conda/envs/qsiprep/lib/python3.10/site-packages/qsiprep/workflows/fieldmap/unwarp.py", line 180, in init_sdc_unwarp_wf
    vsm2dfm = pe.Node(itk.FUGUEvsm2ANTSwarp(), name="vsm2dfm")
AttributeError: module 'niworkflows.interfaces.itk' has no attribute 'FUGUEvsm2ANTSwarp'

which seems to be a version problem in qsiprep as shown in Error when using FUGUE for fieldmap (after removing niworkflows) · Issue #752 · PennLINC/qsiprep · GitHub
I will download the latest version and try again, Thank you very much!