Filter per_object


is it possible to create per_object filters?

would be a very common procedure for instance to throw away all cells where " nucleus_area < X "

somehow i only get the option to create filters “per_image”…

do i do something wrong in the .properties file?


Hey Tischi,

Unfortunately it’s not yet possible to create per-object filters. This is basically because of legacy code that I’ve yet to have time to update since it’s pretty heavily ingrained. There is, however, a bit of a workaround with the current version of CPA:

Since gates can be used as filters, you can open up histogram, view a per-object measurement that you want to filter and draw a gate that filters the objects in the desired range.

The per-object gate won’t be available for use in classifier.
CPA doesn’t do anything smart if you try to filter per-image (or per-well) data with a per-object gate… basically, I’d expect it to return images or wells that have ANY objects that meet the gate criteria, but I can’t even promise you that until I see the query it builds.

What it’s good for is filtering per-object data in any of the plotting tools or PlateViewer.


PS: if you need to edit the gate bounds by hand, try saving your properties file from CPA (save it as a new name) and then look at the gate definitions stored in there. You’ll probably be able to figure out how to hack it.

Hey Adam,

thank you for the answer!

what i would like to do in the end is

  • using the BoxPlot tool to plot, for instance, the average intensity of all cells that are in the same well (this is already possible using grouping, very nice!!)

  • however, i would like to restrict above analysis to cells, where “nucleus_area > A” AND “nucleus_solidity > B” AND …
    basically only evaluate cells that passed several quality control criteria.

the Histogram-Gate combination is in principle a perfect visual interface to generate this quality control gates, the only issue being that i do not know how to combine different gates…is this possible?

Best, Tischi

Ah, great suggestion (combining gates)! This is definitely something we’re considering, especially in the sense that we’d like to be able to use gates as classifiers and vice-versa.

Anyway, as for your problem, you should be able to hack your way around it by creating gates that define the bounds of your QC criteria, saving your properties file, then looking in the props file. You’ll notice that the gates are stored in a line like this:

You can probably figure out how to combine them by doing something like this:

gates = { u'test': " ((u'per_image', u'ImageNumber'), (128.05098387096774, 235.20449999999994)) ]", u'asdf': " ((u'per_image', u'ImageNumber'), (52.680290322580632, 135.31562903225807)) ]", u'test_and_asdf': " ((u'per_image', u'ImageNumber'), (52.680290322580632, 135.31562903225807)), ((u'per_image', u'ImageNumber'), (128.05098387096774, 235.20449999999994)) ]" }

NOTE: I’ve separated the line for readability but it must be encoded on a SINGLE LINE, so don’t put any return carriages in your gates field.

Give it a shot. If you have trouble figuring it out, you can always send it to me and I’ll try to help.


thanks…i’ll give it a shot…

that works!
would of course be nice if that could be done within CPA in the future :wink:
i am sure it is of general interest to do cell-based quality control based on multiple criteria.

Definitely, I’ve already filed a ticket for it. Shouldn’t be difficult to implement.