First, a minor point--
It is only necessary to execute define_shape() once: after all sections exist.
forall { . . . define_shape() }
calls it N times, where N is the total number of sections that exist. That won't do anything bad; it just wastes a bit of CPU time (for most model cells, probably not even enough to notice).
Now for your real problem and what to do about it.
Code: Select all
na_ion mechanism not inserted in section sElec
I dug around the extracellular code and tried to hunt down the source.
The first step in debugging is indeed to localize the problem, but you looked in the wrong place.
grep sElec *hoc
would show you that sElec is specifically mentioned only in calcrxc.hoc, which is one of the "library" of files that you loaded for the purpose of applying an extracellular stimulus. Furthermore,
grep create *hoc
would show you that those files create just that one section, and
sElec psection()
would confirm that sElec has no mechanisms that have anything to do with na.
Furthermore, none of the code in the "extracellular stimulus library" (what a glorious term) has anything to do with any particular ionic species.
An error message of the form
x_ion mechanism not inserted in section foo
means that some statement is trying to access the reversal potential, current, or concentration of some ionic species x in a section foo that does not have those variables.
The typical cause of such an error message is a statement that (1) assumes all sections have a mechanism that references a particular ionic current, concentration, or reversal potential, and (2) is executed AFTER model setup ("model setup" specifically means code that creates sections or specifies their anatomical or biophysical properties). The offending code will probably start with
forall
and it is likely to be executed during simulation initialization or execution.
The fix is to find and fix the offending forall statements. In the particular code you borrowed, examine Figure5d.hoc and you'll see
Code: Select all
proc init() {
. . .
forall {
v=-60 // VREST FOR ALL COMPARTMENTS
finitialize(v) // reset all state variables
fcurrent() // calculate all currents
e_pas = v + (ina + ik)/g_pas // calculate leak equilibrium potential
}
}
The purpose of this proc init() is to ensure that all sections will have a resting potential of -60 mV. It does this by adjusting each section's e_pas so that i_pas is equal and opposite to the sum of resting sodium and potassium currents at -60 mV. It works fine as long as each section's ena, ek, and their corresponding ionic conductances are uniform over that section's length. What's causing you a problem is that this code assumes that all sections involve na, k, and pas! That is true only for the sections created by the model authors' own code. There is also a potential performance issue, because it calls finitialize() on each pass through the loop, and that isn't necessary. It also calls fcurrent(), which isn't necessary at all (finitialize() alone takes care of that), but fcurrent() is computationally cheap.
The easiest fix is to comment out proc init(), that is change
to
and change
to
and insert this right after it:
Code: Select all
objref model
model = new SectionList()
forall model.append()
proc init(){
forsec DRG gkbar_iM = KCNQ // set KCNQ channel density
v = -60 // desired resting potential
finitialize(v)
forsec model e_pas = v + (ina + ik)/g_pas // ensure resting potential
}