Qupath - Annotations orientation

Hi there. @petebankhead

I’ve classified my tissue cores in TMAs manually to separate different types of tissues, so when I detect DAB staining, I could also compare the expression in epithelial, connective, and others separately (I didn’t use training for some reasons and did it all manual). For saving my data, I am using both the TMA measurements table and annotation measurements. The TMA measurement table shows the detections, based on the order I have selected the TMAs, but the annotations are randomly distributed in the datasheet, so when I copy them in an excel file, I have to find one by one and find the associated TMA. By any chance, I change the orientation so that it would be in the same order as my TMAs? There is a part in the annotation measurement data sheet called TMA, but it is empty.

Thanks in advance

Hi @sadaffazeli1995 I’m afraid I don’t have time to get into the details of this at the moment – there are lots of other people here who use QuPath and may be able to help, not just me.

I think that a screenshot might be needed, as it is difficult to picture exactly how your cores/annotations are arranged.

1 Like

Sure thanks for your help.

Hi @sadaf,

In this linked this post you’ll see the below script which will fill in the “TMA Core” column of your annotation table. Your use case might be more complex so more info would be good as Pete said.

def hierarchy = getCurrentHierarchy()
def tmaGrid = getCurrentHierarchy().getTMAGrid()
def unassigned = getAnnotationObjects().findAll {it.getParent().isRootObject()}
removeObjects(unassigned, true)

for (annotation in unassigned) {
    def roi = annotation.getROI()
    def core = PathObjectTools.getTMACoreForPixel(tmaGrid,roi.getCentroidX(), roi.getCentroidY())
    hierarchy.addPathObjectBelowParent(core, annotation, false)

print 'Done!'
1 Like

It would help to understand the overall goal of the exported data. If you want cell counts per annotation per TMA core, that would likely require a script that:
For each core:
get all annotations. For each annotation: get a count of all cells (possibly per cell class).
Each of these measurements, add to the TMA core measurement list
Resulting in something like
Core A1: Tumor: Positive Cells - 1375
Or possibly Tumor1, Tumor2, etc if you need separate measurements per annotation.

If an annotation is inside of a Core already, it should have a measurement field called “Parent” that indicates the core as well.

That is just a guess though, as the explanation was not completely clear to me.


Thanks a lot :slightly_smiling_face:

1 Like