From 89b2b877d60f42c205a0a175b8ef6f62c6f7c6d3 Mon Sep 17 00:00:00 2001 From: Marcelo Zoccoler Date: Thu, 25 Apr 2024 10:03:48 +0200 Subject: [PATCH] mirror properties and features attributes if they are set before --- napari_skimage_regionprops/_table.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/napari_skimage_regionprops/_table.py b/napari_skimage_regionprops/_table.py index 1c62ead..6ca93b8 100644 --- a/napari_skimage_regionprops/_table.py +++ b/napari_skimage_regionprops/_table.py @@ -34,12 +34,16 @@ def __init__(self, layer: "napari.layers.Layer", viewer: "napari.Viewer" = None) # Check if features and properties are already defined if not hasattr(layer, "features"): layer.features = {} + else: + # Mirror properties to features + layer.properties = layer.features.to_dict(orient="list") if not hasattr(layer, "properties"): layer.properties = {} + else: + # Mirror features to properties + layer.features = pd.DataFrame(layer.properties) if hasattr(layer, "properties"): self.set_content(layer.properties) - elif hasattr(layer, "features"): - self.set_content(layer.features.to_dict(orient="list")) else: self.set_content({})