In [1]:
from brian import *
Leaky Integrate and Fire neuron, defined by the differential equation:
tau dV/dt = -(V-El)
with a threshold value Vt and reset value Vr.
In [2]:
model_lif = 'dV/dt = -(V-El)/tau : volt'
Setting the parameters
In [3]:
tau = 20 * msecond # membrane time constant
Vt = -50 * mvolt # spike threshold
Vr = -60 * mvolt # reset value
El = -45 * mvolt # resting potential (same as the reset)
psp = 0.5 * mvolt # postsynaptic potential size
N_neurons = 40
Creating the group of neurons
In [4]:
G = NeuronGroup(N=N_neurons, model=model_lif, threshold=Vt, reset=Vr)
Introducing some noise in the neuron resting potentials
In [5]:
G.V = Vr + rand(N_neurons)*(Vt - Vr)
Making connections
In [6]:
C = Connection(G, G)
C.connect_random(sparseness=0.1, weight=psp)
In [7]:
M_spikes = SpikeMonitor(G)
M_membrane = StateMonitor(G, 'V', record=True)
In [8]:
run(200 * msecond)
Number of spikes
In [9]:
print M_spikes.nspikes
Raster plot
In [10]:
raster_plot()
show()
Membrane potentials of 2 neurons
In [11]:
plot(M_membrane.times / ms, M_membrane[1] / mV)
plot(M_membrane.times / ms, M_membrane[5] / mV)
xlabel('Time (in ms)')
ylabel('Membrane potential (in mV)')
title('Membrane potential for neurons 1 and 5')
show()