Page 1 of 1

Odd error with analytical solution

Posted: Wed Aug 05, 2009 1:09 am
by Bill Connelly
Hi,

A while ago I had a model of a depressing synapse that ran slowly because I had numerous differential equations. I've converted them to an analytical solution. It runs quickly, but I get the following error if I try to run it twice in a row, without quiting NEURON

exp(5645.55) out of range, returning exp(700)
exp(21914) out of range, returning exp(700)
exp(12344.3) out of range, returning exp(700)
exp(4433.3) out of range, returning exp(700)

I assume that means that that I'm passing 5645 (or those other large numbers) to the exp function, I can see why that would error. But this is my problem 1) Why would it error only on the second run, (there are now random variables) 2) How did it get 5656 in the first place? All of the exp functions look like this:
exp(-k*(t-t0))
The largest value of k is .1, the largest value of t is 500 and the smallest value of t0 is 0; so the largest the argument to the exp function should get is 50.

Whats going on here?

Code: Select all

NEURON {
POINT_PROCESS depsyn3
NONSPECIFIC_CURRENT i
RANGE i, e, tau, kA, kB, kC, dec, A, B, C, O, F, t0
}

PARAMETER {
e = -70 (millivolts)
tau = 7 (ms)
kA = 0.00017 (/ms)
kB = 0.01 (/ms)
kC = 0.1 (/ms)
dec = 0.3
A = 0
B = 0
C = 0
O = 1
F = 0
t0 = 0
}

STATE {
g
}

INITIAL {
g = 0
}

ASSIGNED {
  v (millivolt)
  i (nanoamp)
}

BREAKPOINT {
SOLVE state METHOD cnexp
i = g * (v - e)
}

DERIVATIVE state {
g' = -g/tau
}

NET_RECEIVE(weight (microsiemens)) {
A = A * exp(-kA*(t-t0))
B = B * exp(-kB*(t-t0))
C = C * exp(-kC*(t-t0))
t0=t

F = A * 0.5 + B * 0.3 + C * 0.2
O = 1 - F

g = (g + weight) * O

O = O * dec

F = 1 - O
A = F
B = F
C = F
}
P.S. Please correct me if I've got any STATES that should be PARAMETERS or RANGE variables that don't need to be there, or something along those lines; as I don't fully appreciate where I need to declare what.

Re: Odd error with analytical solution

Posted: Wed Aug 05, 2009 11:36 am
by ted
To discover where things are going wrong, embed printf statements that report the most recently computed value. For example,

Code: Select all

INITIAL {
printf("Initializing:  A = %g, B = %g, C = %g\n", A, B, C)
  g = 0
}
 . . .
NET_RECEIVE(weight (microsiemens)) {
  A = A * exp(-kA*(t-t0))
printf("A = %g\n")
  B = B * exp(-kB*(t-t0))
printf("B = %g\n")
A different question: are you quite sure that the implementation does what you want? This implementation has two features that you may want to reconsider:

1. It can handle only one input stream. A, B, and C will have the same values after n input events at times t1...tn, regardless of whether the events arrived from one source or multiple sources. Usually one wants a mechanism in which each input stream elicits postsynaptic effects that reflect only the prior activity of that stream; for an example, see 10.1.6. Example 10.5: Use-dependent synaptic plasticity in The NEURON Book. You can get stream-specific use-dependent plasticity by eliminating A, B, C, and t0 from the PARAMETER and NEURON blocks and making them part of the weight vector

Code: Select all

NET_RECEIVE(weight (microsiemens), A, B, C, t0 (ms)) {
If you do this, you don't have to explicitly declare or initialize these variables--they will automatically be 0.
To assign some other initial values to them, insert an INITIAL block into the NET_RECEIVE block like so:

Code: Select all

NET_RECEIVE(weight (microsiemens), A, B, C, t0 (ms)) {
  INITIAL {
    A = whatever
    B = etc.
   . . .
  }
 . . . body of NET_RECEIVE block follows . . .
}
2. The RHS of
g = (g + weight) * O
means that a new input event perturbs g in two ways:
(1) it makes g jump up by the amount weight * O, which is equivalent to saying that "the effective strength of a synapse depends on its prior history of activation" -- so far, so good --
and
(2) it also depresses the effects of all previous synaptic activations by the factor (1-O). This second perturbation is at odds with the usual conceptual models of use-dependent plasticity, which assume that each input event elicits a postsynaptic effect whose magnitude and time course depend on prior events and are not affected by subsequent inputs. If this is what you want, fine. But if not, you can get rid of it by writing
g = g + weight * O


Do you really want to make A, B, and C all equal to F?

Re: Odd error with analytical solution

Posted: Wed Aug 05, 2009 5:27 pm
by Bill Connelly
Thanks Ted, worked perfectly. The whole 'arguments that aren't really arguements' thing with the NET_RECEIVE block confused me.

Re: Odd error with analytical solution

Posted: Wed Aug 05, 2009 9:46 pm
by ted
Computer language syntax seems weird to all but native speakers. Native speakers of computer language seem weird to all but themselves.