Calcium activated Potassium Current

NMODL and the Channel Builder.
Post Reply
davidfourie

Calcium activated Potassium Current

Post by davidfourie »

I am designing a Calcium activated Potassium Current whish has an activation dependent on both voltage and Ca and a deactivation dependant purely on Ca.

I have created as below:

: Calcium-activated K channel
: based on "calcium-activated, voltage gated current" from "The Neuron Book" by N.T. Carnevale

Code: Select all

NEURON {
  SUFFIX caK
  USEION k READ ik WRITE ik
  USEION ca READ cai, eca WRITE cai VALENCE 2            :due to cai being writen eca (calcium Equilibrium potential) is atamatically calculated.
  RANGE gbar
}


UNITS {
  (mV) = (millivolt)  
  (mA) = (milliamp)  
  (S) = (siemens)  
  (molar) = (1/liter)  
  (mM) = (millimolar) 
  (uM) = (micromolar) 
  FARADAY = (faraday) (kilocoulombs)  
  R = (k-mole) (joule/degC)
}


PARAMETER {
  CaConst = 1.727378108173      :units?  constant caculated from "1/(z*F*Vol)"  (z=2, F=faraday constant, Vol = 3*(10-6))
  kca     = 360   (S/s)         :rate constant unit is S-1
  bca     = 0.05  (uM)          :backround calcium is 0.05 microMolar
  initCa  = 100   (uM)          :initial internal calcium levels ***(estimate for testing)***
  gbar    = 3.2   (S/cm2)       :Maximum conductance
  fconst  = 0.6   (mV/uM)
  vao1    = 0     (mV)
  vao2    = -16   (mV)
  sao1    = -23   (mV)
  sao2    = -5    (mV)
  c1      = 2.5   (uM)
  c2      = 0.7   (uM)
  c3      = 0.6   (uM)
  
}


ASSIGNED {
  eca   (mV)            :Reversal Potential
  cai   (mM)            :intercellular calcium concentration
  v     (mV)            :voltage
  ik    (mA/cm2)        :potasium current
  g (S/cm2)        	    :macroscopic conductance
  i (mA/cm2)         	  :current passing through g
}


STATE { a b cac (mM) }          :a is the activation, b is the inactivation, cac is calcium concentration


BREAKPOINT {
  SOLVE state METHOD cnexp
  g  = gbar * a * b       
  i  = g * (v - eca)            :current calculation uses the automatically calculated eca
  ik = i
  cai = cac                     :assign WRITE cai with calculated cac
}


DERIVATIVE state {
  UNITSOFF
    a'    = (aSte(v, cai) - a) * 600
    b'    = (bSte(cai) - b) * 35
    cac'  = (CaConst * ik - kca * cai + kca * bca)*1000       :original formula calculates in uM added *1000 converts to mM
  UNITSON
}

INITIAL {
  UNITSOFF
    a   = aSte(v, cai) * 600
    b   = bSte(cai) * 35
    cac = (CaConst * ik - kca * initCa + kca * bca)*1000       :original formula calculates in uM added *1000 converts to mM
  UNITSON
}

:*****steady state of a********
FUNCTION aSte(vm (mV), caCon (mM) ) (/ms) {
  UNITSOFF
    aSte = 1/(1 + exp((vm + vao1 +  fconst * caCon)/sao1))*1/(1 + exp((vm - vao2 + fconst * caCon)/sao2))*(caCon/(c1 + caCon))
  UNITSON
}
:*****steady state of b********
FUNCTION bSte(caCon (mM) ) (/ms) {
  UNITSOFF
    bSte = c2/(c3+caCon) 
  UNITSON
}

but when I come to create the .mod file using nrnmkdll i get the folllowing message:

Code: Select all

gcc -mno-cygwin -I/cygdrive/c/Neuron/nrn59/src/scopmath -I/cygdrive/c/Neuron/nrn59/src/nrnoc -I/cygdrive/c/Neuron/nrn59/src/oc -I/cygdrive/c/Neuron/nrn59/lib -I/cygdrive/c/Neuron/nrn59/mingw -c mod_func.c
nocmodl calciumActivated
Translating calciumActivated.mod into calciumActivated.c
cai is WRITE but is not a STATE and has no assignment statement at line 92 in file calciumActivated.mod
^
make: *** [calciumActivated.o] Error 1

