Fmriprep error: Reference passed is not aligned with spline grids

There are multiple sets of fmap files for that subject

i believe the error you experienced maybe specific to the *acq-SEfmapBOLD* files. When I first ran fMRIprep on this subject, i deleted the *acq-SEfmapBOLD* files, and kept the *acq-GEfmap* files. That was when i encountered the “Reference passed is not aligned with spline grids” error.

In my second attempt i did the reverse, deleting *acq-GEfmap* and kept *acq-SEfmapBOLD*, and i think had a similar error to the one you encountered here. I cant verify exactly the error because i’ve deleted the output; i’m tight on storage space. But i vaguely recalled some kind of indexing error.

I also limited my run to the GEfmap files. Could you run the following script on your output directory?

#!/bin/env python
# /// script
# requires-python = ">=3.13"
# dependencies = ["nibabel", "typer"]
# ///
from pathlib import Path

import nibabel as nb
import typer


def main(paths: list[Path]) -> None:
    for path in paths:
        img = nb.load(path)
        axcodes = nb.aff2axcodes(img.affine)

        print(f"{path}: {axcodes}")


if __name__ == "__main__":
    typer.run(main)

e.g.,

$ python summary.py /path/to/outputs/**/*.nii.gz

@Patricia_Fernandes I think I will need a subject. I’m having trouble figuring out how to get my data in the same state as yours to reproduce this.

(fmriprepenv) [junhong.yu@hpc-wfly-h001 output]$ python summary.py sub-010088/ses-01/func/*.nii.gz
sub-010088/ses-01/func/sub-010088_ses-01_task-rest_acq-AP_run-01_desc-brain_mask.nii.gz: ('L', 'S', 'P')
sub-010088/ses-01/func/sub-010088_ses-01_task-rest_acq-AP_run-01_desc-coreg_boldref.nii.gz: ('L', 'S', 'P')
sub-010088/ses-01/func/sub-010088_ses-01_task-rest_acq-AP_run-01_desc-hmc_boldref.nii.gz: ('L', 'S', 'P')
sub-010088/ses-01/func/sub-010088_ses-01_task-rest_acq-AP_run-01_space-MNI152NLin6Asym_boldref.nii.gz: ('R', 'A', 'S')
sub-010088/ses-01/func/sub-010088_ses-01_task-rest_acq-AP_run-01_space-MNI152NLin6Asym_desc-brain_mask.nii.gz: ('R', 'A', 'S')

the full error log from sub-10088.html
Node Name: fmriprep_24_0_wf.sub_010088_wf.bold_ses_01_task_rest_acq_AP_run_01_wf.bold_native_wf.boldref_fmap

File: <workdir>/sub-010088/log/20241025-161033_4cc10f6d-a6a7-40c3-b396-c25cc709ce2f/crash-20241025-162128-junhong.yu-boldref_fmap-028017f1-65b6-4d78-be14-25048f587163.txt
Working Directory: /home/junhong.yu/NC/work/fmriprep_24_0_wf/sub_010088_wf/bold_ses_01_task_rest_acq_AP_run_01_wf/bold_native_wf/boldref_fmap
Inputs:

    fmap_ref_file:
    in_coeffs:
    inverse: [True]
    target_ref_file:
    transforms:

Traceback (most recent call last):
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/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 boldref_fmap.

Traceback:
	Traceback (most recent call last):
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/fmriprep/interfaces/resampling.py", line 171, in _run_interface
	    fieldmap = reconstruct_fieldmap(
	               ^^^^^^^^^^^^^^^^^^^^^
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/fmriprep/interfaces/resampling.py", line 674, in reconstruct_fieldmap
	    raise ValueError('Reference passed is not aligned with spline grids')
	ValueError: Reference passed is not aligned with spline grids

Node Name: fmriprep_24_0_wf.sub_010088_wf.bold_ses_01_task_rest_acq_AP_run_01_wf.bold_anat_wf.fmap_recon

File: <workdir>/sub-010088/log/20241025-161033_4cc10f6d-a6a7-40c3-b396-c25cc709ce2f/crash-20241025-193434-junhong.yu-fmap_recon-a5754951-5c75-43e9-ad3e-0cf271a18ee6.txt
Working Directory: /home/junhong.yu/NC/work/fmriprep_24_0_wf/sub_010088_wf/bold_ses_01_task_rest_acq_AP_run_01_wf/bold_anat_wf/fmap_recon
Inputs:

    fmap_ref_file:
    in_coeffs:
    inverse: [False]
    target_ref_file:
    transforms:

Traceback (most recent call last):
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/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 fmap_recon.

Traceback:
	Traceback (most recent call last):
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/fmriprep/interfaces/resampling.py", line 171, in _run_interface
	    fieldmap = reconstruct_fieldmap(
	               ^^^^^^^^^^^^^^^^^^^^^
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/fmriprep/interfaces/resampling.py", line 674, in reconstruct_fieldmap
	    raise ValueError('Reference passed is not aligned with spline grids')
	ValueError: Reference passed is not aligned with spline grids

Node Name: fmriprep_24_0_wf.sub_010088_wf.bold_ses_01_task_rest_acq_AP_run_01_wf.bold_std_wf.fmap_recon

File: <workdir>/sub-010088/log/20241025-161033_4cc10f6d-a6a7-40c3-b396-c25cc709ce2f/crash-20241025-201525-junhong.yu-fmap_recon.a0-3fbd5aeb-b9ad-46c6-9b9f-b25ecfeb567d.txt
Working Directory: /home/junhong.yu/NC/work/fmriprep_24_0_wf/sub_010088_wf/bold_ses_01_task_rest_acq_AP_run_01_wf/bold_std_wf/_in_tuple_MNI152NLin6Asym.resnative/fmap_recon
Inputs:

    fmap_ref_file:
    in_coeffs:
    inverse: [False]
    target_ref_file:
    transforms:

Traceback (most recent call last):
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/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 fmap_recon.

Traceback:
	Traceback (most recent call last):
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/fmriprep/interfaces/resampling.py", line 171, in _run_interface
	    fieldmap = reconstruct_fieldmap(
	               ^^^^^^^^^^^^^^^^^^^^^
	  File "/home/junhong.yu/fmriprepenv/lib64/python3.11/site-packages/fmriprep/interfaces/resampling.py", line 674, in reconstruct_fieldmap
	    raise ValueError('Reference passed is not aligned with spline grids')
	ValueError: Reference passed is not aligned with spline grids

I’m running fMRIprep with a previously computed freesurfer output directory if it matters

Thanks. I’ll give it another try. I didn’t run FreeSurfer, for speed, but I’m surprised that it didn’t work.

Just a note that I wasn’t able to replicate this issue in the development version on either of your datasets. I’m trying again with 24.1.1.