I want to make a function that calculates the somatic distance of a section similar to this thread:
http://www.neuron.yale.edu/phpbb/viewto ... =15&t=2892
something like:
Code: Select all
func cableDist() {local dist
$o1.sec print secname() // checking imported section
$o1.parent print secname() // checking that section has parent
objref s // this works
$o1 s = new SectionRef() // this don't work! (syntax error)
// This is basically what I would like to do
while (s.has_parent) {
dist += L
s.parent {
s = new SectionRef()
if (s.has_parent) {
dist += L // don't count length of soma
}
}
}
return dist
}
Code: Select all
// cell 1
create soma, dend[2]
access soma
connect dend[0](0), soma(1)
connect dend[1](0), dend[0](1)
load_file("functions.hoc")
objref s1
dend[1] s1 = new SectionRef()
cableDist(s1)
Similar code (see thread above) works fine if I use it "on line" in the main script but when I try to place it in a function I get problems.
With the current setup I get syntax error bu I have earlier obtained both segmentation error and stack type error (bad stack access: expecting(double);really(unknown)).
All help would be appreciated!
Robert