#!pip install ANNarchy
COBA and CUBA networks
This notebook reproduces the benchmarks used in:
Brette, R., Rudolph, M., Carnevale, T., Hines, M., Beeman, D., Bower, J. M., et al. (2007), Simulation of networks of spiking neurons: a review of tools and strategies., J. Comput. Neurosci., 23, 3, 349–98
They are based on the balanced network proposed by:
Vogels, T. P. and Abbott, L. F. (2005), Signal propagation and logic gating in networks of integrate-and-fire neurons., J. Neurosci., 25, 46, 10786–95
Each network is composed of 4000 neurons (3200 excitatory and 800 inhibitory), reciprocally connected with a probability of 0.02 (sparse connection).
The CUBA network uses a current-based integrate-and-fire neuron model:
\tau \cdot \frac{dv (t)}{dt} = E_l - v(t) + g_\text{exc} (t) - g_\text{inh} (t)
while the COBA model uses conductance-based IF neurons:
\tau \cdot \frac{dv (t)}{dt} = E_l - v(t) + g_\text{exc} (t) * (E_\text{exc} - v(t)) + g_\text{inh} (t) * (E_\text{inh} - v(t)) + I(t)
Apart from the neuron model and synaptic weights, both networks are equal, so we’ll focus on the COBA network here.
The discretization step has to be set to 0.1 ms:
import numpy as np
import ANNarchy as ann
=0.1) ann.setup(dt
ANNarchy 4.8 (4.8.2) on darwin (posix).
Neuron definition
= ann.Neuron(
COBA ="""
parameters El = -60.0 : population
Vr = -60.0 : population
Erev_exc = 0.0 : population
Erev_inh = -80.0 : population
Vt = -50.0 : population
tau = 20.0 : population
tau_exc = 5.0 : population
tau_inh = 10.0 : population
I = 20.0 : population
""",
="""
equations tau * dv/dt = (El - v) + g_exc * (Erev_exc - v) + g_inh * (Erev_inh - v ) + I
tau_exc * dg_exc/dt = - g_exc
tau_inh * dg_inh/dt = - g_inh
""",
= "v > Vt",
spike = "v = Vr",
reset = 5.0
refractory )
= ann.Neuron(
CUBA ="""
parameters El = -49.0 : population
Vr = -60.0 : population
Vt = -50.0 : population
tau_m = 20.0 : population
tau_exc = 5.0 : population
tau_inh = 10.0 : population
""",
="""
equations tau_m * dv/dt = (El - v) + g_exc - g_inh
tau_exc * dg_exc/dt = - g_exc
tau_inh * dg_inh/dt = - g_inh
""",
= "v > Vt",
spike = "v = Vr",
reset = 5.0
refractory )
The neurons define exponentially-decreasing conductance g_exc and g_inh for the excitatory and inhibitory conductances/currents, respectively. They also define a refractory period of 5 ms.
Population
# COBA network
= ann.Population(geometry=4000, neuron=COBA)
P_COBA = P_COBA[:3200] ; P_COBA_I = P_COBA[3200:]
P_COBA_E
# CUBA network
= ann.Population(geometry=4000, neuron=CUBA)
P_CUBA = P_CUBA[:3200] ; P_CUBA_I = P_CUBA[3200:] P_CUBA_E
For both networks, we create a population of COBA neurons, and assign the 3200 first ones to an excitatory sub-population and the 800 last ones to an inhibitory sub-population.
It would have been equivalent to declare two separate populations as:
= ann.Population(geometry=3200, neuron=COBA)
P_COBA_E = ann.Population(geometry= 800, neuron=COBA) P_COBA_I
but splitting a global population allows to apply methods to all neurons, for example when recording all spikes with a single monitor, or when initializing populations parameters uniformly.
We now initialize the variables of both populations:
# COBA
= ann.Normal(-55.0, 5.0)
P_COBA.v = ann.Normal(4.0, 1.5)
P_COBA.g_exc = ann.Normal(20.0, 12.0)
P_COBA.g_inh
# CUBA
= ann.Uniform(-60.0, -50.0) P_CUBA.v
Connections
The neurons are randomly connected with a probability of 0.02. Excitatory neurons project on all other neurons with the target “exc” and a weight of 0.6 (COBA) or , while the inhibitory neurons have the target “inh” and a weight of 6.7.
# COBA
= 0.6
we_COBA = 6.7
wi_COBA = ann.Projection(pre=P_COBA_E, post=P_COBA, target='exc')
Ce_COBA =we_COBA, probability=0.02)
Ce_COBA.connect_fixed_probability(weights
= ann.Projection(pre=P_COBA_I, post=P_COBA, target='inh')
Ci_COBA =wi_COBA, probability=0.02)
Ci_COBA.connect_fixed_probability(weights
# CUBA
= 0.27 * 60.0 / 10.0 # 0.7 * (Vmean - E_rev_exc) / gL (mV)
we_CUBA = 4.5 * 20.0 / 10.0 # 4.5 * (Vmean - E_rev_inh) / gL (mV)
wi_CUBA = ann.Projection(pre=P_CUBA_E, post=P_CUBA, target='exc')
Ce_CUBA =we_CUBA, probability=0.02)
Ce_CUBA.connect_fixed_probability(weights
= ann.Projection(pre=P_CUBA_I, post=P_CUBA, target='inh')
Ci_CUBA =wi_CUBA, probability=0.02) Ci_CUBA.connect_fixed_probability(weights
<ANNarchy.core.Projection.Projection at 0x1338f2d50>
compile() ann.
Compiling ... OK
Simulation
We first define a monitor to record the spikes emitted in the two populations:
= ann.Monitor(P_COBA, ['spike'])
m_COBA = ann.Monitor(P_CUBA, ['spike']) m_CUBA
We can then simulate for 1 second:
1000.) ann.simulate(
We retrieve the recorded spikes from the monitor:
= m_COBA.get('spike')
data_COBA = m_CUBA.get('spike') data_CUBA
and compute a raster plot from the data:
= m_COBA.raster_plot(data_COBA)
t_COBA, n_COBA = m_CUBA.raster_plot(data_CUBA) t_CUBA, n_CUBA
t
and n
are lists representing for each spike emitted during the simulation the time at which it was emitted and the index the neuron which fired. The length of this list represents the total number of spikes in the popultion, so we can compute the population mean firing rate:
print('Mean firing rate in the COBA population: ' + str(len(t_COBA) / 4000.) + 'Hz')
print('Mean firing rate in the CUBA population: ' + str(len(t_CUBA) / 4000.) + 'Hz')
Mean firing rate in the COBA population: 22.0885Hz
Mean firing rate in the CUBA population: 5.7385Hz
Finally, we can show the raster plot with matplotlib:
import matplotlib.pyplot as plt
=(15, 8))
plt.figure(figsize121)
plt.subplot("COBA")
plt.title('.', markersize=0.5)
plt.plot(t_COBA, n_COBA, 'Time (ms)')
plt.xlabel('# neuron')
plt.ylabel(122)
plt.subplot("CUBA")
plt.title('.', markersize=0.5)
plt.plot(t_CUBA, n_CUBA, 'Time (ms)')
plt.xlabel('# neuron')
plt.ylabel( plt.show()
More detailed information about the activity of the population is provided by the inter-spike interval and the coefficient of variation, for both of which values we offer methods provided by the Monitor class.
= m_COBA.inter_spike_interval(data_COBA)
isi_COBA = m_COBA.inter_spike_interval(data_CUBA)
isi_CUBA
=(15, 8))
plt.figure(figsize121)
plt.subplot("COBA")
plt.title(
plt.hist(isi_COBA)'ISI (ms)')
plt.xlabel('n in bin')
plt.ylabel(122)
plt.subplot("CUBA")
plt.title(
plt.hist(isi_CUBA)'ISI (ms)')
plt.xlabel('n in bin')
plt.ylabel( plt.show()
= m_COBA.coefficient_of_variation(data_COBA)
cov_COBA = m_COBA.coefficient_of_variation(data_CUBA)
cov_CUBA
=(15, 8))
plt.figure(figsize121)
plt.subplot("COBA")
plt.title(
plt.hist(cov_COBA)'ISI CV')
plt.xlabel('n in bin')
plt.ylabel(122)
plt.subplot("CUBA")
plt.title(
plt.hist(cov_CUBA)'ISI CV')
plt.xlabel('n in bin')
plt.ylabel( plt.show()