NEST main@caf0ae8
 
Loading...
Searching...
No Matches
clopath_synapse.h
Go to the documentation of this file.
1/*
2 * clopath_synapse.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef CLOPATH_SYNAPSE_H
24#define CLOPATH_SYNAPSE_H
25
26// C++ includes:
27#include <cmath>
28
29// Includes from nestkernel:
31#include "connection.h"
32#include "connector_model.h"
33#include "event.h"
34#include "nest.h"
35#include "ring_buffer.h"
36
37
38namespace nest
39{
40
41/* BeginUserDocs: synapse, chemical, functional, stdp, 3-factor
42
43Short description
44+++++++++++++++++
45
46Synapse type for voltage-based STDP after Clopath
47
48Description
49+++++++++++
50
51``clopath_synapse`` is a connector to create Clopath synapses as defined
52in :footcite:p:`Clopath2010a`. In contrast to usual STDP, the change of the synaptic weight does
53not only depend on the pre- and postsynaptic spike timing but also on the
54postsynaptic membrane potential.
55
56Clopath synapses require archiving of continuous quantities. Therefore Clopath
57synapses can only be connected to neuron models that are capable of doing this
58archiving. So far, compatible models are ``aeif_psc_delta_clopath`` and
59``hh_psc_alpha_clopath``.
60
61.. warning::
62
63 This synaptic plasticity rule does not take
64 :ref:`precise spike timing <sim_precise_spike_times>` into
65 account. When calculating the weight update, the precise spike time part
66 of the timestamp is ignored.
67
68See also :footcite:p:`Clopath2010b`, :footcite:p:`Torben-Nielsen2010`.
69
70Parameters
71++++++++++
72
73======= ====== ==========================================================
74tau_x ms Time constant of the trace of the presynaptic spike train
75Wmax real Maximum allowed weight
76Wmin real Minimum allowed weight
77======= ====== ==========================================================
78
79Other parameters like the amplitudes for long-term potentiation (LTP) and
80depression (LTD) are stored in the neuron models that are compatible with the
81Clopath synapse.
82
83Transmits
84+++++++++
85
86SpikeEvent
87
88References
89++++++++++
90
91.. footbibliography::
92
93See also
94++++++++
95
96stdp_synapse, aeif_psc_delta_clopath, hh_psc_alpha_clopath
97
98Examples using this model
99+++++++++++++++++++++++++
100
101.. listexamples:: iaf_psc_alpha
102
103EndUserDocs */
104
105// connections are templates of target identifier type (used for pointer /
106// target index addressing) derived from generic connection template
107void register_clopath_synapse( const std::string& name );
108
109template < typename targetidentifierT >
110class clopath_synapse : public Connection< targetidentifierT >
111{
112
113public:
116
121
127
128
133 clopath_synapse( const clopath_synapse& ) = default;
135
136 // Explicitly declare all methods inherited from the dependent base
137 // ConnectionBase. This avoids explicit name prefixes in all places these
138 // functions are used. Since ConnectionBase depends on the template parameter,
139 // they are not automatically found in the base class.
144
148 void get_status( Dictionary& d ) const;
149
153 void set_status( const Dictionary& d, ConnectorModel& cm );
154
160 bool send( Event& e, size_t t, const CommonSynapseProperties& cp );
161
162
164 {
165 public:
166 // Ensure proper overriding of overloaded virtual functions.
167 // Return values from functions are ignored.
169 size_t
170 handles_test_event( SpikeEvent&, size_t ) override
171 {
172 return invalid_port;
173 }
174 };
175
176 void
177 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
178 {
179 ConnTestDummyNode dummy_target;
180
181 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
182
184 }
185
186 void
187 set_weight( double w )
188 {
189 weight_ = w;
190 }
191
192private:
193 double
194 depress_( double w, double dw )
195 {
196 w -= dw;
197 return w > Wmin_ ? w : Wmin_;
198 }
199
200 double
201 facilitate_( double w, double dw, double x_bar )
202 {
203 w += dw * x_bar;
204 return w < Wmax_ ? w : Wmax_;
205 }
206
207 // data members of each connection
208 double weight_;
209 double x_bar_;
210 double tau_x_;
211 double Wmin_;
212 double Wmax_;
213
215};
216
217template < typename targetidentifierT >
219
226template < typename targetidentifierT >
227inline bool
229{
230 double t_spike = e.get_stamp().get_ms();
231 // use accessor functions (inherited from Connection< >) to obtain delay and
232 // target
233 Node* target = get_target( t );
234 double dendritic_delay = get_delay();
235
236 // get spike history in relevant range (t1, t2] from postsynaptic neuron
237 std::deque< histentry_extended >::iterator start;
238 std::deque< histentry_extended >::iterator finish;
239
240 // For a new synapse, t_lastspike_ contains the point in time of the last
241 // spike. So we initially read the
242 // history(t_last_spike - dendritic_delay, ..., T_spike-dendritic_delay]
243 // which increases the access counter for these entries.
244
245 // Note that in the STDP synapse, this loop iterates over post spikes,
246 // whereas here we loop over continuous-time history entries (see
247 // histentry_extended).
248 target->get_LTP_history( t_lastspike_ - dendritic_delay, t_spike - dendritic_delay, &start, &finish );
249 while ( start != finish )
250 {
251 const double minus_dt = t_lastspike_ - ( start->t_ + dendritic_delay );
252
253 // facilitation due to postsynaptic activity since last pre-synaptic spike
254 weight_ = facilitate_( weight_, start->dw_, x_bar_ * exp( minus_dt / tau_x_ ) );
255
256 ++start;
257 }
258
259 // depression due to new pre-synaptic spike
260 weight_ = depress_( weight_, target->get_LTD_value( t_spike - dendritic_delay ) );
261
262 e.set_receiver( *target );
263 e.set_weight( weight_ );
264 // use accessor functions (inherited from Connection< >) to obtain delay in
265 // steps and rport
266 e.set_delay_steps( get_delay_steps() );
267 e.set_rport( get_rport() );
268 e();
269
270 // compute the trace of the presynaptic spike train
271 x_bar_ = x_bar_ * std::exp( ( t_lastspike_ - t_spike ) / tau_x_ ) + 1.0 / tau_x_;
272
273 t_lastspike_ = t_spike;
274
275 return true;
276}
277
278
279template < typename targetidentifierT >
282 , weight_( 1.0 )
283 , x_bar_( 0.0 )
284 , tau_x_( 15.0 )
285 , Wmin_( 0.0 )
286 , Wmax_( 100.0 )
287 , t_lastspike_( 0.0 )
288{
289}
290
291template < typename targetidentifierT >
292void
294{
295 ConnectionBase::get_status( d );
296 d[ names::weight ] = weight_;
297 d[ names::x_bar ] = x_bar_;
298 d[ names::tau_x ] = tau_x_;
299 d[ names::Wmin ] = Wmin_;
300 d[ names::Wmax ] = Wmax_;
301 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
302}
303
304template < typename targetidentifierT >
305void
307{
308 ConnectionBase::set_status( d, cm );
309 d.update_value( names::weight, weight_ );
310 d.update_value( names::x_bar, x_bar_ );
311 d.update_value( names::tau_x, tau_x_ );
312 d.update_value( names::Wmin, Wmin_ );
313 d.update_value( names::Wmax, Wmax_ );
314
315 // check if weight_ and Wmin_ has the same sign
316 if ( not( ( ( weight_ >= 0 ) - ( weight_ < 0 ) ) == ( ( Wmin_ >= 0 ) - ( Wmin_ < 0 ) ) ) )
317 {
318 throw BadProperty( "Weight and Wmin must have same sign." );
319 }
320
321 // check if weight_ and Wmax_ has the same sign
322 if ( not( ( ( weight_ >= 0 ) - ( weight_ < 0 ) ) == ( ( Wmax_ > 0 ) - ( Wmax_ <= 0 ) ) ) )
323 {
324 throw BadProperty( "Weight and Wmax must have same sign." );
325 }
326}
327
328} // of namespace nest
329
330#endif // of #ifndef CLOPATH_SYNAPSE_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
Class containing the common properties for all connections of a certain type.
Definition common_synapse_properties.h:50
Base class for dummy nodes used in connection testing.
Definition connection.h:67
Base class for representing connections.
Definition connection.h:110
void check_connection_(Node &dummy_target, Node &source, Node &target, const size_t receptor_type)
This function calls check_connection() on the sender to check if the receiver accepts the event type ...
Definition connection.h:319
long get_delay_steps() const
Return the delay of the connection in steps.
Definition connection.h:181
Node * get_target(const size_t tid) const
Definition connection.h:239
size_t get_rport() const
Definition connection.h:244
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
Definition connector_model.h:69
Encapsulate information sent between nodes.
Definition event.h:103
Base class for all NEST network objects.
Definition node.h:99
virtual void register_stdp_connection(double, double)
Register a STDP connection.
Definition node.cpp:211
Event for spike information.
Definition event.h:418
Definition clopath_synapse.h:164
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition clopath_synapse.h:170
Definition clopath_synapse.h:111
double tau_x_
Definition clopath_synapse.h:210
clopath_synapse(const clopath_synapse &)=default
Copy constructor.
double depress_(double w, double dw)
Definition clopath_synapse.h:194
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition clopath_synapse.h:177
Connection< targetidentifierT > ConnectionBase
Definition clopath_synapse.h:115
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition clopath_synapse.h:293
bool send(Event &e, size_t t, const CommonSynapseProperties &cp)
Send an event to the receiver of this connection.
Definition clopath_synapse.h:228
CommonSynapseProperties CommonPropertiesType
Definition clopath_synapse.h:114
double weight_
Definition clopath_synapse.h:208
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
double x_bar_
Definition clopath_synapse.h:209
double Wmax_
Definition clopath_synapse.h:212
double t_lastspike_
Definition clopath_synapse.h:214
clopath_synapse()
Default Constructor.
Definition clopath_synapse.h:280
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition clopath_synapse.h:306
double Wmin_
Definition clopath_synapse.h:211
double facilitate_(double w, double dw, double x_bar)
Definition clopath_synapse.h:201
void set_weight(double w)
Definition clopath_synapse.h:187
static constexpr ConnectionModelProperties properties
Definition clopath_synapse.h:117
clopath_synapse & operator=(const clopath_synapse &)=default
virtual size_t handles_test_event(SpikeEvent &, size_t receptor_type)
Check if the node can handle a particular event and receptor type.
Definition node.cpp:271
const std::string x_bar("x_bar")
const std::string Wmin("Wmin")
const std::string tau_x("tau_x")
const std::string weight("weight")
const std::string size_of("sizeof")
const std::string Wmax("Wmax")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_clopath_synapse(const std::string &name)
Definition clopath_synapse.cpp:32
ConnectionModelProperties
Definition connector_model.h:49
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:141