There was an error in the process of creating nrnmech.dll
Press Return key to exit

I am hoping someone will be able to explain what this means.

yours
David Fourie
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Calcium activated Potassium Current

Post by ted »

Actually, this is one of the more meaningful error messages that I have seen the NMODL
compiler generate.

An ionic concentration is calculated by integrating the net current of a particular ionic
species, so it is a state variable of the conceptual model. cai must therefore be declared
in the STATE block. To you, cac may mean "intracellular calcium concentration," but it
has no special meaning to NMODL, which is rather rigid about these things: for any ionic
species x, the intra and extracellular concentrations must be called xi and xo.

Before you start revising this code, changing every instance of cac to cai etc., I should
point out that you will do yourself a big favor by breaking this mechanism into two parts:
a calcium accumulation mechanism, which does nothing more than compute and WRITE
cai, and a voltage- and calcium-gated potassium conductance mechanism which READs
cai. Focus on the calcium accumulation mechanism first, and when you are sure that it
works properly, then turn your attention to the potassium conductance mechanism. This
modular programming strategy will make development and debugging much easier.

You will find examples of calcium accumulation mechanisms in chapter 9 of The NEURON
Book, but let me also bring your attention to c:\nrnxx\examples\nrniv\nmodl (under
UNIX/Linux and on the Mac, get the gzipped tar source code for nrn and expand
it, then look in nrn-x.x/share/examples/nrniv/nmodl ). Check out the files called ca*.*,
which include implementations of 6 different calcium accumulation mechanisms, plus
the hoc and ses files needed to demonstrate them in operation.

A final comment: it is generally not a good idea to "hard code" compartment volume
into a mod file, as has been done here with CaConst. I suppose it's OK if one's aim is
limited to reproducing a model that was originally implemented for something other than
NEURON, but eventually it seems that the need always arises to reuse any given
mechanism outside of its original context. This almost invariably means using different
diameters, lengths, volumes, surface areas etc, which causes much inconvenience
because all such magic numbers are broken and users must dig into old, stale code
to figure out how it should have been written in the first place.
davidfourie

Questions on your advise

Post by davidfourie »

I have attempted the calcium accumilation.

Code: Select all

: intracellular calcium ion accumulation
NEURON {
  SUFFIX caInt
  USEION ca READ ica, cai WRITE cao
}

UNITS {
  (mV)      = (millivolt)
  (mA)      = (milliamp)
  FARADAY   = (faraday) (coulombs)
  (molar)   = (1/liter)
  (mM)      = (millimolar)
  (uM)      = (micromolar)
  (S)       = (siemens)
}

PARAMETER {
  z        = 2
  vol     = 0.000003                   :3 * 10-6
  kca    = 360       (S/s)             :Half maximum potential
  bkCa  = 0.05      (mM)            :backround calcium
  
}

ASSIGNED { 
  ica   (mA/cm2)
  cai   (mM) 
 }

STATE { cao (mM) cVol (m3) }  :Wrong units

BREAKPOINT { SOLVE state METHOD cnexp }

DERIVATIVE state {
  UNITSOFF
    cVol' = (1/z*FARADAY*vol)         :CaConst = 1.727378108173      :units?  constant caculated from "1/(z*F*Vol)"  (z=2, F=faraday constant, Vol = 3*(10-6))
    cao' 	= cVol * ica - kca * cai + kca * bkCa
  UNITSON    

}

Issues that I have:

I have hard-coded the volume again. I understand if it is taken from the hoc it can be reused but i dont know how to implement this.
[/code]
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

A good way to learn programming is by imitation. So let's start by examining the code for a
simple calcium accumulation mechanism that works: cacum.mod, which is in
c:\nrnxx\examples\nrniv\nmodl (UNIX/Linux/OS X users should get the gzipped source
code for NEURON, expand it, and look at nrn-x.x/share/examples/nrniv/nmodl/cacum.mod).

Code: Select all

COMMENT
        calcium accumulation into a volume of area*depth next to the
        membrane with a decay (time constant tau) to resting level
        given by the global calcium variable cai0_ca_ion
ENDCOMMENT

NEURON {
        SUFFIX cacum
        USEION ca READ ica WRITE cai
        RANGE depth, tau, cai0
}

