NEST main@d22e9b2
 
Loading...
Searching...
No Matches
iaf_cond_alpha.h
Go to the documentation of this file.
1/*
2 * iaf_cond_alpha.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_ALPHA_H
24#define IAF_COND_ALPHA_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_alpha_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 alpha-shaped synaptic conductances
67
68Description
69+++++++++++
70
71``iaf_cond_alpha`` is a leaky integrate-and-fire neuron model with
72
73* a hard threshold,
74* a fixed refractory period,
75* :math:`\alpha`-shaped synaptic conductances, normalized such that an event of weight 1.0 results in a peak conductance of 1 nS.
76
77The model follows the conductance-based integrate-and-fire framework discussed in
78:footcite:p:`Meffin2004`, :footcite:p:`Bernander1991`, :footcite:p:`Kuhn2004`.
79
80Membrane potential evolution, spike emission, and refractoriness
81................................................................
82
83The membrane potential evolves according to
84
85.. math::
86
87 \frac{dV_\text{m}}{dt} = \frac{ -g_{\text{L}} (V_{\text{m}} - E_{\text{L}}) - I_{\text{syn}} + I_\text{e} } {C_{\text{m}}}
88
89where the synaptic input current :math:`I_{\text{syn}}(t)` is discussed below and :math:`I_\text{e}` is
90a constant input current set as a model parameter.
91
92A spike is emitted at time step :math:`t^*=t^{k+1}` if
93
94.. math::
95
96 V_\text{m}(t_k) < V_{th} \quad\text{and}\quad V_\text{m}(t^{k+1})\geq V_\text{th} \;.
97
98Subsequently,
99
100.. math::
101
102 V_\text{m}(t) = V_{\text{reset}} \quad\text{for}\quad t^* \leq t \leq t^* + t_{\text{ref}} \;,
103
104that is, the membrane potential is clamped to :math:`V_{\text{reset}}` during the refractory period.
105
106Synaptic input
107..............
108
109The synaptic input current has an excitatory and an inhibitory component
110
111.. math::
112
113 I_{\text{syn}}(t) = I_{\text{syn, ex}}(t) + I_{\text{syn, in}}(t)
114
115where
116
117.. math::
118
119 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) \;,
120
121where :math:`j` indexes either excitatory (:math:`\text{X} = \text{ex}`)
122or inhibitory (:math:`\text{X} = \text{in}`) presynaptic neurons,
123:math:`k` indexes the spike times of neuron :math:`j`, and :math:`d_j`
124is the delay from neuron :math:`j`.
125
126The individual synaptic conductances are given by
127
128.. math::
129
130 g_{\text{X}}(t) = \frac{e}{\tau_{\text{syn, X}}} \, t \, e^{-\frac{t}{\tau_{\text{syn, X}}}} \Theta(t)
131
132where :math:`\Theta(x)` is the Heaviside step function. The conductances are normalized to unit
133peak, that is,
134
135.. math::
136
137 g_{\text{X}}(t= \tau_{\text{syn, X}}) = 1 \;,
138
139as the connnection of the weight :math:`w_{j}` from neuron :math:`j` (excitatory if
140:math:`w_{j} > 0` or inhibitory if :math:`w_{j} < 0`) is written explicitly in the equation for total
141synaptic current.
142
143.. note::
144
145 This model integrates the subthreshold and synaptic dynamics with an
146 adaptive-step-size Runge-Kutta-Fehlberg solver from the GNU Scientific Library.
147
148Parameters
149++++++++++
150
151The following parameters can be set in the status dictionary.
152
153=============== ================== =============================== ========================================================================
154**Parameter** **Default** **Math equivalent** **Description**
155=============== ================== =============================== ========================================================================
156``E_L`` -70 mV :math:`E_\text{L}` Leak reversal potential
157``C_m`` 250 pF :math:`C_{\text{m}}` Capacity of the membrane
158``t_ref`` 2 ms :math:`t_{\text{ref}}` Duration of refractory period
159``V_th`` -55 mV :math:`V_{\text{th}}` Spike threshold
160``V_reset`` -60 mV :math:`V_{\text{reset}}` Reset potential of the membrane
161``E_ex`` 0 mV :math:`E_\text{ex}` Excitatory reversal potential
162``E_in`` -85 mV :math:`E_\text{in}` Inhibitory reversal potential
163``g_L`` 16.6667 nS :math:`g_\text{L}` Leak conductance
164``tau_syn_ex`` 0.2 ms :math:`\tau_{\text{syn, ex}}` Rise time of the excitatory synaptic conductance
165``tau_syn_in`` 2.0 ms :math:`\tau_{\text{syn, in}}` Rise time of the inhibitory synaptic conductance
166``I_e`` 0 pA :math:`I_\text{e}` Constant input current
167=============== ================== =============================== ========================================================================
168
169The following state variables evolve during simulation and are available either as neuron properties or as recordables.
170
171================== ================= ========================== =================================
172**State variable** **Initial value** **Math equivalent** **Description**
173================== ================= ========================== =================================
174``V_m`` -70 mV :math:`V_{\text{m}}` Membrane potential
175``g_ex`` 0 nS :math:`g_{\text{ex}}` Excitatory synaptic conductance
176``g_in`` 0 nS :math:`g_{\text{in}}` Inhibitory synaptic conductance
177================== ================= ========================== =================================
178
179Sends
180+++++
181
182SpikeEvent
183
184Receives
185++++++++
186
187SpikeEvent, CurrentEvent, DataLoggingRequest
188
189References
190++++++++++
191
192.. footbibliography::
193
194See also
195++++++++
196
197iaf_cond_exp, iaf_cond_alpha_mc
198
199Examples using this model
200+++++++++++++++++++++++++
201
202.. listexamples:: iaf_cond_alpha
203
204EndUserDocs */
205// clang-format on
206
207void register_iaf_cond_alpha( const std::string& name );
208
209class iaf_cond_alpha : public ArchivingNode
210{
211
212 // Boilerplate function declarations --------------------------------
213
214public:
215 iaf_cond_alpha();
216 iaf_cond_alpha( const iaf_cond_alpha& );
217 ~iaf_cond_alpha() override;
218
219 /*
220 * Import all overloaded virtual functions that we
221 * override in this class. For background information,
222 * see http://www.gotw.ca/gotw/005.htm.
223 */
224
225 using Node::handle;
226 using Node::handles_test_event;
227
228 size_t send_test_event( Node& tagret, size_t receptor_type, synindex, bool ) override;
229
230 size_t handles_test_event( SpikeEvent&, size_t ) override;
231 size_t handles_test_event( CurrentEvent&, size_t ) override;
232 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
233
234 void handle( SpikeEvent& ) override;
235 void handle( CurrentEvent& ) override;
236 void handle( DataLoggingRequest& ) override;
237
238 void get_status( Dictionary& ) const override;
239 void set_status( const Dictionary& ) override;
240
241private:
242 void init_buffers_() override;
243 void pre_run_hook() override;
244 void update( Time const&, const long, const long ) override;
245
246 // END Boilerplate function declarations ----------------------------
247
248 // Friends --------------------------------------------------------
249
250 // make dynamics function quasi-member
251 friend int iaf_cond_alpha_dynamics( double, const double*, double*, void* );
252
253 // The next two classes need to be friends to access the State_ class/member
254 friend class RecordablesMap< iaf_cond_alpha >;
255 friend class UniversalDataLogger< iaf_cond_alpha >;
256
257private:
258 // Parameters class -------------------------------------------------
259
261 struct Parameters_
262 {
263 double V_th;
264 double V_reset;
265 double t_ref;
266 double g_L;
267 double C_m;
268 double E_ex;
269 double E_in;
270 double E_L;
271 double tau_synE;
272 double tau_synI;
273 double I_e;
274
275 Parameters_();
276
277 void get( Dictionary& ) const;
278 void set( const Dictionary&, Node* node );
279 };
280
281 // State variables class --------------------------------------------
282
292public:
293 struct State_
294 {
296 enum StateVecElems
297 {
298 V_M = 0,
299 DG_EXC,
300 G_EXC,
301 DG_INH,
302 G_INH,
303 STATE_VEC_SIZE
304 };
305
307 double y[ STATE_VEC_SIZE ];
308
310 int r;
311
312 State_( const Parameters_& );
313 State_( const State_& );
314
315 State_& operator=( const State_& );
316
317 void get( Dictionary& ) const;
318
323 void set( const Dictionary&, const Parameters_&, Node* );
324 };
325
326private:
327 // Buffers class --------------------------------------------------------
328
335 struct Buffers_
336 {
337 Buffers_( iaf_cond_alpha& );
338 Buffers_( const Buffers_&, iaf_cond_alpha& );
339
341 UniversalDataLogger< iaf_cond_alpha > logger_;
342
344 RingBuffer spike_exc_;
345 RingBuffer spike_inh_;
346 RingBuffer currents_;
347
348 /* GSL ODE stuff */
349 gsl_odeiv_step* s_;
350 gsl_odeiv_control* c_;
351 gsl_odeiv_evolve* e_;
352 gsl_odeiv_system sys_;
353
354 // Since IntegrationStep_ is initialized with step_, and the resolution
355 // cannot change after nodes have been created, it is safe to place both
356 // here.
357 double step_;
358 double IntegrationStep_;
359
367 double I_stim_;
368 };
369
370 // Variables class -------------------------------------------------------
371
376 struct Variables_
377 {
382 double PSConInit_E;
383
388 double PSConInit_I;
389
391 int RefractoryCounts;
392 };
393
394 // Access functions for UniversalDataLogger -------------------------------
395
397 template < State_::StateVecElems elem >
398 double
399 get_y_elem_() const
400 {
401 return S_.y[ elem ];
402 }
403
405 double
406 get_r_() const
407 {
408 return Time::get_resolution().get_ms() * S_.r;
409 }
410
411 // Data members -----------------------------------------------------------
412
413 // keep the order of these lines, seems to give best performance
414 Parameters_ P_;
415 State_ S_;
416 Variables_ V_;
417 Buffers_ B_;
418
420 static RecordablesMap< iaf_cond_alpha > recordablesMap_;
421};
422
423
424// Boilerplate inline function definitions ----------------------------------
425
426inline size_t
427iaf_cond_alpha::send_test_event( Node& target, size_t receptor_type, synindex, bool )
428{
429 SpikeEvent e;
430 e.set_sender( *this );
431 return target.handles_test_event( e, receptor_type );
432}
433
434inline size_t
435iaf_cond_alpha::handles_test_event( SpikeEvent&, size_t receptor_type )
436{
437 if ( receptor_type != 0 )
438 {
439 throw UnknownReceptorType( receptor_type, get_name() );
440 }
441 return 0;
442}
443
444inline size_t
445iaf_cond_alpha::handles_test_event( CurrentEvent&, size_t receptor_type )
446{
447 if ( receptor_type != 0 )
448 {
449 throw UnknownReceptorType( receptor_type, get_name() );
450 }
451 return 0;
452}
453
454inline size_t
455iaf_cond_alpha::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
456{
457 if ( receptor_type != 0 )
458 {
459 throw UnknownReceptorType( receptor_type, get_name() );
460 }
461 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
462}
463
464inline void
465iaf_cond_alpha::get_status( Dictionary& d ) const
466{
467 P_.get( d );
468 S_.get( d );
470
471 d[ names::recordables ] = recordablesMap_.get_list();
472}
473
474inline void
475iaf_cond_alpha::set_status( const Dictionary& d )
476{
477 Parameters_ ptmp = P_; // temporary copy in case of errors
478 ptmp.set( d, this ); // throws if BadProperty
479 State_ stmp = S_; // temporary copy in case of errors
480 stmp.set( d, ptmp, this ); // throws if BadProperty
481
482 // We now know that (ptmp, stmp) are consistent. We do not
483 // write them back to (P_, S_) before we are also sure that
484 // the properties to be set in the parent class are internally
485 // consistent.
487
488 // if we get here, temporaries contain consistent set of properties
489 P_ = ptmp;
490 S_ = stmp;
491}
492
493} // namespace
494
495#endif // IAF_COND_ALPHA_H
496
497#endif // HAVE_GSL
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 y("y")
const std::string E_in("E_in")
const std::string target("target")
const std::string E_ex("E_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