Hi everyone,
a colleague and I have used this script for a long period of time, but with the recent updates it gives us the error “ERROR: It looks like you have tried to import a class ‘qupath.lib.objects.classes.PathClassFactory.PathClasses’ that doesn’t exist!” - In version 0.1.2 it is still functioning. With the most recent one, we are at a loss how to make it work again.
Cheers & thanks, Julia
import qupath.lib.gui.QuPathGUI
import qupath.lib.scripting.QP;
import qupath.lib.objects.classes.PathClassFactory.PathClasses
import qupath.lib.objects.classes.PathClass
import qupath.lib.objects.classes.PathClassFactory
import qupath.lib.projects.ProjectImageEntry;
String outputFilepath = "F:\\Projekte\\xyz\\outputData.tsv"
Map countDetectionObjects() {
def countMap = [:]
for (pathObject in QP.getDetectionObjects()) {
def pathClass = pathObject.getPathClass()
def count = countMap.get(pathClass)
if (count == null)
countMap.put(pathClass, 1)
else
countMap.put(pathClass, count + 1)
}
return countMap
}
void printData(String sampleName, List orderedHeader, Map countMap, File file) {
file << "\n"
file << sampleName
orderedHeader.each {
file << "\t" + countMap.get(it)
}
}
File outputData = new File(outputFilepath)
PrintWriter writer = new PrintWriter(outputData);
writer.print("");
// Get QuPath & viewers
def qupath = getQuPath()
Map countMap = countDetectionObjects()
List orderedHeader = new ArrayList(countMap.keySet())
outputData << "filepath"
orderedHeader.each {
outputData << "\t" + it
}
// Get the current project
def project = qupath.getProject()
List<ProjectImageEntry> myImages = project.imageList
def viewer = qupath.getViewer()
javafx.application.Platform.runLater({ ->
myImages.each { ProjectImageEntry myImage ->
qupath.openImageEntry(myImage)
printData(myImage.serverPath, orderedHeader, countDetectionObjects(), outputData)
}
})