UNITS {
        (mM) = (milli/liter)
        (mA) = (milliamp)
        F = (faraday) (coulombs)
}

PARAMETER {
        depth = 1 (nm)  : assume volume = area*depth
        tau = 10 (ms)
        cai0 = 50e-6 (mM)       : Requires explicit use in INITIAL
                        : block for it to take precedence over cai0_ca_ion
                        : Do not forget to initialize in hoc if different
                        : from this default.
}

ASSIGNED {
        ica (mA/cm2)
}

STATE {
        cai (mM)
}

INITIAL {
        cai = cai0
}

BREAKPOINT {
        SOLVE integrate METHOD derivimplicit
}

DERIVATIVE integrate {
        cai' = -ica/depth/F/2 * (1e7) + (cai0 - cai)/tau
}
Starting at the NEURON block, note that the USEION statement declares that this
mechanism WRITEs cai, the concentration of ca adjacent to the internal surface of the
cell membrane.

Note that ica is ASSIGNED (it is the net transmembrane calcium current produced by all
mechanisms that are attached to the section that WRITE ica), and cai is a STATE.

I will omit discussion of initialization and the role of cai0_ca_ion, which are covered at
several points in The NEURON Book and probably also in this Forum.

Skipping down to the BREAKPOINT block, note that it contains a single statement:
SOLVE integrate METHOD derivimplicit
derivimplicit is a first-order accurate implicit integration method that is suitable for general
ordinary differential equations (ODEs) regardless of stiffness or nonlinearity. It works well
for ion accumulation mechanisms whose kinetics are described by an ODE. Which
happens to be the case for this example, as we see from the DERIVATIVE block.

The second term on the right hand side (RHS) of the DERIVATIVE block
(cai0 - cai)/tau
implements a pump that clears calcium from the inside of the cell at a rate that is proportional
to how far cai has strayed from a "set point" cai0.

The first term on the RHS
-ica/depth/F/2 * (1e7)
was written in a way that takes advantage of the "precedence rules" that govern evaluation
of mathematical expressions in NMODL. Rewritten for humans, but omitting the scale
factor (1e7), this is simply
-ica / (2 * F * depth)
ica is in units of current/area, but the LHS is in units of concentration/time.
The units of ica / (2 * F) are moles/(area time), give or take a scale factor. The units of
depth are length, so ica / (2 * F * depth) has units of moles / (area * length * time) =
moles / (volume * time). All that is needed is a scale factor to reconcile cm2, microns,
liters, milliamperes, milliseconds, and the units of F. That's what the (1e7) is for, but should
it be in the numerator or the denominator? As one of my favorite math textbooks would
say, "This is left as an exercise to the reader."

But what is the physical meaning of the first term on the RHS
-ica/depth/F/2 * (1e7)
?
It is this: when calcium enters the cell, it accumulates in a shell, of thickness "depth," that
lies just inside the cell membrane. To a first approximation, the volume of this shell is the
product of "depth" and the membrane surface area. So if we have a segment whose
surface area is A, the volume of the shell is A*depth. The rate of calcium influx into the
segment is
-ica * A / (2 * F)
again ignoring any scale factors that might be needed to reconcile different units.
To get the rate of change of cai that this ca flux would produce, we must divide by shell
volume, so we have
-ica * A / (2 * F * A * depth) = -ica / (2 * F * depth)

"Fine, but what if I want ca to spread across the entire diameter of the segment, not just
pile up in a shell next to the membrane?"

In that case, we must remember that the surface area of a segment is
PI * diam * segment_length
so the rate of calcium influx is
-ica * PI * diam * segment_length / (2 * F)
The volume of a segment is
PI * (diam * diam) * segment_length / 4
so the rate of change of cai would be
( -ica * PI * diam * segment_length / (2 * F) ) * ( 4 / (PI * (diam * diam) * segment_length) )

Gathering terms and rearranging, we have
-2 * ica / (F * diam)
which of course needs a scale factor to reconcile units.

Speaking of units, there should be no need for UNITSOFF . . . UNITSON, regardless of
whether cai is restricted to a shell or allowed to penetrate to the core of the section.

Clear as mud, right? If you have made it this far, you can probably make a pretty good
guess about what to fix in your own mod file, or maybe you'll just decide to chuck it and
use cacum.mod (with whatever further changes might be needed to accomplish your
aims).
Post Reply