How to make CellProfiler modules run more conditional?

Hi,
The diversity of the objects in my images can be very large (e.g. detection of fruits). That’s why the object detection not always works for all objects. Sometimes I try to overcome this by adding a Flag module to check whether an object is detected or not or it meets some criteria. I can skip the image (if the object is well detected in the first part of the pipeline) or run the last part of the pipeline for objects which are more suited for this type of analysis (the last part of the pipeline after the flag). I have to overwrite the results (mostly an output of saved images) for images which pass the flag criteria.

This is quite an awkward way of running a pipeline. It would be much nicer if it would be possible to run parts of a pipeline based on measured criteria. I mostly use the ClassifyPixels module. It would be nice to use different Classifiers based on some criteria. I know that CellProfiler is not provisioned to work like this but maybe you have any suggestions for me or are there chances that in the future CellProfiler will get such capabilities?

Regards, Peter

Hi Peter,

This sort of if/then conditional execution is an interesting idea, and we internally have discussed this in the past. Our lead software engineer says though: “A feature like this imposes a bit more of a development burden than we can undertake right now.” This would break open CP’s linear pipeline structure, though we do of course understand the benefits of conditionals or sub-loops, which we often just run multiple pipelines to accomplish goals like illumination correction, Z-Projections, etc.

We could instead suggest Knime (knime.org) which might be a better tool for this sort of if / then problem. Knime has a visual graphical UI that allows more complicated connectivities, and also integrates with CellProfiler (http://www.cellprofiler.org/interfaces.shtml and https://tech.knime.org/community/cellprofiler; and for the developers: https://github.com/CellProfiler/knime-bridge). Let us know if you try this out, and good luck!

Hi,
I may not be following your question, properly, Peter, but my first thought was why not use the concept of separate object names for different branches of your pipeline? That is, objects that pass some filter are named “GoodObjects” and those that don’t are “BadObjects”, then downstream modules do whatever you want to do on either one object type or the other. Does that suit your situation?
Anne

Hi Anne,

Thank you for your suggestion! It may work for some circumstances (nice to have an alternative like this) but not, I think (or not straight forward) in my projects:

I have 2 different examples:

  1. In one case I try to detect a Petri dish and use this as a mask to look only inside the Petri dish for objects to count. In some pictures I’m not able to detect the Petri dish properly because of slight different lighting or a small part of the edge of the dish is beside the image. In this case I have no Dish object and so no analysis of the objects.

To overcome this I first try to reconstruct part of the dish by detecting objects in the dish and use the Morph module for Convex Hull.
It looks like this:

  1. Detect objects ‘A’
  2. Reconstruct part of dish (object ‘Dish1’) based on objects ‘A’ in dish
  3. Mask image based on object ‘Dish1’
  4. count objects ‘A’ in masked image
  5. Detects Petri Dish (object ‘Dish2’)
  6. Flag: if Petri ‘Dish2’ count == 0 -> skip image
  7. Flag: if Petri ‘Dish2’ count == 1 -> count objects ‘A’ in image with ‘Dish2’ as mask

The preferred method is the counting of object with Dish2 as mask because of reflection of objects ‘A’ in the Petri dish edge. I erode this edge to remove the reflection.

  1. In the other example I have a large diversity (mostly color) of fruits. I try to detect some parts in these fruits by Classify Pixels but it only works well with specific classifiers for each of the type of fruit.
    I was thinking on first detecting the type of fruit based on color and then use the proper specific classifier.
    Don’t know how to fit this in your suggestion of ‘GoodObjects’ and ‘BadObjects’.

David also gave me a suggestion to use KNIME. I’ll give this a try. Hope it works for CellProfiler in combination with the Classify Pixels module.

Regards,
Peter