Neurite analysis

Hi guys,

I’ve worked a couple of hours on a pipeline to analyze neurites branching off, and I’d like to share it.
It still needs a bit of tweaking, but I think I’ve brought it a good way through.

I just got some questions to get me going:

  1. How do I get rid of the speckles and spots without erasing the neurites? Even using tubeness or a tophat, they are still there, and when they touch the neurite, they generate a lot of branches when I skeletonize the image afterwards. I have thought of running an erosion on the tubeness image, afterwards IdentifyPrimaryObjects, filtering out all the small objects whose FormFactor is near 1, or which are very small, and later running a dilation/closing to stitch my objects back together again. I dont know why, but it felt rather clumsy to me. I’m sure there must be a better way.

  2. When I run MeasureNeurons with the neuron graph relationship, it’s always giving me the same error:

Traceback (most recent call last): File "/Applications/", line 309, in run File "/Applications/", line 350, in run File "/Applications/", line 675, in make_neuron_graph File "/Applications/", line 3648, in pairwise_permutations File "/Applications/", line 156, in __getitem__ File "/Applications/", line 259, in __getitem__ File "/Applications/", line 197, in check_bounds IndexError: index (24) out of range

  1. The output of MeasureNeurons (i checked it on another pipeline, where it worked ok) doesnt give the angles of the branches when they cross or branch off, or if its a 3 or 4 branch point. This is precious information if you want to know whether the neurites just passed around each other, or if it’s a real branch. There are so many cross-overs that I have to flag, or else I won’t get the real distance of the neurite before the next ‘real’ branch. Should I work on python , extending the module, write an ImageJ script, or you know any better option? Pruning branches would be another important aspect.

  2. Any other suggestions are very welcome! Pipeline and images attached. I haven’t found a ready to use pipeline for this analysis elsewhere in the forum or in the examples area in the cp website. Have I missed something?

Sorry if it got too long for a single question =)

Thanks in advance!

Roberto (1.96 MB)

Hi Roberto,

Lots of good questions!

These images do have a lot of spots. If at all possible, try removing them on the biology side before image analysis (if they are debris or contamination). Otherwise you can try and use the Smooth module to filter out objects the size of a typical spot, but you will likely remove some neurites as well. Another thought is to try EnhanceOrSuppressFeatures and suppress around the size of the spots, but I fear the same problem of removing neurites by mistake. You can also try identifying the round spots with a Circular Hough filter (“Circles” in EnhanceOrSuppress), subtract off this image from your Tubeness image.

By the way, you can implement Tubeness within CellProfiler by using the RunImageJ module (doesn’t work on a Mac yet, though).

This error with the graph relationship output is fixed now, so to use this before the next release (not any time soon, I’d say) you can use the newest Git revision
or try the bleeding edge compiled versions: … TrunkBuild

That is correct, and it is in our plans to update this module with this sort of information. However note that separating crossings from branchings is not an trivial problem, even with this extra information. But if want to give a crack at it, by all means! You can contribute code to Github and we can check it over.

Yes, creating an ExampleNeurons pipeline is on my personal todo list, since I have worked on a number of neuron projects. However, there are about as many neuron pipeline variants as neural cell types! So this makes an example pipeline of more limited use. But I will put up something in the not too distant future.

It looks like you have come a long way so far. Another thought, though it may not be possible for you I realize, is to use dapi to mark the nuclei and this would simplify your pipeline a lot, as I read it. I have spent a lot of time using open or other morphological operators to define some, but a nuclear marker is worth gold for this purpose.


Hi David,

Thank you for your quick reply ! I’ve tried following up on your hints.

The debris are products of dead cells, and I should quantify them, too. They are an integral part of the experiment, so i cannot get rid of them so easily on the biology side. As you wrote, the smooth and supression methods all erase the neurites as well. This spot erasing is a tough one. The Circular Hough filter gives me an Image with big circles wherever I had a spot, but they are hard to filter from the smears left by the neurites when I apply the Hough filter. Help!

I come from Matlab, and it’s been surely hard to install the correct version of Python with all the dependencies and run the developers version of CellProfiler on my Mac. Should i consider developing on PC, because of installation ease?

I’ve read through the MeasureNeurons module in python, though, and it’s amazing how much you can do with so little coding. i’ve been tinkering around with a script to measure the branch angles and so forth to flag crossings in Matlab. I can tell you i need a lot more coding in Matlab.

I’ve had some ideas on how to detangle the neurons, and it’s actually some basic stuff already in CellProfiler, but not available for this operation. Basically using the intensity measurements on the neurites to profile them. Whenever you have a crossing, connect those branches that are most similar. And if you use the angle information, too, and weigh these two things out, It should calculate the branch correlation correctly most of the time. Another measure very useful for this, would be the width of the neurite (biggest fitting circle with the skel pixels as centers).

Eagerly waiting on this one!

There is a dapi channel on the image and it’s shown as blue in the outline output image, but I left the morphological operators for the soma on the pipeline as means to have 2 models of extracting the soma. Thank you very much for all your help, and i hope the next message i’ll bring some scripting on the measureneurons module. Hope it doesnt take me all the year!