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

Check OMERO color versus napari colormaps and use them if they exist #78

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
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
15 changes: 11 additions & 4 deletions src/napari_omero/plugins/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dask.array as da
from dask.delayed import delayed
from napari.types import LayerData
from vispy.color import Colormap
from napari.utils.colormaps import ensure_colormap

Check warning on line 6 in src/napari_omero/plugins/loaders.py

View check run for this annotation

Codecov / codecov/patch

src/napari_omero/plugins/loaders.py#L6

Added line #L6 was not covered by tests

from napari_omero.utils import PIXEL_TYPES, lookup_obj, parse_omero_url, timer
from napari_omero.widgets import QGateWay
Expand Down Expand Up @@ -78,9 +78,16 @@
colors = []
for ch in channels:
# use current rendering settings from OMERO
color = ch.getColor().getRGB()
color = [r / 256 for r in color]
colors.append(Colormap([[0, 0, 0], color]))
color = ch.getColor().getHtml()

Check warning on line 81 in src/napari_omero/plugins/loaders.py

View check run for this annotation

Codecov / codecov/patch

src/napari_omero/plugins/loaders.py#L81

Added line #L81 was not covered by tests
# work around a napari bug https://github.com/napari/napari/issues/7504
if color == "000000":
colors.append(ensure_colormap("gray_r"))
if color == "FFFFFF":
colors.append(ensure_colormap("gray"))

Check warning on line 86 in src/napari_omero/plugins/loaders.py

View check run for this annotation

Codecov / codecov/patch

src/napari_omero/plugins/loaders.py#L83-L86

Added lines #L83 - L86 were not covered by tests
else:
# if the colormap exists in napari, use it
# otherwise, create a custom colormap
colors.append(ensure_colormap("#" + color))

Check warning on line 90 in src/napari_omero/plugins/loaders.py

View check run for this annotation

Codecov / codecov/patch

src/napari_omero/plugins/loaders.py#L90

Added line #L90 was not covered by tests

contrast_limits = [[ch.getWindowStart(), ch.getWindowEnd()] for ch in channels]

Expand Down
Loading