From dea6438539ef25085beae39b7ee449b0ce595551 Mon Sep 17 00:00:00 2001 From: jmoore Date: Wed, 4 May 2022 11:12:40 +0200 Subject: [PATCH 1/2] Image name for single channel image --- napari_ome_zarr/_reader.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/napari_ome_zarr/_reader.py b/napari_ome_zarr/_reader.py index 8259e94..a297c1f 100644 --- a/napari_ome_zarr/_reader.py +++ b/napari_ome_zarr/_reader.py @@ -133,6 +133,15 @@ def f(*args: Any, **kwargs: Any) -> List[LayerData]: np.squeeze(level, axis=channel_axis) for level in node.data ] else: + + metadata["name"] = "unnamed" + image = node.metadata.get("ome-xml:image", None) + # Pull from OME-XML metadata + if image: + metadata["name"] = image.name + + # Pull from NGFF metadata? + # TBD # Handle the removal of vispy requirement from ome-zarr-py cms = node.metadata.get("colormap", []) for idx, cm in enumerate(cms): From 2ec35485a60c2aa1173fde0908e8ec44e344e4b5 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 12 Sep 2022 15:17:53 +0200 Subject: [PATCH 2/2] wip: assign name or "unnamed" if not found --- napari_ome_zarr/_reader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/napari_ome_zarr/_reader.py b/napari_ome_zarr/_reader.py index a297c1f..7d99c19 100644 --- a/napari_ome_zarr/_reader.py +++ b/napari_ome_zarr/_reader.py @@ -32,7 +32,8 @@ def napari_get_reader(path: PathLike) -> Optional[ReaderFunction]: zarr = parse_url(path) if zarr: reader = Reader(zarr) - return transform(reader()) + rv = transform(reader()) + return rv # Ignoring this path return None @@ -132,6 +133,9 @@ def f(*args: Any, **kwargs: Any) -> List[LayerData]: data = [ np.squeeze(level, axis=channel_axis) for level in node.data ] + metadata["name"] = [ + metadata.get("name", "unnamed") for x in range(3) + ] else: metadata["name"] = "unnamed"