I’m having a bit of trouble with expanding and setting to the class of the greatest intersection. Currently, I can select objects below a certain size threshold, and assign them to a class:
import static qupath.lib.gui.scripting.QPEx.*
////////
//Variables to set
max_object_size=20000 //Max size of annotations to reclassify, in micrometers
class_name='Tumor' //class to set small objects to
////////
//get resolution
double pixelSize = getCurrentImageData().getServer().getPixelCalibration().getAveragedPixelSize()
//convert micrometer area into pixels
size_thresh_pix=max_object_size/Math.pow(pixelSize,2)
//select small annotations
def smallAnnotations = getAnnotationObjects().findAll {it.getROI().getArea() < size_thresh_pix}
//reclassify all small objects to this class
def selected_name = getPathClass(class_name)
smallAnnotations.each {it.setPathClass(selected_name)}
//Merge all objects of same class (optional)
//annotations = getAnnotationObjects().findAll {it.isAnnotation() && it.getPathClass() == getPathClass(class_name)}
//mergeAnnotations(annotations)
The reason I’m trying to do this is to measure:
- the area of necrosis in the image. The pixel classifier I’m using to generate the annotations yields small fragments of misclassifications throughout the image (even at the lowest resolution listed in the drop-down menu)
- mean intensity of DAB staining in the viable tumor area
Given that others haven’t made similar posts, I feel like I’m missing something… Is there a way to set the resolution for a pixel classifier to a value not listed in the drop-down menu? Or is this a case for using superpixel segmentations?