In [1]:
from brian import *


/usr/lib/pymodules/python2.7/brian/utils/sparse_patch/__init__.py:36: UserWarning: Couldn't find matching sparse matrix patch for scipy version 0.10.1, but in most cases this shouldn't be a problem.
  warnings.warn("Couldn't find matching sparse matrix patch for scipy version %s, but in most cases this shouldn't be a problem." % scipy.__version__)

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)

Monitoring activity


In [7]:
M_spikes = SpikeMonitor(G)
M_membrane = StateMonitor(G, 'V', record=True)

Running the simulation


In [8]:
run(200 * msecond)

Results

Number of spikes


In [9]:
print M_spikes.nspikes


442

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()