Page 1 of 1
UNITSON and UNITSOFF to remove inconsistency?
Posted: Mon Apr 05, 2010 8:17 am
by Nin
Hi everybody,
I am just adding a new mechanism to model a synapse by the product of 2 exponential functions, as follows (very simplified):
Code: Select all
NEURON {
POINT_PROCESS syn
RANGE gmax, tau0, tau1, e_rev, i
NONSPECIFIC_CURRENT i
}
UNITS {
(nA) = (nanoamp)
(mV) = (millivolt)
(uS) = (micromho)
}
PARAMETER {
tau0 = 0.3 (ms)
tau1 = 5.0 (ms)
gmax = 0.0 (uS)
e_rev = 0.0 (mV)
}
ASSIGNED {
i (nA)
g (uS)
v (mV)
}
UNITSOFF
INDEPENDENT { t FROM 0 TO 1 WITH 1 (ms) }
FUNCTION conductance(x) {
conductance = gmax*(1-exp(-t/tau0))*(exp(-t/tau1))
}
BREAKPOINT {
g = conductance(t)
i = g*(v - e_rev)
}
UNITSON
Everything works fine, but I was wondering why there is an inconsistency in the units in the function "conductance" (obviously, only when I remove the UNITSON/OFF). In my mechanism, in contrary to the example described in the NEURON book (page 227), the result of e**(-t/tau0) should be non-dimensional. Do I have to set the units of t in the UNIT block?
A second brief question: If i call neuron with nrniv the mechanism is not loaded. Even if I call later load_file("nrngui.hoc") the mechanism does not appear. Do I have always to use nrngui to call the simulation when I have compiled mechanisms?
Thanks a lot for your help in advance!
Re: UNITSON and UNITSOFF to remove inconsistency?
Posted: Mon Apr 05, 2010 9:48 am
by ted
Unrelated comment:
INDEPENDENT statements serve no useful purpose in NEURON mod files and should be eliminated.
There are three problems. First, FUNCTION conductance() returns a value whose units should be specified as (uS). Second, the argument to conductance() is not used in the body of the FUNCTION. Third, the units of the argument should be specified. The corrected FUNCTION is
Code: Select all
FUNCTION conductance(x (ms)) (uS) {
conductance = gmax*(1-exp(-x/tau0))*(exp(-x/tau1))
}
Make these changes and the UNITSOFF . . . UNITSON directive can be deleted.
This mechanism has the following limitations.
(1) It will only produce a single conductance transient which occurs at a predetermined time.
(2) It will work only with fixed time step integration.
If this is OK with you, nothing more needs to be done to it.
Re: UNITSON and UNITSOFF to remove inconsistency?
Posted: Mon Apr 05, 2010 12:46 pm
by Nin
Thanks a lot for your fantastic advices! This is my first mod and It would have took me ages to get to that!
Now I am ready to start the simulations. The real mechanism would look like this (just if somebody wants to use it):
Code: Select all
:synapse.mod
TITLE Synaptic conductances of CA3 neurons
COMMENT
synaptic current modeled with monoexponential rise
and decay conductances defined by:
i = g * (v-e_rev),
where i is current in nA, g is conductance in microhms,
v is membrane potential (in mV) and e_rev is the reversal potential
of the synapse (in mV)
g = 0 for t < tonset and
g = ( (1-exp(-(t-tonset)/tau0)*(exp(-(t-tonset)/tau1))) for t > tonset
the function is normalized to the time of the peak so that gmax is the peak of the conductance.
ENDCOMMENT
NEURON {
POINT_PROCESS synapse
RANGE gmax, tonset, tau0, tau1, e_rev, i
NONSPECIFIC_CURRENT i
}
UNITS {
(nA) = (nanoamp)
(mV) = (millivolt)
(uS) = (micromho)
}
PARAMETER {
tonset = 0.0 (ms)
tau0 = 0.3 (ms)
tau1 = 5.0 (ms)
gmax = 0.0 (uS)
e_rev = 0.0 (mV)
}
ASSIGNED {
i (nA)
g (uS)
v (mV)
}
FUNCTION biexponential(x (ms)) {
biexponential = (1-exp(-(x-tonset)/tau0))*(exp(-(x-tonset)/tau1))
}
: Tpeak was solved arithmetically with Sage
: Tpeak is a as function of tau0, tau1 and tonset
LOCAL norm
FUNCTION conductance(x (ms)) (uS) {
LOCAL tpeak
tpeak = tau0*log(tau1/tau0 + 1) + tonset
: function is normalized to tpeak
norm = biexponential(x)/biexponential(tpeak)
if (x < tonset) {
conductance = 0
}
else {
: now the peak conductance is in gmax
conductance = gmax*norm
}
}
BREAKPOINT {
g = conductance(t)
i = g*(v - e_rev)
}
(1) It will only produce a single conductance transient which occurs at a predetermined time.
Now I added a tonset variable to decide at which time the conductance starts!
(2) It will work only with fixed time step integration.
No idea how to fix that.
Thanks a lot for your help!
Re: UNITSON and UNITSOFF to remove inconsistency?
Posted: Mon Apr 05, 2010 1:40 pm
by ted
My suggestion is that you use the built-in Exp2Syn, which is mathematically equivalent* and also has the following advantages:
(1) Exp2Syn is usable with fixed dt AND variable dt integration, but the "synapse" mechanism will only work with fixed dt.
(2) Exp2Syn is useful in models of individual cells and networks because it can be driven by multiple input streams of spike events with as many or as few events per stream as one would wish, and will generate appropriate conductance transients in response to any series of input events. "synapse," on the other hand, can only be employed in situations in which it is useful to produce a single conductance transient at a predetermined onset time.
*--(1-exp(-(x-tonset)/tau0)) * (exp(-(x-tonset)/tau1)) =
exp(-(x-tonset)/tau1) - exp(-(x-tonset)(1/tau0 + 1/tau1))
Let t = x-tonset
k1 = 1/tau1
k2 = 1/tau0 + 1/tau1
Then
exp(-(x-tonset)/tau1) - exp(-(x-tonset)(1/tau0 + 1/tau1)) =
exp(-k1*t) - exp(k2*t)
An Exp2Syn driven by a single input event produces a conductance transient that is proportional to
-exp(-t/tau1) + exp(-t/tau2)
Re: UNITSON and UNITSOFF to remove inconsistency?
Posted: Tue Apr 06, 2010 2:20 pm
by Nin
I totally agree with you, Exp2Syn is what I needed. In any case, I wanted to get familiar with NMODL language, and this was a very good opportunity.
Thanks a lot for your patient and care!
Best.