File size: 455 Bytes
a4ba047 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | """Print the QSIPrep-formula pivot A[:3,:3] @ c and its norm for two centre definitions."""
import sys
import nibabel as nb
import numpy as np
img = nb.load(sys.argv[1])
a = img.affine
s = np.array(img.shape[:3])
for name, c in (("(shape-1)/2", (s - 1) / 2), ("shape/2", s / 2)):
p = a[:3, :3] @ c
print(name, p.round(3), round(float(np.linalg.norm(p)), 3))
print("origin", a[:3, 3].round(3), "norm", round(float(np.linalg.norm(a[:3, 3])), 3))
|