NEST main@caf0ae8
 
Loading...
Searching...
No Matches
gif_pop_psc_exp.h
Go to the documentation of this file.
1/*
2 * gif_pop_psc_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 PP_POP_PSC_BETA_H
24#define PP_POP_PSC_BETA_H
25
26
27// Includes from nestkernel:
28#include "nest.h"
29#include "node.h"
30#include "random_generators.h"
31#include "ring_buffer.h"
33
34#ifdef HAVE_GSL
35
36namespace nest
37{
38
39class Network;
40
41/* BeginUserDocs: neuron, integrate-and-fire, current-based, adaptation, stochastic
42
43Short description
44+++++++++++++++++
45
46Population of generalized integrate-and-fire neurons (GIF) with exponential
47postsynaptic currents and adaptation (from the Gerstner lab)
48
49
50Description
51+++++++++++
52
53This model simulates a population of spike-response model neurons with
54multi-timescale adaptation and exponential postsynaptic currents, as
55described by Schwalger et al. (2017) :footcite:p:`Schwalger2017`.
56
57The single neuron model is defined by the hazard function
58
59.. math::
60
61 h(t) = \lambda_0 \exp\frac{V_m(t) - E_{\text{sfa}}(t)}{\Delta_V}
62
63After each spike, the membrane potential :math:`V_m` is reset to
64:math:`V_{\text{reset}}`. Spike frequency
65adaptation is implemented by a set of exponentially decaying traces, the
66sum of which is :math:`E_{\text{sfa}}`. Upon a spike, each of the adaptation traces is
67incremented by the respective :math:`q_{\text{sfa}}` and decays with the respective time constant
68:math:`\tau_{\text{sfa}}`.
69
70The corresponding single neuron model is available in NEST as ``gif_psc_exp``.
71The default parameters, although some are named slightly different, are not
72matched in both models for historical reasons. See below for the parameter
73translation.
74
75Connecting two population models corresponds to full connectivity of every
76neuron in each population. An approximation of random connectivity can be
77implemented by connecting populations using a ``bernoulli_synapse``.
78
79
80Parameters
81++++++++++
82
83The following parameters can be set in the status Dictionary.
84
85
86=========== ============= =====================================================
87 V_reset mV Membrane potential is reset to this value after
88 a spike
89 V_T_star mV Threshold level of the membrane potential
90 E_L mV Resting potential
91 Delta_V mV Noise level of escape rate
92 C_m pF Capacitance of the membrane
93 tau_m ms Membrane time constant
94 t_ref ms Duration of refractory period
95 I_e pA Constant input current
96 N integer Number of neurons in the population
97 len_kernel integer Refractory effects are accounted for up to len_kernel
98 time steps
99 lambda_0 1/s Firing rate at threshold
100 tau_syn_ex ms Time constant for excitatory synaptic currents
101 tau_syn_in ms Time constant for inhibitory synaptic currents
102 tau_sfa list of ms vector Adaptation time constants
103 q_sfa list of ms Adaptation kernel amplitudes
104 BinoRand boolean If True, binomial random numbers are used, otherwise
105 we use Poisson distributed spike counts
106=========== ============= =====================================================
107
108
109=============== ============ =============================
110**Parameter translation to gif_psc_exp**
111-----------------------------------------------------------
112gif_pop_psc_exp gif_psc_exp relation
113tau_m g_L tau_m = C_m / g_L
114N --- use N gif_psc_exp neurons
115=============== ============ =============================
116
117
118References
119++++++++++
120
121.. footbibliography::
122
123Sends
124+++++
125
126SpikeEvent
127
128Receives
129++++++++
130
131SpikeEvent, CurrentEvent, DataLoggingRequest
132
133See also
134++++++++
135
136gif_psc_exp, bernoulli_synapse
137
138Examples using this model
139+++++++++++++++++++++++++
140
141.. listexamples:: gif_pop_psc_exp
142
143EndUserDocs */
144
145
159void register_gif_pop_psc_exp( const std::string& name );
160
161class gif_pop_psc_exp : public Node
162{
163
164public:
165 gif_pop_psc_exp();
166 gif_pop_psc_exp( const gif_pop_psc_exp& );
167
173 using Node::handle;
174 using Node::handles_test_event;
175
176 size_t send_test_event( Node&, size_t, synindex, bool ) override;
177
178 void handle( SpikeEvent& ) override;
179 void handle( CurrentEvent& ) override;
180 void handle( DataLoggingRequest& ) override;
181
182 size_t handles_test_event( SpikeEvent&, size_t ) override;
183 size_t handles_test_event( CurrentEvent&, size_t ) override;
184 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
185
186 void get_status( Dictionary& ) const override;
187 void set_status( const Dictionary& ) override;
188
189private:
190 void init_buffers_() override;
191 void pre_run_hook() override;
192
193 void update( Time const&, const long, const long ) override;
194
195 double escrate( const double );
196 long draw_poisson( const double n_expect_ );
197 long draw_binomial( const double n_expect_ );
198 double adaptation_kernel( const int k );
199 int get_history_size();
200
201 // The next two classes need to be friends to access the State_ class/member
202 friend class RecordablesMap< gif_pop_psc_exp >;
203 friend class UniversalDataLogger< gif_pop_psc_exp >;
204
205 // ----------------------------------------------------------------
206
210 struct Parameters_
211 {
213 long N_;
214
216 double tau_m_;
217
219 double c_m_;
220
222 double t_ref_;
223
225 double lambda_0_;
226
228 double Delta_V_;
229
231 long len_kernel_;
232
234 double I_e_;
235
237 double V_reset_;
238
240 double V_T_star_;
241
243 double E_L_;
244
246 double tau_syn_ex_;
247 double tau_syn_in_;
248
250 std::vector< double > tau_sfa_;
251
253 std::vector< double > q_sfa_;
254
256 bool BinoRand_;
257
258 Parameters_();
259 void get( Dictionary& ) const;
260 void set( const Dictionary&, Node* node );
261 };
262
263 // ----------------------------------------------------------------
264
268 struct State_
269 {
270 double y0_; // DC input current
271 double I_syn_ex_; // synaptic current
272 double I_syn_in_; // synaptic current
273 double V_m_; // membrane potential
274 double n_expect_; // expected spike number
275 double theta_hat_; // adapting threshold for non-refractory neurons
276 long n_spikes_; // number of spikes
277
278 // internal switch signaling that state vectors are initialized
279 bool initialized_;
280
281 State_();
282
283 void get( Dictionary&, const Parameters_& ) const;
284 void set( const Dictionary&, const Parameters_&, Node* );
285 };
286
287 // ----------------------------------------------------------------
288
292 struct Buffers_
293 {
294 Buffers_( gif_pop_psc_exp& );
295 Buffers_( const Buffers_&, gif_pop_psc_exp& );
296
298 RingBuffer ex_spikes_;
299 RingBuffer in_spikes_;
300 RingBuffer currents_;
301
303 UniversalDataLogger< gif_pop_psc_exp > logger_;
304 };
305
306 // ----------------------------------------------------------------
307
311 struct Variables_
312 {
313
314 double R_; // membrane resistance
315 double P20_; // membrane integration constant
316 double P22_; // membrane integration constant
317 double P11_ex_; // synaptic integration constant
318 double P11_in_; // synaptic integration constant
319 int k_ref_; // length of refractory period in time steps
320
321 std::vector< double > Q30_; // QR adaptation integration constant
322 std::vector< double > Q30K_; // QR adaptation integration constant
323 std::vector< double > theta_; // adaptation kernel
324 std::vector< double > theta_tld_; // QR adaptation kernel
325
326 double h_; // simulation time step in ms
327 double min_double_;
328
329 RngPtr rng_; // random number generator of own thread
330
331 poisson_distribution poisson_dist_;
332 binomial_distribution bino_dist_;
333
334 double x_; // internal variable of population dynamics
335 double z_; // internal variable of population dynamics
336 double lambda_free_; // hazard rate for non-refractory neurons
337 std::vector< double > m_; // survival buffer
338 std::vector< double > n_; // population activity buffer
339 std::vector< double > u_; // mean of survivals
340 std::vector< double > v_; // variance of survivals
341 std::vector< double > lambda_; // escape rates buffer
342 std::vector< double > g_; // adaptation variables
343
344 int k0_; // rotating index of history buffers
345 };
346
347 // Access functions for UniversalDataLogger -----------------------
348
350 double
351 get_V_m_() const
352 {
353 return S_.V_m_;
354 }
355
357 double
358 get_n_events_() const
359 {
360 return S_.n_spikes_;
361 }
362
364 double
365 get_E_sfa_() const
366 {
367 return S_.theta_hat_;
368 }
369
371 double
372 get_mean_() const
373 {
374 return S_.n_expect_;
375 }
376
378 double
379 get_I_syn_ex_() const
380 {
381 return S_.I_syn_ex_;
382 }
383 double
384 get_I_syn_in_() const
385 {
386 return S_.I_syn_in_;
387 }
388
389
390 // ----------------------------------------------------------------
391
398 Parameters_ P_;
399 State_ S_;
400 Variables_ V_;
401 Buffers_ B_;
405 static RecordablesMap< gif_pop_psc_exp > recordablesMap_;
406};
407
408inline size_t
409gif_pop_psc_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
410{
411 SpikeEvent e;
412 e.set_sender( *this );
413
414 return target.handles_test_event( e, receptor_type );
415}
416
417inline size_t
418gif_pop_psc_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
419{
420 if ( receptor_type != 0 )
421 {
422 throw UnknownReceptorType( receptor_type, get_name() );
423 }
424 return 0;
425}
426
427inline size_t
428gif_pop_psc_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
429{
430 if ( receptor_type != 0 )
431 {
432 throw UnknownReceptorType( receptor_type, get_name() );
433 }
434 return 0;
435}
436
437inline size_t
438gif_pop_psc_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
439{
440 if ( receptor_type != 0 )
441 {
442 throw UnknownReceptorType( receptor_type, get_name() );
443 }
444 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
445}
446
447inline void
448gif_pop_psc_exp::get_status( Dictionary& d ) const
449{
450 P_.get( d );
451 S_.get( d, P_ );
452 // MoD: In models derived from ArchivingNode, here get_status of the
453 // parent class is called. Since this model derives from Node, and
454 // not from ArchivingNode, this call has been disabled here
455 // (Node does not have a comparable method).
456 // ArchivingNode::get_status(d);
457 d[ names::recordables ] = recordablesMap_.get_list();
458}
459
460inline void
461gif_pop_psc_exp::set_status( const Dictionary& d )
462{
463 Parameters_ ptmp = P_; // temporary copy in case of errors
464 ptmp.set( d, this ); // throws if BadProperty
465 State_ stmp = S_; // temporary copy in case of errors
466 stmp.set( d, ptmp, this ); // throws if BadProperty
467
468 // We now know that (ptmp, stmp) are consistent. We do not
469 // write them back to (P_, S_) before we are also sure that
470 // the properties to be set in the parent class are internally
471 // consistent.
472
473 // MoD: In models derived from ArchivingNode, here set_status of the
474 // parent class is called. Since this model derives from Node, and
475 // not from ArchivingNode, this call has been disabled here
476 // (Node does not have a comparable method).
477 // ArchivingNode::set_status(d);
478
479 // if we get here, temporaries contain consistent set of properties
480 P_ = ptmp;
481 S_ = stmp;
482}
483
484} // namespace
485
486
487#endif /* HAVE_GSL */
488#endif /* #ifndef PP_POP_PSC_BETA_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
const std::string recordables("recordables")
const std::string d("d")
const std::string target("target")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
RandomDistribution< std::poisson_distribution< unsigned long > > poisson_distribution
Definition random_generators.h:60
RandomDistribution< std::binomial_distribution< unsigned long > > binomial_distribution
Definition random_generators.h:56
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
Declarations for base class Node.