NEST main@f146f75
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
80.. note::
81
82 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
83 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
84 the inhibitory one, and also sets the direction of the post-synaptic current.
85 Spike connections must use the default ``receptor_type`` of 0.
86
87 See :ref:`synapse_selection` for the conventions used by other models.
88
89Parameters
90++++++++++
91
92The following parameters can be set in the status Dictionary.
93
94
95=========== ============= =====================================================
96 V_reset mV Membrane potential is reset to this value after
97 a spike
98 V_T_star mV Threshold level of the membrane potential
99 E_L mV Resting potential
100 Delta_V mV Noise level of escape rate
101 C_m pF Capacitance of the membrane
102 tau_m ms Membrane time constant
103 t_ref ms Duration of refractory period
104 I_e pA Constant input current
105 N integer Number of neurons in the population
106 len_kernel integer Refractory effects are accounted for up to len_kernel
107 time steps
108 lambda_0 1/s Firing rate at threshold
109 tau_syn_ex ms Time constant for excitatory synaptic currents
110 tau_syn_in ms Time constant for inhibitory synaptic currents
111 tau_sfa list of ms vector Adaptation time constants
112 q_sfa list of ms Adaptation kernel amplitudes
113 BinoRand boolean If True, binomial random numbers are used, otherwise
114 we use Poisson distributed spike counts
115=========== ============= =====================================================
116
117
118=============== ============ =============================
119**Parameter translation to gif_psc_exp**
120-----------------------------------------------------------
121gif_pop_psc_exp gif_psc_exp relation
122tau_m g_L tau_m = C_m / g_L
123N --- use N gif_psc_exp neurons
124=============== ============ =============================
125
126
127References
128++++++++++
129
130.. footbibliography::
131
132Sends
133+++++
134
135SpikeEvent
136
137Receives
138++++++++
139
140SpikeEvent, CurrentEvent, DataLoggingRequest
141
142See also
143++++++++
144
145gif_psc_exp, bernoulli_synapse
146
147Examples using this model
148+++++++++++++++++++++++++
149
150.. listexamples:: gif_pop_psc_exp
151
152EndUserDocs */
153
154
168void register_gif_pop_psc_exp( const std::string& name );
169
170class gif_pop_psc_exp : public Node
171{
172
173public:
174 gif_pop_psc_exp();
175 gif_pop_psc_exp( const gif_pop_psc_exp& );
176
182 using Node::handle;
183 using Node::handles_test_event;
184
185 size_t send_test_event( Node&, size_t, synindex, bool ) override;
186
187 void handle( SpikeEvent& ) override;
188 void handle( CurrentEvent& ) override;
189 void handle( DataLoggingRequest& ) override;
190
191 size_t handles_test_event( SpikeEvent&, size_t ) override;
192 size_t handles_test_event( CurrentEvent&, size_t ) override;
193 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
194
195 void get_status( Dictionary& ) const override;
196 void set_status( const Dictionary& ) override;
197
198private:
199 void init_buffers_() override;
200 void pre_run_hook() override;
201
202 void update( Time const&, const long, const long ) override;
203
204 double escrate( const double );
205 long draw_poisson( const double n_expect_ );
206 long draw_binomial( const double n_expect_ );
207 double adaptation_kernel( const int k );
208 int get_history_size();
209
210 // The next two classes need to be friends to access the State_ class/member
211 friend class RecordablesMap< gif_pop_psc_exp >;
212 friend class UniversalDataLogger< gif_pop_psc_exp >;
213
214 // ----------------------------------------------------------------
215
219 struct Parameters_
220 {
222 long N_;
223
225 double tau_m_;
226
228 double c_m_;
229
231 double t_ref_;
232
234 double lambda_0_;
235
237 double Delta_V_;
238
240 long len_kernel_;
241
243 double I_e_;
244
246 double V_reset_;
247
249 double V_T_star_;
250
252 double E_L_;
253
255 double tau_syn_ex_;
256 double tau_syn_in_;
257
259 std::vector< double > tau_sfa_;
260
262 std::vector< double > q_sfa_;
263
265 bool BinoRand_;
266
267 Parameters_();
268 void get( Dictionary& ) const;
269 void set( const Dictionary&, Node* node );
270 };
271
272 // ----------------------------------------------------------------
273
277 struct State_
278 {
279 double y0_; // DC input current
280 double I_syn_ex_; // synaptic current
281 double I_syn_in_; // synaptic current
282 double V_m_; // membrane potential
283 double n_expect_; // expected spike number
284 double theta_hat_; // adapting threshold for non-refractory neurons
285 long n_spikes_; // number of spikes
286
287 // internal switch signaling that state vectors are initialized
288 bool initialized_;
289
290 State_();
291
292 void get( Dictionary&, const Parameters_& ) const;
293 void set( const Dictionary&, const Parameters_&, Node* );
294 };
295
296 // ----------------------------------------------------------------
297
301 struct Buffers_
302 {
303 Buffers_( gif_pop_psc_exp& );
304 Buffers_( const Buffers_&, gif_pop_psc_exp& );
305
307 RingBuffer ex_spikes_;
308 RingBuffer in_spikes_;
309 RingBuffer currents_;
310
312 UniversalDataLogger< gif_pop_psc_exp > logger_;
313 };
314
315 // ----------------------------------------------------------------
316
320 struct Variables_
321 {
322
323 double R_; // membrane resistance
324 double P20_; // membrane integration constant
325 double P22_; // membrane integration constant
326 double P11_ex_; // synaptic integration constant
327 double P11_in_; // synaptic integration constant
328 int k_ref_; // length of refractory period in time steps
329
330 std::vector< double > Q30_; // QR adaptation integration constant
331 std::vector< double > Q30K_; // QR adaptation integration constant
332 std::vector< double > theta_; // adaptation kernel
333 std::vector< double > theta_tld_; // QR adaptation kernel
334
335 double h_; // simulation time step in ms
336 double min_double_;
337
338 RngPtr rng_; // random number generator of own thread
339
340 poisson_distribution poisson_dist_;
341 binomial_distribution bino_dist_;
342
343 double x_; // internal variable of population dynamics
344 double z_; // internal variable of population dynamics
345 double lambda_free_; // hazard rate for non-refractory neurons
346 std::vector< double > m_; // survival buffer
347 std::vector< double > n_; // population activity buffer
348 std::vector< double > u_; // mean of survivals
349 std::vector< double > v_; // variance of survivals
350 std::vector< double > lambda_; // escape rates buffer
351 std::vector< double > g_; // adaptation variables
352
353 int k0_; // rotating index of history buffers
354 };
355
356 // Access functions for UniversalDataLogger -----------------------
357
359 double
360 get_V_m_() const
361 {
362 return S_.V_m_;
363 }
364
366 double
367 get_n_events_() const
368 {
369 return S_.n_spikes_;
370 }
371
373 double
374 get_E_sfa_() const
375 {
376 return S_.theta_hat_;
377 }
378
380 double
381 get_mean_() const
382 {
383 return S_.n_expect_;
384 }
385
387 double
388 get_I_syn_ex_() const
389 {
390 return S_.I_syn_ex_;
391 }
392 double
393 get_I_syn_in_() const
394 {
395 return S_.I_syn_in_;
396 }
397
398
399 // ----------------------------------------------------------------
400
407 Parameters_ P_;
408 State_ S_;
409 Variables_ V_;
410 Buffers_ B_;
412
414 static RecordablesMap< gif_pop_psc_exp > recordablesMap_;
415};
416
417inline size_t
418gif_pop_psc_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
419{
421 e.set_sender( *this );
422
423 return target.handles_test_event( e, receptor_type );
424}
425
426inline size_t
427gif_pop_psc_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
428{
429 if ( receptor_type != 0 )
430 {
431 throw UnknownReceptorType( receptor_type, get_name() );
432 }
433 return 0;
434}
435
436inline size_t
437gif_pop_psc_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
438{
439 if ( receptor_type != 0 )
440 {
441 throw UnknownReceptorType( receptor_type, get_name() );
442 }
443 return 0;
444}
445
446inline size_t
447gif_pop_psc_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
448{
449 if ( receptor_type != 0 )
450 {
451 throw UnknownReceptorType( receptor_type, get_name() );
452 }
453 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
454}
455
456inline void
457gif_pop_psc_exp::get_status( Dictionary& d ) const
458{
459 P_.get( d );
460 S_.get( d, P_ );
461 // MoD: In models derived from ArchivingNode, here get_status of the
462 // parent class is called. Since this model derives from Node, and
463 // not from ArchivingNode, this call has been disabled here
464 // (Node does not have a comparable method).
465 // ArchivingNode::get_status(d);
466 d[ names::recordables ] = recordablesMap_.get_list();
467}
468
469inline void
470gif_pop_psc_exp::set_status( const Dictionary& d )
471{
472 Parameters_ ptmp = P_; // temporary copy in case of errors
473 ptmp.set( d, this ); // throws if BadProperty
474 State_ stmp = S_; // temporary copy in case of errors
475 stmp.set( d, ptmp, this ); // throws if BadProperty
476
477 // We now know that (ptmp, stmp) are consistent. We do not
478 // write them back to (P_, S_) before we are also sure that
479 // the properties to be set in the parent class are internally
480 // consistent.
481
482 // MoD: In models derived from ArchivingNode, here set_status of the
483 // parent class is called. Since this model derives from Node, and
484 // not from ArchivingNode, this call has been disabled here
485 // (Node does not have a comparable method).
486 // ArchivingNode::set_status(d);
487
488 // if we get here, temporaries contain consistent set of properties
489 P_ = ptmp;
490 S_ = stmp;
491}
492
493} // namespace
494
495
496#endif /* HAVE_GSL */
497#endif /* #ifndef PP_POP_PSC_BETA_H */
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 target("target")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
RandomDistribution< std::binomial_distribution< unsigned long > > binomial_distribution
Definition random_generators.h:56
BaseRandomGenerator * RngPtr
Definition random_generators.h:50
RandomDistribution< std::poisson_distribution< unsigned long > > poisson_distribution
Definition random_generators.h:60
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
Declarations for base class Node.