Skip to content

Commit 81235d1

Browse files
authored
Merge pull request #1388 from schmitts/Brunel_2000
Add simulations to reproduce figure 8 of Brunel (2000)
2 parents 83898fb + fd65d86 commit 81235d1

File tree

2 files changed

+155
-1
lines changed

2 files changed

+155
-1
lines changed

examples/frompapers/Brunel_2000.py

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Fig. 8 from:
4+
5+
Brunel, N. Dynamics of Sparsely Connected Networks of Excitatory and
6+
Inhibitory Spiking Neurons. J Comput Neurosci 8, 183–208
7+
(2000). https://doi.org/10.1023/A:1008925309027
8+
9+
Inspired by http://neuronaldynamics.epfl.ch
10+
11+
Sebastian Schmitt, 2022
12+
"""
13+
14+
import random
15+
from brian2 import *
16+
import matplotlib.pyplot as plt
17+
18+
19+
def sim(g, nu_ext_over_nu_thr, sim_time, ax_spikes, ax_rates, rate_tick_step):
20+
"""
21+
g -- relative inhibitory to excitatory synaptic strength
22+
nu_ext_over_nu_thr -- ratio of external stimulus rate to threshold rate
23+
sim_time -- simulation time
24+
ax_spikes -- matplotlib axes to plot spikes on
25+
ax_rates -- matplotlib axes to plot rates on
26+
rate_tick_step -- step size for rate axis ticks
27+
"""
28+
29+
# network parameters
30+
N_E = 10000
31+
gamma = 0.25
32+
N_I = round(gamma * N_E)
33+
N = N_E + N_I
34+
epsilon = 0.1
35+
C_E = epsilon * N_E
36+
C_ext = C_E
37+
38+
# neuron parameters
39+
tau = 20 * ms
40+
theta = 20 * mV
41+
V_r = 10 * mV
42+
tau_rp = 2 * ms
43+
44+
# synapse parameters
45+
J = 0.1 * mV
46+
D = 1.5 * ms
47+
48+
# external stimulus
49+
nu_thr = theta / (J * C_E * tau)
50+
51+
defaultclock.dt = 0.1 * ms
52+
53+
neurons = NeuronGroup(N,
54+
"""
55+
dv/dt = -v/tau : volt (unless refractory)
56+
""",
57+
threshold="v > theta",
58+
reset="v = V_r",
59+
refractory=tau_rp,
60+
method="exact",
61+
)
62+
63+
excitatory_neurons = neurons[:N_E]
64+
inhibitory_neurons = neurons[N_E:]
65+
66+
exc_synapses = Synapses(excitatory_neurons, target=neurons, on_pre="v += J", delay=D)
67+
exc_synapses.connect(p=epsilon)
68+
69+
inhib_synapses = Synapses(inhibitory_neurons, target=neurons, on_pre="v += -g*J", delay=D)
70+
inhib_synapses.connect(p=epsilon)
71+
72+
nu_ext = nu_ext_over_nu_thr * nu_thr
73+
74+
external_poisson_input = PoissonInput(
75+
target=neurons, target_var="v", N=C_ext, rate=nu_ext, weight=J
76+
)
77+
78+
rate_monitor = PopulationRateMonitor(neurons)
79+
80+
# record from the first 50 excitatory neurons
81+
spike_monitor = SpikeMonitor(neurons[:50])
82+
83+
run(sim_time, report='text')
84+
85+
ax_spikes.plot(spike_monitor.t / ms, spike_monitor.i, "|")
86+
ax_rates.plot(rate_monitor.t / ms, rate_monitor.rate / Hz)
87+
88+
ax_spikes.set_yticks([])
89+
90+
ax_spikes.set_xlim(*params["t_range"])
91+
ax_rates.set_xlim(*params["t_range"])
92+
93+
ax_rates.set_ylim(*params["rate_range"])
94+
ax_rates.set_xlabel("t [ms]")
95+
96+
ax_rates.set_yticks(
97+
np.arange(
98+
params["rate_range"][0], params["rate_range"][1] + rate_tick_step, rate_tick_step
99+
)
100+
)
101+
102+
plt.subplots_adjust(hspace=0)
103+
104+
105+
parameters = {
106+
"A": {
107+
"g": 3,
108+
"nu_ext_over_nu_thr": 2,
109+
"t_range": [500, 600],
110+
"rate_range": [0, 6000],
111+
"rate_tick_step": 1000,
112+
},
113+
"B": {
114+
"g": 6,
115+
"nu_ext_over_nu_thr": 4,
116+
"t_range": [1000, 1200],
117+
"rate_range": [0, 400],
118+
"rate_tick_step": 100,
119+
},
120+
"C": {
121+
"g": 5,
122+
"nu_ext_over_nu_thr": 2,
123+
"t_range": [1000, 1200],
124+
"rate_range": [0, 200],
125+
"rate_tick_step": 50,
126+
},
127+
"D": {
128+
"g": 4.5,
129+
"nu_ext_over_nu_thr": 0.9,
130+
"t_range": [1000, 1200],
131+
"rate_range": [0, 250],
132+
"rate_tick_step": 50,
133+
},
134+
}
135+
136+
for panel, params in parameters.items():
137+
138+
fig = plt.figure(figsize=(4, 5))
139+
fig.suptitle(panel)
140+
141+
gs = fig.add_gridspec(ncols=1, nrows=2, height_ratios=[4, 1])
142+
143+
ax_spikes, ax_rates = gs.subplots(sharex="col")
144+
145+
sim(
146+
params["g"],
147+
params["nu_ext_over_nu_thr"],
148+
params["t_range"][1] * ms,
149+
ax_spikes,
150+
ax_rates,
151+
params["rate_tick_step"],
152+
)
153+
154+
plt.show()

0 commit comments

Comments
 (0)