NEST main@caf0ae8
 
Loading...
Searching...
No Matches
glif_cond.h
Go to the documentation of this file.
1/*
2 * glif_cond.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 GLIF_COND_H
24#define GLIF_COND_H
25
26// Generated includes:
27#include "config.h"
28
29#ifdef HAVE_GSL
30
31// C includes:
32#include <gsl/gsl_errno.h>
33#include <gsl/gsl_matrix.h>
34#include <gsl/gsl_odeiv.h>
35
36#include "archiving_node.h"
37#include "connection.h"
38#include "event.h"
39#include "nest_types.h"
40#include "ring_buffer.h"
42
43/* BeginUserDocs: neuron, integrate-and-fire, conductance-based, adaptation, hard threshold
44
45Short description
46+++++++++++++++++
47
48Conductance-based generalized leaky integrate and fire (GLIF) model (from the Allen Institute)
49
50Description
51+++++++++++
52
53``glif_cond`` provides five generalized leaky integrate
54and fire (GLIF) models :footcite:p:`Teeter2018` with conductance-based synapses.
55Incoming spike events induce a postsynaptic change of conductance modeled
56by an alpha function :footcite:p:`Meffin2004`. The alpha function is normalized such that an event
57of weight 1.0 results in a peak conductance change of 1 nS at :math:`t = \tau_\mathrm{syn}`.
58On the postsynaptic side, there can be arbitrarily many synaptic time constants.
59This can be reached by specifying separate receptor ports, each for a different
60time constant. The port number has to match the respective ``receptor_type`` in
61the connectors.
62
63The five GLIF models are:
64
65* **GLIF Model 1** - Traditional leaky integrate and fire (LIF)
66* **GLIF Model 2** - Leaky integrate and fire with biologically defined reset rules
67 (LIF_R)
68* **GLIF Model 3** - Leaky integrate and fire with after-spike currents (LIF_ASC)
69* **GLIF Model 4** - Leaky integrate and fire with biologically defined reset rules
70 and after-spike currents (LIF_R_ASC)
71* **GLIF Model 5** - Leaky integrate and fire with biologically defined reset rules,
72 after-spike currents and a voltage dependent threshold (LIF_R_ASC_A)
73
74Remarks:
75
76GLIF model mechanism setting is based on three parameters
77(``spike_dependent_threshold``, ``after_spike_currents``, ``adapting_threshold``).
78The settings of these three parameters for the five GLIF models are listed
79below. Other combinations of these parameters will not be supported.
80
81+--------+---------------------------+----------------------+--------------------+
82| Model | spike_dependent_threshold | after_spike_currents | adapting_threshold |
83+========+===========================+======================+====================+
84| GLIF1 | False | False | False |
85+--------+---------------------------+----------------------+--------------------+
86| GLIF2 | True | False | False |
87+--------+---------------------------+----------------------+--------------------+
88| GLIF3 | False | True | False |
89+--------+---------------------------+----------------------+--------------------+
90| GLIF4 | True | True | False |
91+--------+---------------------------+----------------------+--------------------+
92| GLIF5 | True | True | True |
93+--------+---------------------------+----------------------+--------------------+
94
95Typical parameter setting of different levels of GLIF models for different cells
96can be found and downloaded in the `Allen Cell Type Database
97<https://celltypes.brain-map.org>`_. For example, the default parameter setting of this
98``glif_cond`` neuron model was from the parameter values of GLIF Model 5 of Cell
99490626718, which can be retrieved from the `Allen Brain Atlas
100<https://celltypes.brain-map.org/mouse/experiment/electrophysiology/
101490626718>`_, with units being converted from SI units (i.e., V, S (1/Ohm),
102F, s, A) to NEST used units (i.e., mV, nS (1/GOhm), pF, ms, pA) and values
103being rounded to appropriate digits for simplification.
104
105For models with spike dependent threshold (i.e., GLIF2, GLIF4 and GLIF5),
106parameter setting of ``voltage_reset_fraction`` and ``voltage_reset_add`` may lead
107to the situation that voltage is bigger than threshold after reset. In this case,
108the neuron will continue to spike until the end of the simulation regardless the
109stimulated inputs. We recommend the setting of the parameters of these three models
110to follow the condition of
111
112.. math::
113
114 E_L + \mathrm{voltage\_reset\_fraction} \cdot \left( V_\mathrm{th} - E_L \right)
115 + \mathrm{voltage\_reset\_add} < V_\mathrm{th} + \mathrm{th\_spike\_add}
116
117Parameters
118++++++++++
119
120The following parameters can be set in the status Dictionary.
121
122========= ======== ============================================================
123**Membrane parameters**
124-------------------------------------------------------------------------------
125V_m double Membrane potential in mV (absolute value)
126V_th double Instantaneous threshold in mV
127g double Membrane conductance in nS
128E_L double Resting membrane potential in mV
129C_m double Capacitance of the membrane in pF
130t_ref double Duration of refractory time in ms
131V_reset double Reset potential of the membrane in mV (GLIF 1 or GLIF 3)
132========= ======== ============================================================
133
134========================= =============== =====================================
135**Spike adaptation and firing intensity parameters**
136-------------------------------------------------------------------------------
137th_spike_add double Threshold addition following spike
138 in mV (delta_theta_s in Equation (6)
139 in :footcite:p:`Teeter2018`)
140th_spike_decay double Spike-induced threshold time
141 constant in 1/ms (bs in Equation (2)
142 in :footcite:p:`Teeter2018`)
143voltage_reset_fraction double Voltage fraction coefficient
144 following spike (fv in Equation (5)
145 in :footcite:p:`Teeter2018`)
146voltage_reset_add double Voltage addition following spike in
147 mV (-delta_V (sign flipped) in
148 Equation (5) in :footcite:p:`Teeter2018`)
149asc_init double vector Initial values of after-spike
150 currents in pA
151asc_decay double vector After-spike current time constants
152 in 1/ms (kj in Equation (3) in :footcite:p:`Teeter2018`)
153asc_amps double vector After-spike current amplitudes in
154 pA (deltaIj in Equation (7) in :footcite:p:`Teeter2018`)
155asc_r double vector Current fraction following spike
156 coefficients for fj in Equation (7)
157 in :footcite:p:`Teeter2018`
158th_voltage_index double Adaptation index of threshold - A
159 'leak-conductance' for the
160 voltage-dependent component of the
161 threshold in 1/ms (av in Equation
162 (4) in :footcite:p:`Teeter2018`)
163th_voltage_decay double Voltage-induced threshold time
164 constant - Inverse of which is the
165 time constant of the
166 voltage-dependent component of the
167 threshold in 1/ms (bv in Equation
168 (4) in :footcite:p:`Teeter2018`)
169tau_syn double vector Rise time constants of the synaptic
170 alpha function in ms
171E_rev double vector Reversal potential in mV
172spike_dependent_threshold bool flag whether the neuron has
173 biologically defined reset rules
174 with a spike dependent threshold
175 component
176after_spike_currents bool flag whether the neuron has after
177 spike currents
178adapting_threshold bool flag whether the neuron has a
179 voltage dependent threshold component
180========================= =============== =====================================
181
182References
183++++++++++
184
185.. footbibliography::
186
187See also
188++++++++
189
190gif_psc_exp_multisynapse, gif_cond_exp, gif_cond_exp_multisynapse, gif_pop_psc_exp
191
192Examples using this model
193+++++++++++++++++++++++++
194
195.. listexamples:: glif_cond
196
197EndUserDocs */
198
199namespace nest
200{
201
202extern "C" int glif_cond_dynamics( double, const double*, double*, void* );
203
204void register_glif_cond( const std::string& name );
205
206class glif_cond : public ArchivingNode
207{
208public:
209 glif_cond();
210
211 glif_cond( const glif_cond& );
212
213 ~glif_cond() override;
214
215 using Node::handle;
216 using Node::handles_test_event;
217
218 size_t send_test_event( Node&, size_t, synindex, bool ) override;
219
220 void handle( SpikeEvent& ) override;
221 void handle( CurrentEvent& ) override;
222 void handle( DataLoggingRequest& ) override;
223
224 size_t handles_test_event( SpikeEvent&, size_t ) override;
225 size_t handles_test_event( CurrentEvent&, size_t ) override;
226 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
227
228 void get_status( Dictionary& ) const override;
229 void set_status( const Dictionary& ) override;
230
231private:
233 void init_buffers_() override;
234
236 void pre_run_hook() override;
237
239 void update( Time const&, const long, const long ) override;
240
241 // make dynamics function quasi-member
242 friend int glif_cond_dynamics( double, const double*, double*, void* );
243
244 // The next three classes need to be friends to access the State_ class/member
245 friend class DynamicRecordablesMap< glif_cond >;
246 friend class DynamicUniversalDataLogger< glif_cond >;
247 friend class DataAccessFunctor< glif_cond >;
248
249 struct Parameters_
250 {
251 double G_;
252 double E_L_;
253 double th_inf_;
254 double C_m_;
255 double t_ref_;
256 double V_reset_;
257 double th_spike_add_;
258 double th_spike_decay_;
259 double voltage_reset_fraction_;
260 double voltage_reset_add_;
261 double th_voltage_index_;
263 double th_voltage_decay_;
265 std::vector< double > asc_init_;
266 std::vector< double > asc_decay_;
267 std::vector< double > asc_amps_;
268 std::vector< double > asc_r_;
269 std::vector< double > tau_syn_;
270 std::vector< double > E_rev_;
271
273 bool has_connections_;
274
276 bool has_theta_spike_;
277
279 bool has_asc_;
280
282 bool has_theta_voltage_;
283
284 size_t n_receptors_() const;
285
286 Parameters_();
287
288 void get( Dictionary& ) const;
289 double set( const Dictionary&, Node* );
290 };
291
292
293 struct State_
294 {
295
296 double threshold_;
297 double threshold_spike_;
298 double threshold_voltage_;
299 std::vector< double > ASCurrents_;
300 double ASCurrents_sum_;
301 int refractory_steps_;
302
309 enum StateVecElems
310 {
311 V_M = 0,
312 I,
313 ASC_SUM,
314 TH,
315 TH_SPK,
316 TH_VLT,
317 DG_SYN,
318 G_SYN,
319 STATE_VECTOR_MIN_SIZE
320 };
321
322 static const size_t NUMBER_OF_FIXED_STATES_ELEMENTS = 1; // V_M
323 static const size_t NUMBER_OF_RECORDABLES_ELEMENTS = DG_SYN - 1; // I, ASC, TH, Th_SPK, TH_VLT
324 static const size_t NUMBER_OF_STATES_ELEMENTS_PER_RECEPTOR = 2; // DG_SYN, G_SYN
325
326 std::vector< double > y_;
327
328 State_( const Parameters_& );
329
330 void get( Dictionary&, const Parameters_& ) const;
331 void set( const Dictionary&, const Parameters_&, double, Node* );
332 };
333
334
335 struct Buffers_
336 {
337 Buffers_( glif_cond& );
338 Buffers_( const Buffers_&, glif_cond& );
339
340 std::vector< RingBuffer > spikes_;
341 RingBuffer currents_;
342
344 DynamicUniversalDataLogger< glif_cond > logger_;
345
346 /* GSL ODE stuff */
347 gsl_odeiv_step* s_;
348 gsl_odeiv_control* c_;
349 gsl_odeiv_evolve* e_;
350 gsl_odeiv_system sys_;
351
352 // IntegrationStep_ should be reset with the neuron on ResetNetwork,
353 // but remain unchanged during calibration. Since it is initialized with
354 // step_, and the resolution cannot change after nodes have been created,
355 // it is safe to place both here.
356 double step_;
357 double IntegrationStep_;
358
366 double I_;
367 };
368
369 struct Variables_
370 {
371 int RefractoryCounts_;
372 double theta_spike_decay_rate_;
373 double theta_spike_refractory_decay_rate_;
374 double theta_voltage_decay_rate_inverse_;
375 double potential_decay_rate_;
376 double abpara_ratio_voltage_;
377 std::vector< double > asc_decay_rates_;
378 std::vector< double > asc_stable_coeff_;
379 std::vector< double > asc_refractory_decay_rates_;
380 double phi;
381
386 std::vector< double > CondInitialValues_;
387 };
388
389 Parameters_ P_;
390 State_ S_;
391 Variables_ V_;
392 Buffers_ B_;
393
394 // Mapping of recordables names to access functions
395 DynamicRecordablesMap< glif_cond > recordablesMap_;
396
397 // Data Access Functor getter
398 DataAccessFunctor< glif_cond > get_data_access_functor( size_t elem );
399 inline double
400 get_state_element( size_t elem )
401 {
402 if ( elem == glif_cond::State_::V_M )
403 {
404 return S_.y_[ elem ] + P_.E_L_;
405 }
406 else if ( elem == glif_cond::State_::I )
407 {
408 return B_.I_;
409 }
410 else if ( elem == glif_cond::State_::ASC_SUM )
411 {
412 return S_.ASCurrents_sum_;
413 }
414 else if ( elem == glif_cond::State_::TH )
415 {
416 return S_.threshold_ + P_.E_L_;
417 }
418 else if ( elem == glif_cond::State_::TH_SPK )
419 {
420 return S_.threshold_spike_;
421 }
422 else if ( elem == glif_cond::State_::TH_VLT )
423 {
424 return S_.threshold_voltage_;
425 }
426 else
427 {
428 return S_.y_[ elem - glif_cond::State_::NUMBER_OF_RECORDABLES_ELEMENTS ];
429 }
430 };
431
432 // Utility function that inserts the synaptic conductances to the
433 // recordables map
434
435 std::string get_g_receptor_name( size_t receptor );
436 void insert_conductance_recordables( size_t first = 0 );
437};
438
439
440inline size_t
441glif_cond::Parameters_::n_receptors_() const
442{
443 return tau_syn_.size();
444}
445
446
447inline size_t
448glif_cond::send_test_event( Node& target, size_t receptor_type, synindex, bool )
449{
450 SpikeEvent e;
451 e.set_sender( *this );
452 return target.handles_test_event( e, receptor_type );
453}
454
455inline size_t
456glif_cond::handles_test_event( CurrentEvent&, 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
466glif_cond::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
467{
468 if ( receptor_type != 0 )
469 {
470 throw UnknownReceptorType( receptor_type, get_name() );
471 }
472
473 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
474}
475
476inline void
477glif_cond::get_status( Dictionary& d ) const
478{
479 // get our own parameter and state data
480 P_.get( d );
481 S_.get( d, P_ );
482
483 // get information managed by parent class
485
486 d[ names::recordables ] = recordablesMap_.get_list();
487}
488
489inline void
490glif_cond::set_status( const Dictionary& d )
491{
492 Parameters_ ptmp = P_; // temporary copy in case of errors
493 const double delta_EL = ptmp.set( d, this ); // throws if BadProperty
494 State_ stmp = S_; // temporary copy in case of errors
495 stmp.set( d, ptmp, delta_EL, this ); // throws if BadProperty
496
498
499 /*
500 * Here is where we must update the recordablesMap_ if new receptors
501 * are added!
502 */
503 if ( ptmp.n_receptors_() > P_.n_receptors_() ) // Number of receptors increased
504 {
505 for ( size_t receptor = P_.n_receptors_(); receptor < ptmp.n_receptors_(); ++receptor )
506 {
507 size_t elem = glif_cond::State_::G_SYN + receptor * glif_cond::State_::NUMBER_OF_STATES_ELEMENTS_PER_RECEPTOR;
508 recordablesMap_.insert( get_g_receptor_name( receptor ), get_data_access_functor( elem ) );
509 }
510 }
511 else if ( ptmp.n_receptors_() < P_.n_receptors_() )
512 { // Number of receptors decreased
513 for ( size_t receptor = ptmp.n_receptors_(); receptor < P_.n_receptors_(); ++receptor )
514 {
515 recordablesMap_.erase( get_g_receptor_name( receptor ) );
516 }
517 }
518
519 // if we get here, temporaries contain consistent set of properties
520 P_ = ptmp;
521 S_ = stmp;
522}
523
524} // namespace nest
525
526#endif // HAVE_GSL
527#endif
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 I("I")
const std::string target("target")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
const double e
Definition numerics.cpp:32