Skip to content

Commit 3a5467f

Browse files
committed
fix: roll back original implementation
1 parent 4ace2be commit 3a5467f

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

nitransforms/io/afni.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,16 @@ def from_string(cls, string):
111111
def to_ras(self, moving=None, reference=None):
112112
"""Return a nitransforms internal RAS+ matrix."""
113113
# swapaxes is necessary, as axis 0 encodes series of transforms
114+
retval = LPS @ np.swapaxes(self.structarr["parameters"].T, 0, 1) @ LPS
115+
reference = _ensure_image(reference)
116+
if reference is not None and _is_oblique(reference.affine):
117+
retval = retval @ _cardinal_rotation(reference.affine, True)
114118

115-
pre_rotation = post_rotation = np.eye(4)
116-
if reference is not None and _is_oblique(ref_aff := _ensure_image(reference).affine):
117-
pre_rotation = _cardinal_rotation(ref_aff, True)
118-
if moving is not None and _is_oblique(mov_aff := _ensure_image(moving).affine):
119-
post_rotation = _cardinal_rotation(mov_aff, True)
119+
moving = _ensure_image(moving)
120+
if moving is not None and _is_oblique(moving.affine):
121+
retval = _cardinal_rotation(moving.affine, False) @ retval
120122

121-
return (
122-
post_rotation
123-
@ LPS
124-
@ np.swapaxes(self.structarr["parameters"].T, 0, 1)
125-
@ LPS
126-
@ pre_rotation
127-
)
123+
return retval
128124

129125

130126
class AFNILinearTransformArray(BaseLinearTransformList):

0 commit comments

Comments
 (0)