-
Notifications
You must be signed in to change notification settings - Fork 358
/
clopath_synapse.h
311 lines (255 loc) · 9.22 KB
/
clopath_synapse.h
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/*
* clopath_synapse.h
*
* This file is part of NEST.
*
* Copyright (C) 2004 The NEST Initiative
*
* NEST is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* NEST is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef CLOPATH_SYNAPSE_H
#define CLOPATH_SYNAPSE_H
// C++ includes:
#include <cmath>
// Includes from nestkernel:
#include "common_synapse_properties.h"
#include "connection.h"
#include "connector_model.h"
#include "event.h"
#include "ring_buffer.h"
// Includes from sli:
#include "dictdatum.h"
#include "dictutils.h"
namespace nest
{
/* BeginUserDocs: synapse, spike-timing-dependent plasticity, Clopath plasticity
Short description
+++++++++++++++++
Synapse type for voltage-based STDP after Clopath
Description
+++++++++++
clopath_synapse is a connector to create Clopath synapses as defined
in [1]_. In contrast to usual STDP, the change of the synaptic weight does
not only depend on the pre- and postsynaptic spike timing but also on the
postsynaptic membrane potential.
Clopath synapses require archiving of continuous quantities. Therefore Clopath
synapses can only be connected to neuron models that are capable of doing this
archiving. So far, compatible models are aeif_psc_delta_clopath and
hh_psc_alpha_clopath.
Parameters
++++++++++
======= ====== ==========================================================
tau_x ms Time constant of the trace of the presynaptic spike train
Wmax real Maximum allowed weight
Wmin real Minimum allowed weight
======= ====== ==========================================================
Other parameters like the amplitudes for long-term potentiation (LTP) and
depression (LTD) are stored in in the neuron models that are compatible with the
Clopath synapse.
Transmits
+++++++++
SpikeEvent
References
++++++++++
.. [1] Clopath et al. (2010). Connectivity reflects coding:
a model of voltage-based STDP with homeostasis.
Nature Neuroscience 13:3, 344--352. DOI: https://doi.org/10.1038/nn.2479
.. [2] Clopath and Gerstner (2010). Voltage and spike timing interact
in STDP – a unified model. Frontiers in Synaptic Neuroscience 2:25.
DOI: https://doi.org/10.3389/fnsyn.2010.00025
.. [3] Voltage-based STDP synapse (Clopath et al. 2010) on ModelDB
https://senselab.med.yale.edu/ModelDB/showmodel.cshtml?model=144566
See also
++++++++
stdp_synapse, aeif_psc_delta_clopath, hh_psc_alpha_clopath
EndUserDocs */
// connections are templates of target identifier type (used for pointer /
// target index addressing) derived from generic connection template
template < typename targetidentifierT >
class clopath_synapse : public Connection< targetidentifierT >
{
public:
typedef CommonSynapseProperties CommonPropertiesType;
typedef Connection< targetidentifierT > ConnectionBase;
/**
* Default Constructor.
* Sets default values for all parameters. Needed by GenericConnectorModel.
*/
clopath_synapse();
/**
* Copy constructor.
* Needs to be defined properly in order for GenericConnector to work.
*/
clopath_synapse( const clopath_synapse& ) = default;
// Explicitly declare all methods inherited from the dependent base
// ConnectionBase. This avoids explicit name prefixes in all places these
// functions are used. Since ConnectionBase depends on the template parameter,
// they are not automatically found in the base class.
using ConnectionBase::get_delay_steps;
using ConnectionBase::get_delay;
using ConnectionBase::get_rport;
using ConnectionBase::get_target;
/**
* Get all properties of this connection and put them into a dictionary.
*/
void get_status( DictionaryDatum& d ) const;
/**
* Set properties of this connection from the values given in dictionary.
*/
void set_status( const DictionaryDatum& d, ConnectorModel& cm );
/**
* Send an event to the receiver of this connection.
* \param e The event to send
* \param cp common properties of all synapses (empty).
*/
void send( Event& e, thread t, const CommonSynapseProperties& cp );
class ConnTestDummyNode : public ConnTestDummyNodeBase
{
public:
// Ensure proper overriding of overloaded virtual functions.
// Return values from functions are ignored.
using ConnTestDummyNodeBase::handles_test_event;
port
handles_test_event( SpikeEvent&, rport )
{
return invalid_port_;
}
};
void
check_connection( Node& s, Node& t, rport receptor_type, const CommonPropertiesType& )
{
ConnTestDummyNode dummy_target;
ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
t.register_stdp_connection( t_lastspike_ - get_delay(), get_delay() );
}
void
set_weight( double w )
{
weight_ = w;
}
private:
double
depress_( double w, double dw )
{
w -= dw;
return w > Wmin_ ? w : Wmin_;
}
double
facilitate_( double w, double dw, double x_bar )
{
w += dw * x_bar;
return w < Wmax_ ? w : Wmax_;
}
// data members of each connection
double weight_;
double x_bar_;
double tau_x_;
double Wmin_;
double Wmax_;
double t_lastspike_;
};
/**
* Send an event to the receiver of this connection.
* \param e The event to send
* \param t The thread on which this connection is stored.
* \param cp Common properties object, containing the stdp parameters.
*/
template < typename targetidentifierT >
inline void
clopath_synapse< targetidentifierT >::send( Event& e, thread t, const CommonSynapseProperties& )
{
double t_spike = e.get_stamp().get_ms();
// use accessor functions (inherited from Connection< >) to obtain delay and
// target
Node* target = get_target( t );
double dendritic_delay = get_delay();
// get spike history in relevant range (t1, t2] from postsynaptic neuron
std::deque< histentry_extended >::iterator start;
std::deque< histentry_extended >::iterator finish;
// For a new synapse, t_lastspike_ contains the point in time of the last
// spike. So we initially read the
// history(t_last_spike - dendritic_delay, ..., T_spike-dendritic_delay]
// which increases the access counter for these entries.
// At registration, all entries' access counters of
// history[0, ..., t_last_spike - dendritic_delay] have been
// incremented by ArchivingNode::register_stdp_connection(). See bug #218 for
// details.
target->get_LTP_history( t_lastspike_ - dendritic_delay, t_spike - dendritic_delay, &start, &finish );
// facilitation due to postsynaptic activity since last pre-synaptic spike
while ( start != finish )
{
const double minus_dt = t_lastspike_ - ( start->t_ + dendritic_delay );
weight_ = facilitate_( weight_, start->dw_, x_bar_ * exp( minus_dt / tau_x_ ) );
++start;
}
// depression due to new pre-synaptic spike
weight_ = depress_( weight_, target->get_LTD_value( t_spike - dendritic_delay ) );
e.set_receiver( *target );
e.set_weight( weight_ );
// use accessor functions (inherited from Connection< >) to obtain delay in
// steps and rport
e.set_delay_steps( get_delay_steps() );
e.set_rport( get_rport() );
e();
// compute the trace of the presynaptic spike train
x_bar_ = x_bar_ * std::exp( ( t_lastspike_ - t_spike ) / tau_x_ ) + 1.0 / tau_x_;
t_lastspike_ = t_spike;
}
template < typename targetidentifierT >
clopath_synapse< targetidentifierT >::clopath_synapse()
: ConnectionBase()
, weight_( 1.0 )
, x_bar_( 0.0 )
, tau_x_( 15.0 )
, Wmin_( 0.0 )
, Wmax_( 100.0 )
, t_lastspike_( 0.0 )
{
}
template < typename targetidentifierT >
void
clopath_synapse< targetidentifierT >::get_status( DictionaryDatum& d ) const
{
ConnectionBase::get_status( d );
def< double >( d, names::weight, weight_ );
def< double >( d, names::x_bar, x_bar_ );
def< double >( d, names::tau_x, tau_x_ );
def< double >( d, names::Wmin, Wmin_ );
def< double >( d, names::Wmax, Wmax_ );
def< long >( d, names::size_of, sizeof( *this ) );
}
template < typename targetidentifierT >
void
clopath_synapse< targetidentifierT >::set_status( const DictionaryDatum& d, ConnectorModel& cm )
{
ConnectionBase::set_status( d, cm );
updateValue< double >( d, names::weight, weight_ );
updateValue< double >( d, names::x_bar, x_bar_ );
updateValue< double >( d, names::tau_x, tau_x_ );
updateValue< double >( d, names::Wmin, Wmin_ );
updateValue< double >( d, names::Wmax, Wmax_ );
// check if weight_ and Wmin_ has the same sign
if ( not( ( ( weight_ >= 0 ) - ( weight_ < 0 ) ) == ( ( Wmin_ >= 0 ) - ( Wmin_ < 0 ) ) ) )
{
throw BadProperty( "Weight and Wmin must have same sign." );
}
// check if weight_ and Wmax_ has the same sign
if ( not( ( ( weight_ >= 0 ) - ( weight_ < 0 ) ) == ( ( Wmax_ > 0 ) - ( Wmax_ <= 0 ) ) ) )
{
throw BadProperty( "Weight and Wmax must have same sign." );
}
}
} // of namespace nest
#endif // of #ifndef CLOPATH_SYNAPSE_H