Download hmc/reference/scripts/pivot_norm.py from neurodeskorg/webapps: direct link, hf CLI and curl.
- Browser
- Download file 455 Bytes
-
https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/pivot_norm.py
- Command line
-
hf download hf://datasets/neurodeskorg/webapps/hmc/reference/scripts/pivot_norm.py
-
curl -L -o pivot_norm.py https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/pivot_norm.py
455 Bytes
| """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)) | |