how to pass variables into mod file?

NMODL and the Channel Builder.
Post Reply
yj232

how to pass variables into mod file?

Post by yj232 »

I need to do the user-defined short-term plasticity.
My code is modified from Exp2Syn. Fac is for facilitation, Dep is for depression and DepR and FacR is for their recoveries.


NEURON {
POINT_PROCESS PlaExp2Syn
RANGE tau1, tau2, e, i
NONSPECIFIC_CURRENT i

RANGE g
RANGE Fac, Dep, FacR, DepR, F, D, plas
}

UNITS {
(nA) = (nanoamp)
(mV) = (millivolt)
(umho) = (micromho)
}

PARAMETER {
tau1 = 0.1 (ms) < 1e-9, 1e9 >
tau2 = 0.3 (ms) < 1e-9, 1e9 >
e = 0 (mV)
: these values are from Yan's model
}

ASSIGNED {
v (mV)
i (nA)
g (us)
factor
total (us)
Fac
FacR
Dep
DepR
plas
}

STATE {
A (us)
B (us)

}

INITIAL {
LOCAL tp
if (tau1/tau2 > 0.9999) {
tau1 = 0.9999*tau2
}
:when tau1>tau2, the syanpse turns into an alpha function synapse

A = 0
B = 0
D = 1
F = 1
tp = (tau1*tau2)/(tau2 - tau1) * log(tau2/tau1)
factor = -exp(-tp/tau1) + exp(-tp/tau2)
factor = 1/factor
}

BREAKPOINT {
SOLVE state METHOD cnexp
g = B - A
i = g*(v - e)
plas = D * F
}

DERIVATIVE state {
A' = -A/tau1
B' = -B/tau2
D' = DepR*(1-plas) - Dep
F' = Fac - FacR*(1-plas)
}

NET_RECEIVE(weight (us), Fac, FacR, Dep, DepR) {

:tsyn = t

A = A + weight*factor*plas
B = B + weight*factor*plas

}

I pass the Fac, FacR, Dep and DepR as weight array. in the format
netcon.weight[0]=weight
netcon.weight[1]=Fac
netcon.weight[2]=FacR
netcon.weight[3]=Dep
netcon.weight[4]=DepR

but no matter how I changed the value of Fac, FacR, Dep and DepR in hoc file, the EPSPs are not affected. But when I assign values to them in the mod file, EPSPs show plasticity.
Can you please tell me how to fix this? that means how can i change the short-term plasticity in hoc without recompiling the mod file each time?

Thanks a lot!
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: how to pass variables into mod file?

Post by ted »

This mechanism doesn't do what you think it should because the Fac, Dep, FacR, and DepR that are declared to be RANGE variables have nothing to do with the Fac, FacR, Dep, and DepR that are part of the weight vector. And you definitely do not want to be using hoc statements to assign values to the weight vector's elements. If you want to see examples of NMODL code for synaptic mechanisms that have short term plasticity, please go to ModelDB http://senselab.med.yale.edu/modeldb/ and examine entries 3815 and 3264. All statements that involve the weight vector's elements should be in the NET_RECEIVE block.

In the NMODL code you posted, the statements that govern the plasticity state variables seem unlikely to produce meaningful results. What is your conceptual model of short term plasticity, stated as algebraic or differential equations?
yj232

Re: how to pass variables into mod file?

Post by yj232 »

Thanks for the reply.
what i want to do is define the facilitation/depression and their recovery rates in the hoc to change the PSP.
the plasticity are governed by these simple equations.
PSPn=PSPn-1*plasticity
plasticity=depression*facilitation
depression'= Depression_Recovery *( 1- plasticity) - Depression * PSPn-1
facilitation' = Facilitation * PSPn-1 - Facilitation Recovery * ( 1 - plasticity)

initial values for depression and facilitation is 1.

Thanks a lot!
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: how to pass variables into mod file?

Post by ted »

In this equation
depression'= Depression_Recovery *( 1- plasticity) - Depression * PSPn-1
are "depression" and "Depresson" supposed to be the same variable?

In this equation
facilitation' = Facilitation * PSPn-1 - Facilitation Recovery * ( 1 - plasticity)
are "facilitation" and "Facilitation" supposed to be the same variable?

Assuming that the answers to these questions are "yes" and "yes"--

What is supposed to happen to depression and facilitation if there are no inputs? According to the equations, depression = facilitaton = 1 is not a stable point unless PSP amplitude is 0, and if psp amplitude is 0, it will stay 0 forever. Or do you really want depression and facilitation to start changing even if there are no inputs?
yj232

Re: how to pass variables into mod file?

Post by yj232 »

Sorry no they are not supposed to be the same. Depression and Facilitation are supposed to be a constant defined by user (passing to the NET_RECEIVE) and depression and facilitation are the components of plasticity.
plasticity = depression * facilitation
depression'= Depression_Recovery *( 1- plasticity) - Depression * PSPn-1
facilitation' = Facilitation * PSPn-1 - Facilitation Recovery * ( 1 - plasticity)

Depression, Depression_Recovery, Facilitation, Facilitation_Recovery are all constants defined by hoc. depression and facilitation are time-dependent and determine the amplitude of PSPs.

I changed my code as this:

