NEST main@caf0ae8
 
Loading...
Searching...
No Matches
iaf_psc_exp.h
Go to the documentation of this file.
1/*
2 * iaf_psc_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_PSC_EXP_H
24#define IAF_PSC_EXP_H
25
26// Includes from nestkernel:
27#include "archiving_node.h"
28#include "connection.h"
29#include "event.h"
30#include "nest_types.h"
31#include "recordables_map.h"
32#include "ring_buffer.h"
34
35namespace nest
36{
37// Disable clang-formatting for documentation due to over-wide table.
38// clang-format off
39/* BeginUserDocs: neuron, integrate-and-fire, current-based, hard threshold
40
41Short description
42+++++++++++++++++
43
44Leaky integrate-and-fire neuron model with exponential-shaped input currents
45
46Description
47+++++++++++
48
49``iaf_psc_exp`` a leaky integrate-and-fire model with
50
51* a hard threshold (if :math:`\delta=0`, see below)
52* a fixed refractory period,
53* no adaptation mechanisms,
54* exponential-shaped synaptic input currents according to :footcite:p:`Tsodyks2000`.
55
56Membrane potential evolution, spike emission, and refractoriness
57................................................................
58
59The membrane potential evolves according to
60
61.. math::
62
63 \frac{dV_\text{m}}{dt} = -\frac{V_{\text{m}} - E_\text{L}}{\tau_{\text{m}}} + \frac{I_{\text{syn}} + I_\text{e}}{C_{\text{m}}}
64
65where the synaptic input current :math:`I_{\text{syn}}(t)` is discussed below and :math:`I_\text{e}` is
66a constant input current set as a model parameter.
67
68A spike is emitted at time step :math:`t^*=t_{k+1}` if
69
70.. math::
71
72 V_\text{m}(t_k) < V_{\text{th}} \quad\text{and}\quad V_\text{m}(t_{k+1})\geq V_\text{th} \;.
73
74Subsequently,
75
76.. math::
77
78 V_\text{m}(t) = V_{\text{reset}} \quad\text{for}\quad t^* \leq t < t^* + t_{\text{ref}} \;,
79
80that is, the membrane potential is clamped to :math:`V_{\text{reset}}` during the refractory period.
81
82.. note::
83
84 Spiking in this model can be either deterministic (:math:`\delta=0`) or stochastic (:math:`\delta > 0`).
85 In the stochastic case, this model implements a type of spike response model with escape noise.
86 Spiking is given by an inhomogeneous Poisson process with rate
87
88 .. math::
89 \rho \exp \left( \frac{V_{\text{m}} - V_{\text{th}}}{\delta} \right).
90
91Synaptic input
92..............
93
94The synaptic input current has an excitatory and an inhibitory component
95
96.. math::
97
98 I_{\text{syn}}(t) = I_{\text{syn, ex}}(t) + I_{\text{syn, in}}(t)
99
100where
101
102.. math::
103
104 I_{\text{syn, X}}(t) = \sum_{j} \sum_{k} i_{\text{syn, X}}(t-t_j^k-d_j) \;,
105
106where :math:`j` indexes either excitatory (:math:`\text{X} = \text{ex}`)
107or inhibitory (:math:`\text{X} = \text{in}`) presynaptic neurons,
108:math:`k` indexes the spike times of neuron :math:`j`, and :math:`d_j`
109is the delay from neuron :math:`j`.
110
111The individual post-synaptic currents (PSCs) are given by
112
113.. math::
114
115 i_{\text{syn, X}}(t) = w \cdot e^{-\frac{t}{\tau_{\text{syn, X}}}} \cdot \Theta(t)
116
117where :math:`w` is a weight (excitatory if :math:`w > 0` or inhibitory if :math:`w < 0`), and :math:`\Theta(x)` is the Heaviside step function. The time dependent components of the PSCs are normalized to unit maximum, so that,
118
119.. math::
120
121 i_{\text{syn, X}}(t= 0) = w \;.
122
123As a consequence, the total charge :math:`q` transferred by a single PSC depends
124on the synaptic time constant according to
125
126.. math::
127
128 q = \int_0^{\infty} i_{\text{syn, X}}(t) dt = w \cdot \tau_{\text{syn, X}} \;.
129
130
131.. note::
132
133
134 If ``tau_m`` is very close to ``tau_syn_ex`` or ``tau_syn_in``, the model
135 will numerically behave as if ``tau_m`` is equal to ``tau_syn_ex`` or
136 ``tau_syn_in``, respectively, to avoid numerical instabilities.
137
138 NEST uses exact integration :footcite:p:`Rotter1999`, :footcite:p:`Diesmann2001` to integrate subthreshold membrane dynamics
139 with maximum precision.
140
141 For implementation details see the
142 `IAF Integration Singularity notebook <../model_details/IAF_Integration_Singularity.ipynb>`_.
143
144``iaf_psc_exp`` can handle current input in two ways:
145
1461. Current input through ``receptor_type`` 0 is handled as a stepwise constant
147 current input as in other iaf models, that is, this current directly enters the
148 membrane potential equation.
1492. In contrast, current input through ``receptor_type`` 1 is filtered through an
150 exponential kernel with the time constant of the excitatory synapse,
151 ``tau_syn_ex``.
152
153 For an example application, see :footcite:p:`Schuecker2015`.
154
155 **Warning:** this current input is added to the state variable
156 ``i_syn_ex_``. If this variable is being recorded, its numerical value
157 will thus not correspond to the excitatory synaptic input current, but to
158 the sum of excitatory synaptic input current and the contribution from
159 receptor type 1 currents.
160
161For conversion between postsynaptic potentials (PSPs) and PSCs,
162please refer to the ``postsynaptic_potential_to_current`` function in
163`PyNEST Microcircuit: Helper Functions <https://github.com/INM-6/microcircuit-PD14-model/blob/main/PyNEST/src/microcircuit/helpers.py>`_.
164
165Parameters
166++++++++++
167
168The following parameters can be set in the status dictionary.
169
170
171=============== ================== =============================== ========================================================================
172**Parameter** **Default** **Math equivalent** **Description**
173=============== ================== =============================== ========================================================================
174``E_L`` -70 mV :math:`E_\text{L}` Resting membrane potential
175``C_m`` 250 pF :math:`C_{\text{m}}` Capacity of the membrane
176``tau_m`` 10 ms :math:`\tau_{\text{m}}` Membrane time constant
177``t_ref`` 2 ms :math:`t_{\text{ref}}` Duration of refractory period
178``V_th`` -55 mV :math:`V_{\text{th}}` Spike threshold
179``V_reset`` -70 mV :math:`V_{\text{reset}}` Reset potential of the membrane
180``tau_syn_ex`` 2 ms :math:`\tau_{\text{syn, ex}}` Rise time of the excitatory synaptic alpha function
181``tau_syn_in`` 2 ms :math:`\tau_{\text{syn, in}}` Rise time of the inhibitory synaptic alpha function
182``I_e`` 0 pA :math:`I_\text{e}` Constant input current
183``delta`` 0 mV :math:`\delta` Parameter scaling stochastic spiking
184``rho`` 0.01 1/s :math:`\rho` Baseline stochastic spiking
185=============== ================== =============================== ========================================================================
186
187The following state variables evolve during simulation and are available either as neuron properties or as recordables.
188
189================== ================= ========================== =================================
190**State variable** **Initial value** **Math equivalent** **Description**
191================== ================= ========================== =================================
192``V_m`` -70 mV :math:`V_{\text{m}}` Membrane potential
193``I_syn_ex`` 0 pA :math:`I_{\text{syn, ex}}` Excitatory synaptic input current
194``I_syn_in`` 0 pA :math:`I_{\text{syn, in}}` Inhibitory synaptic input current
195================== ================= ========================== =================================
196
197
198References
199++++++++++
200
201.. footbibliography::
202
203Sends
204+++++
205
206SpikeEvent
207
208Receives
209++++++++
210
211SpikeEvent, CurrentEvent, DataLoggingRequest
212
213See also
214++++++++
215
216iaf_cond_exp, iaf_psc_exp_ps
217
218Examples using this model
219+++++++++++++++++++++++++
220
221.. listexamples:: iaf_psc_exp
222
223EndUserDocs */
224
240void register_iaf_psc_exp( const std::string& name );
241
243{
244
245public:
246 iaf_psc_exp();
247 iaf_psc_exp( const iaf_psc_exp& );
248
254 using Node::handle;
256
257 size_t send_test_event( Node&, size_t, synindex, bool ) override;
258
259 void handle( SpikeEvent& ) override;
260 void handle( CurrentEvent& ) override;
261 void handle( DataLoggingRequest& ) override;
262
263 size_t handles_test_event( SpikeEvent&, size_t ) override;
264 size_t handles_test_event( CurrentEvent&, size_t ) override;
265 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
266
267 void get_status( Dictionary& ) const override;
268 void set_status( const Dictionary& ) override;
269
270private:
271 void init_buffers_() override;
272 void pre_run_hook() override;
273
274 void update( const Time&, const long, const long ) override;
275
276 // intensity function
277 double phi_() const;
278
279 // The next two classes need to be friends to access the State_ class/member
280 friend class RecordablesMap< iaf_psc_exp >;
281 friend class UniversalDataLogger< iaf_psc_exp >;
282
283 // ----------------------------------------------------------------
284
289 {
291 double Tau_;
292
294 double C_;
295
297 double t_ref_;
298
300 double E_L_;
301
303 double I_e_;
304
307 double Theta_;
308
310 double V_reset_;
311
313 double tau_ex_;
314
316 double tau_in_;
317
319 double rho_;
320
322 double delta_;
323
324 Parameters_();
325
326 void get( Dictionary& ) const;
327
331 double set( const Dictionary&, Node* node );
332 };
333
334 // ----------------------------------------------------------------
335
339 struct State_
340 {
341 // state variables
342 double i_0_;
343 double i_1_;
344 double i_syn_ex_;
346 double i_syn_in_;
347 double V_m_;
348 int r_ref_;
349
350 State_();
351
352 void get( Dictionary&, const Parameters_& ) const;
353
359 void set( const Dictionary&, const Parameters_&, const double, Node* );
360 };
361
362 // ----------------------------------------------------------------
363
388
389 // ----------------------------------------------------------------
390
395 {
401 // double PSCInitialValue_;
402
403 // time evolution operator
404 double P20_;
405 double P11ex_;
406 double P11in_;
407 double P21ex_;
408 double P21in_;
409 double P22_;
410
413
415
417 };
418
419 // Access functions for UniversalDataLogger -------------------------------
420
422 inline double
423 get_V_m_() const
424 {
425 return S_.V_m_ + P_.E_L_;
426 }
427
428 inline double
430 {
431 return S_.i_syn_ex_;
432 }
433
434 inline double
436 {
437 return S_.i_syn_in_;
438 }
439
440 // ----------------------------------------------------------------
441
456};
457
458
459inline size_t
460iaf_psc_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
461{
462 SpikeEvent e;
463 e.set_sender( *this );
464 return target.handles_test_event( e, receptor_type );
465}
466
467inline size_t
469{
470 if ( receptor_type != 0 )
471 {
472 throw UnknownReceptorType( receptor_type, get_name() );
473 }
474 return 0;
475}
476
477inline size_t
479{
480 if ( receptor_type == 0 )
481 {
482 return 0;
483 }
484 else if ( receptor_type == 1 )
485 {
486 return 1;
487 }
488 else
489 {
490 throw UnknownReceptorType( receptor_type, get_name() );
491 }
492}
493
494inline size_t
496{
497 if ( receptor_type != 0 )
498 {
499 throw UnknownReceptorType( receptor_type, get_name() );
500 }
501 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
502}
503
504inline void
506{
507 P_.get( d );
508 S_.get( d, P_ );
510
511 d[ names::recordables ] = recordablesMap_.get_list();
512}
513
514inline void
516{
517 Parameters_ ptmp = P_; // temporary copy in case of errors
518 const double delta_EL = ptmp.set( d, this ); // throws if BadProperty
519 State_ stmp = S_; // temporary copy in case of errors
520 stmp.set( d, ptmp, delta_EL, this ); // throws if BadProperty
521
522 // We now know that (ptmp, stmp) are consistent. We do not
523 // write them back to (P_, S_) before we are also sure that
524 // the properties to be set in the parent class are internally
525 // consistent.
527
528 // if we get here, temporaries contain consistent set of properties
529 P_ = ptmp;
530 S_ = stmp;
531}
532
533inline double
535{
536 assert( P_.delta_ > 0. );
537 return P_.rho_ * std::exp( 1. / P_.delta_ * ( S_.V_m_ - P_.Theta_ ) );
538}
539
540} // namespace
541
542#endif // IAF_PSC_EXP_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
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: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
Base class for RNG engine wrappers.
Definition random_generators.h:67
Event for electrical currents.
Definition event.h:569
Request data to be logged/logged data to be sent.
Definition event.h:636
Base class for all NEST network objects.
Definition node.h:99
std::string get_name() const
Return class name.
Definition node.cpp:105
Map names of recordables to data access functions.
Definition recordables_map.h:61
Event for spike information.
Definition event.h:418
Definition nest_time.h:135
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
Definition iaf_psc_exp.h:243
Variables_ V_
Definition iaf_psc_exp.h:450
double get_I_syn_in_() const
Definition iaf_psc_exp.h:435
friend class UniversalDataLogger< iaf_psc_exp >
Definition iaf_psc_exp.h:281
iaf_psc_exp()
Definition iaf_psc_exp.cpp:214
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition iaf_psc_exp.h:460
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition iaf_psc_exp.h:505
void init_buffers_() override
Configure persistent internal data structures.
Definition iaf_psc_exp.cpp:236
Buffers_ B_
Definition iaf_psc_exp.h:451
Parameters_ P_
Instances of private data structures for the different types of data pertaining to the model.
Definition iaf_psc_exp.h:448
double get_V_m_() const
Read out the real membrane potential.
Definition iaf_psc_exp.h:423
State_ S_
Definition iaf_psc_exp.h:449
double phi_() const
Definition iaf_psc_exp.h:534
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition iaf_psc_exp.cpp:244
void update(const Time &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition iaf_psc_exp.cpp:288
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition iaf_psc_exp.h:515
static RecordablesMap< iaf_psc_exp > recordablesMap_
Mapping of recordables names to access functions.
Definition iaf_psc_exp.h:455
void handle(SpikeEvent &) override
Handle incoming spike events.
Definition iaf_psc_exp.cpp:351
double get_I_syn_ex_() const
Definition iaf_psc_exp.h:429
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition iaf_psc_exp.h:468
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
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:265
const std::string recordables("recordables")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_iaf_psc_exp(const std::string &name)
The present implementation uses individual variables for the components of the state vector and the n...
Definition iaf_psc_exp.cpp:50
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Buffers of the model.
Definition iaf_psc_exp.h:368
UniversalDataLogger< iaf_psc_exp > logger_
Logger for all analog data.
Definition iaf_psc_exp.h:386
MultiChannelInputBuffer< NUM_INPUT_CHANNELS > input_buffer_
buffers and sums up incoming spikes/currents
Definition iaf_psc_exp.h:383
@ NUM_INPUT_CHANNELS
Definition iaf_psc_exp.h:379
@ SYN_EX
Definition iaf_psc_exp.h:376
@ I0
Definition iaf_psc_exp.h:377
@ SYN_IN
Definition iaf_psc_exp.h:375
@ I1
Definition iaf_psc_exp.h:378
Independent parameters of the model.
Definition iaf_psc_exp.h:289
double t_ref_
Refractory period in ms.
Definition iaf_psc_exp.h:297
double delta_
Width of threshold region in mV.
Definition iaf_psc_exp.h:322
double tau_in_
Time constant of inhibitory synaptic current in ms.
Definition iaf_psc_exp.h:316
double tau_ex_
Time constant of excitatory synaptic current in ms.
Definition iaf_psc_exp.h:313
double Tau_
Membrane time constant in ms.
Definition iaf_psc_exp.h:291
Parameters_()
Sets default parameter values.
Definition iaf_psc_exp.cpp:71
double V_reset_
reset value of the membrane potential
Definition iaf_psc_exp.h:310
double E_L_
Resting potential in mV.
Definition iaf_psc_exp.h:300
double Theta_
Threshold, RELATIVE TO RESTING POTENTIAL(!).
Definition iaf_psc_exp.h:307
double C_
Membrane capacitance in pF.
Definition iaf_psc_exp.h:294
double rho_
Stochastic firing intensity at threshold in 1/s.
Definition iaf_psc_exp.h:319
double I_e_
External current in pA.
Definition iaf_psc_exp.h:303
double set(const Dictionary &, Node *node)
Set values from dictionary.
Definition iaf_psc_exp.cpp:117
void get(Dictionary &) const
Store current values in dictionary.
Definition iaf_psc_exp.cpp:101
State variables of the model.
Definition iaf_psc_exp.h:340
double i_syn_ex_
Postsynaptic current for excitatory inputs (includes contribution from current input on receptor type...
Definition iaf_psc_exp.h:344
int r_ref_
Absolute refractory counter (no membrane potential propagation)
Definition iaf_psc_exp.h:348
void set(const Dictionary &, const Parameters_ &, const double, Node *)
Set values from dictionary.
Definition iaf_psc_exp.cpp:188
double V_m_
Membrane potential.
Definition iaf_psc_exp.h:347
double i_0_
Stepwise constant input current.
Definition iaf_psc_exp.h:342
State_()
Default initialization.
Definition iaf_psc_exp.cpp:86
double i_1_
Current input that is filtered through the excitatory synapse exponential kernel.
Definition iaf_psc_exp.h:343
double i_syn_in_
Postsynaptic current for inhibitory inputs.
Definition iaf_psc_exp.h:346
void get(Dictionary &, const Parameters_ &) const
Definition iaf_psc_exp.cpp:182
Internal variables of the model.
Definition iaf_psc_exp.h:395
double P21ex_
Definition iaf_psc_exp.h:407
RngPtr rng_
random number generator of my own thread
Definition iaf_psc_exp.h:416
double weighted_spikes_ex_
Definition iaf_psc_exp.h:411
double P21in_
Definition iaf_psc_exp.h:408
double P20_
Amplitude of the synaptic current.
Definition iaf_psc_exp.h:404
double weighted_spikes_in_
Definition iaf_psc_exp.h:412
double P22_
Definition iaf_psc_exp.h:409
double P11in_
Definition iaf_psc_exp.h:406
int RefractoryCounts_
Definition iaf_psc_exp.h:414
double P11ex_
Definition iaf_psc_exp.h:405