NEST main@f146f75
Loading...
Searching...
No Matches
iaf_psc_exp_ps_lossless.h
Go to the documentation of this file.
1/*
2 * iaf_psc_exp_ps_lossless.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_PS_LOSSLESS_H
24#define IAF_PSC_EXP_PS_LOSSLESS_H
25
26// C++ includes:
27#include <vector>
28
29// Generated includes:
30#include "config.h"
31
32// Includes from libnestutil:
33#include "archiving_node.h"
34#include "connection.h"
35#include "event.h"
36#include "iaf_propagator.h"
37#include "nest_types.h"
38#include "recordables_map.h"
39#include "ring_buffer.h"
40#include "slice_ring_buffer.h"
42
43
44namespace nest
45{
46
47/* BeginUserDocs: neuron, integrate-and-fire, current-based, precise, hard threshold
48
49Short description
50+++++++++++++++++
51
52Current-based leaky integrate-and-fire neuron with exponential-shaped
53postsynaptic currents predicting the exact number of spikes using a
54state space analysis
55
56Description
57+++++++++++
58
59``iaf_psc_exp_ps_lossless`` is the precise state space implementation of the leaky
60integrate-and-fire model neuron with exponential postsynaptic currents
61that uses time reversal to detect spikes :footcite:p:`Krishnan2018`. This is the most exact
62implementation available.
63
64Time-reversed state space analysis provides a general method to solve the
65threshold-detection problem for an integrable, affine or linear time
66evolution. This method is based on the idea of propagating the threshold
67backwards in time, and see whether it meets the initial state, rather
68than propagating the initial state forward in time and see whether it
69meets the threshold.
70
71.. note::
72
73 If `tau_m` is very close to `tau_syn_ex` or `tau_syn_in`, the model
74 will numerically behave as if `tau_m` is equal to `tau_syn_ex` or
75 `tau_syn_in`, respectively, to avoid numerical instabilities.
76
77 For implementation details see the
78 `IAF Integration Singularity notebook <../model_details/IAF_Integration_Singularity.ipynb>`_.
79
80.. note::
81
82 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
83 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
84 the inhibitory one, and also sets the direction of the post-synaptic current.
85 Spike connections must use the default ``receptor_type`` of 0.
86
87 See :ref:`synapse_selection` for the conventions used by other models.
88
89Parameters
90++++++++++
91
92The following parameters can be set in the status dictionary.
93
94=========== ======== ==========================================================
95 E_L mV Resting membrane potential
96 C_m pF/mum^2 Specific capacitance of the membrane
97 tau_m ms Membrane time constant
98 tau_syn_ex ms Excitatory synaptic time constant
99 tau_syn_in ms Inhibitory synaptic time constant
100 t_ref ms Duration of refractory period
101 V_th mV Spike threshold
102 I_e pA Constant input current
103 V_min mV Absolute lower value for the membrane potential.
104 V_reset mV Reset value for the membrane potential.
105=========== ======== ==========================================================
106
107References
108++++++++++
109
110.. footbibliography::
111
112Sends
113+++++
114
115SpikeEvent
116
117Receives
118++++++++
119
120SpikeEvent, CurrentEvent, DataLoggingRequest
121
122See also
123++++++++
124
125iaf_psc_exp_ps
126
127Examples using this model
128+++++++++++++++++++++++++
129
130.. listexamples:: iaf_psc_exp_ps_lossless
131
132EndUserDocs */
133
134void register_iaf_psc_exp_ps_lossless( const std::string& name );
135
137{
138public:
144
153
159 using Node::handle;
161
162 size_t send_test_event( Node&, size_t, synindex, bool ) override;
163
164 size_t handles_test_event( SpikeEvent&, size_t ) override;
165 size_t handles_test_event( CurrentEvent&, size_t ) override;
166 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
167
168 void handle( SpikeEvent& ) override;
169 void handle( CurrentEvent& ) override;
170 void handle( DataLoggingRequest& ) override;
171
172 bool
173 is_off_grid() const override // uses off_grid events
174 {
175 return true;
176 }
177
178 void get_status( Dictionary& ) const override;
179 void set_status( const Dictionary& ) override;
180
190 double threshold_distance( double t_step ) const;
191
192private:
198 void init_buffers_() override;
199 void pre_run_hook() override;
200
218 void update( Time const& origin, const long from, const long to ) override;
220
221 // The next two classes need to be friends to access the State_ class/member
223 friend class UniversalDataLogger< iaf_psc_exp_ps_lossless >;
224
229 void propagate_( const double dt );
230
242 void emit_spike_( const Time& origin, const long lag, const double t0, const double dt );
243
251 void emit_instant_spike_( const Time& origin, const long lag, const double spike_offset );
252
268 double is_spike_( const double );
269
273
274 // ----------------------------------------------------------------
275
280 {
282 double tau_m_;
283
285 double tau_ex_;
286
288 double tau_in_;
289
291 double c_m_;
292
294 double t_ref_;
295
297 double E_L_;
298
300 double I_e_;
301
304 double U_th_;
305
308 double U_min_;
309
313 double U_reset_;
314
315 Parameters_();
316
317 void get( Dictionary& ) const;
318 double set( const Dictionary&, Node* node );
319 };
320
321 // ----------------------------------------------------------------
322
326 struct State_
327 {
328 double y0_;
329 double I_syn_ex_;
330 double I_syn_in_;
331 double y2_;
332
336
337 State_();
338
339 void get( Dictionary&, const Parameters_& ) const;
340 void set( const Dictionary&, const Parameters_&, double delta_EL, Node* );
341 };
342
343 // ----------------------------------------------------------------
344
363
364 // ----------------------------------------------------------------
365
370 {
371 double h_ms_;
374 double exp_tau_ex_;
375 double exp_tau_in_;
376 double P20_;
377 double P21_in_;
378 double P21_ex_;
379 double y0_before_;
382 double y2_before_;
383
388 double a1_;
389 double a2_;
390 double a3_;
391 double a4_;
393
398 double b1_;
399 double b2_;
400 double b3_;
401 double b4_;
403
408 double c1_;
409 double c2_;
410 double c3_;
411 double c4_;
412 double c5_;
413 double c6_;
415 };
416
417 // Access functions for UniversalDataLogger -------------------------------
418
420 double
421 get_V_m_() const
422 {
423 return S_.y2_ + P_.E_L_;
424 }
425 double
427 {
428 return S_.I_syn_ex_ + S_.I_syn_in_;
429 }
430 double
432 {
433 return S_.I_syn_ex_;
434 }
435 double
437 {
438 return S_.I_syn_in_;
439 }
440 // ----------------------------------------------------------------
441
453
456};
457
458inline size_t
459iaf_psc_exp_ps_lossless::send_test_event( Node& target, size_t receptor_type, synindex, bool )
460{
461 SpikeEvent e;
462 e.set_sender( *this );
463 return target.handles_test_event( e, receptor_type );
464}
465
466inline size_t
468{
469 if ( receptor_type != 0 )
470 {
471 throw UnknownReceptorType( receptor_type, get_name() );
472 }
473 return 0;
474}
475
476inline size_t
478{
479 if ( receptor_type != 0 )
480 {
481 throw UnknownReceptorType( receptor_type, get_name() );
482 }
483 return 0;
484}
485
486inline size_t
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
498{
499 P_.get( d );
500 S_.get( d, P_ );
502
503 d[ names::recordables ] = recordablesMap_.get_list();
504}
505
506inline void
508{
509 Parameters_ ptmp = P_; // temporary copy in case of errors
510 double delta_EL = ptmp.set( d, this ); // throws if BadProperty
511 State_ stmp = S_; // temporary copy in case of errors
512 stmp.set( d, ptmp, delta_EL, 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} // namespace
525#endif // IAF_PSC_EXP_PS_LOSSLESS_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Exact integration voltage propagator for models with exponential psc.
Definition iaf_propagator.h:101
ArchivingNode()
Definition archiving_node.cpp:37
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
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
Buffer Layout.
Definition ring_buffer.h:83
Queue for all spikes arriving into a neuron.
Definition slice_ring_buffer.h:63
Event for spike information.
Definition event.h:420
Definition nest_time.h:135
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
void init_buffers_() override
Configure persistent internal data structures.
Definition iaf_psc_exp_ps_lossless.cpp:263
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition iaf_psc_exp_ps_lossless.h:497
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition iaf_psc_exp_ps_lossless.h:507
iaf_psc_exp_ps_lossless()
Basic constructor.
Definition iaf_psc_exp_ps_lossless.cpp:241
double is_spike_(const double)
Retrospective spike detection by state space analysis.
Definition iaf_psc_exp_ps_lossless.cpp:595
void emit_instant_spike_(const Time &origin, const long lag, const double spike_offset)
Emit a single spike at a precisely given time.
Definition iaf_psc_exp_ps_lossless.cpp:560
void update(Time const &origin, const long from, const long to) override
Time Evolution Operator.
Definition iaf_psc_exp_ps_lossless.cpp:316
Buffers_ B_
Definition iaf_psc_exp_ps_lossless.h:451
Variables_ V_
Definition iaf_psc_exp_ps_lossless.h:450
double get_V_m_() const
Read out the real membrane potential.
Definition iaf_psc_exp_ps_lossless.h:421
void emit_spike_(const Time &origin, const long lag, const double t0, const double dt)
Emit a single spike caused by DC current in absence of spike input.
Definition iaf_psc_exp_ps_lossless.cpp:535
void handle(SpikeEvent &) override
Handle incoming spike events.
Definition iaf_psc_exp_ps_lossless.cpp:473
double get_I_syn_in_() const
Definition iaf_psc_exp_ps_lossless.h:436
double get_I_syn_ex_() const
Definition iaf_psc_exp_ps_lossless.h:431
Parameters_ P_
Instances of private data structures for the different types of data pertaining to the model.
Definition iaf_psc_exp_ps_lossless.h:448
State_ S_
Definition iaf_psc_exp_ps_lossless.h:449
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_ps_lossless.h:459
bool is_off_grid() const override
Returns true if the node sends/receives off-grid events.
Definition iaf_psc_exp_ps_lossless.h:173
friend class RecordablesMap< iaf_psc_exp_ps_lossless >
Definition iaf_psc_exp_ps_lossless.h:222
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_ps_lossless.h:467
double get_I_syn_() const
Definition iaf_psc_exp_ps_lossless.h:426
double threshold_distance(double t_step) const
Based on the current state, compute the value of the membrane potential after taking a timestep of le...
Definition iaf_psc_exp_ps_lossless.cpp:581
void propagate_(const double dt)
Propagate neuron state.
Definition iaf_psc_exp_ps_lossless.cpp:510
IAFPropagatorExp propagator_ex_
Propagator object for updating synaptic components.
Definition iaf_psc_exp_ps_lossless.h:271
static RecordablesMap< iaf_psc_exp_ps_lossless > recordablesMap_
Mapping of recordables names to access functions.
Definition iaf_psc_exp_ps_lossless.h:455
IAFPropagatorExp propagator_in_
Definition iaf_psc_exp_ps_lossless.h:272
friend class UniversalDataLogger< iaf_psc_exp_ps_lossless >
Definition iaf_psc_exp_ps_lossless.h:223
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition iaf_psc_exp_ps_lossless.cpp:272
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:282
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:271
const std::string recordables("recordables")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_iaf_psc_exp_ps_lossless(const std::string &name)
Definition iaf_psc_exp_ps_lossless.cpp:48
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121
Buffers of the model.
Definition iaf_psc_exp_ps_lossless.h:349
Buffers_(iaf_psc_exp_ps_lossless &)
Definition iaf_psc_exp_ps_lossless.cpp:95
SliceRingBuffer events_
Queue for incoming events.
Definition iaf_psc_exp_ps_lossless.h:357
RingBuffer currents_
Definition iaf_psc_exp_ps_lossless.h:358
UniversalDataLogger< iaf_psc_exp_ps_lossless > logger_
Logger for all analog data.
Definition iaf_psc_exp_ps_lossless.h:361
Independent parameters of the model.
Definition iaf_psc_exp_ps_lossless.h:280
double U_min_
Lower bound, RELATIVE TO RESTING POTENTIAL(!).
Definition iaf_psc_exp_ps_lossless.h:308
double t_ref_
Refractory period in ms.
Definition iaf_psc_exp_ps_lossless.h:294
double tau_in_
Time constant of inh.
Definition iaf_psc_exp_ps_lossless.h:288
double U_reset_
Reset potential.
Definition iaf_psc_exp_ps_lossless.h:313
void get(Dictionary &) const
Store current values in dictionary.
Definition iaf_psc_exp_ps_lossless.cpp:109
Parameters_()
Sets default parameter values.
Definition iaf_psc_exp_ps_lossless.cpp:70
double set(const Dictionary &, Node *node)
Set values from dictionary.
Definition iaf_psc_exp_ps_lossless.cpp:124
double c_m_
Membrane capacitance in pF.
Definition iaf_psc_exp_ps_lossless.h:291
double U_th_
Threshold, RELATIVE TO RESTING POTENTIAL(!).
Definition iaf_psc_exp_ps_lossless.h:304
double tau_ex_
Time constant of exc.
Definition iaf_psc_exp_ps_lossless.h:285
double tau_m_
Membrane time constant in ms.
Definition iaf_psc_exp_ps_lossless.h:282
double E_L_
Resting potential in mV.
Definition iaf_psc_exp_ps_lossless.h:297
double I_e_
External DC current [pA].
Definition iaf_psc_exp_ps_lossless.h:300
State variables of the model.
Definition iaf_psc_exp_ps_lossless.h:327
void set(const Dictionary &, const Parameters_ &, double delta_EL, Node *)
Definition iaf_psc_exp_ps_lossless.cpp:222
double last_spike_offset_
Offset of most recent spike.
Definition iaf_psc_exp_ps_lossless.h:335
void get(Dictionary &, const Parameters_ &) const
Definition iaf_psc_exp_ps_lossless.cpp:210
bool is_refractory_
True while refractory.
Definition iaf_psc_exp_ps_lossless.h:333
double y2_
Membrane potential (relative to resting potential).
Definition iaf_psc_exp_ps_lossless.h:331
double y0_
External input current.
Definition iaf_psc_exp_ps_lossless.h:328
double I_syn_in_
Inh. exponential current.
Definition iaf_psc_exp_ps_lossless.h:330
long last_spike_step_
Time stamp of most recent spike.
Definition iaf_psc_exp_ps_lossless.h:334
State_()
Default initialization.
Definition iaf_psc_exp_ps_lossless.cpp:84
double I_syn_ex_
Exc. exponential current.
Definition iaf_psc_exp_ps_lossless.h:329
Internal variables of the model.
Definition iaf_psc_exp_ps_lossless.h:370
double y2_before_
y2_ at beginning of ministep
Definition iaf_psc_exp_ps_lossless.h:382
double exp_tau_in_
exp(-h/tau_in)
Definition iaf_psc_exp_ps_lossless.h:375
double y0_before_
y0_ at beginning of ministep
Definition iaf_psc_exp_ps_lossless.h:379
double b3_
Definition iaf_psc_exp_ps_lossless.h:400
double c4_
Definition iaf_psc_exp_ps_lossless.h:411
double I_syn_in_before_
Isyn_in at beginning of ministep.
Definition iaf_psc_exp_ps_lossless.h:381
double a1_
Pre-computed constants for inequality V < g(h, I_e).
Definition iaf_psc_exp_ps_lossless.h:388
double b4_
Definition iaf_psc_exp_ps_lossless.h:401
double c1_
Pre-computed constants for inequality V < b(I_e).
Definition iaf_psc_exp_ps_lossless.h:408
double P21_in_
Progagator matrix element, 2nd row.
Definition iaf_psc_exp_ps_lossless.h:377
double exp_tau_ex_
exp(-h/tau_ex)
Definition iaf_psc_exp_ps_lossless.h:374
double a3_
Definition iaf_psc_exp_ps_lossless.h:390
double b2_
Definition iaf_psc_exp_ps_lossless.h:399
double P21_ex_
Progagator matrix element, 2nd row.
Definition iaf_psc_exp_ps_lossless.h:378
double c5_
Definition iaf_psc_exp_ps_lossless.h:412
long refractory_steps_
Refractory time in steps.
Definition iaf_psc_exp_ps_lossless.h:372
double P20_
Progagator matrix element, 2nd row.
Definition iaf_psc_exp_ps_lossless.h:376
double h_ms_
Time resolution [ms].
Definition iaf_psc_exp_ps_lossless.h:371
double a2_
Definition iaf_psc_exp_ps_lossless.h:389
double a4_
Definition iaf_psc_exp_ps_lossless.h:391
double b1_
Pre-computed constants for inequality V < f(h, I).
Definition iaf_psc_exp_ps_lossless.h:398
double c3_
Definition iaf_psc_exp_ps_lossless.h:410
double expm1_tau_m_
expm1(-h/tau_m)
Definition iaf_psc_exp_ps_lossless.h:373
double c2_
Definition iaf_psc_exp_ps_lossless.h:409
double I_syn_ex_before_
Isyn_ex at beginning of ministep.
Definition iaf_psc_exp_ps_lossless.h:380
double c6_
Definition iaf_psc_exp_ps_lossless.h:413