SDC error using phasediff fmap in qsiprep

qsiprep_latest_docker_GREfmapSDC.txt (66.2 KB)

Summary of what happened:

i wanna SDC using phasediff fieldmap correction because of not having RPE data. but the following errors is continuing. i repeatedly confirmed ‘IntendedFor’ field in ‘phasediff’ fieldmap json file also have no errors(“IntendedFor”: [ “dwi/sub-001_acq-AP_dwi.nii.gz” ] ). it is so painful…

please any advise.
(i attached a txt file including all coding results)

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

docker run -ti --rm \
    -v /home/park/Desktop/NI_2/KSHAP_18bul/dwi:/data \
    -v /home/park/Desktop/NI_2/KSHAP_18bul/dwi/derivatives:/out \
    -v /home/park/Desktop/files/license.txt:/opt/freesurfer/license.txt \
    pennbbl/qsiprep:latest \
    /data /out participant \
    --participant-label 002 \
    --output-resolution 1.2 \
    --fs-license-file /opt/freesurfer/license.txt \
    --skip-anat-based-spatial-normalization \
    --work-dir /home/park/Desktop/temp --write-graph --stop-on-first-crash

Version:

QSIPREP latest

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

Docker

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

bids-validator@1.8.4

	1: [WARN] The Authors field of dataset_description.json should contain an array of fields - with one author per field. This was triggered based on the presence of only one author field. Please ignore if all contributors are already properly listed. (code: 102 - TOO_FEW_AUTHORS)

	Please visit https://neurostars.org/search?q=TOO_FEW_AUTHORS for existing conversations about this issue.

        Summary:                  Available Tasks:        Available Modalities: 
        1445 Files, 9.49GB                                MRI                   
        120 - Subjects                                                          
        1 - Session                                                             


	If you have any questions, please post on https://neurostars.org/tags/bids.
240122-09:25:29,636 nipype.workflow INFO:
	 Running with omp_nthreads=8, nthreads=20
240122-09:25:29,636 nipype.workflow IMPORTANT:
	 
    Running qsiprep version 0.20.1.dev0+geda84d5.d20240112:
      * BIDS dataset path: /data.
      * Participant list: ['002'].
      * Run identifier: 20240122-092524_1791354d-ccc7-4ac4-9b5f-ba08e48a5166.

Relevant log outputs (up to 20 lines):

Node: qsiprep_wf.single_subject_002_wf.dwi_preproc_acq_AP_wf.hmc_sdc_wf.sdc_wf.sdc_unwarp_wf.fmap2ref_apply
Working directory: /tmp/work/qsiprep_wf/single_subject_002_wf/dwi_preproc_acq_AP_wf/hmc_sdc_wf/sdc_wf/sdc_unwarp_wf/fmap2ref_apply

Node inputs:

args = <undefined>
compress_report = auto
default_value = 0.0
dimension = 3
environ = {'NSLOTS': '1'}
float = True
input_image = <undefined>
input_image_type = <undefined>
interpolation = BSpline
interpolation_parameters = <undefined>
invert_transform_flags = <undefined>
num_threads = 1
out_postfix = _trans
out_report = report.svg
output_image = <undefined>
print_out_composite_warp_file = <undefined>
reference_image = <undefined>
transforms = <undefined>

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.10/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 /tmp/work/qsiprep_wf/single_subject_002_wf/dwi_preproc_acq_AP_wf/hmc_sdc_wf/sdc_wf/phdiff_wf/compfmap/sub-002_phasediff_rads_unwrapped_filt_demean_maths_fmap.nii.gz --interpolation BSpline --output sub-002_phasediff_rads_unwrapped_filt_demean_maths_fmap_trans.nii.gz --reference-image /tmp/work/qsiprep_wf/single_subject_002_wf/dwi_preproc_acq_AP_wf/hmc_sdc_wf/b0_ref_to_lps/topup_imain_LPS.nii.gz --transform /tmp/work/qsiprep_wf/single_subject_002_wf/dwi_preproc_acq_AP_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.10/site-packages/nipype/interfaces/base/core.py", line 398, in run
	    runtime = self._post_run_hook(runtime)
	  File "/usr/local/miniconda/lib/python3.10/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.10/site-packages/nipype/interfaces/mixins/reporting.py", line 50, in _post_run_hook
	    self._generate_report()
	  File "/usr/local/miniconda/lib/python3.10/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.10/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.10/site-packages/nibabel/affines.py", line 96, 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)

Screenshots / relevant information:


Hi @sangmin_park,

Thanks for the report. This has been reported as an issue previously here: Dimension mismatch when using --prefer_dedicated_fmaps · Issue #597 · PennLINC/qsiprep · GitHub . Based on that, I am guessing your DWI and fmap images have different affines, leading to the error. If the affines are very close to each other, you’ll probably be okay if you copy the affine from DWI to fmap (not other way around because then you’ll have to rotate the b-matrix too).

Best,
Steven

1 Like

oh thank you. but i don’t know how to copy affine from DWi to fmap. can you provide me with any source?

Best,
Sangmin

Hi @sangmin_park

As a minimal example,

import nibabel as nib

# Load the NIfTI images
nifti1 = nib.load('image1.nii.gz')
nifti2 = nib.load('image2.nii.gz')

# Get the affine transformation matrix from the first image
affine_matrix = nifti1.affine

# Apply the affine transformation to the header of the second image
nifti2_with_affine = nib.Nifti1Image(nifti2.get_fdata(), affine_matrix)

# Save the result to a new NIfTI file
nib.save(nifti2_with_affine, 'image2_with_affine.nii.gz')

I would make sure the two affines are similar to each other though before you do this. If they are too different you can try the SyN fieldmapless method (--use-syn-sdc --force-syn --ignore fieldmaps) or wait until synb0-disco is incorporated into qsiprep.

Best,
Steven

1 Like

thank you very much!!

i will try it.

Best,
Sangmin