-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo_cx_Up-Down.py
245 lines (210 loc) · 10 KB
/
demo_cx_Up-Down.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
"""
2Layer Cortical Network Simulation
Destexhe Lab, Lyle Muller
LTS 2-Layer Demo
18 Mar 2010
This file implements a PyNN version of the model detailed in
Destexhe, A. Self-sustained asynchronous irregular states and
Up/Down states in thalamic, cortical and thalamocortical
networks of nonlinear integrate-and-fire neurons.
Journal of Computational Neuroscience 27: 493-506, 2009.
arXiv preprint: http://arxiv.org/abs/0809.0654
This file reproduces Fig 13 of that paper
Updated to work with PyNN 0.8, August 2016 by Andrew Davison
"""
import numpy.random, os
from pyNN.nest import *
from numpy import *
import matplotlib.pyplot as plot
from pyNN.utility import Timer, plotting
setup()
### Switch Statements
DistanceDep = True
run_time = 5000.0 # ms
b = .005 # b = .05 SA, .005 WA
#
# Population Numbers
py_n = 1600
inh_n = 400
pyB_n = 400
inhB_n = 100
#
# Synaptic Conductances / External Stimulation
g_e = 6e-3 # nS
g_i = 67e-3 # nS
g_ext = 6e-3
stim_dur = 50.0
p_c = .02
scale_factor = round((py_n+inh_n) / (pyB_n+inhB_n))
inter_p_c = .01
#
# Parameters
py_params = {'tau_m' : 20.0, # ms
'tau_syn_E' : 5.0,
'tau_syn_I' : 10.0,
'tau_refrac' : 2.5,
'v_rest' : -60.0,
'v_reset' : -60.0,
'v_thresh' : -50.0,
'delta_T' : 2.5,
'tau_w' : 600.0,
'cm' : 0.200,
'a' : 0.001e3,
'b' : b }
pyB_params = {'tau_m' : 20.0, # ms
'tau_syn_E' : 5.0,
'tau_syn_I' : 10.0,
'tau_refrac' : 2.5,
'v_rest' : -60.0,
'v_reset' : -60.0,
'v_thresh' : -50.0,
'delta_T' : 2.5,
'tau_w' : 600.0,
'cm' : 0.200,
'a' : 0.001e3,
'b' : b }
inh_params = {'tau_m' : 20.0, # ms
'tau_syn_E' : 5.0,
'tau_syn_I' : 10.0,
'tau_refrac' : 2.5,
'v_rest' : -60.0,
'v_reset' : -60.0,
'v_thresh' : -50.0,
'delta_T' : 2.5,
'tau_w' : 600.0,
'cm' : 0.200,
'a' : 0.001e3,
'b' : 0.0 }
V_INIT = -60
print("Building Network")
# Create Populations
py = Population(py_n, EIF_cond_alpha_isfa_ista, cellparams=py_params, initial_values={'v': V_INIT})
inh = Population(inh_n, EIF_cond_alpha_isfa_ista, cellparams=inh_params, initial_values={'v': V_INIT})
pyB = Population(pyB_n, EIF_cond_alpha_isfa_ista, cellparams=pyB_params, initial_values={'v': V_INIT})
inhB = Population(inhB_n, EIF_cond_alpha_isfa_ista, cellparams=inh_params, initial_values={'v': V_INIT})
#
# External Stimulation - Start of Simulation
ext_py = Population(1, SpikeSourcePoisson,
cellparams={'start':0.0, 'rate':50., 'duration':stim_dur})
ext_prj_py = Projection(ext_py, py, FixedProbabilityConnector(.02),
synapse_type=StaticSynapse(weight=g_ext, delay=None),
receptor_type='excitatory')
ext_pyB = Population(1, SpikeSourcePoisson,
cellparams={'start':0.0, 'rate':50., 'duration':stim_dur})
ext_prj_pyB = Projection(ext_pyB, pyB, FixedProbabilityConnector(.02),
synapse_type=StaticSynapse(weight=g_ext, delay=None),
receptor_type='excitatory')
#
# LTS Subgroup - 10% of Layer B
cells = pyB.local_cells
#cells = numpy.random.permutation(cells)[0:int(0.1*len(cells))]
cells = cells[0:int(0.05*len(cells))]
for cell in cells:
cell.a = 0.02e3
cell.b = 0.0
# Connect Groups - Random Connect
print("Random Connect")
rng = NumpyRNG(1235342134, parallel_safe=False)
py_py = Projection(py, py,
FixedProbabilityConnector(p_c, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_e, delay=None),
receptor_type='excitatory')
print("Number of Synapses (py_py):", len(py_py))
py_inh = Projection(py, inh,
FixedProbabilityConnector(p_c, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_e, delay=None),
receptor_type='excitatory')
print("Number of Synapses (py_inh):", len(py_inh))
inh_py = Projection(inh, py,
FixedProbabilityConnector(p_c, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_i, delay=None),
receptor_type='inhibitory')
print("Number of Synapses (inh_py):", len(inh_py))
inh_inh = Projection(inh, inh,
FixedProbabilityConnector(p_c, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_i, delay=None),
receptor_type='inhibitory')
print("Number of Synapses (inh_inh):", len(inh_inh))
pyB_pyB = Projection(pyB, pyB,
FixedProbabilityConnector(p_c*scale_factor, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_e, delay=None),
receptor_type='excitatory')
print("Number of Synapses (pyB_pyB):", len(pyB_pyB))
pyB_inhB = Projection(pyB, inhB,
FixedProbabilityConnector(p_c*scale_factor, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_e, delay=None),
receptor_type='excitatory')
print("Number of Synapses (pyB_inhB):", len(pyB_inhB))
inhB_pyB = Projection(inhB, pyB,
FixedProbabilityConnector(p_c*scale_factor, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_i, delay=None),
receptor_type='inhibitory')
print("Number of Synapses (inhB_pyB):", len(inhB_pyB))
inhB_inhB = Projection(inhB, inhB,
FixedProbabilityConnector(p_c*scale_factor, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_i, delay=None),
receptor_type='inhibitory')
print("Number of Synapses (inhB_inhB):", len(inhB_inhB))
### Excitatory Connection Between the Layers
py_pyB = Projection(py, pyB,
FixedProbabilityConnector(inter_p_c, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_e, delay=None),
receptor_type='excitatory')
pyB_py = Projection(pyB, py,
FixedProbabilityConnector(inter_p_c, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_e, delay=None),
receptor_type='excitatory')
py_inhB = Projection(py, inhB,
FixedProbabilityConnector(inter_p_c, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_e, delay=None),
receptor_type='excitatory')
pyB_inh = Projection(pyB, inh,
FixedProbabilityConnector(inter_p_c, allow_self_connections=False, rng=rng),
synapse_type=StaticSynapse(weight=g_e, delay=None),
receptor_type='excitatory')
# Recording
#pyB.record_v(10)
#inhB.record_v(10)
py.record('spikes')
inh.record('spikes')
pyB.record('spikes')
inhB.record('spikes')
#
print("Running Network")
timer = Timer()
timer.reset()
run(run_time)
simCPUtime = timer.elapsedTime()
print("Simulation Time: %s" % str(simCPUtime))
py_sp = py.get_data().segments[0].spiketrains
# print("Layer A Pyramidal Mean Rate (initial stimulation): %s" % str(py_sp.mean_rate(t_start=0,
# t_stop=stim_dur)))
# print("Layer A Pyramidal Mean Rate: %s" % str(py_sp.mean_rate(t_start=stim_dur,
# t_stop=run_time)))
# print("Layer A Pyramidal Mean CV: %s" % str(mean(py_sp.cv_isi(float_only=True))))
plotting.plot_spiketrains(plot.subplot(221), py_sp, label='PY Layer A', ms=0.1)
inh_sp = inh.get_data().segments[0].spiketrains
# print("Layer A Interneuron Mean Rate (initial stimulation): %s" % str(inh_sp.mean_rate(t_start=0,
# t_stop=stim_dur)))
# print("Layer A Interneuron Mean Rate: %s" % str(inh_sp.mean_rate(t_start=stim_dur,
# t_stop=run_time)))
# print("Layer A Interneuron Mean CV: %s" % str(mean(inh_sp.cv_isi(float_only=True))))
plotting.plot_spiketrains(plot.subplot(222), inh_sp, label='INH Layer A', ms=0.1)
pyB_sp = pyB.get_data().segments[0].spiketrains
# print("Layer B Pyramidal Mean Rate (initial stimulation): %s" % str(pyB_sp.mean_rate(t_start=0,
# t_stop=stim_dur)))
# print("Layer B Pyramidal Mean Rate: %s" % str(pyB_sp.mean_rate(t_start=stim_dur,
# t_stop=run_time)))
# print("Layer B Pyramidal Mean CV: %s" % str(mean(pyB_sp.cv_isi(float_only=True))))
plotting.plot_spiketrains(plot.subplot(223), pyB_sp, label='PY Layer B', ms=0.1)
plot.axhline(y=.05*pyB_n, linewidth=2, color='r')
inhB_sp = inhB.get_data().segments[0].spiketrains
# print("Layer B Interneuron Mean Rate (initial stimulation): %s" % str(inhB_sp.mean_rate(t_start=0,
# t_stop=stim_dur)))
# print("Layer B Interneuron Mean Rate: %s" % str(inhB_sp.mean_rate(t_start=stim_dur,
# t_stop=run_time)))
# print("Layer B Interneuron Mean CV: %s" % str(mean(inhB_sp.cv_isi(float_only=True))))
plotting.plot_spiketrains(plot.subplot(224), inhB_sp, label='INH Layer B', ms=0.1, xlabel="Time(ms)", xticks=True)
plot.savefig("demo_cx_Up-Down.png")
# Cleanup
end()