NEST main@f146f75
Loading...
Searching...
No Matches
pp_cond_exp_mc_urbanczik.h
Go to the documentation of this file.
1/*
2 * pp_cond_exp_mc_urbanczik.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_COND_EXP_MC_URBANCZIK_H
24#define PP_COND_EXP_MC_URBANCZIK_H
25
26// Generated includes:
27#include "config.h"
28
29#ifdef HAVE_GSL
30
31// C++ includes:
32#include <vector>
33
34// C includes:
35#include <gsl/gsl_errno.h>
36#include <gsl/gsl_matrix.h>
37#include <gsl/gsl_odeiv.h>
38
39// Includes from nestkernel:
40#include "connection.h"
41#include "event.h"
42#include "nest_types.h"
43#include "random_generators.h"
44#include "recordables_map.h"
45#include "ring_buffer.h"
49
50
51namespace nest
52{
60extern "C" int pp_cond_exp_mc_urbanczik_dynamics( double, const double*, double*, void* );
61
73class pp_cond_exp_mc_urbanczik_parameters
74{
75 friend class pp_cond_exp_mc_urbanczik;
76 friend class UrbanczikArchivingNode< pp_cond_exp_mc_urbanczik_parameters >;
77
78private:
80 enum Compartments_
81 {
82 SOMA = 0,
83 DEND,
84 NCOMP
85 };
86
87 double phi_max;
88 double rate_slope;
89 double beta;
90 double theta;
91 double phi( double u ) const;
92 double h( double u ) const;
93
94public:
95 // The Urbanczik parameters need to be public within this class as they are passed to the GSL solver
96 double g_conn[ NCOMP ];
97 double g_L[ NCOMP ];
98 double C_m[ NCOMP ];
99 double E_L[ NCOMP ];
100 double tau_syn_ex[ NCOMP ];
101 double tau_syn_in[ NCOMP ];
102};
103
104/* BeginUserDocs: neuron, point process, conductance-based, stochastic
105
106Short description
107+++++++++++++++++
108
109Two-compartment point process neuron with conductance-based synapses
110
111Description
112+++++++++++
113
114pp_cond_exp_mc_urbanczik is an implementation of a two-compartment spiking
115point process neuron with conductance-based synapses as it is used
116in :footcite:p:`Urbanczik2014`. It is capable of connecting to an :doc:`Urbanczik synapse
117<urbanczik_synapse>`.
118
119The model has two compartments: soma and dendrite, labeled as s and p,
120respectively. Each compartment can receive spike events and current input
121from a current generator. Additionally, an external (rheobase) current can be
122set for each compartment.
123
124Synapses, including those for injection external currents, are addressed through
125the receptor types given in the receptor_types entry of the state Dictionary.
126Note that in contrast to the single-compartment models, all
127synaptic weights must be positive numbers! The distinction between excitatory
128and inhibitory synapses is made explicitly by specifying the receptor type of
129the synapse. For example, receptor_type=dendritic_exc results in an excitatory
130input and receptor_type=dendritic_inh results in an inhibitory input to the
131dendritic compartment.
132
133.. _multicompartment-models:
134
135Multicompartment models and synaptic delays
136+++++++++++++++++++++++++++++++++++++++++++
137
138Note that in case of multicompartment models that represent the dendrite
139explicitly, the interpretation of the synaptic delay in NEST requires careful
140consideration. In NEST, the delay is at least one simulation time step and is
141assumed to be located entirely at the postsynaptic side. For point neurons, it
142represents the time it takes for an incoming spike to travel along the
143postsynaptic dendrite before it reaches the soma, see :ref:`panel a)
144<fig-multicompartment>`. Conversely, if the synaptic weight depends on the
145state of the postsynaptic neuron, the delay also represents the time it takes
146for the information on the state to propagate back through the dendrite to the
147synapse.
148
149For multicompartment models in NEST, this means the delay is positioned directly
150behind the incoming synapse, that is, before the first dendritic compartment on the
151postsynaptic side, see :ref:`panel b) <fig-multicompartment>`. Therefore, the
152delay specified in the synapse model does *not* account for any delay that might
153be associated with information traveling through the explicitly modeled
154dendritic compartments.
155
156In the :doc:`Urbanczik synapse <urbanczik_synapse>`, the change of the synaptic
157weight is driven by an error signal, which is the difference between the firing
158rate of the soma (derived from the somatic spike train :math:`S_{post}`) and the
159dendritic prediction of the firing rate of the soma (derived from the dendritic
160membrane potential :math:`V`). The original publication :footcite:p:`Urbanczik2014` does not assume any
161delay in the interaction between the soma and the dendritic compartment.
162Therefore, we evaluate the firing rate and the dendritic prediction at equal
163time points to calculate the error signal at that time point. Due to the
164synaptic delay :math:`d`, the synapse combines a delayed version of the error
165signal with the presynaptic spike train (:math:`S_{pre}`), see :ref:`panel c)
166<fig-multicompartment>`.
167
168.. _fig-multicompartment:
169
170.. figure:: ../static/img/multicompartment.png
171 :width: 75 %
172
173 a) Two point neurons (red circles *pre* and *post*) connected via a synapse.
174 In NEST, the delay is entirely on the postsynaptic side, and in the case of point
175 neurons, it is interpreted as the dendritic delay. b) Two two-compartment
176 neuron models composed of a somatic (green) and a dendritic (blue)
177 compartment. The soma of the presynaptic neuron is connected to the dendrite
178 of the postsynaptic neuron. The synaptic delay is located behind the synapse
179 and before the dendrite. c) Time trace of the State variables that enter the
180 Urbanczik-Senn rule. Due to the synaptic delay :math:`d`, the presynaptic
181 spike train (top) is combined with a delayed version of the postsynaptic
182 quantities; the dendritic membrane potential (middle) and the somatic spike
183 train (bottom).
184
185See :doc:`../auto_examples/urbanczik_synapse_example` to learn more.
186
187Parameters
188++++++++++
189
190The following parameters can be set in the status Dictionary. Parameters
191for each compartment are collected in a sub-Dictionary; these sub-dictionaries
192are called "soma" and "dendritic", respectively. In the list below,
193these parameters are marked with an asterisk.
194
195============ ===== =====================================================
196 V_m* mV Membrane potential
197 E_L* mV Leak reversal potential
198 C_m* pF Capacity of the membrane
199 E_ex* mV Excitatory reversal potential
200 E_in* mV Inhibitory reversal potential
201 g_L* nS Leak conductance
202 tau_syn_ex* ms Decay time constant of excitatory synaptic conductance
203 (exponential function)
204 tau_syn_in* ms Decay time constant of inhibitory synaptic conductance
205 (exponential function)
206 I_e* pA Constant input current
207 g_sp nS Coupling between soma and dendrite
208 g_ps nS Coupling between dendrite and soma
209 t_ref ms Duration of refractory period
210============ ===== =====================================================
211
212.. note::
213
214 The neuron model uses standard units of NEST instead of the unitless quantities
215 used in :footcite:p:`Urbanczik2014`.
216
217.. note::
218
219 All parameters that occur for both compartments are stored as C arrays, with
220 index 0 being soma.
221
222Sends
223+++++
224
225SpikeEvent
226
227Receives
228++++++++
229
230SpikeEvent, CurrentEvent, DataLoggingRequest
231
232References
233++++++++++
234
235.. footbibliography::
236
237See also
238++++++++
239
240urbanczik_synapse
241
242Examples using this model
243+++++++++++++++++++++++++
244
245.. listexamples:: pp_cond_exp_mc_urbanczik
246
247EndUserDocs */
248
249void register_pp_cond_exp_mc_urbanczik( const std::string& name );
250
251class pp_cond_exp_mc_urbanczik : public UrbanczikArchivingNode< pp_cond_exp_mc_urbanczik_parameters >
252{
253
254 // Boilerplate function declarations --------------------------------
255
256public:
257 pp_cond_exp_mc_urbanczik();
258 pp_cond_exp_mc_urbanczik( const pp_cond_exp_mc_urbanczik& );
259 ~pp_cond_exp_mc_urbanczik() override;
260
266 using Node::handle;
267 using Node::handles_test_event;
268
269 size_t send_test_event( Node&, size_t, synindex, bool ) override;
270
271 void handle( SpikeEvent& ) override;
272 void handle( CurrentEvent& ) override;
273 void handle( DataLoggingRequest& ) override;
274
275 size_t handles_test_event( SpikeEvent&, size_t ) override;
276 size_t handles_test_event( CurrentEvent&, size_t ) override;
277 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
278
279 void get_status( Dictionary& ) const override;
280 void set_status( const Dictionary& ) override;
281
282private:
283 void init_buffers_() override;
284 void pre_run_hook() override;
285 void update( Time const&, const long, const long ) override;
286
287 // Enumerations and constants specifying structure and properties ----
288
290 enum Compartments_
291 {
292 SOMA = 0,
293 DEND,
294 NCOMP
295 };
296
302 static const size_t MIN_SPIKE_RECEPTOR = 1;
303
307 enum SpikeSynapseTypes
308 {
309 SOMA_EXC = MIN_SPIKE_RECEPTOR,
310 SOMA_INH,
311 DEND_EXC,
312 DEND_INH,
313 SUP_SPIKE_RECEPTOR
314 };
315
316 static const size_t NUM_SPIKE_RECEPTORS = SUP_SPIKE_RECEPTOR - MIN_SPIKE_RECEPTOR;
317
323 static const size_t MIN_CURR_RECEPTOR = SUP_SPIKE_RECEPTOR;
324
328 enum CurrentSynapseTypes
329 {
330 I_SOMA = MIN_CURR_RECEPTOR,
331 I_DEND,
332 SUP_CURR_RECEPTOR
333 };
334
335 static const size_t NUM_CURR_RECEPTORS = SUP_CURR_RECEPTOR - MIN_CURR_RECEPTOR;
336
337 // Friends --------------------------------------------------------
338
339 friend int pp_cond_exp_mc_urbanczik_dynamics( double, const double*, double*, void* );
340
341 friend class RecordablesMap< pp_cond_exp_mc_urbanczik >;
342 friend class UniversalDataLogger< pp_cond_exp_mc_urbanczik >;
343
344
345 // Parameters ------------------------------------------------------
346
365 struct Parameters_
366 {
367 double t_ref;
368 double E_ex[ NCOMP ];
369 double E_in[ NCOMP ];
370 double I_e[ NCOMP ];
371
372 pp_cond_exp_mc_urbanczik_parameters urbanczik_params;
373
375 double dead_time_;
376
377 Parameters_();
378 Parameters_( const Parameters_& );
379 Parameters_& operator=( const Parameters_& );
380
381 void get( Dictionary& ) const;
382 void set( const Dictionary& );
383 };
384
385
386 // State variables ------------------------------------------------------
387
392public:
393 struct State_
394 {
395
402 enum StateVecElems_
403 {
404 V_M = 0,
405 G_EXC,
406 G_INH,
407 I_EXC, // in the paper it is I_dnd which accounts for both excitation and inhibition
408 I_INH,
409 STATE_VEC_COMPS
410 };
411
413 static const size_t STATE_VEC_SIZE = to_underlying( STATE_VEC_COMPS ) * to_underlying( NCOMP );
414
416 double y_[ STATE_VEC_SIZE ];
417 int r_;
418
419 State_( const Parameters_& );
420 State_( const State_& );
421
422 State_& operator=( const State_& );
423
424 void get( Dictionary& ) const;
425 void set( const Dictionary&, const Parameters_& );
426
434 static size_t
435 idx( size_t comp, StateVecElems_ elem )
436 {
437 assert( comp * STATE_VEC_COMPS + elem < STATE_VEC_SIZE );
438 return comp * STATE_VEC_COMPS + elem;
439 }
440 };
441
442private:
443 // Internal buffers --------------------------------------------------------
444
448 struct Buffers_
449 {
450 Buffers_( pp_cond_exp_mc_urbanczik& );
452 Buffers_( const Buffers_&, pp_cond_exp_mc_urbanczik& );
453
455 UniversalDataLogger< pp_cond_exp_mc_urbanczik > logger_;
456
460 std::vector< RingBuffer > spikes_;
461 std::vector< RingBuffer > currents_;
462
464 gsl_odeiv_step* s_;
465 gsl_odeiv_control* c_;
466 gsl_odeiv_evolve* e_;
467 gsl_odeiv_system sys_;
468
469 // IntegrationStep_ should be reset with the neuron on ResetNetwork,
470 // but remain unchanged during calibration. Since it is initialized with
471 // step_, and the resolution cannot change after nodes have been created,
472 // it is safe to place both here.
473 double step_;
474 double IntegrationStep_;
475
483 double I_stim_[ NCOMP ];
484 };
485
486 // Internal variables ---------------------------------------------
487
491 struct Variables_
492 {
493 int RefractoryCounts_;
494
495 double h_;
496 RngPtr rng_;
497 poisson_distribution poisson_dist_;
498 };
499
500 // Access functions for UniversalDataLogger -------------------------------
501
506 template < State_::StateVecElems_ elem, Compartments_ comp >
507 double
508 get_y_elem_() const
509 {
510 return S_.y_[ S_.idx( comp, elem ) ];
511 }
512
514 double
515 get_r_() const
516 {
517 return Time::get_resolution().get_ms() * S_.r_;
518 }
519
520 // Data members ----------------------------------------------------
521
522 Parameters_ P_;
523 State_ S_;
524 Variables_ V_;
525 Buffers_ B_;
526
528 static std::vector< std::string > comp_names_;
529
530 // Dictionary of receptor types, leads to seg fault on exit, see #328
531
533 static RecordablesMap< pp_cond_exp_mc_urbanczik > recordablesMap_;
534};
535
536
537// Inline functions of pp_cond_exp_mc_urbanczik_parameters
538inline double
539pp_cond_exp_mc_urbanczik_parameters::phi( double u ) const
540{
541 return phi_max / ( 1.0 + rate_slope * exp( beta * ( theta - u ) ) );
542}
543
544inline double
545pp_cond_exp_mc_urbanczik_parameters::h( double u ) const
546{
547 return 15.0 * beta / ( 1.0 + ( 1.0 / rate_slope ) * exp( -beta * ( theta - u ) ) );
548}
549
550
551// Inline functions of pp_cond_exp_mc_urbanczik
552inline size_t
553pp_cond_exp_mc_urbanczik::send_test_event( Node& target, size_t receptor_type, synindex, bool )
554{
556 e.set_sender( *this );
557 return target.handles_test_event( e, receptor_type );
558}
559
560inline size_t
561pp_cond_exp_mc_urbanczik::handles_test_event( SpikeEvent&, size_t receptor_type )
562{
563 if ( receptor_type < MIN_SPIKE_RECEPTOR or receptor_type >= SUP_SPIKE_RECEPTOR )
564 {
565 if ( receptor_type >= SUP_CURR_RECEPTOR )
566 {
567 throw UnknownReceptorType( receptor_type, get_name() );
568 }
569 else
570 {
571 throw IncompatibleReceptorType( receptor_type, get_name(), "SpikeEvent" );
572 }
573 }
574 return receptor_type - MIN_SPIKE_RECEPTOR;
575}
576
577inline size_t
578pp_cond_exp_mc_urbanczik::handles_test_event( CurrentEvent&, size_t receptor_type )
579{
580 if ( receptor_type < MIN_CURR_RECEPTOR or receptor_type >= SUP_CURR_RECEPTOR )
581 {
582 if ( receptor_type < MIN_CURR_RECEPTOR )
583 {
584 throw IncompatibleReceptorType( receptor_type, get_name(), "CurrentEvent" );
585 }
586 else
587 {
588 throw UnknownReceptorType( receptor_type, get_name() );
589 }
590 }
591 return receptor_type - MIN_CURR_RECEPTOR;
592}
593
594inline size_t
595pp_cond_exp_mc_urbanczik::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
596{
597 if ( receptor_type != 0 )
598 {
599 if ( receptor_type >= SUP_CURR_RECEPTOR )
600 {
601 throw UnknownReceptorType( receptor_type, get_name() );
602 }
603 else
604 {
605 throw IncompatibleReceptorType( receptor_type, get_name(), "DataLoggingRequest" );
606 }
607 }
608 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
609}
610
611inline void
612pp_cond_exp_mc_urbanczik::get_status( Dictionary& d ) const
613{
614 P_.get( d );
615 S_.get( d );
617
618 d[ names::recordables ] = recordablesMap_.get_list();
619
625 Dictionary receptor_dict_;
626 receptor_dict_[ names::soma_exc ] = static_cast< long >( SOMA_EXC );
627 receptor_dict_[ names::soma_inh ] = static_cast< long >( SOMA_INH );
628 receptor_dict_[ names::soma_curr ] = static_cast< long >( I_SOMA );
629
630 receptor_dict_[ names::dendritic_exc ] = static_cast< long >( DEND_EXC );
631 receptor_dict_[ names::dendritic_inh ] = static_cast< long >( DEND_INH );
632 receptor_dict_[ names::dendritic_curr ] = static_cast< long >( I_DEND );
633
634 d[ names::receptor_types ] = receptor_dict_;
635}
636
637inline void
638pp_cond_exp_mc_urbanczik::set_status( const Dictionary& d )
639{
640 Parameters_ ptmp = P_; // temporary copy in case of errors
641 ptmp.set( d ); // throws if BadProperty
642 State_ stmp = S_; // temporary copy in case of errors
643 stmp.set( d, ptmp ); // throws if BadProperty
644
645 // We now know that (ptmp, stmp) are consistent. We do not
646 // write them back to (P_, S_) before we are also sure that
647 // the properties to be set in the parent class are internally
648 // consistent.
650
651 // if we get here, temporaries contain consistent set of properties
652 P_ = ptmp;
653 S_ = stmp;
654}
655
656} // namespace
657
658
659#endif // HAVE_GSL
660#endif // PP_COND_EXP_MC_URBANCZIK_H
Event for electrical currents.
Definition event.h:608
Request data to be logged/logged data to be sent.
Definition event.h:675
Exception to be thrown if the specified receptor type does not accept the event type.
Definition exceptions.h:438
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
An archiving node which additionally archives parameters and buffers needed for the Urbanczik-Senn pl...
Definition urbanczik_archiving_node.h:46
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition urbanczik_archiving_node_impl.h:47
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition urbanczik_archiving_node_impl.h:54
const std::string dendritic_exc("dendritic_exc")
const std::string t_ref("t_ref")
const std::string tau_syn_in("tau_syn_in")
const std::string E_L("E_L")
const std::string I_e("I_e")
const std::string dendritic_curr("dendritic_curr")
const std::string phi_max("phi_max")
const std::string recordables("recordables")
const std::string C_m("C_m")
const std::string d("d")
const std::string receptor_types("receptor_types")
const std::string receptor_type("receptor_type")
const std::string rate_slope("rate_slope")
const std::string E_in("E_in")
const std::string soma_exc("soma_exc")
const std::string beta("beta")
const std::string target("target")
const std::string tau_syn_ex("tau_syn_ex")
const std::string dendritic_inh("dendritic_inh")
const std::string soma_curr("soma_curr")
const std::string theta("theta")
const std::string E_ex("E_ex")
const std::string soma_inh("soma_inh")
const std::string h("h")
const std::string g_L("g_L")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
BaseRandomGenerator * RngPtr
Definition random_generators.h:50
constexpr auto to_underlying(E e) noexcept
Cast enum value to underlying integer type.
Definition nest_types.h:188
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