Adding extracellular stimulation to existing model

Anything that doesn't fit elsewhere.
Post Reply
leo83

Adding extracellular stimulation to existing model

Post by leo83 »

Hi -

I am attempting to add extracellular stimulation to an existing model (https://senselab.med.yale.edu/modeldb/s ... del=187473) from modelDB. I have:

1. Validated that I can reproduce the figures from the paper using the model.

2. Added "insert extracellular" and "insert xtra" into all compartments and called define_shape()

Code: Select all

forall{
insert extracellular xraxial=1e+09 xg=1e+09 xc=0 e_extracellular=0
insert xtra
define_shape()
}
3. Added the necessary *.hoc files to the existing model

Code: Select all

load_file("nrngui.hoc")
load_file("interpxyz.hoc")      // only interpolates sections that have extracellular
load_file("setpointers.hoc")    // automatically calls grindaway() in interpxyz.hoc
load_file("calcrxc.hoc")        // computes transfer r between segments and recording electrodes
load_file("stim.hoc")           // extracellular stimulus
setelec(20000,0,0)              // set position of extracellular electode
After compiling and attempting to run the model, I receive (and am stuck at) the following error:

Code: Select all

na_ion mechanism not inserted in section sElec
I dug around the extracellular code and tried to hunt down the source. I commented out the calcrxc.hoc file and that at least let's me run a simulation but alas no activation of the structure. I plotted e_extracellular and see a rectangular pulse, but it's unclear to me if the structure is actually "feeling" the extracellular stim.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Adding extracellular stimulation to existing model

Post by ted »

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

Code: Select all

proc init() {
to

Code: Select all

/*
proc init() {
and change

Code: Select all

}                       /// end of initialization
to

Code: Select all

}                       /// end of initialization
*/
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
}
leo83

Re: Adding extracellular stimulation to existing model

Post by leo83 »

Thanks Ted. It took some time but I was able to walk through your suggestions and understand them (or at least I think..).

After getting the extracellular mechanisms "to work", I did a simple test to see what the strength duration curve looked like. Although the curve has the typical exponential decay shape observed under extracellular stimulation of an axon, the amplitudes are extremely high (hundreds of milliamps). I can't imagine that this is normal...and am having a difficult time identifying the source of this error. I could not figure out how to attach a file here to show you the SD curve but can send it through email if you prefer.

I thought that the extracellular medium properties were set incorrectly, but that did not have an effect (after setting them to values in the literature or found elsewhere on the forums). It also does not seem to be a scaling error in the distance of the point source from the axon.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Adding extracellular stimulation to existing model

Post by ted »

Variables that affect extracellular stimulation include
distance of the cell from the stimulating electrode(s)
orientation of the cell relative to the extracellular potential gradient
size of the cell
stimulus duration compared to membrane time constant

Far from the electrode(s) the potential gradient will be shallow; this will require a larger stimulus current.
The stimulus will be more effective if the cell's major axis is oriented parallel to the potential gradient, and less effective if it is orthogonal to that gradient.
Narrow diameter axons require a larger stimulus than axons with larger diameter.
Neurite length is also important; cells that are short or lack a long axon require a larger stimulus than cells that are long or have a long axon.
Clinical studies of peripheral nerve typically use stimulus durations of 0.1 ms; increasing stimulus duration reduces the stimulus amplitude required to elicit a spike.

Finally, a word about models: it is impossible to elicit a spike by extracellular stimulation of a single compartment model i.e. a model cell whose membrane potential is uniform over its surface.
Post Reply