Debian Codegraph @

examples/frompapers/Hindmarsh_Rose_1984.py

raw
1 # encoding: utf8
2 """
3 Burst generation in the Hinsmarsh-Rose model. Reproduces Figure 6 of:
4
5 Hindmarsh, J. L., and R. M. Rose.
6 “A Model of Neuronal Bursting Using Three Coupled First Order Differential Equations.”
7 Proceedings of the Royal Society of London. Series B, Biological Sciences 221, no. 1222 (1984): 87–102.
8 """
9 from brian2 import *
10
11 # In the original model, time is measured in arbitrary time units
12 time_unit = 1*ms
13 defaultclock.dt = time_unit/10
14
15 x_1 = -1.6 # leftmost equilibrium point of the model without adaptation
16 a = 1; b = 3; c = 1; d = 5
17 r = 0.001; s = 4
18 eqs = '''
19 dx/dt = (y - a*x**3 + b*x**2 + I - z)/time_unit : 1
20 dy/dt = (c - d*x**2 - y)/time_unit : 1
21 dz/dt = r*(s*(x - x_1) - z)/time_unit : 1
22 I : 1 (constant)
23 '''
24
25 # We run the model with three different currents
26 neuron = NeuronGroup(3, eqs, method='rk4')
27
28 # Set all variables to their equilibrium point
29 neuron.x = x_1
30 neuron.y = 'c - d*x**2'
31 neuron.z = 'r*(s*(x - x_1))'
32
33 # Set the constant current input
34 neuron.I = [0.4, 2, 4]
35
36 # Record the "membrane potential"
37 mon = StateMonitor(neuron, 'x', record=True)
38
39 run(2100*time_unit)
40
41 ax_top = plt.subplot2grid((2, 3), (0, 0), colspan=3)
42 ax_bottom_l = plt.subplot2grid((2, 3), (1, 0), colspan=2)
43 ax_bottom_r = plt.subplot2grid((2, 3), (1, 2))
44 for ax in [ax_top, ax_bottom_l, ax_bottom_r]:
45 ax.spines['top'].set_visible(False)
46 ax.spines['right'].set_visible(False)
47 ax.set(ylim=(-2, 2), yticks=[-2, 0, 2])
48
49 ax_top.plot(mon.t/time_unit, mon.x[0])
50
51 ax_bottom_l.plot(mon.t/time_unit, mon.x[1])
52 ax_bottom_l.set_xlim(700, 2100)
53
54 ax_bottom_r.plot(mon.t/time_unit, mon.x[2])
55 ax_bottom_r.set_xlim(1400, 2100)
56 ax_bottom_r.set_yticks([])
57
58 plt.show()