Skip to content

Commit

Permalink
fix: fix selection of label colors for napari 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Jul 11, 2024
1 parent 0926915 commit 018b35e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions package/PartSeg/common_gui/napari_image_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ def get_roi_view_parameters(self, image_info: ImageInfo) -> ColorInfo:
return res

def set_roi_colormap(self, image_info) -> None:
if _napari_ge_5:
image_info.roi.colormap = self.get_roi_view_parameters(image_info)
return

Check warning on line 487 in package/PartSeg/common_gui/napari_image_view.py

View check run for this annotation

Codecov / codecov/patch

package/PartSeg/common_gui/napari_image_view.py#L486-L487

Added lines #L486 - L487 were not covered by tests
if _napari_ge_4_13:
image_info.roi.color = self.get_roi_view_parameters(image_info)
return
Expand Down Expand Up @@ -583,7 +586,10 @@ def set_mask(self, mask: Optional[np.ndarray] = None, image: Optional[Image] = N
else:
image_info.mask.data = mask_marker
image_info.mask.metadata["valid"] = True
image_info.mask.color = self.mask_color()
if _napari_ge_5:
image_info.mask.colormap = self.mask_color()

Check warning on line 590 in package/PartSeg/common_gui/napari_image_view.py

View check run for this annotation

Codecov / codecov/patch

package/PartSeg/common_gui/napari_image_view.py#L590

Added line #L590 was not covered by tests
else:
image_info.mask.color = self.mask_color()
image_info.mask.opacity = self.mask_opacity()
image_info.mask.visible = self.mask_chk.isChecked()
self._toggle_mask_chk_visibility()
Expand All @@ -602,7 +608,10 @@ def update_mask_parameters(self):
for image_info in self.image_info.values():
if image_info.mask is not None:
image_info.mask.opacity = opacity
image_info.mask.color = colormap
if _napari_ge_5:
image_info.mask.colormap = colormap

Check warning on line 612 in package/PartSeg/common_gui/napari_image_view.py

View check run for this annotation

Codecov / codecov/patch

package/PartSeg/common_gui/napari_image_view.py#L612

Added line #L612 was not covered by tests
else:
image_info.mask.color = colormap

def set_image(self, image: Optional[Image] = None):
self.image_info = {}
Expand Down

0 comments on commit 018b35e

Please sign in to comment.