How to run cell detections only for parent path class?

In the given below image there are multiple annotations(1 parent annotation and 2 child annotations) are available. I want to run a cell detection plugin only for parent annotation but when I run the below code in groovy script, it will just remove the 2 child annotations and found the nuclei cell detections for whole parent annotations.

QP.runPlugin('qupath.imagej.detect.nuclei.WatershedCellDetection', '{"detectionImageBrightfield": "Hematoxylin OD", "requestedPixelSizeMicrons": 0.5, "backgroundRadiusMicrons": 5.0, "medianRadiusMicrons": 1.0, "sigmaMicrons": 1.5, "minAreaMicrons": 10.0, "maxAreaMicrons": 400.0, "threshold": 0.1, "maxBackground": 2.0, "watershedPostProcess": true, "cellExpansionMicrons": 5.0, "includeNuclei": true, "smoothBoundaries": true, "makeMeasurements": true}');
How can I collect only the nuclei’s of between parent annotation and outside of child annotations?
It should not affect the child annotations.

Help me to fix this issue.
Thanks in advance.

The outer annotation includes all of the area within it, so the current behavior is correct. If you want to avoid those areas, you need to make holes in the outer annotation by subtraction.

  1. Select an inner annotation
  2. CTRL+Click to select the outer annotation as well
  3. Right click for context menu in an annotation, select Annotation->Subtract
  4. Repeat for second internal annotation.

Alternatively, you can get into scripting and subtract all of the ROIs, but how that works is highly dependent on version, and covered a bit in other forum topics.

Another way to accomplish the same thing is using the brush or wand tool to subtract areas from the parent annotation by holding down the ALT key while drawing.

Thanks for the explanation. If possible can you tell me that how can I achieve this through groovy script?

Again, it depends on version, but if you search the forum, there are threads like these two concerning areas and intersecting them.

Lots of cross linking in those as well. The thread on Reduce Annotations also has some detailed scripts.

Thank you very much @Research_Associate. This one helped me

I am using the QuPath version 0.1.2.

I have another doubt, Is it possible to run simple tissue detection command using groovy script only for selected annotation instead of whole image?

In the given screen shot, the annotation is selected and I want to run the below command only for that selected annotation.

QP.runPlugin('qupath.imagej.detect.tissue.SimpleTissueDetection2', '{"threshold": 210,  "requestedPixelSizeMicrons": 20.0,  "minAreaMicrons": 10000.0,  "maxHoleAreaMicrons": 1000000.0,  "darkBackground": false,  "smoothImage": false,  "medianCleanup": false,  "dilateBoundaries": false,  "smoothCoordinates": true,  "excludeOnBoundary": false,  "singleAnnotation": true}')

No, that is run on the whole image. The closest you could come would be using an ImageJ script, or my tissue detection script (described in the earlier part of this post). While not really intended for brightfield, if you play around with the RGB channel values enough, you might be able to get it to work.

Another option would be exporting that ROI to ImageJ, saving it as a TIFF, and then importing it back into QuPath. At which point (assuming you set the metadata correctly when saving the TIFF) you could run your analysis on the “whole image,” which is now only that rectangle.