NEST main@caf0ae8
 
Loading...
Searching...
No Matches
gif_cond_exp_multisynapse.h
Go to the documentation of this file.
1/*
2 * gif_cond_exp_multisynapse.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_MULTISYNAPSE_H
24#define GIF_COND_EXP_MULTISYNAPSE_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"
41
42#include "nest.h"
43
44namespace nest
45{
46
47extern "C" int gif_cond_exp_multisynapse_dynamics( double, const double*, double*, void* );
48
49/* BeginUserDocs: neuron, integrate-and-fire, conductance-based, adaptation, stochastic
50
51Short description
52+++++++++++++++++
53
54Conductance-based generalized integrate-and-fire neuron (GIF) with multiple synaptic time constants (from the Gerstner
55lab)
56
57Description
58+++++++++++
59
60``gif_cond_exp_multisynapse`` is the generalized integrate-and-fire neuron
61according to Mensi et al. (2012) :footcite:p:`Mensi2012` and Pozzorini et al. (2015) :footcite:p:`Pozzorini2015`, with
62postsynaptic conductances in the form of truncated exponentials.
63
64This model features both an adaptation current and a dynamic threshold for
65spike-frequency adaptation. The membrane potential (V) is described by the
66differential equation:
67
68.. math::
69
70 C \cdot dV(t)/dt = -g_L \cdot (V(t)-E_L) - \eta_1(t) - \eta_2(t) - \ldots - \eta_n(t) + I(t)
71
72where each :math:`\eta_i` is a spike-triggered current (stc), and the neuron
73model can have arbitrary number of them.
74Dynamic of each :math:`\eta_i` is described by:
75
76.. math::
77
78 \tau_{\eta_i} \cdot d{\eta_i}/dt = -\eta_i
79
80and in case of spike emission, its value increased by a constant (which can be
81positive or negative):
82
83.. math::
84
85 \eta_i = \eta_i + q_{\eta_i} \text{ (in case of spike emission).}
86
87Neuron produces spikes stochastically according to a point process with the
88firing intensity:
89
90.. math::
91
92 \lambda(t) = \lambda_0 \cdot \exp(V(t)-V_T(t)) / \Delta_V
93
94where :math:`V_T(t)` is a time-dependent firing threshold:
95
96.. math::
97
98 V_T(t) = V_{T_{star}} + \gamma_1(t) + \gamma_2(t) + \ldots + \gamma_m(t)
99
100where :math:`\gamma_i` is a kernel of spike-frequency adaptation (sfa), and the
101neuron model can have arbitrary number of them.
102Dynamic of each :math:`\gamma_i` is described by:
103
104.. math::
105
106 \tau_{\gamma_i} \cdot d\gamma_i/dt = -\gamma_i
107
108and in case of spike emission, its value increased by a constant (which can be
109positive or negative):
110
111.. math::
112
113 \gamma_i = \gamma_i + q_{\gamma_i} \text{ (in case of spike emission).}
114
115
116.. note::
117
118 In the current implementation of the model,
119 the values of :math:`\eta_i` and :math:`\gamma_i` are affected immediately
120 after spike emission. However, `GIF toolbox <http://wiki.epfl.ch/giftoolbox>`_,
121 which fits the model using experimental data, requires a different set of
122 :math:`\eta_i` and :math:`\gamma_i`. It applies the jump of :math:`\eta_i` and
123 :math:`\gamma_i` after the refractory period. One can easily convert between
124 :math:`q_{\eta/\gamma}` with these two approaches:
125
126 .. math::
127
128 q_{\eta,giftoolbox} = q_{\eta,NEST} \cdot (1 - \exp( -\tau_{ref} / \tau_\eta ))
129
130 The same formula applies for :math:`q_\gamma`.
131
132On the postsynaptic side, there can be arbitrarily many synaptic time
133constants (gif_psc_exp has exactly two: ``tau_syn_ex`` and
134``tau_syn_in``). This can be reached by specifying separate receptor
135ports, each for a different time constant. The port number has to
136match the respective ``receptor_type`` in the connectors. The shape of
137synaptic conductance is exponential.
138
139When connecting to conductance-based multisynapse models, all synaptic weights
140must be non-negative.
141
142Parameters
143++++++++++
144
145The following parameters can be set in the status Dictionary.
146
147========= ====== ======================================================
148**Membrane Parameters**
149---------------------------------------------------------------------------
150 C_m pF Capacity of the membrane
151 t_ref ms Duration of refractory period
152 V_reset mV Reset value for V_m after a spike
153 E_L mV Leak reversal potential
154 g_L nS Leak conductance
155 I_e pA Constant external input current
156========= ====== ======================================================
157
158========= ============== =====================================================
159**Spike adaptation and firing intensity parameters**
160-------------------------------------------------------------------------------
161 q_stc list of nA Values added to spike-triggered currents (stc)
162 after each spike emission
163 tau_stc list of ms Time constants of stc variables
164 q_sfa list of mV Values added to spike-frequency adaptation
165 (sfa) after each spike emission
166 tau_sfa list of ms Time constants of sfa variables
167 Delta_V mV Stochasticity level
168 lambda_0 real Stochastic intensity at firing threshold V_T i
169 n 1/s.
170 V_T_star mV Base threshold
171========= ============== =====================================================
172
173========= ============= ===================================================
174**Synaptic parameters**
175------------------------------------------------------------------------------
176 tau_syn list of ms Time constants of the synaptic conductance
177 (same size as E_rev)
178 E_rev list of mV Reversal potentials (same size as tau_syn)
179========= ============= ===================================================
180
181============== ====== ======================================================
182**Integration parameters**
183------------------------------------------------------------------------------
184 gsl_error_tol real This parameter controls the admissible error of the
185 GSL integrator. Reduce it if NEST complains about
186 numerical instabilities
187============== ====== ======================================================
188
189References
190++++++++++
191
192.. footbibliography::
193
194Sends
195+++++
196
197SpikeEvent
198
199Receives
200++++++++
201
202SpikeEvent, CurrentEvent, DataLoggingRequest
203
204See also
205++++++++
206
207pp_psc_delta, gif_cond_exp, iaf_psc_exp_multisynapse, gif_psc_exp_multisynapse
208
209Examples using this model
210+++++++++++++++++++++++++
211
212.. listexamples:: gif_cond_exp_multisynapse
213
214EndUserDocs */
215
216void register_gif_cond_exp_multisynapse( const std::string& name );
217
218class gif_cond_exp_multisynapse : public ArchivingNode
219{
220
221public:
222 gif_cond_exp_multisynapse();
223 gif_cond_exp_multisynapse( const gif_cond_exp_multisynapse& );
224 ~gif_cond_exp_multisynapse() override;
225
231 using Node::handle;
232 using Node::handles_test_event;
233
234 size_t send_test_event( Node&, size_t, synindex, bool ) override;
235
236 void handle( SpikeEvent& ) override;
237 void handle( CurrentEvent& ) override;
238 void handle( DataLoggingRequest& ) override;
239
240 size_t handles_test_event( SpikeEvent&, size_t ) override;
241 size_t handles_test_event( CurrentEvent&, size_t ) override;
242 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
243
244
245 void get_status( Dictionary& ) const override;
246 void set_status( const Dictionary& ) override;
247
248private:
249 void init_buffers_() override;
250 void pre_run_hook() override;
251
252 void update( Time const&, const long, const long ) override;
253
254 // make dynamics function quasi-member
255 friend int gif_cond_exp_multisynapse_dynamics( double, const double*, double*, void* );
256
257 // The next two classes need to be friends to access the State_ class/member
258 friend class RecordablesMap< gif_cond_exp_multisynapse >;
259 friend class UniversalDataLogger< gif_cond_exp_multisynapse >;
260
261 // ----------------------------------------------------------------
262
266 struct Parameters_
267 {
268 double g_L_;
269 double E_L_;
270 double V_reset_;
271 double Delta_V_;
272 double V_T_star_;
273 double lambda_0_;
276 double t_ref_;
277
279 double c_m_;
280
285 std::vector< double > tau_stc_;
286
288 std::vector< double > q_stc_;
289
291 std::vector< double > tau_sfa_;
292
294 std::vector< double > q_sfa_;
295
297 std::vector< double > tau_syn_;
298
299 std::vector< double > E_rev_;
300
302 double I_e_;
303
305 bool has_connections_;
306
307 double gsl_error_tol;
308
309 Parameters_();
310
311 void get( Dictionary& ) const;
312 void set( const Dictionary&, Node* node );
313
315 inline size_t
316 n_receptors() const
317 {
318 return E_rev_.size();
319 }
320 };
321
322 // ----------------------------------------------------------------
323
327 struct State_
328 {
330 enum StateVecElems
331 {
332 V_M = 0,
333 G,
334 STATE_VEC_SIZE
335 };
336
337 static const size_t NUMBER_OF_FIXED_STATES_ELEMENTS = 1;
338 static const size_t NUM_STATE_ELEMENTS_PER_RECEPTOR = 1;
339
340 std::vector< double > y_;
341
342 double I_stim_;
343 double sfa_;
344 double stc_;
345
346 std::vector< double > sfa_elems_;
347 std::vector< double > stc_elems_;
348
350 unsigned int r_ref_;
351
352 State_( const Parameters_& );
353
354 void get( Dictionary&, const Parameters_& ) const;
355 void set( const Dictionary&, const Parameters_&, Node* );
356
357 }; // State_
358
359 // ----------------------------------------------------------------
360
364 struct Buffers_
365 {
366 Buffers_( gif_cond_exp_multisynapse& );
367 Buffers_( const Buffers_&, gif_cond_exp_multisynapse& );
368
370 std::vector< RingBuffer > spikes_;
371 RingBuffer currents_;
372
374 UniversalDataLogger< gif_cond_exp_multisynapse > logger_;
375
377 gsl_odeiv_step* s_;
378 gsl_odeiv_control* c_;
379 gsl_odeiv_evolve* e_;
380 gsl_odeiv_system sys_;
381
382 // Since IntegrationStep_ is initialized with step_, and the resolution
383 // cannot change after nodes have been created, it is safe to place both
384 // here.
385 double step_;
386 double IntegrationStep_;
387 };
388
389 // ----------------------------------------------------------------
390
394 struct Variables_
395 {
396 std::vector< double > P_sfa_;
397 std::vector< double > P_stc_;
398 RngPtr rng_;
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_.y_[ 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_;
442 static RecordablesMap< gif_cond_exp_multisynapse > recordablesMap_;
443};
444
445inline size_t
446gif_cond_exp_multisynapse::send_test_event( Node& target, size_t receptor_type, synindex, bool )
447{
448 SpikeEvent e;
449 e.set_sender( *this );
450
451 return target.handles_test_event( e, receptor_type );
452}
453
454inline size_t
455gif_cond_exp_multisynapse::handles_test_event( SpikeEvent&, size_t receptor_type )
456{
457 if ( receptor_type <= 0 or receptor_type > P_.n_receptors() )
458 {
459 throw IncompatibleReceptorType( receptor_type, get_name(), "SpikeEvent" );
460 }
461
462 P_.has_connections_ = true;
463 return receptor_type;
464}
465
466inline size_t
467gif_cond_exp_multisynapse::handles_test_event( CurrentEvent&, size_t receptor_type )
468{
469 if ( receptor_type != 0 )
470 {
471 throw UnknownReceptorType( receptor_type, get_name() );
472 }
473 return 0;
474}
475
476inline size_t
477gif_cond_exp_multisynapse::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
478{
479 if ( receptor_type != 0 )
480 {
481 throw UnknownReceptorType( receptor_type, get_name() );
482 }
483 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
484}
485
486inline void
487gif_cond_exp_multisynapse::get_status( Dictionary& d ) const
488{
489 P_.get( d );
490 S_.get( d, P_ );
492 d[ names::recordables ] = recordablesMap_.get_list();
493}
494
495inline void
496gif_cond_exp_multisynapse::set_status( const Dictionary& d )
497{
498 Parameters_ ptmp = P_; // temporary copy in case of errors
499 ptmp.set( d, this ); // throws if BadProperty
500 State_ stmp = S_; // temporary copy in case of errors
501 stmp.set( d, ptmp, this ); // throws if BadProperty
502
503 // We now know that (ptmp, stmp) are consistent. We do not
504 // write them back to (P_, S_) before we are also sure that
505 // the properties to be set in the parent class are internally
506 // consistent.
508
509 // if we get here, temporaries contain consistent set of properties
510 P_ = ptmp;
511 S_ = stmp;
512}
513
514} // namespace
515
516#endif // HAVE_GSL
517#endif /* #ifndef GIF_COND_EXP_MULTISYNAPSE_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 receptor_type("receptor_type")
const std::string n_receptors("n_receptors")
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