Elastic Grid


I’ve been counting cells on sagital slice from mice cortices and I’ve been tinkering with the grid modules.

I need to count the cells in distinct regions of the cortex and I can manually create a mask for every image, defining the subregions of every slice. With relateobjects I can later know which cell counts belong to which regions, but It becomes rather complicated for large amounts of slices. So i turned to grids.

The Grids are all made of equal squares or rectangles, but i would need to make elastic or adaptive grids according to some criteria, i.e. divide the mask in 10 vertical strips where the width of each one is always equal to the masks width along the vertical axis. Or some other automatic elastic fitting of grids into the mask that takes into account the masks form.

Another way of putting it would be analysis of spacial relationships other than the distance from centroid to centroid or centroid to edges in the relateobjects module. It could be measurement of the distance of any cell to another object, not necessarily a parent object, like a line or a spot somewhere else in the image. This would also help the analysis of the effect of gradients on the morphology of cells.

Any ideas?

Thank you very much,

Best Regards,


Hi Roberto,

As you note, CellProfiler isn’t equipped to handle adaptive/elastic grids, and don’t currently have plans for adding that capability in the future. However, one option is to see if there exists an ImageJ plugin that does what you want. If so, you can use the RunImageJ module to run ImageJ with a macro of our design and have ImageJ do the operation and return the result.

The main limitation to this approach is that CellProfiler can only receive images back from ImageJ, so some additional work would be needed to format a putative plugin’s output correctly.


Hi mbray,

I’ve looked it up on the ImageJ plugins page, but nothing was found. I’ve dealt with it using Matlab. It’s a pitty I can’t program in Python or CP isn’t matlab anymore, or else I’d try to integrate it into the a module.

Do you have a page with Matlab scripts for dealing with CP data? I could post it there for other people who might need it.

Thanks again!



You could post your scripts as part of this thread. Alternately, you could upload it to MATLAB Central’s File Exchange.