@@ -108,26 +108,23 @@ def from_string(cls, string):
108
108
sa ["parameters" ] = parameters
109
109
return tf
110
110
111
- def to_ras (self , moving = None , reference = None , pre_rotation = None , post_rotation = None ):
111
+ def to_ras (self , moving = None , reference = None ):
112
112
"""Return a nitransforms internal RAS+ matrix."""
113
113
# swapaxes is necessary, as axis 0 encodes series of transforms
114
- retval = LPS @ np .swapaxes (self .structarr ["parameters" ].T , 0 , 1 ) @ LPS
115
-
116
- if pre_rotation is None and reference is not None :
117
- ref_aff = _ensure_image (reference ).affine
118
- pre_rotation = _cardinal_rotation (ref_aff , True ) if _is_oblique (ref_aff ) else None
119
-
120
- if pre_rotation is not None :
121
- retval = retval @ pre_rotation
122
114
123
- if post_rotation is None and reference is not None :
124
- mov_aff = _ensure_image (moving ).affine
125
- post_rotation = _cardinal_rotation (mov_aff , True ) if _is_oblique (mov_aff ) else None
126
-
127
- if post_rotation is not None :
128
- retval = post_rotation @ retval
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 )
129
120
130
- return retval
121
+ return (
122
+ post_rotation
123
+ @ LPS
124
+ @ np .swapaxes (self .structarr ["parameters" ].T , 0 , 1 )
125
+ @ LPS
126
+ @ pre_rotation
127
+ )
131
128
132
129
133
130
class AFNILinearTransformArray (BaseLinearTransformList ):
@@ -139,7 +136,6 @@ def to_ras(self, moving=None, reference=None):
139
136
"""Return a nitransforms' internal RAS matrix."""
140
137
141
138
pre_rotation = post_rotation = np .eye (4 )
142
-
143
139
if reference is not None and _is_oblique (ref_aff := _ensure_image (reference ).affine ):
144
140
pre_rotation = _cardinal_rotation (ref_aff , True )
145
141
if moving is not None and _is_oblique (mov_aff := _ensure_image (moving ).affine ):
0 commit comments