Download hmc/reference/scripts/conform_diff.py from neurodeskorg/webapps: direct link, hf CLI and curl.
- Browser
- Download file 690 Bytes
-
https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/conform_diff.py
- Command line
-
hf download hf://datasets/neurodeskorg/webapps/hmc/reference/scripts/conform_diff.py
-
curl -L -o conform_diff.py https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/conform_diff.py
690 Bytes
| """Locate differences between the reoriented raw data and the conformed data.""" | |
| import sys | |
| import nibabel as nb | |
| import numpy as np | |
| raw = nb.load(sys.argv[1]) | |
| con = nb.load(sys.argv[2]) | |
| 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( | |
| r.dtype, | |
| c.dtype, | |
| raw.dataobj.slope, | |
| raw.dataobj.inter, | |
| con.dataobj.slope, | |
| con.dataobj.inter, | |
| ) | |
| d = np.abs(r.astype(np.float64) - c) | |
| idx = np.argwhere(d > 0) | |
| print("n diff", len(idx), "vols", np.unique(idx[:, 3])[:20]) | |
| print(r[tuple(idx[0])], c[tuple(idx[0])]) | |