Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions nibabies/interfaces/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,18 @@
target.__class__(target.dataobj, projected_affine, target.header),
)
else:
# Below if statement was taken from fmriprep pull request #3439,
# along with the same explanation:
#
# Hack. Sometimes the reference array is rotated relative to the fieldmap
# and coefficient grids. As far as I know, coefficients are always RAS,
# but good to check before doing this.
if (
nb.aff2axcodes(coefficients[-1].affine)
== ('R', 'A', 'S')
!= nb.aff2axcodes(fmap_reference.affine)
):
fmap_reference = nb.as_closest_canonical(fmap_reference)

Check warning on line 693 in nibabies/interfaces/resampling.py

View check run for this annotation

Codecov / codecov/patch

nibabies/interfaces/resampling.py#L693

Added line #L693 was not covered by tests
if not aligned(fmap_reference.affine, coefficients[-1].affine):
raise ValueError('Reference passed is not aligned with spline grids')
reference, _ = ensure_positive_cosines(fmap_reference)
Expand Down