forked from codecheckers/Larisch-reproduction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fig1_clamp.py
170 lines (144 loc) · 5.27 KB
/
Fig1_clamp.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
"""
Python script to reproduce the voltage clamp experiment.
The membrane potential is fixed to values between -80 mV and 0 mV
and the presynaptic neuron is active with a firing rate of 25 Hz for 50 s.
As in the original publication, the experiment is done to fit
data in the visual cortex and the hippocampus.
See Figure 1. h in Clopath et al. (2010).
"""
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
from ANNarchy import *
setup(dt=1)
from network import *
# Global parameters
duration = 50*1000 # ms
initW = 0.0001
# Spike times
"""
Creates a list of spiking time points. 25 Hz for 50 seconds
"""
spike_times1 = np.asarray(range(0, duration, int(1000/4)))
# Populations
"""
To control the spike timings of the AdEx neurons, an additional input population
is used. The spike timing of the SpikeSourceArray can be determined with a
list of time points.
"""
inpPop1 = SpikeSourceArray(spike_times=spike_times1.tolist())
popN1 = Population(geometry=1,neuron=AdExNeuron, name="N1")
popN2 = Population(geometry=1,neuron=AdExNeuron, name="N2")
"""
Create a own equation for the learning as mentioned by Clopath et. al. (2010).
For more information about define the learning rule and synapses see
'net_fix.py' or 'net_homeostatic.py'.
"""
equatSTDP_clamp = """
ltdTerm = if w>wMin : (aLTD*pre.Spike * pos(u_clamp - thetaLTD)) else : 0.0
ltpTerm = if w<wMax : (aLTP * pos(u_clamp - thetaLTP) *(pre.xtrace)* pos(u_clamp - thetaLTD)) else : 0.0
deltaW = ( -ltdTerm + ltpTerm)
dw/dt = deltaW*0.0 :min=0.0,explicite"""
parameter_clamp="""
thetaLTD = -70.6
thetaLTP = -45.3
aLTD = 0.00014
aLTP = 0.00008
wMin = 0.0
wMax =3.0
u_clamp= -80.0
"""
Syn_clamp = Synapse( parameters = parameter_clamp,
equations= equatSTDP_clamp,
pre_spike='''g_target += w''')
# Projections
projST1_C1 = Projection(
pre=inpPop1,
post=popN1,
target='Exc'
).connect_one_to_one(weights = 30.0)
projC1_C2 = Projection(
pre=popN1,
post=popN2,
target='Exc',
synapse=Syn_clamp
).connect_one_to_one(weights = initW)
# Parameter adjustments
projC1_C2.transmit = 1.0 # to activate the transmission over the synapse
projC1_C2.set_fix = 1.0 # use a fix apmlitude for the LTD term
def run():
# compile command to create the ANNarchy network
compile()
"Runs voltage clamp experiment."
print('Start experiment to reproduce voltage clamp data.')
# create a list of 100 values from -80 mV to 0 mV for the postsynaptic
# membrane potential
post_memb = np.linspace(-80,0,100)
# monitor to save changes in the synapse
dendrite = projC1_C2.dendrite(0)
m_d = Monitor(dendrite, ['deltaW'])#,period=duration)
rec_dW_norm = np.zeros(len(post_memb))
rec_W_norm = np.zeros(len(post_memb))
"""
Voltage clamp experiment with the parameter set for the visual cortex
(standard parameter set).
"""
for i in range(len(post_memb)):
projC1_C2.u_clamp=post_memb[i]
projC1_C2.w = initW # weight must be set manually to the initial value
simulate(duration)
delta_w = m_d.get('deltaW')
rec_dW_norm[i] = np.mean(delta_w)
rec_W_norm[i] = np.mean(projC1_C2.w)+rec_dW_norm[i]
reset()
"""
Voltage clamp experiment with the parameter set for the hippocampal
"""
projC1_C2.thetaLTD = -41.0
projC1_C2.thetaLTP =-38.0
projC1_C2.aLTD = 0.00038
projC1_C2.aLTP = 0.00002
# variable to save the recorded data
rec_dW_hippo = np.zeros(len(post_memb))
rec_W_hippo = np.zeros(len(post_memb))
spike_times1 =np.asarray(range(0, duration, int(1000/10)))
inpPop1.spike_times = spike_times1.tolist()
for i in range(len(post_memb)):
projC1_C2.u_clamp=post_memb[i]
projC1_C2.w = initW # weight must be set manually to the initial value
simulate(duration)
delta_w = m_d.get('deltaW')
rec_dW_hippo[i] = np.mean(delta_w)#
rec_W_hippo[i] = np.mean(projC1_C2.w)+rec_dW_hippo[i]
reset() # reset the network to the initial values
rec_W_norm[rec_W_norm>np.max(rec_W_hippo)] = np.max(rec_W_hippo)
rec_W_norm = rec_W_norm/initW*100.
rec_W_hippo = rec_W_hippo/initW*100.
# Start plotting
# get the index of the theta values to draw the lines in the final plot
theta_m = -70.6
theta_pl= -45.3
ix1 = np.where(post_memb<theta_m)
ixM = np.argmax(post_memb[ix1])
ix1 = np.where(post_memb<theta_pl)
ixPL = np.argmax(post_memb[ix1])
fig,ax = plt.subplots()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.plot(rec_W_norm,'--',color='steelblue',lw=5.0)
plt.plot(rec_W_hippo,color='tomato',lw=5.0)
plt.xlabel('Voltage (mv)', fontsize=25)
plt.ylabel('Normalized weight (%)', fontsize=25)
plt.xticks(np.linspace(0,len(post_memb)-1,5),np.linspace(-80,0,5),fontsize=20)
plt.yticks(fontsize=20)
plt.axvline(ixM,color='k', linestyle='--')
plt.text(ixM,np.max(rec_W_hippo),r'$\theta_{-}$',fontsize=20)
plt.axvline(ixPL,color='k', linestyle='--')
plt.text(ixPL,np.max(rec_W_hippo),r'$\theta_{+}$',fontsize=20)
plt.savefig('Fig1_clamp.png',bbox_inches='tight')
plt.show()
print("Done with the experiment.")
if __name__ == "__main__":
run()