NEST main@f146f75
Loading...
Searching...
No Matches
iaf_cond_beta.h
Go to the documentation of this file.
1/*
2 * iaf_cond_beta.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 IAF_COND_BETA_H
24#define IAF_COND_BETA_H
25
26// Generated includes:
27#include "config.h"
28
29#ifdef HAVE_GSL
30
31// C includes:
32#include <gsl/gsl_errno.h>
33#include <gsl/gsl_matrix.h>
34#include <gsl/gsl_odeiv.h>
35
36// Includes from nestkernel:
37#include "archiving_node.h"
38#include "connection.h"
39#include "event.h"
40#include "nest_types.h"
41#include "recordables_map.h"
42#include "ring_buffer.h"
44
45namespace nest
46{
57extern "C" int iaf_cond_beta_dynamics( double, const double*, double*, void* );
58
59// Disable clang-formatting for documentation due to over-wide tables.
60// clang-format off
61/* BeginUserDocs: neuron, integrate-and-fire, conductance-based, hard threshold
62
63Short description
64+++++++++++++++++
65
66Leaky integrate-and-fire neuron model with beta-function shaped synaptic conductances
67
68Description
69+++++++++++
70
71``iaf_cond_beta`` is a leaky integrate-and-fire neuron model with
72
73* a hard threshold,
74* a fixed refractory period,
75* beta-function shaped synaptic conductances (a difference of two exponentials) with separate rise and decay
76 times, normalized such that an event of weight 1.0 results in a peak conductance of 1 nS.
77
78The model follows the conductance-based integrate-and-fire framework discussed in
79:footcite:p:`Meffin2004`, :footcite:p:`Bernander1991`, :footcite:p:`Kuhn2004`, :footcite:p:`Rotter1999`,
80:footcite:p:`Roth2010`.
81
82Membrane potential evolution, spike emission, and refractoriness
83................................................................
84
85The membrane potential evolves according to
86
87.. math::
88
89 \frac{dV_\text{m}}{dt} = \frac{ -g_{\text{L}} (V_{\text{m}} - E_{\text{L}}) - I_{\text{syn}} + I_\text{e} } {C_{\text{m}}}
90
91where the synaptic input current :math:`I_{\text{syn}}(t)` is discussed below and :math:`I_\text{e}` is
92a constant input current set as a model parameter.
93
94A spike is emitted at time step :math:`t^*=t^{k+1}` if
95
96.. math::
97
98 V_\text{m}(t_k) < V_{th} \quad\text{and}\quad V_\text{m}(t^{k+1})\geq V_\text{th} \;.
99
100Subsequently,
101
102.. math::
103
104 V_\text{m}(t) = V_{\text{reset}} \quad\text{for}\quad t^* \leq t \leq t^* + t_{\text{ref}} \;,
105
106that is, the membrane potential is clamped to :math:`V_{\text{reset}}` during the refractory period.
107
108Synaptic input
109..............
110
111The synaptic input current has an excitatory and an inhibitory component
112
113.. math::
114
115 I_{\text{syn}}(t) = I_{\text{syn, ex}}(t) + I_{\text{syn, in}}(t)
116
117where
118
119.. math::
120
121 I_{\text{syn, X}}(t) = (V_{\text{m}}(t) - E_{\text{syn, X}}) \sum_{j} w_j \sum_k g_{\text{X}}(t-t_j^k-d_j) \;,
122
123where :math:`j` indexes either excitatory (:math:`\text{X} = \text{ex}`)
124or inhibitory (:math:`\text{X} = \text{in}`) presynaptic neurons,
125:math:`k` indexes the spike times of neuron :math:`j`, and :math:`d_j`
126is the delay from neuron :math:`j`.
127
128The individual synaptic conductances are beta-function shaped, that is, given by the difference of two
129exponentials with separate rise and decay time constants,
130
131.. math::
132
133 g_{\text{X}}(t) =
134 \frac{ e^{-\frac{t}{\tau_{\text{decay, X}}}} - e^{-\frac{t}{\tau_{\text{rise, X}}}} }
135 { e^{-\frac{t_{\text{peak, X}}}{\tau_{\text{decay, X}}}} - e^{-\frac{t_{\text{peak, X}}}{\tau_{\text{rise, X}}}} }
136 \, \Theta(t)
137
138where :math:`\Theta(x)` is the Heaviside step function and
139
140.. math::
141
142 t_{\text{peak, X}} = \frac{ \tau_{\text{decay, X}} \, \tau_{\text{rise, X}} }
143 { \tau_{\text{decay, X}} - \tau_{\text{rise, X}} }
144 \ln \frac{ \tau_{\text{decay, X}} }{ \tau_{\text{rise, X}} }
145
146is the time at which the conductance attains its maximum. The conductances are normalized to
147unit peak, that is,
148
149.. math::
150
151 g_{\text{X}}(t = t_{\text{peak, X}}) = 1 \;,
152
153as the weight of the connection :math:`w_{j}` from neuron :math:`j` (excitatory if
154:math:`w_{j} > 0` or inhibitory if :math:`w_{j} < 0`) is written explicitly in the equation for the total
155synaptic current.
156
157For :math:`\tau_{\text{rise, X}} = \tau_{\text{decay, X}}`, which is the case for the default
158parameters, the beta function reduces to the alpha function of ``iaf_cond_alpha``, and the model
159uses that form.
160
161.. note::
162
163 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
164 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
165 the inhibitory one. Only the absolute value of the weight sets the conductance
166 amplitude. Spike connections must use the default ``receptor_type`` of 0.
167
168 See :ref:`synapse_selection` for the conventions used by other models. For input
169 separation by ``receptor_type``, see ``iaf_cond_alpha_mc``.
170
171 This model integrates the dynamics with an adaptive-step-size Runge-Kutta-Fehlberg
172 solver from the GNU Scientific Library.
173
174Parameters
175++++++++++
176
177The following parameters can be set in the status dictionary.
178
179================ =========== =============================== ===================================================
180**Parameter** **Default** **Math equivalent** **Description**
181================ =========== =============================== ===================================================
182``E_L`` -70 mV :math:`E_\text{L}` Leak reversal potential
183``C_m`` 250 pF :math:`C_{\text{m}}` Capacity of the membrane
184``t_ref`` 2 ms :math:`t_{\text{ref}}` Duration of refractory period
185``V_th`` -55 mV :math:`V_{\text{th}}` Spike threshold
186``V_reset`` -60 mV :math:`V_{\text{reset}}` Reset potential of the membrane
187``E_ex`` 0 mV :math:`E_\text{ex}` Excitatory reversal potential
188``E_in`` -85 mV :math:`E_\text{in}` Inhibitory reversal potential
189``g_L`` 16.6667 nS :math:`g_\text{L}` Leak conductance
190``tau_rise_ex`` 0.2 ms :math:`\tau_{\text{rise, ex}}` Rise time of the excitatory synaptic conductance
191``tau_decay_ex`` 0.2 ms :math:`\tau_{\text{decay, ex}}` Decay time of the excitatory synaptic conductance
192``tau_rise_in`` 2.0 ms :math:`\tau_{\text{rise, in}}` Rise time of the inhibitory synaptic conductance
193``tau_decay_in`` 2.0 ms :math:`\tau_{\text{decay, in}}` Decay time of the inhibitory synaptic conductance
194``I_e`` 0 pA :math:`I_\text{e}` Constant input current
195================ =========== =============================== ===================================================
196
197The following state variables evolve during simulation and are available either as neuron properties or as recordables.
198
199================== ================= ========================== =================================
200**State variable** **Initial value** **Math equivalent** **Description**
201================== ================= ========================== =================================
202``V_m`` -70 mV :math:`V_{\text{m}}` Membrane potential
203``g_ex`` 0 nS :math:`g_{\text{ex}}` Excitatory synaptic conductance
204``g_in`` 0 nS :math:`g_{\text{in}}` Inhibitory synaptic conductance
205================== ================= ========================== =================================
206
207
208Sends
209+++++
210
211SpikeEvent
212
213Receives
214++++++++
215
216SpikeEvent, CurrentEvent, DataLoggingRequest
217
218References
219++++++++++
220
221.. footbibliography::
222
223See also
224++++++++
225
226iaf_cond_exp, iaf_cond_alpha, iaf_cond_alpha_mc
227
228Examples using this model
229+++++++++++++++++++++++++
230
231.. listexamples:: iaf_cond_beta
232
233EndUserDocs */
234// clang-format on
235
236void register_iaf_cond_beta( const std::string& name );
237
238class iaf_cond_beta : public ArchivingNode
239{
240
241 // Boilerplate function declarations --------------------------------
242
243public:
244 iaf_cond_beta();
245 iaf_cond_beta( const iaf_cond_beta& );
246 ~iaf_cond_beta() override;
247
248 /*
249 * Import all overloaded virtual functions that we
250 * override in this class. For background information,
251 * see http://www.gotw.ca/gotw/005.htm.
252 */
253
254 using Node::handle;
255 using Node::handles_test_event;
256
257 size_t send_test_event( Node& tagret, size_t receptor_type, synindex, bool ) override;
258
259 size_t handles_test_event( SpikeEvent&, size_t ) override;
260 size_t handles_test_event( CurrentEvent&, size_t ) override;
261 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
262
263 void handle( SpikeEvent& ) override;
264 void handle( CurrentEvent& ) override;
265 void handle( DataLoggingRequest& ) override;
266
267 void get_status( Dictionary& ) const override;
268 void set_status( const Dictionary& ) override;
269
270private:
271 void init_buffers_() override;
272 double get_normalisation_factor( double, double );
273 void pre_run_hook() override;
274 void update( Time const&, const long, const long ) override;
275
276 // END Boilerplate function declarations ----------------------------
277
278 // Friends --------------------------------------------------------
279
280 // make dynamics function quasi-member
281 friend int iaf_cond_beta_dynamics( double, const double*, double*, void* );
282
283 // The next two classes need to be friends to access the State_ class/member
284 friend class RecordablesMap< iaf_cond_beta >;
285 friend class UniversalDataLogger< iaf_cond_beta >;
286
287private:
288 // Parameters class -------------------------------------------------
289
291 struct Parameters_
292 {
293 double V_th;
294 double V_reset;
295 double t_ref;
296 double g_L;
297 double C_m;
298 double E_ex;
299 double E_in;
300 double E_L;
301 double tau_rise_ex;
302 double tau_decay_ex;
303 double tau_rise_in;
304 double tau_decay_in;
305 double I_e;
306
307 Parameters_();
308
309 void get( Dictionary& ) const;
310 void set( const Dictionary&, Node* node );
311 };
312
313 // State variables class --------------------------------------------
314
324public:
325 struct State_
326 {
328 enum StateVecElems
329 {
330 V_M = 0,
331 DG_EXC,
332 G_EXC,
333 DG_INH,
334 G_INH,
335 STATE_VEC_SIZE
336 };
337
339 double y[ STATE_VEC_SIZE ];
340
342 int r;
343
344 State_( const Parameters_& );
345 State_( const State_& );
346
347 State_& operator=( const State_& );
348
349 void get( Dictionary& ) const;
350
355 void set( const Dictionary&, const Parameters_&, Node* );
356 };
357
358private:
359 // Buffers class --------------------------------------------------------
360
367 struct Buffers_
368 {
369 Buffers_( iaf_cond_beta& );
370 Buffers_( const Buffers_&, iaf_cond_beta& );
371
373 UniversalDataLogger< iaf_cond_beta > logger_;
374
376 RingBuffer spike_exc_;
377 RingBuffer spike_inh_;
378 RingBuffer currents_;
379
380 /* GSL ODE stuff */
381 gsl_odeiv_step* s_;
382 gsl_odeiv_control* c_;
383 gsl_odeiv_evolve* e_;
384 gsl_odeiv_system sys_;
385
386 // Since IntegrationStep_ is initialized with step_, and the resolution
387 // cannot change after nodes have been created, it is safe to place both
388 // here.
389 double step_;
390 double IntegrationStep_;
391
399 double I_stim_;
400 };
401
402 // Variables class -------------------------------------------------------
403
408 struct Variables_
409 {
414 double PSConInit_E;
415
420 double PSConInit_I;
421
423 int RefractoryCounts;
424 };
425
426 // Access functions for UniversalDataLogger -------------------------------
427
429 template < State_::StateVecElems elem >
430 double
431 get_y_elem_() const
432 {
433 return S_.y[ elem ];
434 }
435
437 double
438 get_r_() const
439 {
440 return Time::get_resolution().get_ms() * S_.r;
441 }
442
443 // Data members -----------------------------------------------------------
444
445 // keep the order of these lines, seems to give best performance
446 Parameters_ P_;
447 State_ S_;
448 Variables_ V_;
449 Buffers_ B_;
450
452 static RecordablesMap< iaf_cond_beta > recordablesMap_;
453};
454
455
456// Boilerplate inline function definitions ----------------------------------
457
458inline size_t
459iaf_cond_beta::send_test_event( Node& target, size_t receptor_type, synindex, bool )
460{
462 e.set_sender( *this );
463 return target.handles_test_event( e, receptor_type );
464}
465
466inline size_t
467iaf_cond_beta::handles_test_event( SpikeEvent&, size_t receptor_type )
468{
469 if ( receptor_type != 0 )
470 {
471 throw UnknownReceptorType( receptor_type, get_name() );
472 }
473 return 0;
474}
475
476inline size_t
477iaf_cond_beta::handles_test_event( CurrentEvent&, size_t receptor_type )
478{
479 if ( receptor_type != 0 )
480 {
481 throw UnknownReceptorType( receptor_type, get_name() );
482 }
483 return 0;
484}
485
486inline size_t
487iaf_cond_beta::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
488{
489 if ( receptor_type != 0 )
490 {
491 throw UnknownReceptorType( receptor_type, get_name() );
492 }
493 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
494}
495
496inline void
497iaf_cond_beta::get_status( Dictionary& d ) const
498{
499 P_.get( d );
500 S_.get( d );
502
503 d[ names::recordables ] = recordablesMap_.get_list();
504}
505
506inline void
507iaf_cond_beta::set_status( const Dictionary& d )
508{
509 Parameters_ ptmp = P_; // temporary copy in case of errors
510 ptmp.set( d, this ); // throws if BadProperty
511 State_ stmp = S_; // temporary copy in case of errors
512 stmp.set( d, ptmp, this ); // throws if BadProperty
513
514 // We now know that (ptmp, stmp) are consistent. We do not
515 // write them back to (P_, S_) before we are also sure that
516 // the properties to be set in the parent class are internally
517 // consistent.
519
520 // if we get here, temporaries contain consistent set of properties
521 P_ = ptmp;
522 S_ = stmp;
523}
524
525} // namespace
526
527#endif // HAVE_GSL
528
529#endif // IAF_COND_BETA_H
A node which archives spike history for the purposes of spike-timing dependent plasticity (STDP).
Definition archiving_node.h:49
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition archiving_node.cpp:249
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition archiving_node.cpp:265
Event for electrical currents.
Definition event.h:608
Request data to be logged/logged data to be sent.
Definition event.h:675
Base class for all NEST network objects.
Definition node.h:99
Event for spike information.
Definition event.h:420
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
const std::string t_ref("t_ref")
const std::string E_L("E_L")
const std::string I_e("I_e")
const std::string V_reset("V_reset")
const std::string recordables("recordables")
const std::string C_m("C_m")
const std::string d("d")
const std::string V_th("V_th")
const std::string tau_rise_in("tau_rise_in")
const std::string tau_decay_in("tau_decay_in")
const std::string y("y")
const std::string E_in("E_in")
const std::string tau_decay_ex("tau_decay_ex")
const std::string target("target")
const std::string E_ex("E_ex")
const std::string tau_rise_ex("tau_rise_ex")
const std::string g_L("g_L")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
RecordablesMap< binary_neuron< TGainfunction > > binary_neuron< TGainfunction >::recordablesMap_
Definition binary_neuron.h:319
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121
const double e
Definition numerics.cpp:32