Have Filter Objects use a user calculated threshold value

Hi,

I would like to filter objects based on a threshold determined by Otsu’s method. Or at a minimum I would like the Filter Objects module to use a number that I provide in a file or something. I’m trying to modify the Filter Objects module because I would like it to save the object outlines the way it normally does so I can see how well the threshold works.

The reason I would like to do this is that for my application the optimal threshold moves around a bit due to the biology and imaging conditions. Using a fixed number isn’t very helpful.

I’ve managed to get a development version of CP open within wingIDE. Ouch. I can put a breakpoint right within the Filter Objects module at line 345 ( def run(self, workspace) ) code, but even though I see all the variables in memory and can load a value from a text file I have no idea where I should pass my new number.

I see that I could load some data with the LoadData module, but it doesn’t look like the Filter Objects would have access to that.

Any suggestions, including a better way to approach this problem, are welcome.

Thanks in advance! John

Hi John,

Assuming that you are trying to use an intensity threshold (whether it is per-object or per-image) and you have already made intensity measurements on the objects (let’s say “Nuclei” for the sake of argument) in question, you can filter them based on it using the following approach:

  • Using CalculateMath, subtract the intensity-based threshold from the appropriate intensity measurement for the Nuclei. Note that whether the threshold is an image or object measurement, the result gets stored with the Nuclei measurements.
  • Using FilterObjects, select Nuclei as the object, the Math measurement as the category and select the name you gave it. You can then use 0 as the min or max permissible value, depending on whether you want to filter objects with intensities above or below the threshold.

Note that you can use Metadata in CalculateMath, originating from a csv file or elsewhere. Also note I’ve assumed an intensity-based filtering, but this approach should work with other types of measurements.

Regards,
-Mark

Hi Mark,

Thanks for the reply. I’m not seeing how I can do an ‘ApplyThreshold’ on objects. That module seems to only take images as input.

I’ve taken a different approach where I just replace the value in the pipeline and run CP in a loop calling it once for each image set and then finding and replacing the value in the pipeline before each run. I’ll post my python code for that as soon as I’ve got it all working. In case anyone cares. Unfortunately I’ve run into a bug in the OverlayOutlines module (see recent post to that regard).

-John