# Implementing Izhikevich's spiking neuron model

I am trying to implement Izhikevich's simple spiking neuron model which is given by

V'(t) = 0.04 V^2+5V+140-u+I
u'(t) = a(bv-u)
if V=30 mV then V=c, u=u+d


I am using a=0.02, b=0.2, c=-65, d=8

I can solve the coupled equations using NDSolve with the initial conditions of V and u, which gives me the interpolating functions for V(t) and u(t) and then I can plot them within a time window. But my problem is implementing the "If" condition within the boundary condition of NDSolve. Could someone please help me to figure out how to implement that If condition within NDSolve? Another problem is, how to then apply the resulting spiking neuron signals to a system? For example, in Simulink we can simply connect a signal source to a system. Let's say here I find the transfer function of my system where I want to apply the spiking neuron as the input. Typically I we use Outputresponse in mathematica to get output of the system against a standard signal input. But in this case, is there a way to use a similar method to get the system's response with the derived spiking neuron train as input? Thanks

• Edit your question using Mathematica syntax for the equations. Time dependence should be included for all instances of V and u. Is bv a product? If so, is v supposed to be V[t]. Is I an undefined constant or is it Sqrt[-1] Commented Apr 16, 2023 at 19:37

We can use input data from the page. Tonic Spiking model can be implemented as follows

{a, b, c, d} = {0.02, 0.40, -65.0, 2.0};
i[t_] := 10 UnitStep[t - 50];
sol = NDSolve[{v'[t] == .04 v[t]^2 + 5 v[t] + 140 - u[t] + i[t],
u'[t] == a (b v[t] - u[t]), u[0] == 0, v[0] == 18,
WhenEvent[v[t] == 30, {v[t] -> c, u[t] -> u[t] + d}]}, {u, v}, {t,
0, 200}]


Visualization

Plot[{v[t] /. sol[[1]], i[t]}, {t, 0, 200}, PlotRange -> All,
Frame -> True, FrameLabel -> Automatic, PlotPoints -> 200,
PlotStyle -> {Blue, Red}, PlotLegends -> {"v(t)", "I(t)"}]


• Dear Alex, Thank you so much! really appreciate.
– km3
Commented Apr 17, 2023 at 6:22
• You are welcome! Do you need help with Phasic Spiking model implementation? Commented Apr 17, 2023 at 6:30
• Thanks again! I think I can do it. If not I'll come back here. My main problem was to implement the 'If' condition since I was not aware of the WhenEvent function. However, I have an additional question if you can help. What I want to do is to use this tonic spiking as input to a system with transfer function given below
– km3
Commented Apr 17, 2023 at 6:47
• Thanks again! Let me try first. My problem was to implement the 'If' condition, I was not aware of WhenEvent. However, I have an additional question if you can help. I want to use this tonic spiking as input to a system (I have continuous transfer function) to observe the output. Applying this signal directly with OutputResponse will not work as this is a discrete signal. Is there a way to change it to a continuous signal? I can change the transfer function to a discrete system but my aim is to change the input spiking frequency to see at what frequency the system disrupts the signal.
– km3
Commented Apr 17, 2023 at 7:01
• Hi Alex, I have sorted it. Thank you so much for your help. Thanks for pointing me to the right direction. Regards.
– km3
Commented Apr 17, 2023 at 14:52