Annotations deleted after cell detection

I stumbled over an issue using QuPath:

  • Have a parent annotation (“tissue”)
  • tissue contains child annotations (“gland” “stroma”)
  • ran the Analyze → Cell detection → Cell detection built-in plugin (via menu and also tried via script) to detect cells in the “tissue” annotation
  • all existing child annotations got deleted - no warning / no questions asked - prior cell detection
  • cell detection worked nicely but “gland” and “stroma” annotations were gone (have backups)
    Now I am wondering if I am not seeing the option to NOT delete existing child annotations or if this is a bug?
    Can I protect the annotations? Do I have to move them “a lvl up” (not really what I want)? Any tips or suggestions welcome (want to automate/work with scripts as much as possible)

Hi @sekro, it’s not a bug, just how it works… without automatic deleting, much worse things could happen (like the same cells being detected multiple times, but without this being visible since they would be layered on top of one another).

The aim is that most of the time, things just work without too much thought – but sometimes you need to adapt the order of operations to fit with this behavior.

Here, for example, can you just run the cell detection before creating the child annotations?

Alternatively, assuming you’re using v0.2 (it was different in earlier versions) the hierarchy isn’t very rigid. You could just not make the gland/stroma annotations children of tissue when cell detection is called, and (if needed) call Resolve hierarchy later.

Finally, you could export the gland/stroma annotations & reimport them later. That currently requires scripting, but commands will be added to do it through the GUI in a later release.


Hi @petebankhead , many thx for your quick reply! You are right I am on v0.2. Your answer pointed me into the right direction. I solved my problem with a script that removes the child objects from tissue prior cell detection and then puts them back afterwards. Script is on github for those who are interested.
Oh and by the way - can’t say it often enough - great software! Many, many thx for all the work you put into QuPath!

1 Like