| 1 |
""" |
| 2 |
Decision network as in: |
| 3 |
|
| 4 |
Wang, X.-J. |
| 5 |
Probabilistic decision making by slow reverberation in cortical circuits. |
| 6 |
Neuron, 2002, 36, 955-968. |
| 7 |
|
| 8 |
Authors: Klaus Wimmer ([email protected]) and Marcel Stimberg |
| 9 |
""" |
| 10 |
|
| 11 |
from brian2 import * |
| 12 |
|
| 13 |
# ----------------------------------------------------------------------------------------------- |
| 14 |
# Set up the simulation |
| 15 |
# ----------------------------------------------------------------------------------------------- |
| 16 |
|
| 17 |
# Stimulus and simulation parameters |
| 18 |
coh = 12.8 # coherence of random dots |
| 19 |
sigma = 4.0 * Hz # standard deviation of stimulus input |
| 20 |
mu0 = 40.0 * Hz # stimulus input at zero coherence |
| 21 |
mu1 = 40.0 * Hz # selective stimulus input at highest coherence |
| 22 |
stim_interval = 50.0 * ms # stimulus changes every 50 ms |
| 23 |
stim_on = 1000 * ms # stimulus onset |
| 24 |
stim_off = 3000 * ms # stimulus offset |
| 25 |
runtime = 4000 * ms # total simulation time |
| 26 |
|
| 27 |
# External noise inputs |
| 28 |
N_ext = 1000 # number of external Poisson neurons |
| 29 |
rate_ext_E = 2400 * Hz / N_ext # external Poisson rate for excitatory population |
| 30 |
rate_ext_I = 2400 * Hz / N_ext # external Poisson rate for inhibitory population |
| 31 |
|
| 32 |
# Network parameters |
| 33 |
N = 2000 # number of neurons |
| 34 |
f_inh = 0.2 # fraction of inhibitory neurons |
| 35 |
NE = int(N * (1.0 - f_inh)) # number of excitatory neurons (1600) |
| 36 |
NI = int(N * f_inh) # number of inhibitory neurons (400) |
| 37 |
fE = 0.15 # coding fraction |
| 38 |
subN = int(fE * NE) # number of neurons in decision pools (240) |
| 39 |
|
| 40 |
# Neuron parameters |
| 41 |
El = -70.0 * mV # resting potential |
| 42 |
Vt = -50.0 * mV # firing threshold |
| 43 |
Vr = -55.0 * mV # reset potential |
| 44 |
CmE = 0.5 * nF # membrane capacitance for pyramidal cells (excitatory neurons) |
| 45 |
CmI = 0.2 * nF # membrane capacitance for interneurons (inhibitory neurons) |
| 46 |
gLeakE = 25.0 * nS # membrane leak conductance of excitatory neurons |
| 47 |
gLeakI = 20.0 * nS # membrane leak conductance of inhibitory neurons |
| 48 |
refE = 2.0 * ms # refractory periodof excitatory neurons |
| 49 |
refI = 1.0 * ms # refractory period of inhibitory neurons |
| 50 |
|
| 51 |
# Synapse parameters |
| 52 |
V_E = 0. * mV # reversal potential for excitatory synapses |
| 53 |
V_I = -70. * mV # reversal potential for inhibitory synapses |
| 54 |
tau_AMPA = 2.0 * ms # AMPA synapse decay |
| 55 |
tau_NMDA_rise = 2.0 * ms # NMDA synapse rise |
| 56 |
tau_NMDA_decay = 100.0 * ms # NMDA synapse decay |
| 57 |
tau_GABA = 5.0 * ms # GABA synapse decay |
| 58 |
alpha = 0.5 * kHz # saturation of NMDA channels at high presynaptic firing rates |
| 59 |
C = 1 * mmole # extracellular magnesium concentration |
| 60 |
|
| 61 |
# Synaptic conductances |
| 62 |
gextE = 2.1 * nS # external -> excitatory neurons (AMPA) |
| 63 |
gextI = 1.62 * nS # external -> inhibitory neurons (AMPA) |
| 64 |
gEEA = 0.05 * nS / NE * 1600 # excitatory -> excitatory neurons (AMPA) |
| 65 |
gEIA = 0.04 * nS / NE * 1600 # excitatory -> inhibitory neurons (AMPA) |
| 66 |
gEEN = 0.165 * nS / NE * 1600 # excitatory -> excitatory neurons (NMDA) |
| 67 |
gEIN = 0.13 * nS / NE * 1600 # excitatory -> inhibitory neurons (NMDA) |
| 68 |
gIE = 1.3 * nS / NI * 400 # inhibitory -> excitatory neurons (GABA) |
| 69 |
gII = 1.0 * nS / NI * 400 # inhibitory -> inhibitory neurons (GABA) |
| 70 |
|
| 71 |
# Synaptic footprints |
| 72 |
Jp = 1.7 # relative synaptic strength inside a selective population (1.0: no potentiation)) |
| 73 |
Jm = 1.0 - fE * (Jp - 1.0) / (1.0 - fE) |
| 74 |
|
| 75 |
# Neuron equations |
| 76 |
# Note the "(unless refractory)" statement serves to clamp the membrane voltage during the refractory period; |
| 77 |
# otherwise the membrane potential continues to be integrated but no spikes are emitted. |
| 78 |
eqsE = """ |
| 79 |
label : integer (constant) # label for decision encoding populations |
| 80 |
dV/dt = (- gLeakE * (V - El) - I_AMPA - I_NMDA - I_GABA - I_AMPA_ext + I_input) / CmE : volt (unless refractory) |
| 81 |
|
| 82 |
I_AMPA = s_AMPA * (V - V_E) : amp |
| 83 |
ds_AMPA / dt = - s_AMPA / tau_AMPA : siemens |
| 84 |
|
| 85 |
I_NMDA = gEEN * s_NMDA_tot * (V - V_E) / ( 1 + exp(-0.062 * V/mvolt) * (C/mmole / 3.57) ) : amp |
| 86 |
s_NMDA_tot : 1 |
| 87 |
|
| 88 |
I_GABA = s_GABA * (V - V_I) : amp |
| 89 |
ds_GABA / dt = - s_GABA / tau_GABA : siemens |
| 90 |
|
| 91 |
I_AMPA_ext = s_AMPA_ext * (V - V_E) : amp |
| 92 |
ds_AMPA_ext / dt = - s_AMPA_ext / tau_AMPA : siemens |
| 93 |
|
| 94 |
I_input : amp |
| 95 |
|
| 96 |
ds_NMDA / dt = - s_NMDA / tau_NMDA_decay + alpha * x * (1 - s_NMDA) : 1 |
| 97 |
dx / dt = - x / tau_NMDA_rise : 1 |
| 98 |
""" |
| 99 |
|
| 100 |
eqsI = """ |
| 101 |
dV/dt = (- gLeakI * (V - El) - I_AMPA - I_NMDA - I_GABA - I_AMPA_ext) / CmI : volt (unless refractory) |
| 102 |
|
| 103 |
I_AMPA = s_AMPA * (V - V_E) : amp |
| 104 |
ds_AMPA / dt = - s_AMPA / tau_AMPA : siemens |
| 105 |
|
| 106 |
I_NMDA = gEIN * s_NMDA_tot * (V - V_E) / ( 1 + exp(-0.062 * V/mvolt) * (C/mmole / 3.57) ): amp |
| 107 |
s_NMDA_tot : 1 |
| 108 |
|
| 109 |
I_GABA = s_GABA * (V - V_I) : amp |
| 110 |
ds_GABA / dt = - s_GABA / tau_GABA : siemens |
| 111 |
|
| 112 |
I_AMPA_ext = s_AMPA_ext * (V - V_E) : amp |
| 113 |
ds_AMPA_ext / dt = - s_AMPA_ext / tau_AMPA : siemens |
| 114 |
""" |
| 115 |
|
| 116 |
# Neuron populations |
| 117 |
popE = NeuronGroup(NE, model=eqsE, threshold='V > Vt', reset='V = Vr', refractory=refE, method='euler', name='popE') |
| 118 |
popI = NeuronGroup(NI, model=eqsI, threshold='V > Vt', reset='V = Vr', refractory=refI, method='euler', name='popI') |
| 119 |
popE1 = popE[:subN] |
| 120 |
popE2 = popE[subN:2 * subN] |
| 121 |
popE3 = popE[2 * subN:] |
| 122 |
popE1.label = 0 |
| 123 |
popE2.label = 1 |
| 124 |
popE3.label = 2 |
| 125 |
|
| 126 |
# Recurrent excitatory -> excitatory connections mediated by AMPA receptors |
| 127 |
C_EE_AMPA = Synapses(popE, popE, 'w : siemens', on_pre='s_AMPA += w', delay=0.5 * ms, method='euler', name='C_EE_AMPA') |
| 128 |
C_EE_AMPA.connect() |
| 129 |
C_EE_AMPA.w[:] = gEEA |
| 130 |
C_EE_AMPA.w["label_pre == label_post and label_pre < 2"] = gEEA*Jp |
| 131 |
C_EE_AMPA.w["label_pre != label_post and label_post < 2"] = gEEA*Jm |
| 132 |
# Note that this produces the following structure of excitatory connections: |
| 133 |
# |
| 134 |
# | from E1 from E2 from E3 |
| 135 |
# --------------------------------- |
| 136 |
# to E1 | Jp Jm Jm |
| 137 |
# to E2 | Jm Jp Jm |
| 138 |
# to E3 | 1 1 1 |
| 139 |
|
| 140 |
# Recurrent excitatory -> inhibitory connections mediated by AMPA receptors |
| 141 |
C_EI_AMPA = Synapses(popE, popI, on_pre='s_AMPA += gEIA', delay=0.5 * ms, method='euler', name='C_EI_AMPA') |
| 142 |
C_EI_AMPA.connect() |
| 143 |
|
| 144 |
# Recurrent excitatory -> excitatory connections mediated by NMDA receptors |
| 145 |
C_EE_NMDA = Synapses(popE, popE, on_pre='x_pre += 1', delay=0.5 * ms, method='euler', name='C_EE_NMDA') |
| 146 |
C_EE_NMDA.connect(j='i') |
| 147 |
|
| 148 |
# Dummy population to store the summed activity of the three populations |
| 149 |
NMDA_sum_group = NeuronGroup(3, 's : 1', name='NMDA_sum_group') |
| 150 |
|
| 151 |
# Sum the activity according to the subpopulation labels |
| 152 |
NMDA_sum = Synapses(popE, NMDA_sum_group, 's_post = s_NMDA_pre : 1 (summed)', name='NMDA_sum') |
| 153 |
NMDA_sum.connect(j='label_pre') |
| 154 |
|
| 155 |
# Propagate the summed activity to the NMDA synapses |
| 156 |
NMDA_set_total_E = Synapses(NMDA_sum_group, popE, |
| 157 |
'''w : 1 (constant) |
| 158 |
s_NMDA_tot_post = w*s_pre : 1 (summed)''', name='NMDA_set_total_E') |
| 159 |
NMDA_set_total_E.connect() |
| 160 |
NMDA_set_total_E.w = 1 |
| 161 |
NMDA_set_total_E.w["i == label_post and label_post < 2"] = Jp |
| 162 |
NMDA_set_total_E.w["i != label_post and label_post < 2"] = Jm |
| 163 |
|
| 164 |
# Recurrent excitatory -> inhibitory connections mediated by NMDA receptors |
| 165 |
NMDA_set_total_I = Synapses(NMDA_sum_group, popI, |
| 166 |
'''s_NMDA_tot_post = s_pre : 1 (summed)''', name='NMDA_set_total_I') |
| 167 |
NMDA_set_total_I.connect() |
| 168 |
|
| 169 |
# Recurrent inhibitory -> excitatory connections mediated by GABA receptors |
| 170 |
C_IE = Synapses(popI, popE, on_pre='s_GABA += gIE', delay=0.5 * ms, method='euler', name='C_IE') |
| 171 |
C_IE.connect() |
| 172 |
|
| 173 |
# Recurrent inhibitory -> inhibitory connections mediated by GABA receptors |
| 174 |
C_II = Synapses(popI, popI, on_pre='s_GABA += gII', delay=0.5 * ms, method='euler', name='C_II') |
| 175 |
C_II.connect() |
| 176 |
|
| 177 |
# External inputs (fixed background firing rates) |
| 178 |
extinputE = PoissonInput(popE, 's_AMPA_ext', N_ext, rate_ext_E, gextE) |
| 179 |
extinputI = PoissonInput(popI, 's_AMPA_ext', N_ext, rate_ext_I, gextI) |
| 180 |
|
| 181 |
# Stimulus input (updated every 50ms) |
| 182 |
stiminputE1 = PoissonGroup(subN, rates=0*Hz, name='stiminputE1') |
| 183 |
stiminputE2 = PoissonGroup(subN, rates=0*Hz, name='stiminputE2') |
| 184 |
stiminputE1.run_regularly("rates = int(t > stim_on and t < stim_off) * (mu0 + coh / 100.0 * mu1 + sigma*randn())", dt=stim_interval) |
| 185 |
stiminputE2.run_regularly("rates = int(t > stim_on and t < stim_off) * (mu0 - coh / 100.0 * mu1 + sigma*randn())", dt=stim_interval) |
| 186 |
C_stimE1 = Synapses(stiminputE1, popE1, on_pre='s_AMPA_ext += gextE', name='C_stimE1') |
| 187 |
C_stimE1.connect(j='i') |
| 188 |
C_stimE2 = Synapses(stiminputE2, popE2, on_pre='s_AMPA_ext += gextE', name='C_stimE2') |
| 189 |
C_stimE2.connect(j='i') |
| 190 |
|
| 191 |
|
| 192 |
# ----------------------------------------------------------------------------------------------- |
| 193 |
# Run the simulation |
| 194 |
# ----------------------------------------------------------------------------------------------- |
| 195 |
|
| 196 |
# Set initial conditions |
| 197 |
popE.s_NMDA_tot = tau_NMDA_decay * 10 * Hz * 0.2 |
| 198 |
popI.s_NMDA_tot = tau_NMDA_decay * 10 * Hz * 0.2 |
| 199 |
popE.V = Vt - 2 * mV |
| 200 |
popI.V = Vt - 2 * mV |
| 201 |
|
| 202 |
# Record spikes of excitatory neurons in the decision encoding populations |
| 203 |
SME1 = SpikeMonitor(popE1, record=True) |
| 204 |
SME2 = SpikeMonitor(popE2, record=True) |
| 205 |
|
| 206 |
# Record population activity |
| 207 |
R1 = PopulationRateMonitor(popE1) |
| 208 |
R2 = PopulationRateMonitor(popE2) |
| 209 |
|
| 210 |
# Record input |
| 211 |
E1 = StateMonitor(stiminputE1, 'rates', record=0, dt=1*ms) |
| 212 |
E2 = StateMonitor(stiminputE2, 'rates', record=0, dt=1*ms) |
| 213 |
|
| 214 |
# Run the simulation |
| 215 |
run(runtime, report='stdout', profile=True) |
| 216 |
print(profiling_summary()) |
| 217 |
|
| 218 |
# Show results |
| 219 |
fig, axs = plt.subplots(4, 1, sharex=True, layout='constrained', gridspec_kw={'height_ratios': [2, 2, 2, 1]}) |
| 220 |
axs[0].plot(SME1.t / ms, SME1.i, '.', markersize=2, color='darkred') |
| 221 |
axs[0].set(ylabel='population 1', ylim=(0, subN)) |
| 222 |
|
| 223 |
axs[1].plot(SME2.t / ms, SME2.i, '.', markersize=2, color='darkblue') |
| 224 |
axs[1].set(ylabel='population 2', ylim=(0, subN)) |
| 225 |
|
| 226 |
axs[2].plot(R1.t / ms, R1.smooth_rate(window='flat', width=100 * ms) / Hz, color='darkred') |
| 227 |
axs[2].plot(R2.t / ms, R2.smooth_rate(window='flat', width=100 * ms) / Hz, color='darkblue') |
| 228 |
axs[2].set(ylabel='Firing rate (Hz)') |
| 229 |
|
| 230 |
axs[3].plot(E1.t / ms, E1.rates[0] / Hz, color='darkred') |
| 231 |
axs[3].plot(E2.t / ms, E2.rates[0] / Hz, color='darkblue') |
| 232 |
axs[3].set(ylabel='Input (Hz)', xlabel='Time (ms)') |
| 233 |
|
| 234 |
fig.align_ylabels(axs) |
| 235 |
|
| 236 |
plt.show() |