NEST main@f146f75
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 <https://github.com/pozzorin/GIFFittingToolbox>`_,
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
137.. note::
138
139 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
140 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
141 the inhibitory one. Only the absolute value of the weight sets the conductance
142 amplitude. Spike connections must use the default ``receptor_type`` of 0.
143
144 See :ref:`synapse_selection` for the conventions used by other models.
145
146Parameters
147++++++++++
148
149The following parameters can be set in the status Dictionary.
150
151
152======== ======= =======================================
153**Membrane Parameters**
154--------------------------------------------------------
155 C_m pF Capacity of the membrane
156 t_ref ms Duration of refractory period
157 V_reset mV Reset value for V_m after a spike
158 E_L mV Leak reversal potential
159 g_L nS Leak conductance
160 I_e pA Constant external input current
161======== ======= =======================================
162
163========= ================= ===============================================
164**Spike adaptation and firing intensity parameters**
165-----------------------------------------------------------------------------
166 q_stc list of nA Values added to spike-triggered currents (stc)
167 after each spike emission
168 tau_stc list of ms Time constants of stc variables
169 q_sfa list of mV Values added to spike-frequency adaptation
170 (sfa) after each spike emission
171 tau_sfa list of ms Time constants of sfa variables
172 Delta_V mV Stochasticity level
173 lambda_0 real Stochastic intensity at firing threshold V_T i
174 n 1/s.
175 V_T_star mV Base threshold
176========= ================= ===============================================
177
178=========== ======= ===========================================================
179**Synaptic parameters**
180-------------------------------------------------------------------------------
181 E_ex mV Excitatory reversal potential
182 tau_syn_ex ms Decay time of excitatory synaptic conductance
183 E_in mV Inhibitory reversal potential
184 tau_syn_in ms Decay time of the inhibitory synaptic conductance
185=========== ======= ===========================================================
186
187============= ======= =========================================================
188**Integration parameters**
189-------------------------------------------------------------------------------
190gsl_error_tol real This parameter controls the admissible error of the
191 GSL integrator. Reduce it if NEST complains about
192 numerical instabilities.
193============= ======= =========================================================
194
195
196References
197++++++++++
198
199.. footbibliography::
200
201Sends
202+++++
203
204SpikeEvent
205
206Receives
207++++++++
208
209SpikeEvent, CurrentEvent, DataLoggingRequest
210
211See also
212++++++++
213
214pp_psc_delta, gif_cond_exp_multisynapse, gif_psc_exp, gif_psc_exp_multisynapse
215
216Examples using this model
217+++++++++++++++++++++++++
218
219.. listexamples:: gif_cond_exp
220
221EndUserDocs */
222
223void register_gif_cond_exp( const std::string& name );
224
225class gif_cond_exp : public ArchivingNode
226{
227
228public:
229 gif_cond_exp();
230 gif_cond_exp( const gif_cond_exp& );
231 ~gif_cond_exp() override;
232
238 using Node::handle;
239 using Node::handles_test_event;
240
241 size_t send_test_event( Node&, size_t, synindex, bool ) override;
242
243 void handle( SpikeEvent& ) override;
244 void handle( CurrentEvent& ) override;
245 void handle( DataLoggingRequest& ) override;
246
247 size_t handles_test_event( SpikeEvent&, size_t ) override;
248 size_t handles_test_event( CurrentEvent&, size_t ) override;
249 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
250
251
252 void get_status( Dictionary& ) const override;
253 void set_status( const Dictionary& ) override;
254
255private:
256 void init_buffers_() override;
257 void pre_run_hook() override;
258
259 void update( Time const&, const long, const long ) override;
260
261 // make dynamics function quasi-member
262 friend int gif_cond_exp_dynamics( double, const double*, double*, void* );
263
264 // The next two classes need to be friends to access the State_ class/member
265 friend class RecordablesMap< gif_cond_exp >;
266 friend class UniversalDataLogger< gif_cond_exp >;
267
268 // ----------------------------------------------------------------
269
273 struct Parameters_
274 {
275 double g_L_;
276 double E_L_;
277 double V_reset_;
278 double Delta_V_;
279 double V_T_star_;
280 double lambda_0_;
281
282 double E_ex_;
283 double E_in_;
284 double tau_synE_;
285 double tau_synI_;
286
288 double t_ref_;
289
291 double c_m_;
292
295
297 std::vector< double > tau_stc_;
298
300 std::vector< double > q_stc_;
301
303 std::vector< double > tau_sfa_;
304
306 std::vector< double > q_sfa_;
307
309 double I_e_;
310
311 double gsl_error_tol;
312
313 Parameters_();
314
315 void get( Dictionary& ) const;
316 void set( const Dictionary&, Node* node );
317 };
318
319 // ----------------------------------------------------------------
320
324 struct State_
325 {
327 enum StateVecElems
328 {
329 V_M = 0,
330 G_EXC,
331 G_INH,
332 STATE_VEC_SIZE
333 };
334
336 double neuron_state_[ STATE_VEC_SIZE ];
337
338 double I_stim_;
339 double sfa_;
340 double stc_;
341
342 std::vector< double > sfa_elems_;
343 std::vector< double > stc_elems_;
344
346 unsigned int r_ref_;
347
348 State_( const Parameters_& );
349 State_( const State_& );
350
351 State_& operator=( const State_& );
352
353 void get( Dictionary&, const Parameters_& ) const;
354 void set( const Dictionary&, const Parameters_&, Node* );
355 };
356
357 // ----------------------------------------------------------------
358
362 struct Buffers_
363 {
364 Buffers_( gif_cond_exp& );
365 Buffers_( const Buffers_&, gif_cond_exp& );
366
368 RingBuffer spike_exc_;
369 RingBuffer spike_inh_;
370 RingBuffer currents_;
371
373 UniversalDataLogger< gif_cond_exp > logger_;
374
376 gsl_odeiv_step* s_;
377 gsl_odeiv_control* c_;
378 gsl_odeiv_evolve* e_;
379 gsl_odeiv_system sys_;
380
381 // Since IntegrationStep_ is initialized with step_, and the resolution
382 // cannot change after nodes have been created, it is safe to place both
383 // here.
384 double step_;
385 double IntegrationStep_;
386 };
387
388 // ----------------------------------------------------------------
389
393 struct Variables_
394 {
395 std::vector< double > P_sfa_; // decay terms of spike-triggered current elements
396 std::vector< double > P_stc_; // decay terms of adaptive threshold elements
397
398 RngPtr rng_; // random number generator of my own thread
399
400 unsigned int RefractoryCounts_;
401 };
402
403 // Access functions for UniversalDataLogger -----------------------
404
406 template < State_::StateVecElems elem >
407 double
408 get_y_elem_() const
409 {
410 return S_.neuron_state_[ elem ];
411 }
412
414 double
415 get_E_sfa_() const
416 {
417 return S_.sfa_;
418 }
419
421 double
422 get_I_stc_() const
423 {
424 return S_.stc_;
425 }
426
427 // ----------------------------------------------------------------
428
435 Parameters_ P_;
436 State_ S_;
437 Variables_ V_;
438 Buffers_ B_;
440
442 static RecordablesMap< gif_cond_exp > recordablesMap_;
443};
444
445inline size_t
446gif_cond_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
447{
449 e.set_sender( *this );
450
451 return target.handles_test_event( e, receptor_type );
452}
453
454
455inline size_t
456gif_cond_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
457{
458 if ( receptor_type != 0 )
459 {
460 throw UnknownReceptorType( receptor_type, get_name() );
461 }
462 return 0;
463}
464
465inline size_t
466gif_cond_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
467{
468 if ( receptor_type != 0 )
469 {
470 throw UnknownReceptorType( receptor_type, get_name() );
471 }
472 return 0;
473}
474
475inline size_t
476gif_cond_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
477{
478 if ( receptor_type != 0 )
479 {
480 throw UnknownReceptorType( receptor_type, get_name() );
481 }
482 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
483}
484
485inline void
486gif_cond_exp::get_status( Dictionary& d ) const
487{
488 P_.get( d );
489 S_.get( d, P_ );
491 d[ names::recordables ] = recordablesMap_.get_list();
492}
493
494inline void
495gif_cond_exp::set_status( const Dictionary& d )
496{
497 Parameters_ ptmp = P_; // temporary copy in case of errors
498 ptmp.set( d, this ); // throws if BadProperty
499 State_ stmp = S_; // temporary copy in case of errors
500 stmp.set( d, ptmp, this ); // throws if BadProperty
501
502 // We now know that (ptmp, stmp) are consistent. We do not
503 // write them back to (P_, S_) before we are also sure that
504 // the properties to be set in the parent class are internally
505 // consistent.
507
508 // if we get here, temporaries contain consistent set of properties
509 P_ = ptmp;
510 S_ = stmp;
511}
512
513} // namespace
514
515#endif // HAVE_GSL
516#endif /* #ifndef GIF_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 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
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