We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f11d73c commit 8a6f088Copy full SHA for 8a6f088
niworkflows/utils/images.py
@@ -7,7 +7,7 @@ def rotation2canonical(img):
7
"""Calculate the rotation w.r.t. cardinal axes of input image."""
8
img = nb.as_closest_canonical(img)
9
newaff = np.diag(img.header.get_zooms()[:3])
10
- r = newaff @ np.linalg.inv(img.affine[:3, :3])
+ r = newaff @ np.linalg.pinv(img.affine[:3, :3])
11
if np.allclose(r, np.eye(3)):
12
return None
13
return r
@@ -20,8 +20,7 @@ def rotate_affine(img, rot=None):
20
21
22
affine = np.eye(4)
23
- affine[:3, :3] = rot @ img.affine[:3, :3]
24
- affine[:3, 3] = rot @ img.affine[:3, 3]
+ affine[:3] = rot @ img.affine[:3]
25
return img.__class__(img.dataobj, affine, img.header)
26
27
0 commit comments