Debian Codegraph @

examples/frompapers/Clopath_et_al_2010_no_homeostasis.py

raw
1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*-
3 """
4 This code contains an adapted version of the voltage-dependent triplet STDP rule from:
5 Clopath et al., Connectivity reflects coding: a model of voltage-based STDP with homeostasis, Nature Neuroscience, 2010
6 (http://dx.doi.org/10.1038/nn.2479)
7
8 The plasticity rule is adapted for a leaky integrate & fire model in
9 Brian2. In particular, the filters ``v_lowpass1`` and ``v_lowpass2`` are
10 incremented by a constant at every post-synaptic spike time, to
11 compensate for the lack of an actual spike in the integrate & fire
12 model. Moreover, this script does not include the homeostatic
13 metaplasticity.
14
15 As an illustration of the Rule, we simulate a plot analogous to figure 2b in the above article, showing the frequency dependence of plasticity as measured in:
16 Sjöström et al., Rate, timing and cooperativity jointly determine cortical synaptic plasticity. Neuron, 2001.
17 We would like to note that the parameters have been chosen arbitrarily to qualitatively
18 reproduce the behavior of the original works, but need additional fitting.
19
20 We kindly ask to cite both articles when using the model presented below.
21
22 This code was written by Jacopo Bono, 12/2015
23 """
24
25 from brian2 import *
26 ################################################################################
27 # PLASTICITY MODEL
28 ################################################################################
29
30 #### Plasticity Parameters
31
32 V_rest = -70.*mV # resting potential
33 V_thresh = -50.*mV # spiking threshold
34 Theta_low = V_rest # depolarization threshold for plasticity
35 x_reset = 1. # spike trace reset value
36 taux = 15.*ms # spike trace time constant
37 A_LTD = 1.5e-4 # depression amplitude
38 A_LTP = 1.5e-2 # potentiation amplitude
39 tau_lowpass1 = 40*ms # timeconstant for low-pass filtered voltage
40 tau_lowpass2 = 30*ms # timeconstant for low-pass filtered voltage
41
42
43
44 #### Plasticity Equations
45
46
47 # equations executed at every timestep
48 Syn_model = '''
49 w_ampa:1 # synaptic weight (ampa synapse)
50 '''
51
52 # equations executed only when a presynaptic spike occurs
53 Pre_eq = '''
54 g_ampa_post += w_ampa*ampa_max_cond # increment synaptic conductance
55 w_minus = A_LTD*(v_lowpass1_post/mV - Theta_low/mV)*int(v_lowpass1_post/mV - Theta_low/mV > 0) # synaptic depression
56 w_ampa = clip(w_ampa-w_minus,0,w_max) # hard bounds
57 '''
58
59 # equations executed only when a postsynaptic spike occurs
60 Post_eq = '''
61 v_lowpass1 += 10*mV # mimics the depolarisation by a spike
62 v_lowpass2 += 10*mV # mimics the depolarisation by a spike
63 w_plus = A_LTP*x_trace_pre*(v_lowpass2_post/mV - Theta_low/mV)*int(v_lowpass2_post/mV - Theta_low/mV > 0) # synaptic potentiation
64 w_ampa = clip(w_ampa+w_plus,0,w_max) # hard bounds
65 '''
66
67 ################################################################################
68 # I&F Parameters and equations
69 ################################################################################
70
71 #### Neuron parameters
72
73 gleak = 30.*nS # leak conductance
74 C = 300.*pF # membrane capacitance
75 tau_AMPA = 2.*ms # AMPA synaptic timeconstant
76 E_AMPA = 0.*mV # reversal potential AMPA
77
78 ampa_max_cond = 5.e-10*siemens # Ampa maximal conductance
79 w_max = 1. # maximal ampa weight
80
81
82 #### Neuron Equations
83
84 eqs_neurons = '''
85 dv/dt = (gleak*(V_rest-v) + I_ext + I_syn)/C: volt # voltage
86 dv_lowpass1/dt = (v-v_lowpass1)/tau_lowpass1 : volt # low-pass filter of the voltage
87 dv_lowpass2/dt = (v-v_lowpass2)/tau_lowpass2 : volt # low-pass filter of the voltage
88 I_ext : amp # external current
89 I_syn = g_ampa*(E_AMPA-v): amp # synaptic current
90 dg_ampa/dt = -g_ampa/tau_AMPA : siemens # synaptic conductance
91 dx_trace/dt = -x_trace/taux :1 # spike trace
92 '''
93
94
95
96 ################################################################################
97 # Simulation
98 ################################################################################
99
100 #### Parameters
101
102 defaultclock.dt = 100.*us # timestep
103 Nr_neurons = 2 # Number of neurons
104 rate_array = [1., 5., 10., 15., 20., 30., 50.]*Hz # Rates
105 init_weight = 0.5 # initial synaptic weight
106 reps = 15 # Number of pairings
107
108 #### Create neuron objects
109
110 Nrns = NeuronGroup(Nr_neurons, eqs_neurons, threshold='v>V_thresh',
111 reset='v=V_rest;x_trace+=x_reset/(taux/ms)', method='euler')#
112
113 #### create Synapses
114
115 Syn = Synapses(Nrns, Nrns,
116 model=Syn_model,
117 on_pre=Pre_eq,
118 on_post=Post_eq
119 )
120
121 Syn.connect('i!=j')
122
123 #### Monitors and storage
124 weight_result = np.zeros((2, len(rate_array))) # to save the final weights
125
126 #### Run
127
128 # loop over rates
129 for jj, rate in enumerate(rate_array):
130
131 # Calculate interval between pairs
132 pair_interval = 1./rate - 10*ms
133 print('Starting simulations for %s' % rate)
134
135 # Initial values
136 Nrns.v = V_rest
137 Nrns.v_lowpass1 = V_rest
138 Nrns.v_lowpass2 = V_rest
139 Nrns.I_ext = 0*amp
140 Nrns.x_trace = 0.
141 Syn.w_ampa = init_weight
142
143 # loop over pairings
144 for ii in range(reps):
145 # 1st SPIKE
146 Nrns.v[0] = V_thresh + 1*mV
147 # 2nd SPIKE
148 run(10*ms)
149 Nrns.v[1] = V_thresh + 1*mV
150 # run
151 run(pair_interval)
152 print('Pair %d out of %d' % (ii+1, reps))
153
154 #store weight changes
155 weight_result[0, jj] = 100.*Syn.w_ampa[0]/init_weight
156 weight_result[1, jj] = 100.*Syn.w_ampa[1]/init_weight
157
158 ################################################################################
159 # Plots
160 ################################################################################
161
162 stitle = 'Pairings'
163 scolor = 'k'
164
165 figure(figsize=(8, 5))
166 plot(rate_array, weight_result[0,:], '-', linewidth=2, color=scolor)
167 plot(rate_array, weight_result[1,:], ':', linewidth=2, color=scolor)
168 xlabel('Pairing frequency [Hz]', fontsize=22)
169 ylabel('Normalised Weight [%]', fontsize=22)
170 legend(['Pre-Post', 'Post-Pre'], loc='best')
171 subplots_adjust(bottom=0.2, left=0.15, right=0.95, top=0.85)
172 title(stitle)
173 show()