Skip to content

Commit 6b0f3a8

Browse files
oestebaneffigies
andauthored
Update nitransforms/io/afni.py
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 755e8d1 commit 6b0f3a8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

nitransforms/io/afni.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,15 @@ class AFNILinearTransformArray(BaseLinearTransformList):
138138
def to_ras(self, moving=None, reference=None):
139139
"""Return a nitransforms' internal RAS matrix."""
140140

141-
pre_rotation = None
142-
if reference is not None:
143-
ref_aff = _ensure_image(reference).affine
144-
pre_rotation = _cardinal_rotation(ref_aff, True) if _is_oblique(ref_aff) else None
145-
146-
post_rotation = None
147-
if moving is not None:
148-
mov_aff = _ensure_image(moving).affine
149-
post_rotation = _cardinal_rotation(mov_aff, True) if _is_oblique(mov_aff) else None
141+
pre_rotation = post_rotation = np.eye(4)
142+
143+
if reference is not None and _is_oblique(ref_aff := _ensure_image(reference).affine):
144+
pre_rotation = _cardinal_rotation(ref_aff, True)
145+
if moving is not None and _is_oblique(mov_aff := _ensure_image(moving).affine):
146+
post_rotation = _cardinal_rotation(mov_aff, True)
150147

151148
return np.stack([
152-
xfm.to_ras(pre_rotation=pre_rotation, post_rotation=post_rotation)
149+
post_rotation @ xfm.to_ras() @ pre_rotation
153150
for xfm in self.xforms
154151
])
155152

0 commit comments

Comments
 (0)