-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_resolution.py
36 lines (30 loc) · 1.01 KB
/
update_resolution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import z5py
from pybdv.metadata import (write_size_and_resolution, get_size,
get_affine, write_affine)
def update_n5():
path = "./data/S016/images/bdv-n5/S016_aligned_full.n5"
with z5py.File(path, "a") as f:
g = f["setup0/timepoint0"]
new_attrs = {
"pixelResolution": {"dimensions": [0.01, 0.01, 0.04], "unit": "micrometer"},
"resolution": [0.01, 0.01, 0.04],
"units": ["micrometer", "micrometer", "micrometer"]
}
g.attrs.update(new_attrs)
for k, v in g.attrs.items():
print(k, v)
def update_xml():
path = "./data/S016/images/bdv-n5/raw.xml"
size = get_size(path, 0)
resolution = [0.04, 0.01, 0.01]
write_size_and_resolution(path, 0, size, resolution)
aff = get_affine(path, 0)["affine0"]
aff = [val / 1000 for val in aff]
print(aff)
write_affine(path, 0, aff, overwrite=True)
if __name__ == "__main__":
update_n5()
print()
print()
print()
update_xml()