NEST main@caf0ae8
 
Loading...
Searching...
No Matches
iaf_chxk_2008.h
Go to the documentation of this file.
1/*
2 * iaf_chxk_2008.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_CHXK_2008_H
24#define IAF_CHXK_2008_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{
47
48/* BeginUserDocs: neuron, integrate-and-fire, conductance-based, precise, hard threshold
49
50Short description
51+++++++++++++++++
52
53Conductance-based leaky integrate-and-fire neuron model supporting
54precise spike times used in Casti et al. 2008
55
56Description
57+++++++++++
58
59``iaf_chxk_2008`` is an implementation of a spiking neuron using IAF dynamics with
60conductance-based synapses :footcite:p:`Casti2008`. A spike is emitted when the membrane potential
61is crossed from below. After a spike, an afterhyperpolarizing (AHP) conductance
62is activated which repolarizes the neuron over time. Membrane potential is not
63reset explicitly and the model also has no explicit refractory time.
64
65The AHP conductance and excitatory and inhibitory synaptic input conductances
66follow alpha-function time courses as in the ``iaf_cond_alpha`` model.
67
68.. note::
69 In accordance with the original Fortran implementation of the model used
70 in :footcite:p:`Casti2008`, the activation time point for the AHP following a spike is
71 determined by linear interpolation within the time step during which the
72 threshold was crossed.
73
74 ``iaf_chxk_2008`` neurons therefore emit spikes with precise spike time
75 information, but they ignore precise spike times when handling synaptic
76 input.
77
78.. note::
79 In the original Fortran implementation underlying :footcite:p:`Casti2008`, all previous AHP
80 activation was discarded when a new spike occurred, leading to reduced AHP
81 currents in particular during periods of high spiking activity. Set
82 ``ahp_bug`` to ``true`` to obtain this behavior in the model.
83
84Parameters
85++++++++++
86
87The following parameters can be set in the status Dictionary.
88
89======== ======= ===========================================================
90 V_m mV Membrane potential
91 E_L mV Leak reversal potential
92 C_m pF Capacity of the membrane
93 V_th mV Spike threshold
94 E_ex mV Excitatory reversal potential
95 E_in mV Inhibitory reversal potential
96 g_L nS Leak conductance
97 tau_ex ms Rise time of the excitatory synaptic alpha function
98 tau_in ms Rise time of the inhibitory synaptic alpha function
99 I_e pA Constant input current
100 tau_ahp ms Afterhyperpolarization (AHP) time constant
101 E_ahp mV AHP potential
102 g_ahp nS AHP conductance
103 ahp_bug boolean Defaults to false. If true, behaves like original
104 model implementation
105======== ======= ===========================================================
106
107References
108++++++++++
109
110.. footbibliography::
111
112Sends
113+++++
114
115SpikeEvent
116
117Receives
118++++++++
119
120SpikeEvent, CurrentEvent
121
122See also
123++++++++
124
125iaf_cond_alpha
126
127Examples using this model
128+++++++++++++++++++++++++
129
130.. listexamples:: iaf_chxk_2008
131
132EndUserDocs */
133
144extern "C" int iaf_chxk_2008_dynamics( double, const double*, double*, void* );
145
146void register_iaf_chxk_2008( const std::string& name );
147
148class iaf_chxk_2008 : public ArchivingNode
149{
150
151 // Boilerplate function declarations --------------------------------
152
153public:
154 iaf_chxk_2008();
155 iaf_chxk_2008( const iaf_chxk_2008& );
156 ~iaf_chxk_2008() override;
157
163 using Node::handle;
164 using Node::handles_test_event;
165
166 size_t send_test_event( Node&, size_t, synindex, bool ) override;
167
168 bool
169 is_off_grid() const override
170 {
171 return true;
172 }
173
174 size_t handles_test_event( SpikeEvent&, size_t ) override;
175 size_t handles_test_event( CurrentEvent&, size_t ) override;
176 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
177
178 void handle( SpikeEvent& ) override;
179 void handle( CurrentEvent& ) override;
180 void handle( DataLoggingRequest& ) override;
181
182 void get_status( Dictionary& ) const override;
183 void set_status( const Dictionary& ) override;
184
185private:
186 void init_buffers_() override;
187 void pre_run_hook() override;
188 void update( Time const&, const long, const long ) override;
189
190 // END Boilerplate function declarations ----------------------------
191
192 // Friends --------------------------------------------------------
193
194 // make dynamics function quasi-member
195 friend int iaf_chxk_2008_dynamics( double, const double*, double*, void* );
196
197 // The next two classes need to be friends to access the State_ class/member
198 friend class RecordablesMap< iaf_chxk_2008 >;
199 friend class UniversalDataLogger< iaf_chxk_2008 >;
200
201private:
202 // Parameters class -------------------------------------------------
203
205 struct Parameters_
206 {
207 double V_th;
208 double g_L;
209 double C_m;
210 double E_ex;
211 double E_in;
212 double E_L;
213 double tau_synE;
214 double tau_synI;
215 double I_e;
216 double tau_ahp;
217 double g_ahp;
218 double E_ahp;
219 bool ahp_bug;
221
222 Parameters_();
223
224 void get( Dictionary& ) const;
225 void set( const Dictionary&, Node* node );
226 };
227
228 // State variables class --------------------------------------------
229
239public:
240 struct State_
241 {
243 enum StateVecElems
244 {
245 V_M = 0,
246 DG_EXC,
247 G_EXC,
248 DG_INH,
249 G_INH,
250 DG_AHP,
251 G_AHP,
252 STATE_VEC_SIZE
253 };
254
256 double y[ STATE_VEC_SIZE ];
257
259 int r;
260
261 State_( const Parameters_& );
262 State_( const State_& );
263
264 State_& operator=( const State_& );
265
266 void get( Dictionary& ) const;
267
272 void set( const Dictionary&, const Parameters_&, Node* );
273 };
274
275private:
276 // Buffers class --------------------------------------------------------
277
284 struct Buffers_
285 {
286 Buffers_( iaf_chxk_2008& );
287 Buffers_( const Buffers_&, iaf_chxk_2008& );
288
290 UniversalDataLogger< iaf_chxk_2008 > logger_;
291
293 RingBuffer spike_exc_;
294 RingBuffer spike_inh_;
295 RingBuffer currents_;
296
297 /* GSL ODE stuff */
298 gsl_odeiv_step* s_;
299 gsl_odeiv_control* c_;
300 gsl_odeiv_evolve* e_;
301 gsl_odeiv_system sys_;
302
303 // Since IntegrationStep_ is initialized with step_, and the resolution
304 // cannot change after nodes have been created, it is safe to place both
305 // here.
306 double step_;
307 double IntegrationStep_;
308
316 double I_stim_;
317 };
318
319 // Variables class -------------------------------------------------------
320
325 struct Variables_
326 {
331 double PSConInit_E;
332
337 double PSConInit_I;
338
343 double PSConInit_AHP;
344 };
345
346 // Access functions for UniversalDataLogger -------------------------------
347
349 template < State_::StateVecElems elem >
350 double
351 get_y_elem_() const
352 {
353 return S_.y[ elem ];
354 }
355
357 double
358 get_r_() const
359 {
360 return Time::get_resolution().get_ms() * S_.r;
361 }
362
363 double
364 get_I_syn_exc_() const
365 {
366 return S_.y[ State_::G_EXC ] * ( S_.y[ State_::V_M ] - P_.E_ex );
367 }
368 double
369 get_I_syn_inh_() const
370 {
371 return S_.y[ State_::G_INH ] * ( S_.y[ State_::V_M ] - P_.E_in );
372 }
373 double
374 get_I_ahp_() const
375 {
376 return S_.y[ State_::G_AHP ] * ( S_.y[ State_::V_M ] - P_.E_ahp );
377 }
378
379
380 // Data members -----------------------------------------------------------
381
382 // keep the order of these lines, seems to give best performance
383 Parameters_ P_;
384 State_ S_;
385 Variables_ V_;
386 Buffers_ B_;
387
389 static RecordablesMap< iaf_chxk_2008 > recordablesMap_;
390};
391
392
393// Boilerplate inline function definitions ----------------------------------
394
395inline size_t
396iaf_chxk_2008::send_test_event( Node& target, size_t receptor_type, synindex, bool )
397{
398 SpikeEvent e;
399 e.set_sender( *this );
400
401 return target.handles_test_event( e, receptor_type );
402}
403
404inline size_t
405iaf_chxk_2008::handles_test_event( SpikeEvent&, size_t receptor_type )
406{
407 if ( receptor_type != 0 )
408 {
409 throw UnknownReceptorType( receptor_type, get_name() );
410 }
411 return 0;
412}
413
414inline size_t
415iaf_chxk_2008::handles_test_event( CurrentEvent&, size_t receptor_type )
416{
417 if ( receptor_type != 0 )
418 {
419 throw UnknownReceptorType( receptor_type, get_name() );
420 }
421 return 0;
422}
423
424inline size_t
425iaf_chxk_2008::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
426{
427 if ( receptor_type != 0 )
428 {
429 throw UnknownReceptorType( receptor_type, get_name() );
430 }
431 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
432}
433
434inline void
435iaf_chxk_2008::get_status( Dictionary& d ) const
436{
437 P_.get( d );
438 S_.get( d );
440
441 d[ names::recordables ] = recordablesMap_.get_list();
442}
443
444inline void
445iaf_chxk_2008::set_status( const Dictionary& d )
446{
447 Parameters_ ptmp = P_; // temporary copy in case of errors
448 ptmp.set( d, this ); // throws if BadProperty
449 State_ stmp = S_; // temporary copy in case of errors
450 stmp.set( d, ptmp, this ); // throws if BadProperty
451
452 // We now know that (ptmp, stmp) are consistent. We do not
453 // write them back to (P_, S_) before we are also sure that
454 // the properties to be set in the parent class are internally
455 // consistent.
457
458 // if we get here, temporaries contain consistent set of properties
459 P_ = ptmp;
460 S_ = stmp;
461}
462
463} // namespace
464
465
466#endif // HAVE_GSL
467#endif // IAF_CHXK_2008_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 E_L("E_L")
const std::string ahp_bug("ahp_bug")
const std::string I_e("I_e")
const std::string recordables("recordables")
const std::string g_ahp("g_ahp")
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_ahp("E_ahp")
const std::string tau_ahp("tau_ahp")
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