- Code: Select all
tvec = new Vector(num)
at which point
tvec.indgen()
tvec.mul(dt)
gives you a vector with contents 0,dt...(num-1)*dt
BTW, you don't need to define PI--NEURON has it already.
- Code: Select all
I = tvec.mul(2*PI*f*(180/PI))
Is f in Hz? NEURON's t is in ms.
What's the (180/PI) for?
tvec.mul(foo) replaces tvec's contents with foo*old_values, not at all what you intended. You probably meant
- Code: Select all
I = tvec.c
I.mul(2*PI*f/1000)
// or the faster, but maybe more prone to human misreading,
// I = tvec.c.mul(2*PI*f/1000)
// which first copies tvec, then multiplies this copy by the scale factor
- Code: Select all
for i=0, napical-1{
access apical[i] . . .
Each pass of this loop pushes a new section onto the section stack, making it the new "currently accessed section"--but never pops it off. Consequently, any "naked" range variable or section variable (one that is not paired with a disambiguating section name, e.g. v, diam, L, Ra appearing by itself) will mean something different on each pass. This includes instances that appear in Graphs and print statements. When transiently changing the currently accessed section, it's much better to use "section stack syntax"
sectionname statement
For this case, the code becomes
- Code: Select all
for i=0,napical-1 apical[i] {
. . . statements that pertain to apical[i] . . .
}
- Code: Select all
for j= 0, apicalseg{ //For every point on apical dendrite (would be apicalseg+1 points)
position1 = j*(1/apicalseg) //This is the position of the point
. . . etc. . . .
You're trying to drive e_extracellular at the boundaries between compartments. That variable is not available to you. NEURON uses the central difference approximation for the 2nd spatial derivative. Consequently it solves ODEs for membrane potential at normalized distances 0.5/nseg . . . (nseg - 0.5)/nseg from the 0 end of each section. Those are the locations of a section's internal nodes, and those are where you want to drive e_extracellular.
The idiom is
- Code: Select all
for (x,0) {
statements that pertain to the internal node at location x
}
"What harm could come from trying to drive e_extracellular at 0 or 1?"
Attempts to reference a range variable at 0 or 1 end up affecting that range variable at the nearest internal node. You'd end up with two Vectors competing to drive e_extracellular at 0.5/nseg, and another two competing to drive e_extracellular at (nseg - 0.5)/nseg. The result would depend on execution sequence, and would not necessarily reflect your intent.