Download degibbs/validation/scripts/check.py from neurodeskorg/webapps: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/degibbs/validation/scripts/check.py
- Command line
-
hf download hf://datasets/neurodeskorg/webapps/degibbs/validation/scripts/check.py
-
curl -L -o check.py https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/degibbs/validation/scripts/check.py
1.07 kB
| """Checks for the degibbs slab reference (issue #432). Prints JSON facts.""" | |
| import json | |
| import sys | |
| import nibabel as nib | |
| import numpy as np | |
| slab_in, slab_out, slab_1t, full_out, z0, z1 = sys.argv[1:7] | |
| z0, z1 = int(z0), int(z1) | |
| a = nib.load(slab_in) | |
| o = nib.load(slab_out) | |
| x = np.asanyarray(a.dataobj).astype(np.float64) | |
| y = np.asanyarray(o.dataobj) | |
| t = np.asanyarray(nib.load(slab_1t).dataobj) | |
| f = np.asanyarray(nib.load(full_out).dataobj)[:, :, z0:z1, :] | |
| facts = { | |
| "output_dtype": str(y.dtype), | |
| "output_shape": list(y.shape), | |
| "affine_equal": bool(np.allclose(a.affine, o.affine, atol=1e-5)), | |
| "max_abs_diff_vs_full_volume_run": float(np.abs(y - f).max()), | |
| "max_abs_diff_vs_one_thread_run": float(np.abs(y - t).max()), | |
| "nrmse_vs_input": float(np.sqrt(np.mean((y - x) ** 2)) / np.sqrt(np.mean(x**2))), | |
| "output_descrip": o.header["descrip"].tobytes().rstrip(b"\0").decode(), | |
| "output_scl": [float(o.header["scl_slope"]), float(o.header["scl_inter"])], | |
| "output_extensions": len(o.header.extensions), | |
| } | |
| print(json.dumps(facts, indent=2)) | |