NEST main@caf0ae8
 
Loading...
Searching...
No Matches
tsodyks2_synapse.h
Go to the documentation of this file.
1/*
2 * tsodyks2_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 TSODYKS2_SYNAPSE_H
24#define TSODYKS2_SYNAPSE_H
25
26// C++ includes:
27#include <cmath>
28
29// Includes from nestkernel:
30#include "connection.h"
31
32namespace nest
33{
34
35/* BeginUserDocs: synapse, chemical, functional, stp, Tsodyks
36
37Short description
38+++++++++++++++++
39
40Synapse type with short term plasticity
41
42Description
43+++++++++++
44
45This synapse model implements synaptic short-term depression and short-term
46facilitation according to :footcite:p:`Tsodyks1997` and :footcite:p:`Fuhrmann2002`. It solves Eq (2) from
47:footcite:p:`Tsodyks1997` and modulates U according to eq. (2) of :footcite:p:`Fuhrmann2002`.
48
49This connection merely scales the synaptic weight, based on the spike history
50and the parameters of the kinetic model. Thus, it is suitable for all types
51of synaptic dynamics, that is current or conductance based.
52
53The parameter ``A_se`` from the publications is represented by the
54synaptic weight. The variable x in the synapse properties is the
55factor that scales the synaptic weight.
56
57Setting the parameter ``tau_fac`` to zero disables facilitation.
58
59Please note that the initial value of ``u`` should be equal to the value of
60``U``. Thus, when setting a new value for ``U`` before the start of the
61simulation, make sure to set ``u`` to the same value.
62
63.. warning::
64
65 This synaptic plasticity rule does not take
66 :ref:`precise spike timing <sim_precise_spike_times>` into
67 account. When calculating the weight update, the precise spike time part
68 of the timestamp is ignored.
69
70See also :footcite:p:`Maass2002`.
71
72Under identical conditions, the tsodyks2_synapse produces slightly
73lower peak amplitudes than the tsodyks_synapse. However, the
74qualitative behavior is identical. The script
75:doc:`../auto_examples/evaluate_tsodyks2_synapse` compares the two
76synapse models.
77
78Parameters
79++++++++++
80
81The following parameters can be set in the status dictionary:
82
83======== ====== ========================================================
84 U real Parameter determining the increase in u with each spike
85 (U1) [0,1], default = 0.5
86 u real The probability of release (U_se) [0,1],
87 default = U
88 x real Current scaling factor of the weight, default = 1.0
89 tau_fac ms Time constant for facilitation, default = 0 (off)
90 tau_rec ms Time constant for depression, default = 800
91======== ====== ========================================================
92
93References
94++++++++++
95
96.. footbibliography::
97
98Transmits
99+++++++++
100
101SpikeEvent
102
103See also
104++++++++
105
106tsodyks_synapse, stdp_synapse, static_synapse
107
108Examples using this model
109+++++++++++++++++++++++++
110
111.. listexamples:: tsodyks2_synapse
112
113EndUserDocs */
114
115void register_tsodyks2_synapse( const std::string& name );
116
117template < typename targetidentifierT >
118class tsodyks2_synapse : public Connection< targetidentifierT >
119{
120public:
123
127
133
140
145 {
146 }
147
148 // Explicitly declare all methods inherited from the dependent base
149 // ConnectionBase. This avoids explicit name prefixes in all places these
150 // functions are used. Since ConnectionBase depends on the template parameter,
151 // they are not automatically found in the base class.
156
160 void get_status( Dictionary& d ) const;
161
165 void set_status( const Dictionary& d, ConnectorModel& cm );
166
172 bool send( Event& e, size_t t, const CommonSynapseProperties& cp );
173
175 {
176 public:
177 // Ensure proper overriding of overloaded virtual functions.
178 // Return values from functions are ignored.
180 size_t
181 handles_test_event( SpikeEvent&, size_t ) override
182 {
183 return invalid_port;
184 }
185 };
186
187
188 void
189 check_connection( Node& s, Node& t, size_t receptor_type, const CommonPropertiesType& )
190 {
191 ConnTestDummyNode dummy_target;
192 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
193 }
194
195 void
196 set_weight( double w )
197 {
198 weight_ = w;
199 }
200
201
202private:
203 double weight_;
204 double U_;
205 double u_;
206 double x_;
207 double tau_rec_;
208 double tau_fac_;
210};
211
212template < typename targetidentifierT >
214
220template < typename targetidentifierT >
221inline bool
223{
224 Node* target = get_target( t );
225 const double t_spike = e.get_stamp().get_ms();
226
227 if ( t_lastspike_ >= 0.0 )
228 {
229 // only update x and u if this is not the first spike to pass through the synapse
230
231 const double h = t_spike - t_lastspike_;
232 double x_decay = std::exp( -h / tau_rec_ );
233 double u_decay = ( tau_fac_ == 0 ) ? 0.0 : std::exp( -h / tau_fac_ ); // tau_fac == 0 disables facilitation
234
235 // now we compute spike number n+1
236 x_ = 1. + ( x_ - x_ * u_ - 1. ) * x_decay; // Eq. 5 from Maass & Markram (2002)
237 u_ = U_ + u_ * ( 1. - U_ ) * u_decay; // Eq. 4 from Maass & Markram (2002)
238 }
239
240 // We use the current values for the spike number n.
241 e.set_receiver( *target );
242 e.set_weight( x_ * u_ * weight_ );
243 // send the spike to the target
244 e.set_delay_steps( get_delay_steps() );
245 e.set_rport( get_rport() );
246 e();
247
248 t_lastspike_ = t_spike;
249
250 return true;
251}
252
253template < typename targetidentifierT >
256 , weight_( 1.0 )
257 , U_( 0.5 )
258 , u_( U_ )
259 , x_( 1.0 )
260 , tau_rec_( 800.0 )
261 , tau_fac_( 0.0 )
262 , t_lastspike_( -1.0 )
263{
264}
265
266template < typename targetidentifierT >
267void
269{
270 ConnectionBase::get_status( d );
271 d[ names::weight ] = weight_;
272
273 d[ names::dU ] = U_;
274 d[ names::u ] = u_;
275 d[ names::tau_rec ] = tau_rec_;
276 d[ names::tau_fac ] = tau_fac_;
277 d[ names::x ] = x_;
278 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
279}
280
281template < typename targetidentifierT >
282void
284{
285 ConnectionBase::set_status( d, cm );
286 d.update_value( names::weight, weight_ );
287
288 d.update_value( names::dU, U_ );
289 if ( U_ > 1.0 or U_ < 0.0 )
290 {
291 throw BadProperty( "'U' must be in [0,1]." );
292 }
293
294 d.update_value( names::u, u_ );
295 if ( u_ > 1.0 or u_ < 0.0 )
296 {
297 throw BadProperty( "'u' must be in [0,1]." );
298 }
299
300 d.update_value( names::tau_rec, tau_rec_ );
301 if ( tau_rec_ <= 0.0 )
302 {
303 throw BadProperty( "'tau_rec' must be > 0." );
304 }
305
306 d.update_value( names::tau_fac, tau_fac_ );
307 if ( tau_fac_ < 0.0 )
308 {
309 throw BadProperty( "'tau_fac' must be >= 0." );
310 }
311
312 d.update_value( names::x, x_ );
313}
314
315} // namespace
316
317#endif // TSODYKS2_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
Event for spike information.
Definition event.h:418
Definition tsodyks2_synapse.h:175
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition tsodyks2_synapse.h:181
Definition tsodyks2_synapse.h:119
void set_weight(double w)
Definition tsodyks2_synapse.h:196
CommonSynapseProperties CommonPropertiesType
Definition tsodyks2_synapse.h:121
Connection< targetidentifierT > ConnectionBase
Definition tsodyks2_synapse.h:122
static constexpr ConnectionModelProperties properties
Definition tsodyks2_synapse.h:124
double weight_
Definition tsodyks2_synapse.h:203
double u_
dynamic value of probability of release
Definition tsodyks2_synapse.h:205
bool send(Event &e, size_t t, const CommonSynapseProperties &cp)
Send an event to the receiver of this connection.
Definition tsodyks2_synapse.h:222
double t_lastspike_
time point of last spike emitted
Definition tsodyks2_synapse.h:209
double x_
current fraction of the synaptic weight
Definition tsodyks2_synapse.h:206
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &)
Definition tsodyks2_synapse.h:189
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition tsodyks2_synapse.h:268
double U_
unit increment of a facilitating synapse
Definition tsodyks2_synapse.h:204
tsodyks2_synapse()
Default Constructor.
Definition tsodyks2_synapse.h:254
~tsodyks2_synapse()
Default Destructor.
Definition tsodyks2_synapse.h:144
tsodyks2_synapse & operator=(const tsodyks2_synapse &)=default
double tau_rec_
[ms] time constant for recovery
Definition tsodyks2_synapse.h:207
tsodyks2_synapse(const tsodyks2_synapse &)=default
Copy constructor from a property object.
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition tsodyks2_synapse.h:283
double tau_fac_
[ms] time constant for facilitation
Definition tsodyks2_synapse.h:208
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 u("u")
const std::string x("x")
const std::string tau_fac("tau_fac")
const std::string dU("U")
const std::string weight("weight")
const std::string size_of("sizeof")
const std::string tau_rec("tau_rec")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_tsodyks2_synapse(const std::string &name)
Definition tsodyks2_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