FacetsPythonCourse2008: leaky_if.py

File leaky_if.py, 0.6 kB (added by goodman, 7 months ago)
Line 
1 '''
2 A very simple example Brian script to show how to implement
3 a leaky integrate and fire model. In this example, we also
4 drive the single leaky integrate and fire neuron with
5 regularly spaced spikes from the :class:`SpikeGeneratorGroup`.
6 '''
7 from brian import *
8
9 tau = 10*ms
10 Vr = -70*mV
11 Vt = -55*mV
12
13 model = Model(equations='''
14     dV/dt = -(V-Vr)/tau : volt
15     ''', threshold=Vt, reset=Vr)
16 G = NeuronGroup(1,model)
17
18 spikes = linspace(10*ms,100*ms,25)
19 input = MultipleSpikeGeneratorGroup([spikes])
20
21 C = Connection(input, G)
22 C[0,0] = 5*mV
23
24 M = StateMonitor(G, 'V', record=True)
25
26 G.V = Vr
27 run(100*ms)
28 plot(M.times/ms,M[0]/mV)
29 show()