QuPath SetCellIntensityClassifications several measurements as criteria for positivity

Hi everyone

I’m trying to set a detection classification for positive vs. negative, combining 2 criteria (for example “Cytoplasm: DAB OD mean” > 0.25 AND “Nucleus: Hematoxylin OD mean” > 0.3). So any detection which meets both of these criteria should be classified as “positive” and any detection meeting none or just one should be “negative”.
I was using the follwoing script for classification based on 1 measurement:

setCellIntensityClassifications(“Cytoplasm: DAB OD mean”, 0.25);

I’ve read this post (QuPath Multiplex Classifier) however I don’t really want to create a multiplex classifier but rather just need to link two criteria for positivity in detections. (I’m currently still using QuPath 0.1.2 as I’ve started a big project there…)

I’d highly appreciate some help and ideally a script :slight_smile:
Thanks!

I got a hint and found all kind of helpful scripts on that topic (including answering my question) here, just for your information:

2 Likes

and in case of a previously applied detection classification (that is overwritten by the “simple cell classifier” from above) creating a new measurement is a solution:

// set custom thresholds
def th1 = 0.15;
def th2 = 0.2;
def th3 = 12;

for (detection in getDetectionObjects()) {

    // choose custom measurements
    double ch1 = measurement(detection, "Nucleus: DAB OD mean")
    double ch2 = measurement(detection, "Nucleus: Hematoxylin OD mean")
    double ch3 = measurement(detection, "Nucleus: Area")
    double pos = -1
    if (ch1 >= th1 && ch2 >= th2 && ch3 >= th3) {
        pos = 1
    }
    else {
        pos = 0
    } 
    detection.getMeasurementList().addMeasurement("Positive", pos)
    detection.getMeasurementList().closeList()  
}   
fireHierarchyUpdate()
setCellIntensityClassifications("Positive", 1);
print("Done!")
2 Likes