NEST main@f146f75
Loading...
Searching...
No Matches
iaf_cond_exp.h
Go to the documentation of this file.
1/*
2 * iaf_cond_exp.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_EXP_H
24#define IAF_COND_EXP_H
25
26// Generated includes:
27#include "config.h"
28
29#ifdef HAVE_GSL
30
31// External 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_exp_dynamics( double, const double*, double*, void* );
58
59// clang-format off
60/* BeginUserDocs: neuron, integrate-and-fire, conductance-based, hard threshold
61
62Short description
63+++++++++++++++++
64
65Leaky integrate-and-fire neuron model with exponentially-shaped synaptic conductances
66
67
68Description
69+++++++++++
70
71``iaf_cond_exp`` is a leaky integrate-and-fire neuron model with
72
73* a hard threshold,
74* a fixed refractory period,
75* no adaptation mechanisms,
76* exponentially-shaped synaptic conductances according to :footcite:p:`Meffin2004`, normalized such that an event of weight 1.0 results in a peak conductance of 1 nS.
77
78Membrane potential evolution, spike emission, and refractoriness
79................................................................
80
81The membrane potential evolves according to
82
83.. math::
84
85 \frac{dV_\text{m}}{dt} = \frac{ -g_{\text{L}} (V_{\text{m}} - E_{\text{L}}) - I_{\text{syn}} + I_\text{e} } {C_{\text{m}}}
86
87where the synaptic input current :math:`I_{\text{syn}}(t)` is discussed below and :math:`I_\text{e}` is
88a constant input current set as a model parameter.
89
90A spike is emitted at time step :math:`t^*=t_{k+1}` if
91
92.. math::
93
94 V_\text{m}(t_k) < V_{th} \quad\text{and}\quad V_\text{m}(t_{k+1})\geq V_\text{th} \;.
95
96Subsequently,
97
98.. math::
99
100 V_\text{m}(t) = V_{\text{reset}} \quad\text{for}\quad t^* \leq t < t^* + t_{\text{ref}} \;,
101
102that is, the membrane potential is clamped to :math:`V_{\text{reset}}` during the refractory period.
103
104Synaptic input
105..............
106
107The synaptic input current has an excitatory and an inhibitory component
108
109.. math::
110
111 I_{\text{syn}}(t) = I_{\text{syn, ex}}(t) + I_{\text{syn, in}}(t)
112
113where
114
115.. math::
116
117 I_{\text{syn, X}}(t) = (V_{\text{m}}(t) - E_{\text{syn, X}}) \sum_{j} \sum_k g_{\text{j, X}}(t-t_j^k-d_j) \;,
118
119where :math:`j` indexes either excitatory (:math:`\text{X} = \text{ex}`)
120or inhibitory (:math:`\text{X} = \text{in}`) presynaptic neurons,
121:math:`k` indexes the spike times of neuron :math:`j`, and :math:`d_j`
122is the delay from neuron :math:`j`.
123
124The individual synaptic conductances are given by
125
126.. math::
127
128 g_{\text{j, X}}(t) = w_{\text{j}} \cdot e^{-\frac{t}{\tau_{\text{syn, X}}}} \Theta(t)
129
130where :math:`\Theta(x)` is the Heaviside step function. The conductances are normalized to unit maximum, that is,
131
132.. math::
133
134 g_{\text{j, X}}(t= 0) = w_{\text{j}} \;,
135
136where :math:`w` is a weight (excitatory if :math:`w > 0` or inhibitory if :math:`w < 0`).
137
138.. note::
139
140 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
141 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
142 the inhibitory one. Only the absolute value of the weight sets the conductance
143 amplitude. Spike connections must use the default ``receptor_type`` of 0.
144
145 See :ref:`synapse_selection` for the conventions used by other models.
146
147Parameters
148++++++++++
149
150=============== ================== =============================== ========================================================================
151**Parameter** **Default** **Math equivalent** **Description**
152=============== ================== =============================== ========================================================================
153``E_L`` -70 mV :math:`E_\text{L}` Leak reversal potential
154``C_m`` 250 pF :math:`C_{\text{m}}` Capacity of the membrane
155``t_ref`` 2 ms :math:`t_{\text{ref}}` Duration of refractory period
156``V_th`` -55 mV :math:`V_{\text{th}}` Spike threshold
157``V_reset`` -70 mV :math:`V_{\text{reset}}` Reset potential of the membrane
158``E_ex`` 0 mV :math:`E_\text{ex}` Excitatory reversal potential
159``E_in`` -85 mV :math:`E_\text{in}` Inhibitory reversal potential
160``g_L`` -16.6667 nS :math:`g_\text{L}` Leak conductance
161``tau_syn_ex`` 0.2 ms :math:`\tau_{\text{syn, ex}}` Exponential decay time constant of excitatory synaptic conductance kernel
162``tau_syn_in`` 2.0 ms :math:`\tau_{\text{syn, in}}` Exponential decay time constant of inhibitory synaptic conductance kernel
163``I_e`` 0 pA :math:`I_\text{e}` Constant input current
164=============== ================== =============================== ========================================================================
165
166The following state variables evolve during simulation and are available either as neuron properties or as recordables.
167
168================== ================= ========================== =================================
169**State variable** **Initial value** **Math equivalent** **Description**
170================== ================= ========================== =================================
171``V_m`` -70 mV :math:`V_{\text{m}}` Membrane potential
172``g_ex`` 0 nS :math:`g_{\text{ex}}` Excitatory synaptic conductance
173``g_in`` 0 nS :math:`g_{\text{in}}` Inhibitory synaptic conductance
174================== ================= ========================== =================================
175
176Sends
177+++++
178
179SpikeEvent
180
181Receives
182++++++++
183
184SpikeEvent, CurrentEvent, DataLoggingRequest
185
186References
187++++++++++
188
189.. footbibliography::
190
191See also
192++++++++
193
194iaf_psc_delta, iaf_psc_alpha, iaf_psc_exp, iaf_cond_alpha, iaf_cond_beta
195
196Examples using this model
197+++++++++++++++++++++++++
198
199.. listexamples:: iaf_cond_exp
200
201EndUserDocs*/
202// clang-format on
203
204void register_iaf_cond_exp( const std::string& name );
205
206class iaf_cond_exp : public ArchivingNode
207{
208
209public:
210 iaf_cond_exp();
211 iaf_cond_exp( const iaf_cond_exp& );
212 ~iaf_cond_exp() override;
213
219 using Node::handle;
220 using Node::handles_test_event;
221
222 size_t send_test_event( Node&, size_t, synindex, bool ) override;
223
224 void handle( SpikeEvent& ) override;
225 void handle( CurrentEvent& ) override;
226 void handle( DataLoggingRequest& ) override;
227
228 size_t handles_test_event( SpikeEvent&, size_t ) override;
229 size_t handles_test_event( CurrentEvent&, size_t ) override;
230 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
231
232 void get_status( Dictionary& ) const override;
233 void set_status( const Dictionary& ) override;
234
235private:
236 void init_buffers_() override;
237 void pre_run_hook() override;
238 void update( Time const&, const long, const long ) override;
239
240 // END Boilerplate function declarations ----------------------------
241
242 // Friends --------------------------------------------------------
243
244 // make dynamics function quasi-member
245 friend int iaf_cond_exp_dynamics( double, const double*, double*, void* );
246
247 // The next two classes need to be friends to access the State_ class/member
248 friend class RecordablesMap< iaf_cond_exp >;
249 friend class UniversalDataLogger< iaf_cond_exp >;
250
251private:
252 // ----------------------------------------------------------------
253
255 struct Parameters_
256 {
257 double V_th_;
258 double V_reset_;
259 double t_ref_;
260 double g_L;
261 double C_m;
262 double E_ex;
263 double E_in;
264 double E_L;
265 double tau_synE;
266 double tau_synI;
267 double I_e;
268
269 Parameters_();
270
271 void get( Dictionary& ) const;
272 void set( const Dictionary&, Node* node );
273 };
274
275public:
276 // ----------------------------------------------------------------
277
282 struct State_
283 {
285 enum StateVecElems
286 {
287 V_M = 0,
288 G_EXC,
289 G_INH,
290 STATE_VEC_SIZE
291 };
292
294 double y_[ STATE_VEC_SIZE ];
295 int r_;
296
297 State_( const Parameters_& );
298 State_( const State_& );
299
300 State_& operator=( const State_& );
301
302 void get( Dictionary& ) const;
303 void set( const Dictionary&, const Parameters_&, Node* );
304 };
305
306 // ----------------------------------------------------------------
307
308private:
312 struct Buffers_
313 {
314 Buffers_( iaf_cond_exp& );
315 Buffers_( const Buffers_&, iaf_cond_exp& );
316
318 UniversalDataLogger< iaf_cond_exp > logger_;
319
321 RingBuffer spike_exc_;
322 RingBuffer spike_inh_;
323 RingBuffer currents_;
324
326 gsl_odeiv_step* s_;
327 gsl_odeiv_control* c_;
328 gsl_odeiv_evolve* e_;
329 gsl_odeiv_system sys_;
330
331 // Since IntegrationStep_ is initialized with step_, and the resolution
332 // cannot change after nodes have been created, it is safe to place both
333 // here.
334 double step_;
335 double IntegrationStep_;
336
344 double I_stim_;
345 };
346
347 // ----------------------------------------------------------------
348
352 struct Variables_
353 {
354 int RefractoryCounts_;
355 };
356
357 // Access functions for UniversalDataLogger -------------------------------
358
360 template < State_::StateVecElems elem >
361 double
362 get_y_elem_() const
363 {
364 return S_.y_[ elem ];
365 }
366
367 // ----------------------------------------------------------------
368
369 Parameters_ P_;
370 State_ S_;
371 Variables_ V_;
372 Buffers_ B_;
373
375 static RecordablesMap< iaf_cond_exp > recordablesMap_;
376};
377
378
379inline size_t
380iaf_cond_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
381{
383 e.set_sender( *this );
384 return target.handles_test_event( e, receptor_type );
385}
386
387inline size_t
388iaf_cond_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
389{
390 if ( receptor_type != 0 )
391 {
392 throw UnknownReceptorType( receptor_type, get_name() );
393 }
394 return 0;
395}
396
397inline size_t
398iaf_cond_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
399{
400 if ( receptor_type != 0 )
401 {
402 throw UnknownReceptorType( receptor_type, get_name() );
403 }
404 return 0;
405}
406
407inline size_t
408iaf_cond_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
409{
410 if ( receptor_type != 0 )
411 {
412 throw UnknownReceptorType( receptor_type, get_name() );
413 }
414 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
415}
416
417
418inline void
419iaf_cond_exp::get_status( Dictionary& d ) const
420{
421 P_.get( d );
422 S_.get( d );
424
425 d[ names::recordables ] = recordablesMap_.get_list();
426}
427
428inline void
429iaf_cond_exp::set_status( const Dictionary& d )
430{
431 Parameters_ ptmp = P_; // temporary copy in case of errors
432 ptmp.set( d, this ); // throws if BadProperty
433 State_ stmp = S_; // temporary copy in case of errors
434 stmp.set( d, ptmp, this ); // throws if BadProperty
435
436 // We now know that (ptmp, stmp) are consistent. We do not
437 // write them back to (P_, S_) before we are also sure that
438 // the properties to be set in the parent class are internally
439 // consistent.
441
442 // if we get here, temporaries contain consistent set of properties
443 P_ = ptmp;
444 S_ = stmp;
445}
446
447} // namespace
448
449#endif // HAVE_GSL
450#endif // IAF_COND_EXP_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 E_L("E_L")
const std::string I_e("I_e")
const std::string recordables("recordables")
const std::string C_m("C_m")
const std::string d("d")
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
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