Using metadata to adjust cell detection threshold

Hi Qupath Users,
I am doing a cell detection but my slides have variable intensity of hematoxylin. I have noted a threshold value called “T” for cell detection in the metadata of each image. I would like to use that value, add 0.035 to the value then use that as the threshold for a cell detection. Sorry I don’t know the syntax but the the script will be something like:

x double = getMetadata(T);
y double = 0.035;
z double = x+y;
runPlugin(‘qupath.imagej.detect.cells.WatershedCellDetection’…“threshold”: z, “maxBackground”: 2.0,…;

I’d really appreciate it if someone could help me write this correctly.
Thanks,
Alan

Hi @alk,

Is this what you mean?

// Get the value of 'T' from the entry's metadata (as double)
def t = getProjectEntry().getMetadataValue("T") as double

// Add 0.035 to it
def newT = t + 0.035

// Run the plugin with the new value
runPlugin('qupath.imagej.detect.cells.WatershedCellDetection', '{"detectionImageBrightfield": "Hematoxylin OD",  "requestedPixelSizeMicrons": 0.5,  "backgroundRadiusMicrons": 8.0,  "medianRadiusMicrons": 0.0,  "sigmaMicrons": 1.5,  "minAreaMicrons": 10.0,  "maxAreaMicrons": 400.0,  "threshold": ' + newT + ',  "maxBackground": 2.0,  "watershedPostProcess": true,  "cellExpansionMicrons": 5.0,  "includeNuclei": true,  "smoothBoundaries": true,  "makeMeasurements": true}');

yes thats brilliant! thank you very much!

2 Likes