Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop color key #112

Merged
merged 4 commits into from
Jul 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check napari version to use color or colormap for labels
  • Loading branch information
will-moore committed Jul 11, 2024

Verified

This commit was signed with the committer’s verified signature.
commit 003b7beed8cc9d0147d60e12367c612fc5f7f7bc
11 changes: 9 additions & 2 deletions napari_ome_zarr/_reader.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

import logging
import warnings
from importlib.metadata import version
from typing import Any, Dict, Iterator, List, Optional

import numpy as np
@@ -16,9 +17,11 @@

LOGGER = logging.getLogger("napari_ome_zarr.reader")

# NB: color for labels, colormap for images
METADATA_KEYS = ("name", "visible", "contrast_limits", "colormap", "metadata")

# major and minor versions as int
napari_version = tuple(map(int, list(version("napari").split(".")[:2])))


def napari_get_reader(path: PathLike) -> Optional[ReaderFunction]:
"""Returns a reader for supported paths that include IDR ID.
@@ -129,7 +132,11 @@ def f(*args: Any, **kwargs: Any) -> List[LayerData]:
if x in node.metadata:
metadata[x] = node.metadata[x]
elif x == "colormap" and node.metadata["color"]:
metadata[x] = node.metadata["color"]
# key changed 'color' -> 'colormap' in napari 0.5
if napari_version >= (0, 5):
metadata["colormap"] = node.metadata["color"]
else:
metadata["color"] = node.metadata["color"]
if channel_axis is not None:
data = [
np.squeeze(level, axis=channel_axis) for level in node.data