Obtaining polygon vertices from Objects

Dear CellProfiler Community

I’d first like to thank the CellProfiler developer team for this great tool and your support on this board. I’m new to CellProfiler and I’m trying to use it besides Matlab to analyze movies from in vivo two-photon calcium imaging. I’m currently implementing Cellprofiler 2.0 to find regions of interest in these movies (@1.48fps, ~1400 frames per stack, currently >250 stacks and increasing), because finding them by hand takes weeks, obviously. I made huge progress in identifying and segmenting the signals, the only problem is the tracking. As I understood it, the implemented tracker just tracks signals from frame to frame and not through a whole stack. So if a signal disappears for a few frames, it is considered a new signal when it reappears. I understand that this tracker wasn’t designed for this purpose, thats why I wrote my own in Matlab. So far so good :smiley: .

But for further analysis in Matlab, I need to get the regions of interest as polygons. Is there a way to get the polygon vertices for each object? Or could you imagine a way to convert an outline image into polygons and their vertices?

Thank you very much for your answer!

PS: Maybe I need to state, that in the end I’d like to measure intensities, etc. from those ROIs over the whole imaging period.

Hi Kim,

Glad you found CP! To your question, there is not a straightforward way to get polygons out of CP (i.e. without resorting to python coding) that I know of. You could use SaveImages to save “Objects” which is the equivalent of a label matrix. (Object #1 has value=1, Object #2 has value=2, etc).

But first, are your cells actually moving relative to other cells or the image boundaries? In my 2-photon experience, at least, they were not. In that case, you could use MakeProjection > MaximumProjection to create a single image for your stack. Effectively, all your cells will be ‘lit up’ all at once. (You could do this in CP, or often a standalone too like FIJI/ImageJ works very well, i.e. fast, for this). Then you could segment the cells in the MaxProjection in a single step in CP (LoadSingleImage) and then load in your whole stack to do MeasureObjectIntensity. You might need to use the Align module to account for at least X-Y translations in the images across the stack. Does this sound like what you need to do?


Hi David,

Thank you for your very detailed answer. I tried the projection in the beginning with Fiji, but it didn’t work out that well. Because the experiment trials are relatively long, there are sometimes many signals that overlay in the projection. I’ll try it again with a better noise filtering (3D-blur is what I have in mind). I’m sure the way you describe is way faster than what I’m currently trying.

I’ll report my progress, thanks again!

I’m back :smile:

So I tried what you suggested and after a few trials it’s working out pretty well. I still have a problem that some signals get masked by artifacts in the projection, but that’s a minor problem.
So, what I’m basically doing is the following: Every stack consists of 5 trials under identical conditions. With help of Fiji I’m now splitting the stacks into 5 substacks, applying a 3D-gaussian blur and then doing a maximum projection. The projected image is then used to segment the signals in a first pipeline and to measure area and shape. The objects are stored in one image for each trial. This is then used to measure intensities in the original substack, that i convert to single images before loading the pipeline (for some reason, CP runs almost three times faster on my computer, when I use single images). I’m pretty amazed, that everything works so far! Thank you a lot! :smiley:

Still, there’s one thing that bugs me. I’m looking at the objects image from time to time to see if there are artifacts in this trial and to match them to the plots that I get from the measurements. Is there a way to store an object-image including the object-labels, so that I know which number corresponds to which object?

Thank you again

Hi Kim,

Glad the analysis is working well for you. Yes, you can write the object number directly onto an image and save that image.
(1) Add a DisplayDataOnImage and choose Object_Number from your object of interest as the measurement to display. An example is here: http://cl.ly/image/2S1h1X2l1m1V
(2) Then use SaveImages to save your image from DisplayDataOnImage (in the example above, called “DisplayImage”).

Hope this helps,