Integrate and Fire Neuron
In this notebook we will use Python to simulate the integrate and fire (I&F) neuron model. We’ll investigate, in particular, how the spiking activity varies as we adjust the input current \(I\).
1 Preliminaries
Before beginning, let’s load in the Python package we’ll need:
2 Numerical solutions - Introduction
How do we compute a numerical solution to the integrate and fire model? The basic idea is to rearrange the differential equation to get \(V(t+1)\) on the left hand side, and \(V(t)\) on the right hand side. Then, if we know what’s happening at time \(t\), we can solve for what’s happening at time \(t+1\).
For example, consider the differential equation:
\[ \dfrac{dV}{dt} = \dfrac{I}{C} \]
In words, we can think of:
\(dV\) as the “change in voltage V”,
\(dt\) as the “change in time t”.
Let’s consider the case that we record the voltage \(V\) in discrete time steps. So we observe:
\(V[0], V[1], V[2], \ldots\)
at times:
\(dt, \, 2*dt, \, 3*dt, \ldots\)
where \(dt\) is the time between our samples of \(V\).
We can now write the “change in voltage V” as:
\[ dV = V(t+1) - V(t) \]
Notice that the change in voltage is the difference in V between two sequential time samples. Now, let’s rewrite \(\dfrac{dV}{dt}\) as,
\[ \dfrac{dV}{dt} = \dfrac{ V(t+1) - V(t) }{ dt } \]
where we’ve replaced \(dV\). Now, let’s substitute this expression into the equation at the top of this file:
\[ \dfrac{ V(t+1) - V(t) }{ dt } = \dfrac{I}{C}. \]
Solving this equation for \(V(t+1)\) you’ll find that:
\[ V(t+1) = V(t) + dt*(I/C) \]
Notice that, in this expression, we use our current value of the voltage V(t) and the model (I/C) to determine the next value of the voltage V(t+1).
Now, let’s program this equation in Python. First, let’s set the values for the parameters \(I\) and \(C\).
We also need to set the value for \(dt\). This defines the time step for our model. We must choose it small enough so that we don’t miss anything interesting. We’ll choose:
Let’s assume the units of time are seconds. So, we step forward in time by \(0.01\) s.
The right hand side of our equation is nearly defined, but we’re still missing one thing, \(V(t)\).
So here’s an easier question: what initial value do we assign to \(V(t)\)?
To start, we’ll create an array of zeros to hold our results for \(V\):
This array V
consists of 1000 rows and 1 column. We can think of each row entry as corresponding to a discrete step in time. Our goal is to fill-in the values of V
(i.e., step forward in time), in a way consistent with our model.
Let’s choose an initial value for V
of 0.2, which in our simple model we’ll assume represents the rest state.
After the two calculations above, we’ve moved forward two time steps into the future, from \(t=0\) s to \(t=0.01\) s, and then from \(t=0.01\) s to \(t=0.02\) s. But what if we want to know \(V\) at \(t=10\) s? Then, this iteration-by-hand procedure becomes much too boring and error-prone. So, what do we do? Let’s make the computer do it …
3 Numerical solutions - Implementation
Let’s computerize this iteration-by-hand procedure to find V[999]
.
To do so, we’ll use a for-loop.
Here’s what it looks like:
Execute this for-loop and examine the results in vector V
. To do so, let’s plot V
:
This plot is informative, but not great. Really, we’d like to plot the voltage as a function of time, not steps or indices. To do so, we need to define a time axis:
Now, with time defined, let’s redo the plot of the voltage with the axes labeled appropriately.
Finally, let’s put it all together . . .
4 I&F CODE (version 1)
So far, we constructed parts of the I&F model in bits-and-pieces. Let’s now collect all the code, compute a numerical solution to the I&F model, and plot the results (with appropriate axes).
5 Voltage threshold
Notice, our model is missing something important: the reset.
Now, let’s update our model to include the reset. To do so, we’ll add two things to our code.
- First, we’ll define the voltage threshold
Vth
, and reset voltageVreset
. - Second, we’ll check to see if
V
exceedsVth
using an if-statement; if it does, then we’ll setV
equal toVreset
.
6 I&F CODE (version 2)
Now, let’s put it all together to make a complete I&F model (with a thershold and reset), simulate it, and plot the result.
7 Discussion
Describe the main components of the IF model. Draw it (in some way).
Describe the main components of the LIF model. Draw it (in some way).
Describe the differences and similarities between the IF and LIF models.
The IF model is meant to mimic a neurons activity. What is realistic about the IF model? What is unrealistic?
Describe the roles of the IF model parameters
Vreset
andVthreshold
.Consider the IF model. Sketch voltage (V) versus time (t) for a small input current, for a large input current.
- How does an increase in capacitance (C) impact the dynamics?
- Can you interpret this physically?
Plot the f-I curve for the IF model.
8 Challenges
Consider the LIF model. Plot (in Python) voltage (V) versus time (t) for a small input current, for a large input current.
Perform numerical simulations to determine how doubling the capacitance (C) impacts the firing rate of the LIF model. Based on your numerical simulations, does the firing rate increase or decrease? Provide a physical explanation for your results (i.e., how does the charge move around the circuit to impact the firing rate?) HINT: Capacitance represents the capacity of a cell to hold charge.
Perform numerical simulations to determine how doubling the resistance (R) impacts the firing rate of the LIF model. Based on your numerical simulations, does the firing rate increase or decrease? Provide a physical explanation for your results (i.e., how does the charge move around the circuit to impact the firing rate?) HINT: Higher resistance makes it harder for charge to flow in or out of the cell.
Determine how the firing rate of the LIF model varies with input I. Plot the firing rate versus I (i.e., plot the “f-I curve”).
ADVANCED. Simulate the Izhikevich neuron. Provide examples of two different types of spiking activity.