Misidentified Neighbors, Spurious Border Pixels



I’m a first-time poster on these forums, and relatively new to the CellProfiler software. I use the developer’s version of CP for Matlab (with the image processing toolbox) on a computer running Vista.

I’ve been analyzing images of epithelial tissues, and I’ve had a few peculiar problems with some of CellProfiler’s analysis.

  1. Problem with Perimeters

In the MeasureObjectNeighbors module, I’m getting the output for “Percent Touching” (PT), and most of the time it seems to be accurate. Interior cells are generally identified correctly and are assigned a PT value of 100%. Border cells are also generally identified correctly, with a PT value of <100%.

Unfortunately, though, some interior cells are misidentified as having PT < 100%–often as low as 85%. I think that the problem is the way that some borders are developing “bumps” in the interior of the cells. Essentially, these look like extra pixels that are not representative of the cell membrane itself, but rather are spuriously drawn by CP. Because these pixels are present as part of the cell perimeter, and yet they are not shared as pixels with another cell… I believe this is causing the PT value to register as < 100%.

On the image I’ve attached, you can see the yellow cell marked with an ‘x’ as an example. The cell is clearly an interior cell, and yet PT ~ 85% for this cell due to the extra “bumps” of the cell border.

[attachment=0]CP Forum Explanation.PNG[/attachment]

  1. Problem with Inter-cellular Borders and Neighbor Counts

Again in the MeasureObjectNeighbors module, I’m outputting the values of “number of object neighbors. Each cell is color-coded based on the number of neighboring cells… and this works correctly about 95% of the time. However, some cells are misidentified as having fewer neighbors than they actually do.

As an example, please see the image attached, and look at the green cell #46. This cell clearly has 5 neighbors, but CP is only registering 4 of them. Similarly, the orange cell to its right should have 7 neighbors, but it is only identified as having 6. Something is awry with the border separating the green and orange cells here, and I think I know what the problem is… though I don’t know how to fix it.

It appears that when a border is a perfect “staircase” of pixels (see attached image for an illustration), the border is somehow misidentified by CP. It strikes me as particularly odd that this border is still understood to be a “border”, per se, because these are identified as two separate cells. Moreover, this is all identified as usable perimeter since the “Percent Touching” statistic is reported as 100% for both cells involved here. Yet somehow, this neighbor relationship is not identified.

Now, neither of these problems is an isolated incident. They occur for roughly 1-2% of the cells, and in the statistics I’m trying to compile, that’s significant. Any ideas on what could be the cause of these problems I’m having? Any suggestions on how to fix them?

All help is greatly appreciated. If necessary, I’d be glad to include more images illustrating similar cases.



That is strange. Could you send us an example image and the pipeline you are using to analyze it?

You can send them directly to thouis@broad.mit.edu

Thouis Jones
Imaging Platform
Broad Institute


Thanks Thouis, I’ve sent the email and will await your reply. I appreciate how quickly you responded here!


Thouis, any luck finding the cause of this problem?




Hi Matt,

I have a rough idea of what is going wrong, and hope to get a chance to implement a solution by the end of the week. It should be a pretty simple change, I hope.

Thouis Jones


Thanks, the help is appreciated!


Thouis passed the files you sent on to me.

  1. I could not reproduce the PercentTouching problem: The interior
    cells were always reported to be 100% touching. Are you running the
    most recent version of CellProfiler? The revision number in the file MeasureObjectNeighbors.m (in the Module directory) should be 5025.

  2. I found the problem with inter-cellular borders and neighbor
    counts and (I believe) fixed it. I will send you a new version of MeasureObjectNeighbors.m by email. (The forum software would not allow me to attach it.) Can you please place the file in your Modules directory, restart Matlab and CellProfiler, and see if this solves your problem?



To further clarify Vebjorn’s comment about the version number, if you are running the latest version of CellProfiler (1.0.5122), MeasureObjectNeighbors’s module revision number is 5025. We will release the updated version of this module during our next release.


Thanks guys. I’ve been swamped with work the last few days, but I’ll give the suggestions and the new module a full test this weekend when I run some more images through CellProfiler.

I’ll report back with updates on progress. Thanks again.


Everything seems to be in working order now. Thanks for updating the module!