Changing annotations name based on class of the cells detected into this annotation


I have been using qupath for a few weeks now and It’s really helpful and a time saver in term of image analysis. I am analyzing multiplexed images. I use a pixel classifier to isolate blood vessel and create CD31 annotation based on this classifier. I wanted to know if it is possible to change the name of an annotation based on the class of the cells detected into this annotation ? For example if I have CD31 annotation containing cells classified as either CD31+ or CD31+Sox17+, would it be possible to name all annotation containing at least one Cd31+Sox17+ cell, Cd31Sox17 instead of only CD31 ?

thank you !

Yes, you can use annotation.setName(“String”)

The logic would be up to you, but a sample script might look like:

cells = it.getChildObjects()
    flag = false
        if(cell.getPathClass() == getPathClass("CD31+Sox17+")){flag = true}

I winged that, and it may contain typos or other errors, and you will definitely want to change the logic and variables, but it should get you started.

1 Like

This isn’t guaranteed to work; there might be overlaps between annotations (for example) that mean getChildObjects() isn’t trustworthy.

Replacing those lines with the following should behave better:

def hierarchy = getCurrentHierarchy()
getAnnotationObjects().each {
    def cells = hierarchy.getObjectsForROI(null, it.getROI()).findAll {it.isCell()}