Skip to content

Commit

Permalink
Add check about adding existing images/labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jluethi committed Jul 19, 2024
1 parent 6e2d6db commit b023458
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/napari_ome_zarr_navigator/roi_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,18 @@ def add_intensity_roi(
except AttributeError:
rescaling = None

# FIXME: Only add if it doesn't exist in the viewer yet
self._viewer.add_image(
img_roi,
scale=scale_img,
blending=blending,
contrast_limits=rescaling,
colormap=colormap,
name=layer_name,
translate=translate,
)
if layer_name in self._viewer.layers:
logger.info(f"{layer_name} is already loaded")
else:
self._viewer.add_image(
img_roi,
scale=scale_img,
blending=blending,
contrast_limits=rescaling,
colormap=colormap,
name=layer_name,
translate=translate,
)
# TODO: Optionally return some values as well? e.g. if info is needed
# by label loading

Expand Down Expand Up @@ -290,13 +292,16 @@ def run(self):
level_path_img=level,
)

# FIXME: Only add if it doesn't exist in the viewer yet
self.label_layers[label] = self._viewer.add_labels(
label_roi,
scale=scale_label,
name=f"{layer_base_name}{label}",
translate=roi_translation,
)
layer_name = f"{layer_base_name}{label}"
if layer_name in self._viewer.layers:
logger.info(f"{layer_name} is already loaded")
else:
self.label_layers[label] = self._viewer.add_labels(
label_roi,
scale=scale_label,
name=layer_name,
translate=roi_translation,
)

# Load features
features = self._feature_picker.value
Expand Down

0 comments on commit b023458

Please sign in to comment.