@@ -108,26 +108,23 @@ def from_string(cls, string):
108108 sa ["parameters" ] = parameters
109109 return tf
110110
111- def to_ras (self , moving = None , reference = None , pre_rotation = None , post_rotation = None ):
111+ 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-
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
122114
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 )
129120
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+ )
131128
132129
133130class AFNILinearTransformArray (BaseLinearTransformList ):
@@ -139,7 +136,6 @@ def to_ras(self, moving=None, reference=None):
139136 """Return a nitransforms' internal RAS matrix."""
140137
141138 pre_rotation = post_rotation = np .eye (4 )
142-
143139 if reference is not None and _is_oblique (ref_aff := _ensure_image (reference ).affine ):
144140 pre_rotation = _cardinal_rotation (ref_aff , True )
145141 if moving is not None and _is_oblique (mov_aff := _ensure_image (moving ).affine ):
0 commit comments