@@ -156,10 +156,21 @@ def brain_masker(in_file, out_file=None, padding=5):
156
156
return str (out_brain ), str (out_probseg ), str (out_mask )
157
157
158
158
159
- def reorient_pedir (pe_dir , source_ornt = None , target_ornt = None ):
159
+ def reorient_pedir (pe_dir , source_ornt , target_ornt = None ):
160
160
"""Return updated PhaseEncodingDirection to account for an image data array rotation
161
161
162
- This function can accept one or two orientations.
162
+ Orientations form a natural group with identity, product and inverse.
163
+ This function thus has the following properties (here ``e`` is the identity,
164
+ ``*`` the product and ``-`` the inverse; ``a`` and ``b`` are arbitrary orientations):
165
+
166
+ reorient(pe_dir, e, e) == pe_dir
167
+ reorient(pe_dir, a, e) == reorient(pe_dir, a)
168
+ reorient(pe_dir, e, b) == reorient(pe_dir, -b)
169
+ reorient(pe_dir, a, b) == reorient(pe_dir, a * -b, e)
170
+
171
+ Therefore, this function accepts one or two orientations, and precomputed transforms
172
+ from a to b can be passed as the "source" orientation.
173
+
163
174
Passing only a source orientation will rotate into RAS:
164
175
165
176
>>> from nibabel.orientations import axcodes2ornt
@@ -170,9 +181,9 @@ def reorient_pedir(pe_dir, source_ornt=None, target_ornt=None):
170
181
171
182
Passing only a target_ornt will rotate from RAS:
172
183
173
- >>> reorient_pedir("j", target_ornt=axcodes2ornt("RAS"))
184
+ >>> reorient_pedir("j", source_ornt=None, target_ornt=axcodes2ornt("RAS"))
174
185
'j'
175
- >>> reorient_pedir("i", target_ornt=axcodes2ornt("PSL"))
186
+ >>> reorient_pedir("i", source_ornt=None, target_ornt=axcodes2ornt("PSL"))
176
187
'k-'
177
188
178
189
Passing both will rotate from source to target.
@@ -187,7 +198,7 @@ def reorient_pedir(pe_dir, source_ornt=None, target_ornt=None):
187
198
>>> xfm = ornt_transform(axcodes2ornt("LPS"), axcodes2ornt("AIR"))
188
199
>>> reorient_pedir("j", xfm)
189
200
'i-'
190
- >>> reorient_pedir("j", target_ornt=xfm)
201
+ >>> reorient_pedir("j", source_ornt=None, target_ornt=xfm)
191
202
'k-'
192
203
"""
193
204
from nibabel .orientations import ornt_transform
0 commit comments