NEST main@caf0ae8
 
Loading...
Searching...
No Matches
gif_cond_exp.h
Go to the documentation of this file.
1/*
2 * gif_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 GIF_COND_EXP_H
24#define GIF_COND_EXP_H
25
26#include "config.h"
27
28#ifdef HAVE_GSL
29
30// Includes from gnu gsl:
31#include <gsl/gsl_errno.h>
32#include <gsl/gsl_matrix.h>
33#include <gsl/gsl_odeiv.h>
34
35// Includes from nestkernel:
36#include "archiving_node.h"
37#include "connection.h"
38#include "event.h"
39#include "ring_buffer.h"
40
42
43#include "nest.h"
44
45
46namespace nest
47{
48
49extern "C" int gif_cond_exp_dynamics( double, const double*, double*, void* );
50
51/* BeginUserDocs: neuron, integrate-and-fire, conductance-based, adaptation, stochastic
52
53Short description
54+++++++++++++++++
55
56Conductance-based generalized integrate-and-fire neuron (GIF) model (from the Gerstner lab)
57
58Description
59+++++++++++
60
61``gif_psc_exp`` is the generalized integrate-and-fire neuron according to
62Mensi et al. (2012) :footcite:p:`Mensi2012` and Pozzorini et al. (2015) :footcite:p:`Pozzorini2015`, with postsynaptic
63conductances in the form of truncated exponentials.
64
65This model features both an adaptation current and a dynamic threshold for
66spike-frequency adaptation. The membrane potential (V) is described by the
67differential equation:
68
69.. math::
70
71 C*dV(t)/dt = -g_L\cdot(V(t)-E_L) - \eta_1(t) - \eta_2(t) - \ldots
72 - \eta_n(t) + I(t)
73
74where each :math:`\eta_i` is a spike-triggered current (stc), and the neuron
75model can have arbitrary number of them.
76Dynamic of each :math:`\eta_i` is described by:
77
78.. math::
79
80 \tau_\eta{_i}\cdot d{\eta_i}/dt = -\eta_i
81
82and in case of spike emission, its value increased by a constant (which can be
83positive or negative):
84
85.. math::
86
87 \eta_i = \eta_i + q_{\eta_i} \text{ (in case of spike emission).}
88
89Neuron produces spikes stochastically according to a point process with the
90firing intensity:
91
92.. math::
93
94 \lambda(t) = \lambda_0 \cdot \exp (V(t)-V_T(t)) / \Delta_V
95
96where :math:`V_T(t)` is a time-dependent firing threshold:
97
98.. math::
99
100 V_T(t) = V_{T_{star}} + \gamma_1(t) + \gamma_2(t) + \ldots + \gamma_m(t)
101
102where :math:`\gamma_i` is a kernel of spike-frequency adaptation (sfa), and the
103neuron model can have arbitrary number of them.
104Dynamic of each :math:`\gamma_i` is described by:
105
106.. math::
107
108 \tau_{\gamma_i} \cdot d\gamma_i/dt = -\gamma_i
109
110and in case of spike emission, its value increased by a constant (which can be
111positive or negative):
112
113.. math::
114
115 \gamma_i = \gamma_i + q_{\gamma_i} \text{ (in case of spike emission).}
116
117
118Note:
119
120In the current implementation of the model, the values of
121:math:`\eta_i` and :math:`\gamma_i` are affected
122immediately after spike emission. However, `GIF toolbox <http://wiki.epfl.ch/giftoolbox>`_,
123which fits the model using experimental data, requires a different set of
124:math:`\eta_i` and :math:`\gamma_i`. It applies the jump of
125:math:`\eta_i` and :math:`\gamma_i` after the refractory period. One can
126easily convert between :math:`q_\eta/\gamma` of these two approaches:
127
128.. math::
129
130 q{_\eta}_{giftoolbox} = q_{\eta_{NEST}} \cdot (1 - \exp( -\tau_{ref} /
131 \tau_\eta ))
132
133The same formula applies for :math:`q_{\gamma}`.
134
135The shape of synaptic conductance is exponential.
136
137Parameters
138++++++++++
139
140The following parameters can be set in the status Dictionary.
141
142
143======== ======= =======================================
144**Membrane Parameters**
145--------------------------------------------------------
146 C_m pF Capacity of the membrane
147 t_ref ms Duration of refractory period
148 V_reset mV Reset value for V_m after a spike
149 E_L mV Leak reversal potential
150 g_L nS Leak conductance
151 I_e pA Constant external input current
152======== ======= =======================================
153
154========= ================= ===============================================
155**Spike adaptation and firing intensity parameters**
156-----------------------------------------------------------------------------
157 q_stc list of nA Values added to spike-triggered currents (stc)
158 after each spike emission
159 tau_stc list of ms Time constants of stc variables
160 q_sfa list of mV Values added to spike-frequency adaptation
161 (sfa) after each spike emission
162 tau_sfa list of ms Time constants of sfa variables
163 Delta_V mV Stochasticity level
164 lambda_0 real Stochastic intensity at firing threshold V_T i
165 n 1/s.
166 V_T_star mV Base threshold
167========= ================= ===============================================
168
169=========== ======= ===========================================================
170**Synaptic parameters**
171-------------------------------------------------------------------------------
172 E_ex mV Excitatory reversal potential
173 tau_syn_ex ms Decay time of excitatory synaptic conductance
174 E_in mV Inhibitory reversal potential
175 tau_syn_in ms Decay time of the inhibitory synaptic conductance
176=========== ======= ===========================================================
177
178============= ======= =========================================================
179**Integration parameters**
180-------------------------------------------------------------------------------
181gsl_error_tol real This parameter controls the admissible error of the
182 GSL integrator. Reduce it if NEST complains about
183 numerical instabilities.
184============= ======= =========================================================
185
186
187References
188++++++++++
189
190.. footbibliography::
191
192Sends
193+++++
194
195SpikeEvent
196
197Receives
198++++++++
199
200SpikeEvent, CurrentEvent, DataLoggingRequest
201
202See also
203++++++++
204
205pp_psc_delta, gif_cond_exp_multisynapse, gif_psc_exp, gif_psc_exp_multisynapse
206
207Examples using this model
208+++++++++++++++++++++++++
209
210.. listexamples:: gif_cond_exp
211
212EndUserDocs */
213
214void register_gif_cond_exp( const std::string& name );
215
216class gif_cond_exp : public ArchivingNode
217{
218
219public:
220 gif_cond_exp();
221 gif_cond_exp( const gif_cond_exp& );
222 ~gif_cond_exp() override;
223
229 using Node::handle;
230 using Node::handles_test_event;
231
232 size_t send_test_event( Node&, size_t, synindex, bool ) override;
233
234 void handle( SpikeEvent& ) override;
235 void handle( CurrentEvent& ) override;
236 void handle( DataLoggingRequest& ) override;
237
238 size_t handles_test_event( SpikeEvent&, size_t ) override;
239 size_t handles_test_event( CurrentEvent&, size_t ) override;
240 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
241
242
243 void get_status( Dictionary& ) const override;
244 void set_status( const Dictionary& ) override;
245
246private:
247 void init_buffers_() override;
248 void pre_run_hook() override;
249
250 void update( Time const&, const long, const long ) override;
251
252 // make dynamics function quasi-member
253 friend int gif_cond_exp_dynamics( double, const double*, double*, void* );
254
255 // The next two classes need to be friends to access the State_ class/member
256 friend class RecordablesMap< gif_cond_exp >;
257 friend class UniversalDataLogger< gif_cond_exp >;
258
259 // ----------------------------------------------------------------
260
264 struct Parameters_
265 {
266 double g_L_;
267 double E_L_;
268 double V_reset_;
269 double Delta_V_;
270 double V_T_star_;
271 double lambda_0_;
273 double E_ex_;
274 double E_in_;
275 double tau_synE_;
276 double tau_synI_;
279 double t_ref_;
280
282 double c_m_;
283
288 std::vector< double > tau_stc_;
289
291 std::vector< double > q_stc_;
292
294 std::vector< double > tau_sfa_;
295
297 std::vector< double > q_sfa_;
298
300 double I_e_;
301
302 double gsl_error_tol;
303
304 Parameters_();
305
306 void get( Dictionary& ) const;
307 void set( const Dictionary&, Node* node );
308 };
309
310 // ----------------------------------------------------------------
311
315 struct State_
316 {
318 enum StateVecElems
319 {
320 V_M = 0,
321 G_EXC,
322 G_INH,
323 STATE_VEC_SIZE
324 };
325
327 double neuron_state_[ STATE_VEC_SIZE ];
328
329 double I_stim_;
330 double sfa_;
331 double stc_;
332
333 std::vector< double > sfa_elems_;
334 std::vector< double > stc_elems_;
335
337 unsigned int r_ref_;
338
339 State_( const Parameters_& );
340 State_( const State_& );
341
342 State_& operator=( const State_& );
343
344 void get( Dictionary&, const Parameters_& ) const;
345 void set( const Dictionary&, const Parameters_&, Node* );
346 };
347
348 // ----------------------------------------------------------------
349
353 struct Buffers_
354 {
355 Buffers_( gif_cond_exp& );
356 Buffers_( const Buffers_&, gif_cond_exp& );
357
359 RingBuffer spike_exc_;
360 RingBuffer spike_inh_;
361 RingBuffer currents_;
362
364 UniversalDataLogger< gif_cond_exp > logger_;
365
367 gsl_odeiv_step* s_;
368 gsl_odeiv_control* c_;
369 gsl_odeiv_evolve* e_;
370 gsl_odeiv_system sys_;
371
372 // Since IntegrationStep_ is initialized with step_, and the resolution
373 // cannot change after nodes have been created, it is safe to place both
374 // here.
375 double step_;
376 double IntegrationStep_;
377 };
378
379 // ----------------------------------------------------------------
380
384 struct Variables_
385 {
386 std::vector< double > P_sfa_; // decay terms of spike-triggered current elements
387 std::vector< double > P_stc_; // decay terms of adaptive threshold elements
388
389 RngPtr rng_; // random number generator of my own thread
390
391 unsigned 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_.neuron_state_[ elem ];
402 }
403
405 double
406 get_E_sfa_() const
407 {
408 return S_.sfa_;
409 }
410
412 double
413 get_I_stc_() const
414 {
415 return S_.stc_;
416 }
417
418 // ----------------------------------------------------------------
419
426 Parameters_ P_;
427 State_ S_;
428 Variables_ V_;
429 Buffers_ B_;
433 static RecordablesMap< gif_cond_exp > recordablesMap_;
434};
435
436inline size_t
437gif_cond_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
438{
439 SpikeEvent e;
440 e.set_sender( *this );
441
442 return target.handles_test_event( e, receptor_type );
443}
444
445
446inline size_t
447gif_cond_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
448{
449 if ( receptor_type != 0 )
450 {
451 throw UnknownReceptorType( receptor_type, get_name() );
452 }
453 return 0;
454}
455
456inline size_t
457gif_cond_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
458{
459 if ( receptor_type != 0 )
460 {
461 throw UnknownReceptorType( receptor_type, get_name() );
462 }
463 return 0;
464}
465
466inline size_t
467gif_cond_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
468{
469 if ( receptor_type != 0 )
470 {
471 throw UnknownReceptorType( receptor_type, get_name() );
472 }
473 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
474}
475
476inline void
477gif_cond_exp::get_status( Dictionary& d ) const
478{
479 P_.get( d );
480 S_.get( d, P_ );
482 d[ names::recordables ] = recordablesMap_.get_list();
483}
484
485inline void
486gif_cond_exp::set_status( const Dictionary& d )
487{
488 Parameters_ ptmp = P_; // temporary copy in case of errors
489 ptmp.set( d, this ); // throws if BadProperty
490 State_ stmp = S_; // temporary copy in case of errors
491 stmp.set( d, ptmp, this ); // throws if BadProperty
492
493 // We now know that (ptmp, stmp) are consistent. We do not
494 // write them back to (P_, S_) before we are also sure that
495 // the properties to be set in the parent class are internally
496 // consistent.
498
499 // if we get here, temporaries contain consistent set of properties
500 P_ = ptmp;
501 S_ = stmp;
502}
503
504} // namespace
505
506#endif // HAVE_GSL
507#endif /* #ifndef GIF_COND_EXP_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 recordables("recordables")
const std::string d("d")
const std::string gsl_error_tol("gsl_error_tol")
const std::string target("target")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
BaseRandomGenerator * RngPtr
Definition random_generators.h:50
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
const double e
Definition numerics.cpp:32