Skip to content

Commit

Permalink
mirror properties and features attributes if they are set before
Browse files Browse the repository at this point in the history
  • Loading branch information
zoccoler committed Apr 25, 2024
1 parent dd48037 commit 89b2b87
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions napari_skimage_regionprops/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({})

Expand Down

0 comments on commit 89b2b87

Please sign in to comment.