qsiprep icon indicating copy to clipboard operation
qsiprep copied to clipboard

Dimension mismatch when using --prefer_dedicated_fmaps

Open earoy opened this issue 1 year ago • 9 comments

I'm getting a dimension mismatch error when I try to use --prefer_dedicated_fmaps.

Here is my call to qsiprep:

singularity run --cleanenv /scratch/users/ethanroy/singularity_images/qsiprep-0.18.1.sif \
/scratch/groups/jyeatman/ethan/input_test_fmap_reorg \
/scratch/groups/jyeatman/ethan/input_test_fmap_reorg/derivatives participant --participant-label sub-LD4138ses3 \
--prefer_dedicated_fmaps \
-w /scratch/groups/jyeatman/ethan/work \
--output-resolution 1.5

And here is the stack trace:

RuntimeError: Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node fmap2ref_apply.

Cmdline:
	antsApplyTransforms --default-value 0 --dimensionality 3 --float 1 --input /scratch/groups/jyeatman/ethan/work/qsiprep_wf/single_subject_LD4138ses3_wf/dwi_preproc_acq_60_wf/hmc_sdc_wf/sdc_wf/fmap_wf/applymsk/sub-LD4138ses3_acq-60_fieldmap_ras_rad_unwrapped_hz_filt_demean_maths_masked.nii.gz --interpolation BSpline --output sub-LD4138ses3_acq-60_fieldmap_ras_rad_unwrapped_hz_filt_demean_maths_masked_trans.nii.gz --reference-image /scratch/groups/jyeatman/ethan/work/qsiprep_wf/single_subject_LD4138ses3_wf/dwi_preproc_acq_60_wf/hmc_sdc_wf/b0_ref_to_lps/topup_imain_LPS.nii.gz --transform /scratch/groups/jyeatman/ethan/work/qsiprep_wf/single_subject_LD4138ses3_wf/dwi_preproc_acq_60_wf/hmc_sdc_wf/sdc_wf/sdc_unwarp_wf/fmap2ref_reg/transformComposite.h5
Stdout:

Stderr:

Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 398, in run
	    runtime = self._post_run_hook(runtime)
	  File "/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/niworkflows/interfaces/registration.py", line 106, in _post_run_hook
	    return super(ANTSApplyTransformsRPT, self)._post_run_hook(runtime)
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/mixins/reporting.py", line 50, in _post_run_hook
	    self._generate_report()
	  File "/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/niworkflows/interfaces/report_base.py", line 61, in _generate_report
	    cuts = cuts_from_bbox(mask_nii, cuts=n_cuts)
	  File "/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/niworkflows/viz/utils.py", line 215, in cuts_from_bbox
	    ras_coords.append(apply_affine(mask_nii.affine, cross).tolist())
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/affines.py", line 97, in apply_affine
	    pts = pts @ rzs.T + trans[None, :]
	ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 3 is different from 4)

earoy avatar Jul 06 '23 18:07 earoy

The prefer-dedicated-fmaps method is deprecated. Just curious, why are you preferring dedicated fmaps instead of using data from dwi series?

mattcieslak avatar Jul 28 '23 14:07 mattcieslak

Ah okay thanks, that is good to know! Our collaborators provided us with both the dwi series and fieldmaps and so we were trying to make use of those but seems like it's probably best/most straightforward to perform the distortion correction using data from the dwi series? Is there a specific flag to set in order to perform distortion correction that way? When I tried running the command above without the prefer-dedicated-fmaps flag, there doesn't seem to be any evidence of distortion correction in the output report

earoy avatar Aug 02 '23 15:08 earoy

Do the two dwi series have different PhaseEncodingDirections specified in their sidecars?

mattcieslak avatar Aug 02 '23 15:08 mattcieslak

Yes based on the sidecars it looks like the PhaseEncodingDirections are different across the two series

earoy avatar Aug 02 '23 18:08 earoy

Strange update: I just tried running the same call to qsiprep as above (minus the prefer-dedicated-fmaps flag) but using an older version of qsiprep (qsiprep-0.16.1) and things ran smoothly and included the expected distortion correction in the output...I think for the time being I can proceed with the older version of qsiprep but thought I'd flag that for some reason the distortion correction is working with the older version but not the new one.

earoy avatar Aug 05 '23 19:08 earoy

Would you be able to share this dataset with me?

mattcieslak avatar Aug 05 '23 21:08 mattcieslak

I just heard back from our collaborators and unfortunately I don't think I can share the dataset with you based on our data usage agreement.

earoy avatar Aug 10 '23 21:08 earoy

Hi @earoy and @mattcieslak,

I encountered this same error on some older dataset while using version 0.19.1. Matt I will reach out to you to share the data.

Edit: Error was due to mismatching affines between DWI and EPI

smeisler avatar Dec 12 '23 15:12 smeisler

Any updates on this issue? I am getting the same error with the latest version of qsiprep (0.19.1 docker). I checked the affine matrices of my input dwi and all my fmap (2 phase and 2 magnitude) images with nibabel and they match perfectly.

I also ran the same preprocessing on an older version of qsiprep (0.16.1) based on earoy's comment. It completed without error, but there seems to be no difference between the images pre and post SDC visually based on the subject's .html report. The fieldmap it generated looks good though (resembles the fieldmap generated by FSL).

jhauneuro avatar Feb 07 '24 23:02 jhauneuro