Debian Codegraph @

docs_sphinx/user/converting_from_integrated_form.rst

raw
1 .. _integrated_form:
2
3 Converting from integrated form to ODEs
4 =======================================
5
6 Brian requires models to be expressed as systems of first order ordinary differential equations,
7 and the effect of spikes to be expressed as (possibly delayed) one-off changes. However, many
8 neuron models are given in *integrated form*. For example, one form of the Spike Response Model
9 (SRM; Gerstner and Kistler 2002) is defined as
10
11 .. math::
12
13 V(t) = \sum_i w_i \sum_{t_i} \mathrm{PSP}(t-t_i)+V_\mathrm{rest}
14
15 where :math:`V(t)` is the membrane potential, :math:`V_\mathrm{rest}` is the rest potential,
16 :math:`w_i` is the synaptic weight of synapse :math:`i`, and :math:`t_i` are the timings of
17 the spikes coming from synapse :math:`i`, and PSP is a postsynaptic potential function.
18
19 An example PSP is the :math:`\alpha`-function :math:`\mathrm{PSP}(t)=(t/\tau)e^{-t/\tau}`.
20 For this function, we could rewrite the equation above in the following ODE form:
21
22 .. math::
23
24 \tau \frac{\mathrm{d}V}{\mathrm{d}t} & = V_\mathrm{rest}-V+g \\
25 \tau \frac{\mathrm{d}g}{\mathrm{d}t} &= -g \\
26 g &\leftarrow g+w_i\;\;\;\mbox{upon spike from synapse $i$}
27
28 This could then be written in Brian as::
29
30 eqs = '''
31 dV/dt = (V_rest-V+g)/tau : 1
32 dg/dt = -g/tau : 1
33 '''
34 G = NeuronGroup(N, eqs, ...)
35 ...
36 S = Synapses(G, G, 'w : 1', on_pre='g += w')
37
38 To see that these two formulations are the same, you first solve the problem for the case of
39 a single synapse and a single spike at time 0. The initial conditions at :math:`t=0` will be
40 :math:`V(0)=V_\mathrm{rest}`, :math:`g(0)=w`.
41
42 To solve these equations, let's substitute :math:`s=t/\tau` and take derivatives with respect to
43 :math:`s` instead of :math:`t`, set :math:`u=V-V_\mathrm{rest}`, and assume :math:`w=1`.
44 This gives us the equations :math:`u^\prime=g-u`, :math:`g^\prime=-g` with initial conditions
45 :math:`u(0)=0`, :math:`g(0)=1`. At this point, you can either consult a textbook on solving
46 linear systems of differential equations, or just
47 `plug this into Wolfram Alpha <https://www.wolframalpha.com/input/?i=u%27(s)%3Dg(s)-u(s),+g%27(s)%3D-g(s),+u(0)%3D0,+g(0)%3D1>`_
48 to get the solution :math:`g(s)=e^{-s}`, :math:`u(s)=se^{-s}` which is equal to the PSP
49 given above.
50
51 Now we use the linearity of these differential equations to see that it also works when
52 :math:`w\neq 0` and for summing over multiple spikes at different times.
53
54 In general, to convert from integrated form to ODE form, see
55 `Köhn and Wörgötter (1998) <http://www.mitpressjournals.org/doi/abs/10.1162/089976698300017061>`_,
56 `Sánchez-Montañás (2001) <https://link.springer.com/chapter/10.1007/3-540-45720-8_14>`_,
57 and `Jahnke et al. (1999) <http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.20.2284&rep=rep1&type=pdf>`_.
58 However, for some simple and widely used types of synapses, use the list below. In this list, we assume synapses
59 are postsynaptic potentials, but you can replace :math:`V(t)` with a current or conductance for postsynaptic
60 currents or conductances. In each case, we give the Brian code with unitless variables, where ``eqs`` is the
61 differential equations for the target `NeuronGroup`, and ``on_pre`` is the argument to `Synapses`.
62
63 **Exponential synapse** :math:`V(t)=e^{-t/\tau}`::
64
65 eqs = '''
66 dV/dt = -V/tau : 1
67 '''
68 on_pre = 'V += w'
69
70 **Alpha synapse** :math:`V(t)=(t/\tau)e^{-t/\tau}`::
71
72 eqs = '''
73 dV/dt = (x-V)/tau : 1
74 dx/dt = -x/tau : 1
75 '''
76 on_pre = 'x += w'
77
78 :math:`V(t)` reaches a maximum value of :math:`w/e` at time :math:`t=\tau`.
79
80 **Biexponential synapse** :math:`V(t)=p^{-1} \left(e^{-t/\tau_1}-e^{-t/\tau_2}\right)`,
81 where :math:`p = \frac{\tau_1}{\tau_2}^{\frac{\tau_2}{\tau_2 - \tau_2}} - \frac{\tau_1}{\tau_2}^{\frac{\tau_1}{\tau_2 - \tau_2}}` is a normalization factor::
82
83 eqs = '''
84 dV/dt = ((tau_2 / tau_1) ** (tau_1 / (tau_2 - tau_1))*x-V)/tau_1 : 1
85 dx/dt = -x/tau_2 : 1
86 '''
87 on_pre = 'x += w'
88
89 :math:`V(t)` reaches a maximum value of :math:`w` at time
90 :math:`t=\frac{\tau_1\tau_2}{\tau_2-\tau_1}\log\left(\frac{\tau_2}{\tau_1}\right)`.
91
92 **STDP**
93
94 The weight update equation of the standard STDP is also often stated in an integrated form and can be
95 converted to an ODE form. This is covered in
96 :doc:`Tutorial 2 </resources/tutorials/2-intro-to-brian-synapses>`.