Groovy script for QuPath
=File : =
{F6296962}
=Code:=
``` lang=javascript
/*
* Script allows differential analysis based on class name
*
*/
// Specify Class Name
def cat1_name = "Tumor"
def cat2_name = "Stroma"
// For Brightflied, if you want to apply new seetings for color deconvolution
// setColorDeconvolutionStains('{"Name" : "H-DAB default", "Stain 1" : "Hematoxylin", "Values 1" : "0.65111 0.70119 0.29049 ", "Stain 2" : "DAB", "Values 2" : "0.26917 0.56824 0.77759 ", "Background" : " 255 255 255 "}');
def qp = getQuPath()
def project = qp.getProject()
{F6296986}
def h = getCurrentHierarchy()
def annotations_array = getAnnotationObjectsAsArray()
annotations_array.each{
// setSelectedObject(it)
//print it
//currentAnnotation_name = it.getName()
setSelectedObject(it)
if ( it =~ ".*"+cat1_name+".*" ) {
print cat1_name
// replace the line below "runPlugin" by the one you can retrieve from Section "workflow"> "Create Script"
runPlugin('qupath.imagej.detect.nuclei.PositiveCellDetection', '{"detectionImageBrightfield": "Optical density sum", "requestedPixelSizeMicrons": 0.5, "backgroundRadiusMicrons": 8.0, "medianRadiusMicrons": 0.0, "sigmaMicrons": 1.5, "minAreaMicrons": 10.0, "maxAreaMicrons": 400.0, "threshold": 0.1, "maxBackground": 2.0, "watershedPostProcess": true, "excludeDAB": false, "cellExpansionMicrons": 0.0, "includeNuclei": true, "smoothBoundaries": true, "makeMeasurements": true, "thresholdCompartment": "Nucleus: DAB OD mean", "thresholdPositive1": 0.2, "thresholdPositive2": 0.4, "thresholdPositive3": 0.6, "singleThreshold": true}');
} else if ( it =~ ".*"+cat2_name+".*" ) {
print cat2_name
// replace the line below "runPlugin" by the one you can retrieve from Section "workflow"> "Create Script"
runPlugin('qupath.imagej.detect.nuclei.PositiveCellDetection', '{"detectionImageBrightfield": "Optical density sum", "requestedPixelSizeMicrons": 0.5, "backgroundRadiusMicrons": 8.0, "medianRadiusMicrons": 0.0, "sigmaMicrons": 1.5, "minAreaMicrons": 10.0, "maxAreaMicrons": 400.0, "threshold": 0.1, "maxBackground": 2.0, "watershedPostProcess": true, "excludeDAB": false, "cellExpansionMicrons": 0.0, "includeNuclei": true, "smoothBoundaries": true, "makeMeasurements": true, "thresholdCompartment": "Nucleus: DAB OD mean", "thresholdPositive1": 0.2, "thresholdPositive2": 0.4, "thresholdPositive3": 0.6, "singleThreshold": true}');
}else{
print "No parameters for this "+it+" class"
}
}
fireHierarchyUpdate()
// Save the measurements using the fileName
//saveAnnotationMeasurements(new File( project.getBaseDirectory(), currentImage_title+".csv").getAbsolutePath() )
def save_file = new File( project.getBaseDirectory(), current_image_title.toString()+".csv").getAbsolutePath()
print("Saving to "+save_file)
saveAnnotationMeasurements(save_file)
```