NET_RECEIVE(weight (us), Fac, FacR, Dep, DepR, tsyn (ms)) {

INITIAL {
: these are in NET_RECEIVE to be per-stream
F = 1
D = 1
tsyn = t
: this header will appear once per stream
}

D = D * exp(-Dep*(t-tsyn))
F = F * exp(Fac*(t-tsyn))
: depression and facilitation without recovery

tsyn = t

A = A + weight*factor*D*F
B = B + weight*factor*D*F
}
where D and F are for overall depression and facilitation.

I didnt take the recovery mechanisms into account and this part works fine. I've got difficulties in how to put the recovery solution into this equation. I tried it for almost a week and completely lost. Can you help me here with it?
Thanks a lot! You reply my questions everyday!!!
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: how to pass variables into mod file?

Post by ted »

Before it is useful to talk about NMODL code, you must first have equations that do what you want.

These equations are a problem
plasticity = depression * facilitation
depression'= Depression_Recovery *( 1- plasticity) - Depression * PSPn-1
facilitation' = Facilitation * PSPn-1 - Facilitation Recovery * ( 1 - plasticity)
even if you meant to write
plasticity = depression * facilitation
depression'= Depression_Recovery *( 1- plasticity) - depression * PSPn-1
facilitation' = facilitation * PSPn-1 - Facilitation_Recovery * ( 1 - plasticity)

At the start of a simulation, depression = facilitation = 1.
Imagine that the synapse is activated at some time t1 and produces a psp with amplitude a.
depression will equal exp(-a(t-t1)) and facilitation will equal exp(a(t-t1)), so plasticity will stay equal to 1.
In other words, there will be no plasticity at all.

To help you see this, rewrite the equations as
d' = dr * (1 - d*f) - a*d
f' = a*f - fr * (1 - d*f)
(the substitution of d for depression, etc., makes it easier to read and write the equations)
and substitute the solutions
d = exp(-a*t)
f = exp(a*t)
(substituting t for t-t0 is a simple time shift)
for the terms on the right hand side.
You will immediately see that the "recovery" terms become 0, and you are left with
d' = - a*d
f' = a*f
This confirms that the solution to the equations is
d = exp(-a*t)
f = exp(a*t)

And this means that the product D*F in
A = A + weight*factor*D*F
B = B + weight*factor*D*F
is always 1, so there is no plasticity.
yj232

Re: how to pass variables into mod file?

Post by yj232 »

Sorry I may not say it clear.
depression and facilitation are the final result I want. Depression, Facilitation, Depression Recovery and Facilitation Recovery are the constants defined by hoc file. So I have four parameters to control the overall plasticity (Dep for Depression, DepR for Depression Recovery, Fac for Facilitation and FacR for Facilitation Recovery).

PSP_final = PSP * plasticity (PSP for the postsynaptic potential which is dependent on time)
plasticity = D * F (D for depression and F for facilitation. they are the results I want to get from the differential equations)
D' = DepR*(1-plasticity)-Dep*PSP_final
F' = Fac*PSP_final - FacR(1-plasticity)

for now I only consider either depression or facilitation. so it could be simplified as
D' = DepR*(1-D)-Dep*PSP_final = DepR*(1-D)-Dep*D*PSP
F' = Fac*PSP_final-FacR(1-F)=Fac*F*PSP-FacR(1-F)

when DepR and FacR is 0 which means there is no recovery, the equations would be
D' = -Dep*D*PSP
F' = Fac*F*PSP
which is all right as you point it out the result is
D = exp(-Dep*exp(t-tsyn))
F = exp(Fac*exp(t-tsyn))

I just could not get it right for the recovery part. To make it clear, I'll rewrite the equations I want to resolve are:
D' = DepR*(1-D)-Dep*D*PSP
F' = Fac*F*PSP-FacR(1-F)
In these two equations, D and F are to be solved. DepR, Dep, Fac and FacR are constants. I'm a bit confused with the presence of v in these equations. The results of D with nonzero Dep and DepR should be sawtooth-shaped with damping amplitude to a plateau decided by DepR.

Image
I didnt change the color so a bit uneasy to see. The upper trace is the spikes, the middle trace is D (for depression) with a smaller DepR and the lower trace is D with the same Dep and a bigger DepR. PSP is zero when there is no spike delivered to the postsynaptic neuron.
So when a spike arrives, the synapse depresses, but between spikes, the synapse would get some recovery from the depression. The results were done in MATLAB and now I need to build up a larger network so turn to NEURON.
Sorry I've got loads of problems. I've been stuck here for over a week now and catching up to a deadline so really need your help. Thanks a lot!
Last edited by yj232 on Mon Jun 27, 2011 6:38 am, edited 3 times in total.
yj232

Re: how to pass variables into mod file?

Post by yj232 »

I've simplified the equations into easier ones.
D'= -Dep*D : if there is a spike delivered in
D'= DepR*(1-D) : no spikes

same for the facilitation
F'= Fac* F : spikes in
F'= -FacR*(1-F) : no spikes

so during spikes the recovery mechanism take over.
I suppose this should be easier to tackle?
yj232

Re: how to pass variables into mod file?

Post by yj232 »

I think I've got this tackled. Thanks for helping.
Post Reply