from @petebankhead
Yes, the object hierarchy doesn’t usually know when the properties of an object change – which is a good thing, because hierarchy updates are expensive.
You do generally need to remove/add an object if its ROI changes, but not if its classification changes.
get's called then and is probably the cause for loosing the hierarchy. we could just disable it for modifications that are not related to the ROI of the pathobject.
Easiest way would be to add a update_hierarchy kwarg to the PathObjectProxy.add which defaults to True and pass update_hierarchy=False to the callback when updating the class.
We should first add a test that reproduces the current issue though.
As reported here:
https://forum.image.sc/t/paquo-detection-path-class-updates-causing-changes-in-hierarchy/101806/5
Solution is likely to be:
The relevant code paths are:
update_path_class
https://github.com/Bayer-Group/paquo/blob/18ae97a3dd73267d0fada0f15e2515affb1201d5/paquo/pathobjects.py#L221-L229
on an existing hierarchy this will call the
_update_callback
. This is set herePathObjectProxy.add
https://github.com/Bayer-Group/paquo/blob/18ae97a3dd73267d0fada0f15e2515affb1201d5/paquo/hierarchy.py#L132-L146
get's called then and is probably the cause for loosing the hierarchy. we could just disable it for modifications that are not related to the ROI of the pathobject.
Easiest way would be to add a
update_hierarchy
kwarg to thePathObjectProxy.add
which defaults to True and passupdate_hierarchy=False
to the callback when updating the class.We should first add a test that reproduces the current issue though.