Ok I think we are getting somewhere.
In general the distance I would expect for an arbitrary single branch structure in absolute coordinates connected to the mid point of the soma (i.e. we only count the dendritic length) is:
sum( norm( [x(i), y(i), z(i]) - [x(i-1), y(i-1), z(i-1)])
That is if we have two vectors a and b and want to calculate the distance (d) between them:
d = |a - b| = sqrt( (xa-xb)^2 + (ya-yb)^2 + (za-zb)^2 ).
That said, I followed your advice and build the three test models (I did change the soma and connec statement to more resemble the model I'm working with).
Code: Select all
// MODEL 1
////////////////////////////////////////////////////////////
create soma, dend
connect dend(0), soma(0.5)
soma {
pt3dclear()
pt3dadd(-10,0,0,1)
pt3dadd(0,0,0,1)
pt3dadd(10,0,0,1)
}
dend {
pt3dclear()
pt3dadd(0,0,0,1)
pt3dadd(50,0,0,1)
pt3dadd(50,50,0,1)
}
soma distance(0, 0.5)
forall for (x,0) {
print secname(), " ", distance(x) + L/2
}
//MODEL 2
////////////////////////////////////////////////////////////
create soma, dend
connect dend(0), soma(0.5)
soma {
pt3dclear()
pt3dadd(-10,0,0,1)
pt3dadd(0,0,0,1)
pt3dadd(10,0,0,1)
}
dend {
pt3dclear()
pt3dadd(0,0,0,1)
pt3dadd(100,100,0,1)
}
soma distance(0, 0.5)
forall for (x,0) {
print secname(), " ", distance(x) + L/2
}
// MODEL 3
////////////////////////////////////////////////////////////
create soma, dend
connect dend(0), soma(0.5)
soma {
pt3dclear()
pt3dadd(-10,0,0,1)
pt3dadd(0,0,0,1)
pt3dadd(10,0,0,1)
}
dend {
pt3dclear()
pt3dadd(0,0,0,1)
pt3dadd(50,0,0,1)
pt3dadd(100,50,0,1)
}
soma distance(0, 0.5)
forall for (x,0) {
print secname(), " ", distance(x) + L/2
}
Running them one by one I got the following result: 100, 141.4, 120.7
For each of the three test cases I also made one morphology file in the swc format (with a spherical soma).
Code: Select all
# MORPHOLOGY 1
1 1 0 0 0 1 -1 //soma
2 3 50 0 0 1 1
3 3 50 50 0 1 2
# MORPHOLOGY 2
1 1 0 0 0 1 -1 //soma
2 3 100 100 0 1 1
# MORPHOLOGY 3
1 1 0 0 0 1 -1 //soma
2 3 50 0 0 1 1
3 3 100 50 0 1 2
for each of these morphologies I then calcualted the dendritic length (using Matlab and GENESIS) and got the same values as I had obtained using NEURON.
Next insted of just writing hoc code I imported the morphologies using import3d in the same way I had done with the original morphology.
1) launch nrngui
2) click
Tools ->
Miscellaneous ->
Import 3D
3) in the pop up window click
choose a file
4) once the file was imported I clicked
export ->
Cellbuilder
5) In the cellbuilder window I clicked
Management ->
export ->
export to file and save the files without specifying anything else.
After cleaning away some dead code and adding a print statement, the files had the following apperance.
Code: Select all
// model 1
proc celldef() {
topol()
subsets()
}
create soma, dend
proc topol() { local i
connect dend(0), soma(0.5)
basic_shape()
}
proc shape3d_1() {
soma {pt3dclear()
pt3dadd(-1, 0, 0, 2)
pt3dadd(0, 0, 0, 2)
pt3dadd(1, 0, 0, 2)
}
dend {pt3dclear()
pt3dstyle(1, 0, 0, 0)
pt3dadd(50, 0, 0, 2)
pt3dadd(50, 50, 0, 2)
}
}
proc basic_shape() {
shape3d_1()
}
objref all, somatic, basal
proc subsets() { local i
objref all, somatic, basal
all = new SectionList()
soma all.append()
dend all.append()
somatic = new SectionList()
soma somatic.append()
basal = new SectionList()
dend basal.append()
}
access soma
celldef()
objref s
soma distance(0, 0.5)
forall for (x,0) {
s = new SectionRef()
if (s.has_parent) {
print secname(), " ", distance(x) + L/2
}
}
Code: Select all
// model 2
proc celldef() {
topol()
subsets()
}
create soma
proc topol() { local i
basic_shape()
}
proc shape3d_1() {
soma {pt3dclear()
pt3dadd(-1, 0, 0, 2)
pt3dadd(0, 0, 0, 2)
pt3dadd(1, 0, 0, 2)
}
}
proc basic_shape() {
shape3d_1()
}
objref all, somatic
proc subsets() { local i
objref all, somatic
all = new SectionList()
soma all.append()
somatic = new SectionList()
soma somatic.append()
}
access soma
celldef()
objref s
soma distance(0, 0.5)
forall for (x,0) {
s = new SectionRef()
if (s.has_parent) {
print secname(), " ", distance(x) + L/2
}
}
Code: Select all
// model 3
proc celldef() {
topol()
subsets()
geom()
biophys()
geom_nseg()
}
create soma, dend
proc topol() { local i
connect dend(0), soma(0.5)
basic_shape()
}
proc shape3d_1() {
soma {pt3dclear()
pt3dadd(-1, 0, 0, 2)
pt3dadd(0, 0, 0, 2)
pt3dadd(1, 0, 0, 2)
}
dend {pt3dclear()
pt3dstyle(1, 0, 0, 0)
pt3dadd(50, 0, 0, 2)
pt3dadd(100, 50, 0, 2)
}
}
proc basic_shape() {
shape3d_1()
}
objref all, somatic, basal
proc subsets() { local i
objref all, somatic, basal
all = new SectionList()
soma all.append()
dend all.append()
somatic = new SectionList()
soma somatic.append()
basal = new SectionList()
dend basal.append()
}
proc geom() {
}
proc geom_nseg() {
}
proc biophys() {
}
access soma
celldef()
objref s
soma distance(0, 0.5)
forall for (x,0) {
s = new SectionRef()
if (s.has_parent) {
print secname(), " ", distance(x) + L/2
}
}
Interesingly model 1 and model 3 look pretty similar to the models made using hoc code but model 2 is for some reason not having any dendrites at all.
Following this I calculated the distances returned from these models. Here NEURON returned: 50, -, 70.7
To me this indicates that eighter I have done something wrong in the import or the import3d function is doing something I don't understand to the length of each/some sections (perhaps to the first point of the first section of each dendritic stem?).