File size: 806 Bytes
c5e5959
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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)))