NEST main@d22e9b2
 
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-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-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-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 This class distinguishes between excitatory and inhibitory inputs by the sign of the
164 synaptic weight. For input separation by ``receptor_type``, see ``iaf_cond_alpha_mc``.
165 This model integrates the dynamics with an adaptive-step-size Runge-Kutta-Fehlberg
166 solver from the GNU Scientific Library.
167
168Parameters
169++++++++++
170
171The following parameters can be set in the status dictionary.
172
173================ =========== =============================== ===================================================
174**Parameter** **Default** **Math equivalent** **Description**
175================ =========== =============================== ===================================================
176``E_L`` -70 mV :math:`E_\text{L}` Leak reversal potential
177``C_m`` 250 pF :math:`C_{\text{m}}` Capacity of the membrane
178``t_ref`` 2 ms :math:`t_{\text{ref}}` Duration of refractory period
179``V_th`` -55 mV :math:`V_{\text{th}}` Spike threshold
180``V_reset`` -60 mV :math:`V_{\text{reset}}` Reset potential of the membrane
181``E_ex`` 0 mV :math:`E_\text{ex}` Excitatory reversal potential
182``E_in`` -85 mV :math:`E_\text{in}` Inhibitory reversal potential
183``g_L`` 16.6667 nS :math:`g_\text{L}` Leak conductance
184``tau_rise_ex`` 0.2 ms :math:`\tau_{\text{rise, ex}}` Rise time of the excitatory synaptic conductance
185``tau_decay_ex`` 0.2 ms :math:`\tau_{\text{decay, ex}}` Decay time of the excitatory synaptic conductance
186``tau_rise_in`` 2.0 ms :math:`\tau_{\text{rise, in}}` Rise time of the inhibitory synaptic conductance
187``tau_decay_in`` 2.0 ms :math:`\tau_{\text{decay, in}}` Decay time of the inhibitory synaptic conductance
188``I_e`` 0 pA :math:`I_\text{e}` Constant input current
189================ =========== =============================== ===================================================
190
191The following state variables evolve during simulation and are available either as neuron properties or as recordables.
192
193================== ================= ========================== =================================
194**State variable** **Initial value** **Math equivalent** **Description**
195================== ================= ========================== =================================
196``V_m`` -70 mV :math:`V_{\text{m}}` Membrane potential
197``g_ex`` 0 nS :math:`g_{\text{ex}}` Excitatory synaptic conductance
198``g_in`` 0 nS :math:`g_{\text{in}}` Inhibitory synaptic conductance
199================== ================= ========================== =================================
200
201
202Sends
203+++++
204
205SpikeEvent
206
207Receives
208++++++++
209
210SpikeEvent, CurrentEvent, DataLoggingRequest
211
212References
213++++++++++
214
215.. footbibliography::
216
217See also
218++++++++
219
220iaf_cond_exp, iaf_cond_alpha, iaf_cond_alpha_mc
221
222Examples using this model
223+++++++++++++++++++++++++
224
225.. listexamples:: iaf_cond_beta
226
227EndUserDocs */
228// clang-format on
229
230void register_iaf_cond_beta( const std::string& name );
231
232class iaf_cond_beta : public ArchivingNode
233{
234
235 // Boilerplate function declarations --------------------------------
236
237public:
238 iaf_cond_beta();
239 iaf_cond_beta( const iaf_cond_beta& );
240 ~iaf_cond_beta() override;
241
242 /*
243 * Import all overloaded virtual functions that we
244 * override in this class. For background information,
245 * see http://www.gotw.ca/gotw/005.htm.
246 */
247
248 using Node::handle;
249 using Node::handles_test_event;
250
251 size_t send_test_event( Node& tagret, size_t receptor_type, synindex, bool ) override;
252
253 size_t handles_test_event( SpikeEvent&, size_t ) override;
254 size_t handles_test_event( CurrentEvent&, size_t ) override;
255 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
256
257 void handle( SpikeEvent& ) override;
258 void handle( CurrentEvent& ) override;
259 void handle( DataLoggingRequest& ) override;
260
261 void get_status( Dictionary& ) const override;
262 void set_status( const Dictionary& ) override;
263
264private:
265 void init_buffers_() override;
266 double get_normalisation_factor( double, double );
267 void pre_run_hook() override;
268 void update( Time const&, const long, const long ) override;
269
270 // END Boilerplate function declarations ----------------------------
271
272 // Friends --------------------------------------------------------
273
274 // make dynamics function quasi-member
275 friend int iaf_cond_beta_dynamics( double, const double*, double*, void* );
276
277 // The next two classes need to be friends to access the State_ class/member
278 friend class RecordablesMap< iaf_cond_beta >;
279 friend class UniversalDataLogger< iaf_cond_beta >;
280
281private:
282 // Parameters class -------------------------------------------------
283
285 struct Parameters_
286 {
287 double V_th;
288 double V_reset;
289 double t_ref;
290 double g_L;
291 double C_m;
292 double E_ex;
293 double E_in;
294 double E_L;
295 double tau_rise_ex;
296 double tau_decay_ex;
297 double tau_rise_in;
298 double tau_decay_in;
299 double I_e;
300
301 Parameters_();
302
303 void get( Dictionary& ) const;
304 void set( const Dictionary&, Node* node );
305 };
306
307 // State variables class --------------------------------------------
308
318public:
319 struct State_
320 {
322 enum StateVecElems
323 {
324 V_M = 0,
325 DG_EXC,
326 G_EXC,
327 DG_INH,
328 G_INH,
329 STATE_VEC_SIZE
330 };
331
333 double y[ STATE_VEC_SIZE ];
334
336 int r;
337
338 State_( const Parameters_& );
339 State_( const State_& );
340
341 State_& operator=( const State_& );
342
343 void get( Dictionary& ) const;
344
349 void set( const Dictionary&, const Parameters_&, Node* );
350 };
351
352private:
353 // Buffers class --------------------------------------------------------
354
361 struct Buffers_
362 {
363 Buffers_( iaf_cond_beta& );
364 Buffers_( const Buffers_&, iaf_cond_beta& );
365
367 UniversalDataLogger< iaf_cond_beta > logger_;
368
370 RingBuffer spike_exc_;
371 RingBuffer spike_inh_;
372 RingBuffer currents_;
373
374 /* GSL ODE stuff */
375 gsl_odeiv_step* s_;
376 gsl_odeiv_control* c_;
377 gsl_odeiv_evolve* e_;
378 gsl_odeiv_system sys_;
379
380 // Since IntegrationStep_ is initialized with step_, and the resolution
381 // cannot change after nodes have been created, it is safe to place both
382 // here.
383 double step_;
384 double IntegrationStep_;
385
393 double I_stim_;
394 };
395
396 // Variables class -------------------------------------------------------
397
402 struct Variables_
403 {
408 double PSConInit_E;
409
414 double PSConInit_I;
415
417 int RefractoryCounts;
418 };
419
420 // Access functions for UniversalDataLogger -------------------------------
421
423 template < State_::StateVecElems elem >
424 double
425 get_y_elem_() const
426 {
427 return S_.y[ elem ];
428 }
429
431 double
432 get_r_() const
433 {
434 return Time::get_resolution().get_ms() * S_.r;
435 }
436
437 // Data members -----------------------------------------------------------
438
439 // keep the order of these lines, seems to give best performance
440 Parameters_ P_;
441 State_ S_;
442 Variables_ V_;
443 Buffers_ B_;
444
446 static RecordablesMap< iaf_cond_beta > recordablesMap_;
447};
448
449
450// Boilerplate inline function definitions ----------------------------------
451
452inline size_t
453iaf_cond_beta::send_test_event( Node& target, size_t receptor_type, synindex, bool )
454{
455 SpikeEvent e;
456 e.set_sender( *this );
457 return target.handles_test_event( e, receptor_type );
458}
459
460inline size_t
461iaf_cond_beta::handles_test_event( SpikeEvent&, size_t receptor_type )
462{
463 if ( receptor_type != 0 )
464 {
465 throw UnknownReceptorType( receptor_type, get_name() );
466 }
467 return 0;
468}
469
470inline size_t
471iaf_cond_beta::handles_test_event( CurrentEvent&, size_t receptor_type )
472{
473 if ( receptor_type != 0 )
474 {
475 throw UnknownReceptorType( receptor_type, get_name() );
476 }
477 return 0;
478}
479
480inline size_t
481iaf_cond_beta::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
482{
483 if ( receptor_type != 0 )
484 {
485 throw UnknownReceptorType( receptor_type, get_name() );
486 }
487 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
488}
489
490inline void
491iaf_cond_beta::get_status( Dictionary& d ) const
492{
493 P_.get( d );
494 S_.get( d );
496
497 d[ names::recordables ] = recordablesMap_.get_list();
498}
499
500inline void
501iaf_cond_beta::set_status( const Dictionary& d )
502{
503 Parameters_ ptmp = P_; // temporary copy in case of errors
504 ptmp.set( d, this ); // throws if BadProperty
505 State_ stmp = S_; // temporary copy in case of errors
506 stmp.set( d, ptmp, this ); // throws if BadProperty
507
508 // We now know that (ptmp, stmp) are consistent. We do not
509 // write them back to (P_, S_) before we are also sure that
510 // the properties to be set in the parent class are internally
511 // consistent.
513
514 // if we get here, temporaries contain consistent set of properties
515 P_ = ptmp;
516 S_ = stmp;
517}
518
519} // namespace
520
521#endif // HAVE_GSL
522
523#endif // IAF_COND_BETA_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition archiving_node.cpp:220
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition archiving_node.cpp:236
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
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
const double e
Definition numerics.cpp:32