Download hmc/reference/scripts/mask_diff.py from neurodeskorg/webapps: direct link, hf CLI and curl.
- Browser
- Download file 762 Bytes
-
https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/mask_diff.py
- Command line
-
hf download hf://datasets/neurodeskorg/webapps/hmc/reference/scripts/mask_diff.py
-
curl -L -o mask_diff.py https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/mask_diff.py
762 Bytes
| """Describe how a NiFreeze work brainmask differs from the input mask.""" | |
| import sys | |
| import nibabel as nb | |
| import numpy as np | |
| from scipy import ndimage | |
| ref = np.asarray(nb.load(sys.argv[1]).dataobj).astype(bool) | |
| d = np.asarray(nb.load(sys.argv[2]).dataobj) | |
| print("work unique values", np.unique(d, return_counts=True)) | |
| b = d.astype(bool) | |
| print("ref voxels", int(ref.sum()), "work voxels", int(b.sum())) | |
| print("work-only", int((b & ~ref).sum()), "ref-only", int((ref & ~b).sum())) | |
| for it in (1, 2, 3): | |
| dil = ndimage.binary_dilation(ref, iterations=it) | |
| ero = ndimage.binary_erosion(ref, iterations=it) | |
| print( | |
| "dilate", | |
| it, | |
| bool(np.array_equal(dil, b)), | |
| "erode", | |
| it, | |
| bool(np.array_equal(ero, b)), | |
| ) | |