Skip to content

Commit 8a6f088

Browse files
oestebaneffigies
andauthored
Apply suggestions from code review
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent f11d73c commit 8a6f088

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

niworkflows/utils/images.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def rotation2canonical(img):
77
"""Calculate the rotation w.r.t. cardinal axes of input image."""
88
img = nb.as_closest_canonical(img)
99
newaff = np.diag(img.header.get_zooms()[:3])
10-
r = newaff @ np.linalg.inv(img.affine[:3, :3])
10+
r = newaff @ np.linalg.pinv(img.affine[:3, :3])
1111
if np.allclose(r, np.eye(3)):
1212
return None
1313
return r
@@ -20,8 +20,7 @@ def rotate_affine(img, rot=None):
2020

2121
img = nb.as_closest_canonical(img)
2222
affine = np.eye(4)
23-
affine[:3, :3] = rot @ img.affine[:3, :3]
24-
affine[:3, 3] = rot @ img.affine[:3, 3]
23+
affine[:3] = rot @ img.affine[:3]
2524
return img.__class__(img.dataobj, affine, img.header)
2625

2726

0 commit comments

Comments
 (0)