-
Notifications
You must be signed in to change notification settings - Fork 0
/
nest_model.py
123 lines (111 loc) · 2.26 KB
/
nest_model.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
import nest
def create_model(amplitude=-180):
nest.ResetKernel()
# Set simulation kernel
nest.SetKernelStatus({
"local_num_threads": 1,
"resolution": 0.1,
"rng_seed": 1
})
# Create nodes
# excitatory
n1 = nest.Create("iaf_psc_alpha", 300, params={
"C_m": 30,
"E_L": -70,
"V_reset": -70,
"V_th": -60,
"t_ref": 2,
"tau_m": 20,
"tau_syn_ex": 1,
"tau_syn_in": 10,
})
# inhibitory
n2 = nest.Create("iaf_psc_alpha", 500, params={
"C_m": 30,
"E_L": -70,
"V_reset": -70,
"V_th": -60,
"t_ref": 2,
"tau_m": 20,
"tau_syn_ex": 1,
"tau_syn_in": 10,
})
pg1 = nest.Create("poisson_generator", 1, params={
"rate": 800,
"start": 0,
"stop": 2100,
})
vm1 = nest.Create("voltmeter", 1, params={
"interval": 1,
"start": 0,
"stop": 2100,
})
# excitatory
sr1 = nest.Create("spike_recorder", 1, params={
"start": 0,
"stop": 2100,
})
# inhibitory
sr2 = nest.Create("spike_recorder", 1, params={
"start": 0,
"stop": 2100,
})
pg2 = nest.Create("poisson_generator", 1, params={
"rate": 800,
"start": 700,
"stop": 2100,
})
dc1 = nest.Create("dc_generator", 1, params={
"amplitude": amplitude,
"start": 1400,
"stop": 2100,
})
# Connect nodes
nest.Connect(n1, n2, conn_spec={
"rule": "fixed_indegree",
"indegree": 50,
}, syn_spec={
"weight": 30,
"delay": 5,
})
nest.Connect(n2, n1, conn_spec={
"rule": "fixed_indegree",
"indegree": 30,
}, syn_spec={
"weight": -15,
"delay": 5,
})
nest.Connect(n1, n1, conn_spec={
"rule": "fixed_indegree",
"indegree": 50,
}, syn_spec={
"weight": 50,
"delay": 2,
})
nest.Connect(n2, n2, conn_spec={
"rule": "fixed_indegree",
"indegree": 30,
}, syn_spec={
"weight": -5,
"delay": 2,
})
nest.Connect(vm1, n1)
nest.Connect(n1, sr1)
nest.Connect(n2, sr2)
nest.Connect(vm1, n2)
nest.Connect(pg1, n1, syn_spec={
"weight": 65,
})
nest.Connect(pg1, n2, syn_spec={
"weight": 40,
})
nest.Connect(pg2, n2, syn_spec={
"weight": -5,
})
nest.Connect(dc1, n1)
# Run simulation
nest.Simulate(2100)
response = {
"events": [vm1.events, sr1.events, sr2.events]
}
return response