Skip to content

Commit 29fb252

Browse files
committed
Handle more channel metadata
1 parent 68b26bd commit 29fb252

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

napari_ome_zarr/ome_zarr_reader.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,34 @@ def metadata(self):
8888
rsp["channel_axis"] = channel_axis
8989
if "omero" in attrs:
9090
colormaps = []
91-
for ch in attrs["omero"]["channels"]:
91+
ch_names = []
92+
visibles = []
93+
contrast_limits = []
94+
95+
for index, ch in enumerate(attrs["omero"]["channels"]):
9296
color = ch.get("color", None)
9397
if color is not None:
9498
rgb = [(int(color[i : i + 2], 16) / 255) for i in range(0, 6, 2)]
9599
# colormap is range: black -> rgb color
96100
colormaps.append(Colormap([[0, 0, 0], rgb]))
101+
ch_names.append(ch.get("label", str(index)))
102+
visibles.append(ch.get("active", True))
103+
104+
window = ch.get("window", None)
105+
if window is not None:
106+
start = window.get("start", None)
107+
end = window.get("end", None)
108+
if start is None or end is None:
109+
# Disable contrast limits settings if one is missing
110+
contrast_limits = None
111+
elif contrast_limits is not None:
112+
contrast_limits.append([start, end])
113+
97114
rsp["colormap"] = colormaps
115+
rsp["name"] = ch_names
116+
rsp["contrast_limits"] = contrast_limits
117+
rsp["visible"] = visibles
118+
98119
return rsp
99120

100121
class Bioformats2raw(Spec):

0 commit comments

Comments
 (0)