File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -679,6 +679,18 @@ def reconstruct_fieldmap(
679679 target .__class__ (target .dataobj , projected_affine , target .header ),
680680 )
681681 else :
682+ # Below if statement was taken from fmriprep pull request #3439,
683+ # along with the same explanation:
684+ #
685+ # Hack. Sometimes the reference array is rotated relative to the fieldmap
686+ # and coefficient grids. As far as I know, coefficients are always RAS,
687+ # but good to check before doing this.
688+ if (
689+ nb .aff2axcodes (coefficients [- 1 ].affine )
690+ == ('R' , 'A' , 'S' )
691+ != nb .aff2axcodes (fmap_reference .affine )
692+ ):
693+ fmap_reference = nb .as_closest_canonical (fmap_reference )
682694 if not aligned (fmap_reference .affine , coefficients [- 1 ].affine ):
683695 raise ValueError ('Reference passed is not aligned with spline grids' )
684696 reference , _ = ensure_positive_cosines (fmap_reference )
You can’t perform that action at this time.
0 commit comments