Incorrect percentage touching

Hi, developer.

If you load the demo pipeline with the image that I attach, you’ll see the percentage touching in the MeasureObjectNeighbors window is obviously wrong. Could you kindly tell me the cause to this please?

Thank you.
demo.mat (4.22 KB)

This was an error in the display of MeasureObjectNeighbors. Setting the “Expand until adjacent” causes many of the nuclei on the borders to be surrounded by other nuclei, but it was not displaying the correct result of this expansion in the upper right of the figure.

You may want to use “Within a certain distance” with some small value (e.g., 5), instead. This seems to give more expected results.

Hello, thouis,

It sort of work for the image I gave you. When I try what you suggested and set the neighbor distance to 10, it clearly shows that cells at the border has less percentage touching.

However, it wouldn’t work for some other image. For example

The two images differ in that the cell at the border has complete shape. You’ll see in the “Original:Nuclei” display of MeasureObjectNeighbors window. In the previous image, all the cells at the border are considered one nuclei. In the later image, cells are more logically identified. What I’m trying to say is that the later image is what benefit the rest of the analysis.


I’m sorry, I don’t understand what’s going wrong with the new image. It looks like it works correctly. Can you explain what’s different between what you expect and what’s actually happening?

I expect most of the cells in the new image to have 100% touching with neighbors. But the Cellprofiler identifies none of them with 100% touching.

Hi Muyuncai,

I believe you are seeing the same bug reported here (Measure cells at the edge of clumps), which has been fixed in the code but not yet officially released.

A build of CellProfiler including this fix is available from here with the caveats mentioned (take note of the fact that pipelines made with the trunk buld are not backwards compatible).


Oops, sorry. I ran on the trunk when first testing, and saw the weird edge behavior and the wrong display, and thought those were the bugs. I didn’t realize there’d been a different bug fixed between release and current development.

Hello Mark,

Unfortunately, it still doesn’t work. An error pops out, and says:

Traceback (most recent call last):
File “cellprofiler\pipeline.pyc”, line 1343, in run_with_yield
File “cellprofiler\modules\measureobjectneighbors.pyc”, line 546, in display
File “cellprofiler\gui\cpfigure.pyc”, line 826, in subplot_imshow
AttributeError: ColorbarBase instance has no attribute ‘set_ticks’

And the MeasureObjectNeighbor window looks like this when I continue processing.

Hmmm, I don’t seem to get the same error. What was the trunk file name, and can you post the pipeline that generated it?

Also, based on the error message, I think the most straightforward workaround would be to hide the display window for that module (which is, of course, less than ideal… :confused: )