Overall cell ratio for annotations

43 views
Skip to first unread message

Okan Gultekin

unread,
Mar 14, 2019, 11:03:00 AM3/14/19
to QuPath users
Dear all, 
I have started Qupath for my master thesis. I know a little bit coding but I found coding for qupath little bit rough. Therefore, I have a problem to merge two code, not merging but converting. 
I want to get overall cell number ( in percentage) in annotations, not in TMAs. I found the code for TMA ;

import qupath.lib.objects.PathCellObject
def hierarchy = getCurrentHierarchy()
def cores = hierarchy.getTMAGrid().getTMACoreList()


def list = ["foxp3", "dapi", "CD8", "CD8+Foxp3", "PDCD1", "PDCD1+CD8", "PDCD1+Foxp3", "PC1+fox+cd8"]


cores.each {
    //Find the cell count in this core
   def total = hierarchy.getDescendantObjects(it, null, PathCellObject).size()
   //Prevent divide by zero errors in empty TMA cores
   if (total != 0){
      for (className in list) {
        def cellType = hierarchy.getDescendantObjects(it,null, PathCellObject).findAll{it.getPathClass() == getPathClass(className)}.size()
        it.getMeasurementList().putMeasurement(className+" cell %", cellType/(total)*100)
      }
   }
   else {
     for (className in list) {
        it.getMeasurementList().putMeasurement(className+" cell %", 0)
     }
   }
}

SO, Could you help me to change the TMA parts into annotaions? Thank you for help and all the effort

Regards, Okan

micros...@gmail.com

unread,
Mar 14, 2019, 12:01:00 PM3/14/19
to QuPath users
Ah, don't have a chance to really code right now, but is this the sort of thing you are looking for?

Okan Gultekin

unread,
Mar 14, 2019, 2:36:17 PM3/14/19
to QuPath users
Yes, Exactly! Thank you so much :) have a great day!
Reply all
Reply to author
Forward
0 new messages