-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathring_attractor2.py
68 lines (51 loc) · 1.63 KB
/
ring_attractor2.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
from brian import *
#import math
taum = 20 * ms # membrane time constant
taue = 5 * ms # excitatory synaptic time constant
taui = 10 * ms # inhibitory synaptic time constant
Vt = -50 * mV # spike threshold
Vr = -60 * mV # reset value
El = -49 * mV # resting potential
we = (60 * 0.27 / 10) * mV # excitatory synaptic weight
wi = (20 * 4.5 / 10) * mV # inhibitory synaptic weight
n = 40
eqs = Equations('''
dV/dt = (ge-gi-(V-El))/taum : volt
dge/dt = -ge/taue : volt
dgi/dt = -gi/taui : volt
''')
spiketimes = [(0, 1 * ms),(0, 10 * ms)]
G_input = SpikeGeneratorGroup(2, spiketimes)
G_ring = NeuronGroup(N=n, model=eqs, threshold=Vt, reset=Vr)
C1 = Connection(G_input, G_ring, 'ge')
CE = Connection(G_ring, G_ring, 'ge', weight=we)
CI = Connection(G_ring, G_ring, 'gi', weight=wi)
C_ring_i = Connection(G_ring, G_ring, 'ge')
C1[0, 0] = 3 * mV
for i in range(0,n):
for j in range(0,n):
con_strength = (math.cos(2 * math.pi / n * (i - j)) + 1) / 2
CE[i, j] = con_strength * 3 * mV
CI[i, j] = con_strength * 3 * mV
#print i, j
print CE.W
x = arange(n)
y = arange(n)
X, Y = meshgrid(x, y)
#figure()
#contourf(X, Y, CE.W)
#show()
M = SpikeMonitor(G_ring)
MV = StateMonitor(G_ring, 'V', record=True)
Mge = StateMonitor(G_ring, 'ge', record=True)
G_ring.V = Vr + (Vt - Vr) * rand(len(G_ring))
run(1000 * ms)
figure()
subplot(211)
raster_plot(M, title='The ring attractor network', newfigure=False)
subplot(223)
plot(MV.times / ms, MV[0] / mV)
#plot(MV.times / ms, MV[10] / mV)
subplot(224)
plot(Mge.times / ms, Mge[0] / mV)
show()