Removing false positive spots from Qupaths subcellular detections?

Hello everyone.

I have a problem regarding the subcellular detection in Qupath. Basically I have some fluorescence images with in-situ dots in 2 channels. My tissue samples are Lung with quite alot of auto-fluorescence, in combination with some weak signal I get several false positives with my subcellular detections.

The good news is that I have scanned an empty channel where auto-fluorescence is strongly detected. I can use “add intensity features” in my auto-fluorescence channel to add intensities to all my detections. Now I want to remove all subcellular detections with auto-fluorescence intensities above a certain threshhold and then update my cell-detections to the correct number of spots/cell.

Is this possible through a script? I saw Petes warning about adding/deleting spots but that is exactly what I want do do. I previewed my auto-fluorescence measurements and believe removing false positive detections based on the auto-fluorescence intensity should work fairly well.

Image:
bild

Detections:
bild

True Spot Intensities:
bild

False Spot Intensities:
bild

Should be possible with a script, though you will need to calculate new subcellular detection measurements for the parent cells. Guessing that is the warning from Pete, though.

Here are a bunch of scripts and descriptions for how to remove things. And you can make new measurements using the child objects for each cell using variants of these scripts. I’ll take a look in more detail later if I have time, but what you want to do is fairly straightforward.

In case I do have time to look at this later, it would be important to know which version of QuPath you are using. And if it isn’t M4/M5 or 1.2/1.3, you might be on your own :slight_smile:

I’m working in M5.

I’ll take a look at the links you sent and if I make some progress I’ll let you know. Thanks a lot for the help.

I’m still stuck on this one, any help I can get is appreciated. Unfortunately I’m a beginner in both Qupath and scripting.

What I need is a way to loop through all subcellular detections, removing those above a certain threshold of added intensity features. Then updating my cell-detections to the correct number of spots/cell.

Something like this, though you’ll have to edit.

toRemove = []
getCellObjects().each{
    it.getChildObjects().each{ s->
        if (measurement(s, "Subcellular cluster: DAB: Mean channel intensity") > 0.3){
            toRemove << s
        }
    }
}
removeObjects(toRemove,false)
getCellObjects().each{
    sumForCell = 0
    it.getChildObjects().each{ s->
        sumForCell += measurement(s, "Num spots") //or cluster area if you want a more accurate measure of area
    }
    it.getMeasurementList().putMeasurement("Updated Estimated Num Spots", sumForCell)
}

Thanks alot! I will try this out.

Thank you for all the help, I really appreciate everyone helping us beginners getting started. Ended up with something like this in case it might help someone:

toRemove = [ ]
getCellObjects().each{
it.getChildObjects().each{ s->
if (measurement(s, “ROI: 0.32 µm per pixel: FITC: Mean”) > 1000){
toRemove << s
}
}
}
removeObjects(toRemove,false)

getCellObjects().each{
sumForCellCh3 = 0
sumForCellCh4 = 0
it.getChildObjects().each{ s->
def channelName = s.getDisplayedName()
if (channelName.contains(‘Channel 3’)) {
sumForCellCh3 += measurement(s, “Subcellular cluster: Channel 3: Area”)
} else if (channelName.contains(‘Channel 4’)) {
sumForCellCh4 += measurement(s, “Subcellular cluster: Channel 4: Area”)
} }
it.getMeasurementList().putMeasurement(“Updated Estimated Spot Area Ch3”, sumForCellCh3)
it.getMeasurementList().putMeasurement(“Updated Estimated Spot Area Ch4”, sumForCellCh4)
}

1 Like