fMRIprep v23.1.3 -- fmap phasediff shape mismatch

Summary of what happened:

I am running fmriprep v23.1.3 and get an error regarding my fmap. I have a phasediff, magnitude1, and magnitude2 json for each participant. In the phasediff json, I have "IntendedFor", "EchoTime1", "EchoTime2", and "B0FieldIdentifier". In each functional json, I have included "B0FieldSource". All json's have "Units": "Hz". It is something to do with the dimensions of the magnitude & phasediff nii.gz but I'm not sure how to further diagnose.

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

#!/bin/bash
#
#$ -cwd
# error = Merged with joblog
#$ -N fmriprep
#$ -o fmriprep_$JOB_ID.out
#$ -j y
#$ -pe shared 2
#$ -l h_rt=24:00:00,h_data=30G
# Email address to notify
#$ -M $EMAIL
# Notify when
#$ -m bea
#$ -t 1-3
#--------------------

# load the job environment:
. /u/local/Modules/default/init/modules.sh
module use /u/project/CCN/apps/modulefiles

module load freesurfer/7.3.2
module load apptainer/1.2.2

GROUP_HOME=/u/project/silvers/data/
BIDS_DIR="${GROUP_HOME}/bids/IR_bids_pipeline/bids_data"
OUTPUT_DIR="${BIDS_DIR}/derivatives/fmriprep-23.1.3"
FREESURFER_DIR="${BIDS_DIR}/derivatives/freesurfer-7.3.2"

# Make sure FS_LICENSE is defined in the container.
export APPTAINERENV_FS_LICENSE=$GROUP_HOME/scripts/containers/license.txt

# Prepare some writeable bind-mount points.
export APPTAINERENV_TEMPLATEFLOW_HOME=$GROUP_HOME/scripts/containers/templateflow
export APPTAINER_HOME="/u/project/CCN/apps/fmriprep/rh7/23.1.3"
export fmriprep="23.1.3-fmriprep.sif"

# setting singularity command
APPTAINER_CMD="apptainer run --cleanenv -B $TMPDIR:/tmp -B $APPTAINERENV_TEMPLATEFLOW_HOME:/templateflow $APPTAINER_HOME/${fmriprep}"

# Parse the participants.tsv file and extract one subject ID from the line corresponding to this SLURM task.
subject=$( sed -n -E "$(($SGE_TASK_ID))s/sub-(\S*)\>.*/\1/gp" ${GROUP_HOME}/bids/IR_bids_pipeline/participants.tsv )
echo $SGE_TASK_ID

# Single sub
#subject= "IRA053"

# Compose the command line
FMRIPREP_OPTS="
    --omp-nthreads 8
    --nthreads 12
    --mem_mb 30000
    --skip-bids-validation
    --output-spaces MNI152NLin2009cAsym:res-2
    --skull-strip-template MNI152NLin2009cAsym
    --fs-license-file ${APPTAINERENV_FS_LICENSE}
    --fs-subjects-dir ${FREESURFER_DIR}
    "

    # --fs-no-reconall
    # --ignore fieldmaps
    # --ignore slicetiming
    # --skull-strip-template MNI152NLin6Asym
    # --fs-no-reconall
    # --omp-nthreads 8
    # --nthreads 12
    # --mem_mb 30000
    # --dummy-scans 6
    # --use-aroma

cmd="${APPTAINER_CMD} ${BIDS_DIR} ${OUTPUT_DIR} participant --participant-label ${subject} -w /tmp/ -vv ${FMRIPREP_OPTS}"

# Setup done, run the command
echo Running task ${JOB_ID}
echo ${FREESURFER_DIR}/sub-${subject}/scripts/IsRunning*
if [ -e ${FREESURFER_DIR}/sub-${subject}/scripts/IsRunning* ]
then
    rmcmd="rm ${FREESURFER_DIR}/sub-${subject}/scripts/IsRunning*"
    echo ${rmcmd}
    eval ${rmcmd}
fi
echo Commandline: $cmd
eval $cmd

Version:

fmriprep v23.1.3

Environment (Docker, Singularity, custom installation):

Apptainer v1.2.2

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

Yes (see screenshot)

Relevant log outputs (up to 20 lines):

	ValueError: Images have shape mismatch: /u/project/silvers/data/bids/IR_bids_pipeline/bids_data/sub-IRA053/fmap/sub-IRA053_magnitude1.nii.gz (96, 96, 3), /u/project/silvers/data/bids/IR_bids_pipeline/bids_data/sub-IRA053/fmap/sub-IRA053_phasediff.nii.gz (96, 96, 72)

Screenshots / relevant information:

The error is pretty explicit:

ValueError: Images have shape mismatch: /u/project/silvers/data/bids/IR_bids_pipeline/bids_data/sub-IRA053/fmap/sub-IRA053_magnitude1.nii.gz (96, 96, 3), /u/project/silvers/data/bids/IR_bids_pipeline/bids_data/sub-IRA053/fmap/sub-IRA053_phasediff.nii.gz (96, 96, 72)

Your images contain 3D arrays, with shape 96x96x3 and 96x96x72, respectively. It seems that you have a corrupted magnitude1 image. Open /u/project/silvers/data/bids/IR_bids_pipeline/bids_data/sub-IRA053/fmap/sub-IRA053_magnitude1.nii.gz with some viewer to verify. Most likely you will need to reconvert this subject’s data from DICOM.

Thanks for the quick reply! Yes, I agree the error is explicit. I am having a hard time diagnosing the issue though. Should I expect the magnitude1 to also have the dimensions that my phasediff file currently has (96, 96, 72)? This is my first time working with fmap like this, sorry.

I will reconvert to see if anything changes.

Yes, the magnitude and phase (difference) images should be the same size. These are the components of complex-values at each voxel, so there should be exactly as many data points in each. When you have a phase difference map, it means the phase images from the two magnitude images have already been subtracted on-scanner, but the principle is still the same.

FUGUE/Guide - FslWiki probably has the best overview of what these data are with images. (Acquiring and using field maps – Lewis Center for Neuroimaging used to be better, but the images are gone…)