Get row and column number in TMA in QuPath

Hi,

I’m probably overlooking something but I cannot retrieve the column and row number of the TMA core I’m analysing. In my TMA, multiple cores have the same name, so to distinguish them I would like to have this information.
So far I tried with

import qupath.lib.scripting.QP
tmaCoreList = QP.getTMACoreList()
for (tmaCore in tmaCoreList){
    tmaprops = tmaCore.getProperties()
    print(tmaprops.keySet())
    print(tmaprops.get('metadataKeys'))
}

And I got a lot of properties:
[editable, level, uniqueID, displayedName, detection, colorRGB, TMACore, ROI, metadataKeys, locked, annotation, pathClass, metadataMap, name, unmodifiableMetadataMap, tile, rootObject, measurementList, cell, class, missing, childObjects, classProbability, childObjectsAsArray, parent]
But not the row and column. metadataKeys is empty.

Hopefully somebody here knows what to do. Thanks in advance!

I’m not sure how/why the names are the same, but would it be a solution to use TMA → Relabel TMA grid to ensure the names are unique?

The row/column number isn’t a property stored within each code (it can’t be, since the core wouldn’t ‘know’ if extra rows/columns are added to the grid), but rather outside it.

You can access it via something like this:

def hierarchy = getCurrentHierarchy()
def grid = hierarchy.getTMAGrid()
print grid.getGridWidth()
print grid.getGridHeight()
print grid.getTMACore(0, 2)

but relabelling would be an easier solution, if it fits your application.

Dear Pete,
Thank you for the very quick answer and of course for the great software you develop. This solves my problem. The reason the names are the same is that they are automatically imported from SlideScore. It gives the name of the original sample the cores are taken from, and often we have three cores per sample.

2 Likes