How to batch extract cell detection data from multiplex stained TMA?

I am working with a TMA image with multiplex IF staining with 3 immune markers. I want to get the number of cells expressing each markers in both stromal and tumor region seperately. For that, I annotated the tumor and stromal region for all the cores in the TMA and used object classification for detecting each different markers. But I cant find a way to extract numbers of each markers in the annotated region for all the tma cores together. I can only see the data in the annotation bar by manually selecting the annotations for each core separately which is really time consuming. Is there a way to batch extract all the data for all the tma cores together ?
It will be of great help if anyone can provide solution for this. Thanks!

If you like coding magic, take Pete’s script from about an hour ago and change it to cell detections.

    .countBy { it.getPathClass() }
    .each { println "${it.getKey()}\t${it.getValue()}" }

If you want to print it out to a CSV file, you may need to look up how to do that, but that will be standard groovy and not QuPath specific.

If you want it separated by annotation region, you may need to split things up even more, for example:

tumorCells = getCellObjects().findAll{it.getParent().getPathClass() == getPathClass("Tumor")}
tumorCells.countBy { it.getPathClass() }
    .each { println "Tumor: ${it.getKey()}\t${it.getValue()}" }

And similar for other classes. Or you could write the script to cycle through all classes. Maybe there is magic to combine all of that together as well.

1 Like