fMRIPrep magnitude merge (magmrg) affine mismatch error

Hey all,

I’m new to using fMRIPrep so hopefully this question isn’t ridiculous! :crossed_fingers:

I’m hoping for some advice on an error I have maybe 30% of the time when I run fMRIPrep with field maps. I have 2 phase images and 2 magnitude images. When the pipeline tries to merge the magnitude images, if the affines don’t match perfectly it errors out. The images are converted to nifti with dcm2niix, not sure if that’s where the slight difference is introduced. This is the error that comes back for magmrg:

ValueError: Affine for image 1 does not match affine for first image.

In one example the files are:
in_files: ['/data/sub-201240/ses-1701/fmap/sub-201240_ses-1701_magnitude1.nii.gz', '/data/sub-201240/ses-1701/fmap/sub-201240_ses-1701_magnitude2.nii.gz']

These are the s-forms for those files (can see they’re slightly different):

mrinfo -transform Data/sub-201240/ses-1701/fmap/sub-201240_ses-1701
mrinfo: [WARNING] voxel spacings inconsistent between NIFTI s-form and header field pixdim *
0.998210775838638 -0.0442420315152052 0.0402230212944913 -116.995146632195
0.0459532418004959 0.998032105577442 -0.0426639650067973 -97.8777562379837
-0.0382563271583886 0.0444360088674189 0.998279467207376 -66.8465342521667
0 0 0 1
mrinfo -transform Data/sub-201240/ses-1701/fmap/sub-201240_ses-1701
mrinfo: [WARNING] voxel spacings inconsistent between NIFTI s-form and header field pixdim *
0.998210798242074 -0.0442419366781669 0.0402225811809413 -116.995177149773
0.0459531117016308 0.998032117542284 -0.0426638170204718 -97.8777248896658
-0.0382558988635477 0.0444358345598469 0.99827949126504 -66.8465910702944
0 0 0 1

Has anyone else experienced this? Should I just change one magnitude image to match the other with something like fslcpgeom? Or is that problematic? Any advice would be appreciated!

I have experienced this error with fMRIPrep version 20.2.5 via singularity and 22.0.0 via docker.

*the voxel spacings are inconsistent between the s-forms and pixdims for all magnitude images (including the ones that work) so I don’t think this is the problem. *

Thank you,
Sophie