IdentifyPrimaryObjects Threshold per object



Could it be that the “per object” threshold option disappeared in CellProfiler3.0.0 ?


Being terribly tacky and quoting myself:

The removal of per-object was never meant to be permanent; the option was removed because we were not convinced the previous implementation actually worked properly so we wanted to write a new version. If you have a pipeline plus sample images for 2.2 that convincingly demonstrates otherwise, I’d be interested to see it- it means our previous implementation DID actually work and doesn’t need to be rebuilt, which will get it into 3.0 a whole lot faster.


oh, I see, I always used it and it appeared to work…I never really tested it mathematically.
I guess you just have to make sure that only pixels inside the cell objects are taken into account for the threshold algorithms. Couldn’t you simply see in the python code if that is the case?


If you have some example images and a pipeline that you think would be helpful, we’d be happy to take a look :slight_smile:


Just discovering exactly the same issue. I have a pipeline that uses this to identify objects within previously identified objects. I always thought “per object” worked much better than any other threshold strategy (at least that’s the only one for which I managed to get satisfactory identifications). When the background within each object is very variable, the global strategy obviously fails, and the adaptive fails also since objects with different background can be very close. In a way, wasn’t the “per object” strategy like an adaptive strategy, with the difference that the “adaptive window” of the “per object” strategy could be defined more specifically than just by a square of a given size? Please let me know how to share images and pipeline, I’d be very interested to keep this one (if that’s as useful as it seemed to be of course). Something like this:


Pull together the pipeline plus an image set then you can either

  • Zip the files and upload them here
  • Upload them to GoogleDrive/Dropbox etc and post a link here.

We’d really appreciate it!


Sure, see below the link. Let me know if you need anything else and when you finished the download so I can close that door.



I have a plugin computing a local per object threshold level, using a Component tree representation to compute the levels that give the maximum ellipse fit for each object. You can download it from

For more details see:
Petter Ranefall, Sajith Kecheril Sadanandan, Carolina Wählby
International Symposium on Biomedical Imaging (ISBI’16), Prague, Czech Republic, April 13-16, 2016


Hi Alex,

Haven’t had a chance to look at this yet, and I definitely recommend checking out Petter’s plugin, but I have downloaded the files if you want to take them down.


Hi Petter,

I was delighted to see this module available, however I have been unable to see it in my list of modules after putting it into my CellProfiler plugins folder. All of my other plugins show up fine except this one.

Any thoughts on how to rectify the issue?



Hi, thanks for the suggestions, that would be quite brilliant. I have the same issue as Luke though, I can’t seem to see the module available at all. If I only copy the in the plugin folder as the other plugins, I get this (I can’t see a new module PerObjectEllipseFit either):

Could not load PerObjectEllipseFit
Traceback (most recent call last):
File “CellProfiler\cellprofiler\”, line 321, in add_module
File “C:\Program Files\CellProfiler3\Plugins\”, line 11,
import _perObjectEllipsefit as poe
ImportError: No module named _perObjectEllipsefit
could not load these modules: PerObjectEllipseFit

If I copy all the files of the ZIP file from the link to the plugin folder I get this (but still can’t find the module):

Traceback (most recent call last):
File “CellProfiler\cellprofiler\”, line 321, in add_module
File “C:\Program Files\CellProfiler3\Plugins\”, line 26, in
AttributeError: ‘module’ object has no attribute ‘addsitedir’
could not load these modules: setup

Any suggestion would be great!


(on a side note, I am not very sure the “search” function in the “Add module” menu actually works, insofar as it’s meant to search modules by name)

PPS: The module somehow miraculously appeared, not sure what changed. Luke, you might want to look into Add modules / Image Processing instead of Object processing actually. That’s where the PerObjectEllipsefit module is available.


Hi Alex,
You need to copy all the files from the zip to the plugins folder. I should have mentioned that at the moment I have only compiled versions of _perObjectEllipseFit for Windows (.pyd) and for Linux (.so), but no version for Mac.


Hi Petter,

Indeed, all files need to be included for it to work. I had tried with only one first but had realized it wouldn’t work from the error messages from CP. I still do not understand what finally made it work, but it does work, and very nicely actually.

More generally for perhaps a future CP update, it would be absolutely brilliant if this could be implemented in the Identify primary object module, so it’s also possible to adjust / filter the results using all the different additional parameters like threshold correction factor, object split and so on. There are way of working that out after the perObjectEllipseFit, but that would make things much simpler!



So after playing with Alex’s pipeline, once I removed the minimum threshold set I can confirm there was a small difference (353 foci vs 360) in the Global vs PerObject foci detected. I’ll pass that on to the software team and see what we can do about restoring the functionality.