Skip to content

Commit e1a8a12

Browse files
committed
ENH: return image if desired orientation already set
1 parent 8451bfa commit e1a8a12

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

niworkflows/interfaces/cifti.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ def _reorient_image(img, *, target_img=None, orientation=None):
448448
449449
Examples
450450
--------
451+
>>> nimg = _reorient_image(img, target_img=img)
452+
>>> nb.aff2axcodes(nimg.affine)
453+
('R', 'A', 'S')
454+
451455
>>> nimg = _reorient_image(img, target_img=las_img)
452456
>>> nb.aff2axcodes(nimg.affine)
453457
('L', 'A', 'S')
@@ -475,7 +479,9 @@ def _reorient_image(img, *, target_img=None, orientation=None):
475479
else:
476480
raise RuntimeError("No orientation to reorient to!")
477481

478-
if orient0 == tuple('RAS') and orient1 == tuple('LAS'): # RAS -> LAS
482+
if orient0 == orient1: # already in desired orientation
483+
return img
484+
elif orient0 == tuple('RAS') and orient1 == tuple('LAS'): # RAS -> LAS
479485
return img.as_reoriented([[0, -1], [1, 1], [2, 1]])
480486
else:
481487
raise NotImplementedError(

0 commit comments

Comments
 (0)