Download hmc/reference/scripts/conform_facts.py from neurodeskorg/webapps: direct link, hf CLI and curl.
- Browser
- Download file 829 Bytes
-
https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/conform_facts.py
- Command line
-
hf download hf://datasets/neurodeskorg/webapps/hmc/reference/scripts/conform_facts.py
-
curl -L -o conform_facts.py https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/conform_facts.py
829 Bytes
| """Compare the raw DWI grid with QSIPrep's conformed (LPS) grid. Usage: python -I conform_facts.py RAW CONFORMED.""" | |
| import sys | |
| import nibabel as nb | |
| import numpy as np | |
| raw = nb.load(sys.argv[1]) | |
| con = nb.load(sys.argv[2]) | |
| print("raw", raw.shape, raw.get_data_dtype(), nb.aff2axcodes(raw.affine)) | |
| print(np.array2string(raw.affine, precision=6)) | |
| print("conformed", con.shape, con.get_data_dtype(), nb.aff2axcodes(con.affine)) | |
| print(np.array2string(con.affine, precision=6)) | |
| print("scl", con.header["scl_slope"], con.header["scl_inter"]) | |
| ornt = nb.orientations.ornt_transform( | |
| nb.io_orientation(raw.affine), nb.io_orientation(con.affine) | |
| ) | |
| r = nb.orientations.apply_orientation(np.asanyarray(raw.dataobj), ornt) | |
| c = np.asanyarray(con.dataobj) | |
| print("max abs diff after reorientation", np.abs(r.astype(np.float64) - c).max()) | |