Count dendrites touching circles

neurons
dendrites
Tags: #<Tag:0x00007fd543a83bd8> #<Tag:0x00007fd543a83a70>

#1

Hi everyone!

We want to count dendrites touching circles which are set around the cell body in different distances.
(e.g. 9 dendrites touch the first circle, 7 dendrites touch the second circle, 2 dendrites touch the last circle)
Can someone help me to do that in Fiji?
The image below shows how it should look like :slight_smile:


Ideally, all circles are set in a defined distance of course.
Any advice would be more than appreciated.
Cheers :brain:


#2

Good day!

The drawn circles in fact are ellipses.

Touch or cross, this is the question?

Regards

Herbie


#3

Well,

let’s assume your images are binary and that you are able to define a center, e.g. of the cell soma, then I’d use the “Polar Transformer”-plugin. The resulting image respresentation can then be analysed by straight lines instead of circles. The crossing of selection lines can be easily determined from the profiles along these lines.

HTH

Herbie


#4

Hey neurons,

If @Herbie’s solution uses an existing plugin then it may be the most straight forward approach. However, as a stimulatory thought experiment, I have come up with another potential solution. In truth my method is most likely a little computationally inefficient, as it is quite recursive.

My approach (see schematic below) would involve defining multiple adjacent ROIs (green circles) along a predefined arc/ellipse, multiple times if many circles are required, and a set distance (a) from a point of origin (X). This could all be achieved in multi-nested ‘for loops’. Within the inner-most loop you could then perform a check to see if the ROI contains a dendrite (e.g. if binarised, check for black pixels). If a dendrite is found, you can then add it to a higher-level counter ++ for that particular ellipse. However, importantly, you may want to not add to the counter if an adjacent ROI detected the dendrite, as it would indicate that this is the same dendrite (as in the example picture the blue dendrite passes through two adjacent ROIs). If two dendrites are very close to each other, then this adjacent check might fail to differentiate between the two, but you could always decrease the size of the ROIs. Also, if a dendrite comes back on itself, then my method would not work as well.

Your question didn’t indicate that you want to individually follow each dendrite and collect a separate measure of concentric cross-sections for each, so my plan doesn’t incorporate that.

Counting dendrite intersections

Kind regards.


#5

Applying the “Polar Transformer”-plugin to a centered image of your schematic dendrite representation results in the following binarized image:
Polar Transform of neurons_schema

The following ImageJ-macro

h = getHeight();
for ( i = 0; i < 5; i++ ) {
	r = 40 + i * 28;
	makeLine( r, 0, r, h );
	p = getProfile();
	n = upSteps(p);
	print( n + " crossings at radius " + r );
}
function upSteps( a ) {
	sum = 0;
	for ( i = 1; i < a.length; i++ ) {
		if ( (a[i] > 0 && a[i-1] == 0) ) sum++;
	}
	return sum;
}

(Paste the above macro code to an empty macro window (Plugins >> New >> Macro) and run it.)

writes the desired numbers of crossings to the ImageJ log-window:
Ohne Titel-1

Regards

Herbie


#6

@neurons, I’d also recommend to have a look at the extensive documentation of the Sholl Analysis and Strahler Analysis plugins:



#7

Dear Herbie,

thank you for your help!

We agreed on the fact that crossing as well as touching should be included. So regarding to my schema: The dendrite at about 12 o’clock should also be included as it touches the second circle.

Regards,

neurons


#8

Good day,

so does my macro work for you?

Of course, it requires binarized images (alike your schematic image) which in turn will most likely require well-filled neurons …

Please report back.

Regards

Herbie


#9

Dear Herbie,

thank you so much for your effort. Unfortunately your macro is not working for me. (I don’t know why. There is just one yellow line in the picture, no circles, no crossings)
I found the ‘Concentric-Cirlce’ Plug-in which makes it possible to create concentric circles around the center of the cell.
I decided to count the crossing dendrites by myself. It may take more time but works better for me and is presumably more precise.

Do you have any ideas how I can create a macro for this method?

Kind regards,
neurons


#10

Good day,

what you describe is perfectly correct but obviously you don’t know what a polar transformation is.

Please make sure you are up-to-date with this topic and you will recognize that my macro does exactly what you want.

A polar transformation transforms concentric circles to parallel straight lines. Instead of circles with different radii, my macro sequentially creates parallel straight lines and measures the crossings with the transformed dendrites.

If you run my macro for your drawing, does it output the numbers that I’ve posted before?

Regards

Herbie


#11

Dear Herbie,

No.

0 crossings at radius 40
0 crossings at radius 68
0 crossings at radius 96
0 crossings at radius 124
0 crossings at radius 152

Unfortunately, I don’t even have the ‘binarized’ picture that you posted.

Kind regards,
neurons


#12

Ok,

I guess you didn’t remove the circles/ellipses and you didn’t center the drawing as described in my earlier post.

In my next post I’ll provide the centered drawing and the corresponding results.

Meanwhile you may get up-to-date concerning the polar transformation.

Stay tuned

Herbie


#13

Dear,

I guess you didn’t even install the ImageJ-plugin “Polar_Transformer”.

Please install it to your ImageJ plugin directory, if it is not already present. I don’t know if it comes preinstalled with Fiiji. You can download the plugin from
https://imagej.nih.gov/ij/plugins/polar-transformer.html

Copy the following (now centered) drawing of yours and open it in ImageJ:

With this image open, run the following ImageJ macro:

run( "8-bit" );
run( "Polar Transformer", "method=Polar degrees=360 number=720 center_x=300 center_y=300" );
h = getHeight();
for ( i = 0; i < 10; i++ ) {
	r = 40 + i * 28;
	makeLine( r, 0, r, h );
	p = getProfile();
	n = upSteps(p);
	print( n + " crossings at radius " + r );
}
function upSteps( a ) {
	sum = 0;
	for ( i = 1; i < a.length; i++ ) {
		if ( (a[i] > 0 && a[i-1] == 0) ) sum++;
	}
	return sum;
}

(Paste the above macro code to an empty macro window (Plugins >> New >> Macro) and run it.)

You will get the polar transform of the above image

and the log window with the numerical results:

ScreenShot

Please report back about your success!

Regards

Herbie