diff --git a/ome_zarr/data.py b/ome_zarr/data.py index cafa460f..b467f564 100644 --- a/ome_zarr/data.py +++ b/ome_zarr/data.py @@ -155,11 +155,14 @@ def create_zarr( write_multiscale(labels, label_grp) colors = [] + properties = [] for x in range(1, 9): rgba = [randrange(0, 256) for i in range(4)] colors.append({"label-value": x, "rgba": rgba}) + properties.append({"label-value": x, "class": f"class {x}"}) label_grp.attrs["image-label"] = { "version": "0.1", "colors": colors, + "properties": properties, "source": {"image": "../../"}, } diff --git a/tests/test_napari.py b/tests/test_napari.py index d30f20af..12388f53 100644 --- a/tests/test_napari.py +++ b/tests/test_napari.py @@ -13,7 +13,7 @@ def initdir(self, tmpdir): self.path = tmpdir.mkdir("data") create_zarr(str(self.path), astronaut, "astronaut") - def assert_layers(self, layers, visible_1, visible_2): + def assert_layers(self, layers, visible_1, visible_2, label_props=None): # TODO: check name assert len(layers) == 2 @@ -27,6 +27,8 @@ def assert_layers(self, layers, visible_1, visible_2): data, metadata, layer_type = self.assert_layer(label) assert visible_2 == metadata["visible"] + if label_props: + assert label_props == metadata["properties"] def assert_layer(self, layer_data): data, metadata, layer_type = layer_data @@ -47,7 +49,11 @@ def test_labels(self): def test_label(self): filename = str(self.path.join("labels", "astronaut")) layers = napari_get_reader(filename)() - self.assert_layers(layers, False, True) + properties = { + "index": [i for i in range(1, 9)], + "class": [f"class {i}" for i in range(1, 9)], + } + self.assert_layers(layers, False, True, properties) @pytest.mark.skipif( not sys.platform.startswith("darwin") or sys.version_info < (3, 7),