### the distance() function

Posted:

**Tue Jan 07, 2014 10:14 am**Hi,

I want to create a function for setting channel densities etc based on somatic cable/path distance for an anatomically detailed model (the morphology is imported from a .swc file). I first tried this function:

from this tread:

http://www.neuron.yale.edu/phpbb/viewto ... =16&t=1975

that I think calcualtes the distance for each internal node to the center of the soma, right? To get the length from the end of each section I therefore added L/2 to each measurment.

The distances reported from this function was a little shorter than the previously calculated distances (using GENESIS and Matlab) so I desided to calculate the distances manually. This was done by following the example from this thread:

http://www.neuron.yale.edu/phpbb/viewto ... =15&t=2892

i.e. the end of each section the somatic distance were calulated by summing the length of all parent sections higher in the tree. This gave distances that were a little longer but still shorter than the expected ones.

My questions are therfore:

1) what distance does the distance() function calculate?

2) Is it possible to specify metric used in distance(), e.g. dendritic or radial etc?

3) what are the connection between the pt3d from the imported morphology and the distance() function?

4) where do I find the source/hoc code for the distance() function? (I have looked at /usr/local/nrn/share/nrn/lib/hoc/ using grep with no success).

Grateful for any help.

Robert

ps.

I have read about distance() at its reference page:

http://www.neuron.yale.edu/neuron/stati ... l#distance

I want to create a function for setting channel densities etc based on somatic cable/path distance for an anatomically detailed model (the morphology is imported from a .swc file). I first tried this function:

Code: Select all

```
proc alldist() {
soma distance() // make soma(0) be the reference point for distance measurements
forall {
print secname()
for (x,0) print x, " ", distance(x)
}
}
```

http://www.neuron.yale.edu/phpbb/viewto ... =16&t=1975

that I think calcualtes the distance for each internal node to the center of the soma, right? To get the length from the end of each section I therefore added L/2 to each measurment.

The distances reported from this function was a little shorter than the previously calculated distances (using GENESIS and Matlab) so I desided to calculate the distances manually. This was done by following the example from this thread:

http://www.neuron.yale.edu/phpbb/viewto ... =15&t=2892

i.e. the end of each section the somatic distance were calulated by summing the length of all parent sections higher in the tree. This gave distances that were a little longer but still shorter than the expected ones.

My questions are therfore:

1) what distance does the distance() function calculate?

2) Is it possible to specify metric used in distance(), e.g. dendritic or radial etc?

3) what are the connection between the pt3d from the imported morphology and the distance() function?

4) where do I find the source/hoc code for the distance() function? (I have looked at /usr/local/nrn/share/nrn/lib/hoc/ using grep with no success).

Grateful for any help.

Robert

ps.

I have read about distance() at its reference page:

http://www.neuron.yale.edu/neuron/stati ... l#distance