This is discussed briefly in
Example 9.7: Kinetic scheme for a voltage-gated current in
The NEURON Book (pp. 240-245). However, a more explicit example, complete with hoc
code, would be useful. The first question is how to write the NMODL source code. The
second question is how to write the hoc code that is necessary to use this mechanism.
The following example is based on code from Andrew Davison's NEURON implementation
of the Bhalla & Bower olfactory mitral cell model, with some modifications for the sake of
clarity and/or to eliminate/replace deprecated items.
This example involves a potassium current described by
ik = gkbar*n*n*k*(v - ek)
where the gating states n and k are described by the HH-style ODEs
n' = (ninf(v) - n)/ntau(v)
k' = (kinf(v) - k)/ktau(v)
and the steady states and time constants are specified not by algebraic functions but by
interpolation of values from lookup tables.
The NMODL code for this mechanism uses the FUNCTION_TABLE keyword to specify
that the values of kinf, ktau, etc. are to be found by linear interpolation from lookup tables.
Code: Select all
NEURON {
SUFFIX kfast
USEION k READ ek WRITE ik
RANGE gkbar, ik
}
UNITS {
(mA) = (milliamp)
(mV) = (millivolt)
}
PARAMETER {
gkbar= 0.036 (mho/cm2)
}
STATE {
n k
}
ASSIGNED {
v (mV)
ik (mA/cm2)
ek (mV)
}
INITIAL {
n = ninf(v)
k = kinf(v)
}
BREAKPOINT {
SOLVE states METHOD cnexp
ik = gkbar*n*n*k*(v - ek)
}
DERIVATIVE states {
n' = (ninf(v) - n)/ntau(v)
k' = (kinf(v) - k)/ktau(v)
}
FUNCTION_TABLE ninf(v(mV))
FUNCTION_TABLE ntau(v(mV)) (ms)
FUNCTION_TABLE kinf(v(mV))
FUNCTION_TABLE ktau(v(mV)) (ms)
All that remains is to set up the tables of numerical values for kinf, ktau, ninf, and ntau,
and to attach the tables to this mechanism.
Suppose that the numerical values for the lookup tables are stored in four files, called
kfast_k.inf, kfast_k.tau, kfast_n.inf, and kfast_n.tau. The file contents are in the form
v0 p0
v1 p1
v2 p2
. . .
i.e. one pair of numbers per line, where the first number is a membrane potential in mV,
the second is the corresponding gating parameter (a steady state value, or a time
constant in ms), and the v values increase monotonically. For the sake of convenience,
let us assume that each file has exactly the same number and sequence of v values.
This hoc code reads the parameter files, stores the values in Vectors, then attaches the
Vectors to the kfast mechanism with the syntax
table_
funcname_suffix(&
paramvec.x[0],
num, &
indepvarvec.x[0])
where
funcname is the name of the function in the NMODL file
paramvec is the hoc vector that contains the sequence of parameter values
num is the number of rows in the table
indepvarvec is the hoc vector that contains the sequence of independent variable values
(in this case, the sequence of v values).
This code uses the standard run system's clipboard_retrieve(), which in turn uses the
Vector class's scanf() method and therefore requires the table of v, p values to end with
a number followed by a newline (see
http://www.neuron.yale.edu/neuron/stati ... html#scanf
).
Code: Select all
objref kinfvec, ninfvec, ktauvec, ntauvec, vvec
clipboard_retrieve("kfast_k.inf")
kinfvec = hoc_obj_[0]
vvec = hoc_obj_[1]
clipboard_retrieve("kfast_n.inf")
ninfvec = hoc_obj_[0]
clipboard_retrieve("kfast_k.tau")
ktauvec = hoc_obj_[0]
clipboard_retrieve("kfast_n.tau")
ntauvec = hoc_obj_[0]
table_kinf_kfast(&kinfvec.x[0], vvec.size, &vvec.x[0])
table_ninf_kfast(&ninfvec.x[0], vvec.size, &vvec.x[0])
table_ktau_kfast(&ktauvec.x[0], vvec.size, &vvec.x[0])
table_ntau_kfast(&ntauvec.x[0], vvec.size, &vvec.x[0])