-
Notifications
You must be signed in to change notification settings - Fork 0
/
t5.py
91 lines (72 loc) · 1.65 KB
/
t5.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
import numpy as np
import networks as bn
import matplotlib.pyplot as plt
rx = 10
tau = 20e-3
dt = 1e-4
duration = 2
E = 100
I = 100
V_th = 1
V_set = 20
V_reset = 0
w = 1.5
J_EE = w
J_IE = -w
J_II = 0
J_EI = 0
J_XI = 0
J_XE = 0
ts = np.linspace(0, duration, int(duration / dt) - 1)
def do_once():
nw = bn.network(E + I + 1, rx, duration, dt, tau, V_th, V_set, V_reset, J_EE, J_EI, J_IE, J_II, J_XE, J_XI)
for i in range(E):
nw.set_type(i, 1)
nw.connect(i, E + I)
nw.neurons[i].poisson_spike(rx)
for i in range(E, E + I):
nw.set_type(i, 2)
nw.connect(i, E + I)
nw.neurons[i].poisson_spike(rx)
nw.set_type(E + I, 1)
nw.run_duration()
return nw
# x = do_once()
# plt.plot(x.get_E_neuron_V()[E])
# plt.show()
# plt.plot(x.get_input(E+I))
# plt.show()
trials = 15
V = []
S = []
mu = []
sigma = []
for i in range(trials):
V.append(do_once())
print(i)
mu.append(np.mean(V[i].get_V_i(E + I)[1000:-1]))
sigma.append(np.var(V[i].get_V_i(E + I)[1000:-1]))
S.append(V[i].neurons[E + I].output * dt)
# plt.plot(ts,V[i].get_E_neuron_V()[E])
# plt.show()
# plt.plot(ts,V[i].neurons[E+I].output * dt)
# plt.show()
# plt.plot(ts,V[0].get_input()[E+I])
# plt.show()
plt.plot(mu, c='r')
plt.plot(sigma, c='b')
plt.show()
print(np.mean(mu))
print(np.mean(sigma))
# for i in range(int(duration / dt) - 1):
# for j in range(trials):
# if S[j][i] > 0:
# plt.plot(i, 2 * j + 1, '|', c='r')
#
# plt.savefig("spikes2.png", dpi=500)
# plt.show()
spike = np.sum(S, axis=1)
print(spike)
print("mean spike per sec ", np.mean(spike))
# plt.plot(do_once())
# plt.show()