Download load_example.py from SharpMeow/pherc0500p2-lasagnetta: direct link, hf CLI and curl.
- Browser
- Download file 806 Bytes
-
https://huggingface.co/datasets/SharpMeow/pherc0500p2-lasagnetta/resolve/main/load_example.py
- Command line
-
hf download hf://datasets/SharpMeow/pherc0500p2-lasagnetta/load_example.py
-
curl -L -o load_example.py https://huggingface.co/datasets/SharpMeow/pherc0500p2-lasagnetta/resolve/main/load_example.py
806 Bytes
| import json | |
| import numpy as np | |
| import zarr | |
| meta = json.load(open("PHerc0500P2.lasagna.json")) | |
| cos = zarr.open(meta["groups"]["cos"]["zarr"], mode="r") # cos, 2x down from the CT level read | |
| nx = zarr.open(meta["groups"]["nx"]["zarr"], mode="r") # normals, 4x down; stored as v * 127 + 128 | |
| ny = zarr.open(meta["groups"]["ny"]["zarr"], mode="r") | |
| z, y, x = 457, 411, 556 # a voxel on the normals' grid that holds data | |
| a, b = (float(nx[z, y, x]) - 128) / 127, (float(ny[z, y, x]) - 128) / 127 | |
| c = np.sqrt(max(0.0, 1 - a * a - b * b)) # nz is not stored | |
| patch = cos[2 * z, 2 * y:2 * y + 64, 2 * x:2 * x + 64] # the same place on the cos grid | |
| print("normal", round(a, 3), round(b, 3), round(c, 3), "cos patch mean", float(np.mean(patch))) | |