Positive Cell Detection - Exporting Annotation Results

Good morning, I have a question regarding results obtained from +ve cell detection.

I ran quite a heavy quality control process over my TMA cores then run positive cell detection.
I have an issue with the result table however.
image
And this is what I get:


as you can see the results were correctly shown in first core but in the second one the data is missing.

The only way I could get around it is by clicking on show annotations results
image
The issue is that I have to deal with 1000s of cores and these annotations seem to be listed in a random fashion, meaning that I would have to click on an individual core to obtain result from the table.


I was wondering if there is any way to make the annotation results match the core parameters or any other less time consuming way of getting reults for my annotations.

Hope this make sense. Thanks in advance.

1 Like

I suspect the issue is that when editing the annotations, some have gone ‘outside’ the TMA core. Even a little bit is enough for QuPath no longer to treat the annotation as being in the core.

There’s a discussion on the old Google Group at https://groups.google.com/d/msg/qupath-users/ZPllqoasE6I/FCl-G-LWBAAJ

The ‘preferred’ solution (for the software if not the user…) is to always make sure any annotations you edit remain completely inside the core that they should be inside.

If that’s not feasible at this stage, there can be ways to trick QuPath into doing what you want, but the most appropriate tricks would depend upon exactly which version of the software you’re using.

I am afraid that making sure that the annotations are contained within the circle is impossible at this stage (very time constrained atm…). I am using QuPath 0.1.2, do you think there are any ‘‘tricks’’ available to help with the situation?

With all the caveats about backing up first, checking it does the right thing etc. you could try the following script:

/**
 * Assign an annotation to be below a TMA core based on its centroid location.
 */

def hierarchy = getCurrentHierarchy()
def tmaGrid = getCurrentHierarchy().getTMAGrid()

def unassigned = getAnnotationObjects().findAll {it.getParent().isRootObject() && !it.isPoint()}
removeObjects(unassigned, true)
for (annotation in unassigned) {
    def roi = annotation.getROI()
    def core = tmaGrid.getTMACoreForPixel(roi.getCentroidX(), roi.getCentroidY())
    hierarchy.addPathObjectBelowParent(core, annotation, true, false)
}
fireHierarchyUpdate()
print 'Done!'

It aims to override QuPath’s idea of where the annotations should be relative to the TMA core, and assign instead based on the centroid location.

(I don’t have a TMA right here to test it with, but I remember writing the script for that purpose…)

1 Like

Dear Pete I am afraid the script didn’t work.


This is the script editor:

Hmmm… Did you reopen the TMA results table after running the script?
If so and it still doesn’t work, can you specify exactly what steps you did and in what order?

Yes I did reopen the table.
Here is what I did:
Opened project > workflow > create script
I deleted the script that was there to make a window for your script (as shown below)


Then I copied and pasted the script you posted:
image
Then the following message appeared:
image
Then I reopened ‘‘show the TMA results’’ and sadly 0s still appear

1 Like

Strange… is it possible to show an image of a core for which no measurements appear in the table?

Yes, here are some examples:
image
And yes indeed it seems that annotations are slightly out of the TMA grid

1 Like

Ah ok, tracked down a TMA and can replicate the problem in v0.1.2.

Here is modified script (a true is now a false). Do you have any more success with it?
If you have your data before running the last script, it would be best to use it.

/**
 * Assign an annotation to be below a TMA core based on its centroid location.
 */

def hierarchy = getCurrentHierarchy()
def tmaGrid = getCurrentHierarchy().getTMAGrid()

def unassigned = getAnnotationObjects().findAll {it.getParent().isRootObject() && !it.isPoint()}
removeObjects(unassigned, false)
for (annotation in unassigned) {
    def roi = annotation.getROI()
    def core = tmaGrid.getTMACoreForPixel(roi.getCentroidX(), roi.getCentroidY())
    hierarchy.addPathObjectBelowParent(core, annotation, true, false)
}
fireHierarchyUpdate()
print 'Done!'
2 Likes

Thank you so much Pete, this solved my problem!!!
Really appreciate all your hard work on QuPath.

Have a good day!

1 Like

Great! My memory is returning: when I wrote the script, I was most concerned about point annotations… not detected cells. Another separate script handled locating where exactly the points should be.

Glad the true/false switch is all it took to get the cells ending up in the right place as well.