# Converting from integrated form to ODEs¶

Brian requires models to be expressed as systems of first order ordinary differential equations, and the effect of spikes to be expressed as (possibly delayed) one-off changes. However, many neuron models are given in integrated form. For example, one form of the Spike Response Model (SRM; Gerstner and Kistler 2002) is defined as

$V(t) = \sum_i w_i \sum_{t_i} \mathrm{PSP}(t-t_i)+V_\mathrm{rest}$

where $$V(t)$$ is the membrane potential, $$V_\mathrm{rest}$$ is the rest potential, $$w_i$$ is the synaptic weight of synapse $$i$$, and $$t_i$$ are the timings of the spikes coming from synapse $$i$$, and PSP is a postsynaptic potential function.

An example PSP is the $$\alpha$$-function $$\mathrm{PSP}(t)=(t/\tau)e^{-t/\tau}$$. For this function, we could rewrite the equation above in the following ODE form:

$\begin{split}\tau \frac{\mathrm{d}V}{\mathrm{d}t} & = V_\mathrm{rest}-V+g \\ \tau \frac{\mathrm{d}g}{\mathrm{d}t} &= -g \\ g &\leftarrow g+w_i\;\;\;\mbox{upon spike from synapse i}\end{split}$

This could then be written in Brian as:

eqs = '''
dV/dt = (V_rest-V+g)/tau : 1
dg/dt = -g/tau : 1
'''
G = NeuronGroup(N, eqs, ...)
...
S = Synapses(G, G, 'w : 1', on_pre='g += w')


To see that these two formulations are the same, you first solve the problem for the case of a single synapse and a single spike at time 0. The initial conditions at $$t=0$$ will be $$V(0)=V_\mathrm{rest}$$, $$g(0)=w$$.

To solve these equations, let’s substitute $$s=t/\tau$$ and take derivatives with respect to $$s$$ instead of $$t$$, set $$u=V-V_\mathrm{rest}$$, and assume $$w=1$$. This gives us the equations $$u^\prime=g-u$$, $$g^\prime=-g$$ with initial conditions $$u(0)=0$$, $$g(0)=1$$. At this point, you can either consult a textbook on solving linear systems of differential equations, or just plug this into Wolfram Alpha to get the solution $$g(s)=e^{-s}$$, $$u(s)=se^{-s}$$ which is equal to the PSP given above.

Now we use the linearity of these differential equations to see that it also works when $$w\neq 0$$ and for summing over multiple spikes at different times.

In general, to convert from integrated form to ODE form, see Köhn and Wörgötter (1998), Sánchez-Montañás (2001), and Jahnke et al. (1999). However, for some simple and widely used types of synapses, use the list below. In this list, we assume synapses are postsynaptic potentials, but you can replace $$V(t)$$ with a current or conductance for postsynaptic currents or conductances. In each case, we give the Brian code with unitless variables, where eqs is the differential equations for the target NeuronGroup, and on_pre is the argument to Synapses.

Exponential synapse $$V(t)=e^{-t/\tau}$$:

eqs = '''
dV/dt = -V/tau : 1
'''
on_pre = 'V += w'


Alpha synapse $$V(t)=(t/\tau)e^{-t/\tau}$$:

eqs = '''
dV/dt = (x-V)/tau : 1
dx/dt = -x/tau    : 1
'''
on_pre = 'x += w'


$$V(t)$$ reaches a maximum value of $$w/e$$ at time $$t=\tau$$.

Biexponential synapse $$V(t)=\frac{\tau_2}{\tau_2-\tau_1}\left(e^{-t/\tau_1}-e^{-t/\tau_2}\right)$$:

eqs = '''
dV/dt = ((tau_2 / tau_1) ** (tau_1 / (tau_2 - tau_1))*x-V)/tau_1 : 1
dx/dt = -x/tau_2                                                 : 1
'''
on_pre = 'x += w'


$$V(t)$$ reaches a maximum value of $$w$$ at time $$t=\frac{\tau_1\tau_2}{\tau_2-\tau_1}\log\left(\frac{\tau_2}{\tau_1}\right)$$.

STDP

The weight update equation of the standard STDP is also often stated in an integrated form and can be converted to an ODE form. This is covered in Tutorial 2.