napari-clusters-plotter
napari-clusters-plotter copied to clipboard
bug - Manual_Cluster_ID can go missing with feature as color and Surface Data
This probably is somewhat of an edgecase but I found that if you:
- use the cluster plotter and select a feature to color the plot,
- then delete the layers for which the plot was made
- load Surface data with new features
This causes the "Manual_Cluster_ID" column to go missing from the dropdown and you cannot manually annotate labels again until you close and reopen the plotter -> the Reset button does not fix this. I guess this has something to do with the fact that for surface data we have to hard code the features instead of loading them with the viewer.add_surface() function. I guess there is some kind of event that is being skipped because of this
Hi @Cryaaa woah, good catch! Your hypothesis is probably on point - surface_layer.features is currently only tolerated but not really supported. In other words, viewer.add_surface(surface, features=...) won't complain if it receives features and will put them into the layer.features but it probably also doesn't hook up other functionality such as events.
Maybe we could add a little extra statement in the reset button that inserts the MANUAL_CLUSTER_ID if it's not present?
Edit: Just did a little digging and I think from the napari side it's fine as this is now fully supported. Will check!
Edit2: Maaayyybe the underlying problem here is that the clusters-plotter doesn't clean up behind itself properly in case every layer is removed from the viewer. I can reproduce the problem with any sequence like this:
- Use clusters-plotter on layer A
- close layer A (but not the plotter
- open new layer B --> coloring messed up
Edit2: Maaayyybe the underlying problem here is that the clusters-plotter doesn't clean up behind itself properly in case every layer is removed from the viewer. I can reproduce the problem with any sequence like this:
- Use clusters-plotter on layer A
- close layer A (but not the plotter
- open new layer B --> coloring messed up
Actually for me it works fine if the new layer that is added is a points or labels layer. It just snaps back to what it was if reopening the layer or resets when adding a new layer type. For me it's just the surface layer which messes up.
Maybe we could add a little extra statement in the reset button that inserts the
MANUAL_CLUSTER_IDif it's not present?
I think this would definitely be the best approach because it was also my first instinct to use it when realizing the bug so I guess other users might use it similarly
I was able to identify a bunch of related issues. For instance, if you
- add some layers
- do some clustering
- delete the layers
- click reset
- Segfault 😞
#379 should fix it a bit more globally 👍