Matlab Module on CP 2.0


I’ve got a matlab module I’d like to try and use on Cell Profiler 2.0 and would be OK with the loss of speed mentioned here (for now): … ATLAB-(1.0-to-Python-(2.0)

I was just wondering what the steps were to get CellProfiler to recognize my matlab module? I’ve tried putting it in the plugins folder but it doesn’t show up. I could eventually convert it but I’d rather just make sure first that the results are interesting!


Hi James,

Oops, that page is ridiculously out of date. We no longer support MATLAB integration in CP. If you still want to use your module, you have two choices:

  • Fall back to CP 1.0.
  • Post your module here so we can take a look and see if it’s readily portable into Python.

Sorry for the confusion :confused:


Hi Mark,

Thanks for the quick reply. The module was written by Berend Snijder in the Pelkmans lab and does some cool stuff do with population context analysis:
I don’t have much experience porting to python but if you think it’s easily doable I’ll give it a shot!


Mark and I were discussing the measurements made by the Matlab code and I am wondering whether it makes sense to implement similar measurements in CellProfiler instead of replicating the MeasurePopulationContext code as a piece. For instance, we could the Ripley K function which calculates the density of cells within a given radius, normalizing for total cell density. Similarly, a measure of distance to an edge would find a broader use if the inputs were the edges in any binary image (for instance, the output of ApplyThreshold) and any object set.

Population density is a very easy measurement to compute and one that would be appropriate to add to MeasureObjectNeighbors. Distance from an edge is also easy to compute, but I am less sure where it would be added - it could be a supplementary module in the plugins directory. Some of the other parts of the Matlab code are very difficult to implement in the context of CellProfiler - there is code that determines the microscope meander pattern to stitch all images in a well together and that might be specific to their setup or work under only certain conditions.

Which of the measurements output by their module would be the most use for you? I wouldn’t mind writing code for a measurement or two as a plugin with an eye to later integration.

Sounds great (I’ve also spoken to Berend and he thinks this is a good idea too).
The most important measurements for me would be the local cell density and the knowledge of if a cell was an edge cell (and I suppose, though not as important it would be cool to know the number of cells between a cell and its closest edge).

I’m actually next door in the Whitehead if any of this would be made easier by me coming over for a chat (plus I’m a big fan of Cell Profiler so would enjoy talking to the people who made it haha).

It would also be better if (like in the module) - local cell density wasn’t normalized but was an absolute value so that comparisons between wells and other images could be made easily.


I’ve implemented a module that you can put in your plugins directory (go to File/Preferences… in the menu and look for “CellProfiler plugins directory” to see or change the location). It calculates three things: count of neighboring cells within a given radius, the Ripley K function which is a measure of local density of cells relative to the density within the image and distance of each cell from the edge of a binary mask, such as of a wound. The first two are easy to use. The edge measurement’s mask is just slightly difficult to create. I have an example pipeline for the wound-healing image set that comes with the example pipelines. I smooth the image with a large scale (100 pixels in the case of the wound healing) and use the ApplyThreshold module to create a mask that is positive for the tissue region and negative for the background (it doesn’t matter which is positive and negative - the algorithm identifies the border and measures from there).

In any case, attached are the module itself (“”), a PDF snapshot of the output for the wound healing pipeline and the pipeline to use with the wound healing image set. (13.8 KB)
popcontext.pdf (72.9 KB)
popcount.cp (8.36 KB)

Thanks Lee, I will give these a try!

Hi, have these modules (e.g. Ripley’s K function) been implemented in the latest version of CP? I can’t seem to find where they have been added. Thanks for the help.


No, this module was never a part of the official release of CP so hasn’t been kept up to date. You might check with the Snijder and Pelkmans lab, as they may have made a current version. Or, if you are inclined you might try to update the code yourself and contribute to the project!

Great. Thanks for info.

1 Like