NEST main@f146f75
Loading...
Searching...
No Matches
iaf_cond_alpha_mc.h
Go to the documentation of this file.
1/*
2 * iaf_cond_alpha_mc.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 IAF_COND_ALPHA_MC_H
24#define IAF_COND_ALPHA_MC_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 "archiving_node.h"
41#include "connection.h"
42#include "event.h"
43#include "nest_types.h"
44#include "recordables_map.h"
45#include "ring_buffer.h"
47
48
49namespace nest
50{
58extern "C" int iaf_cond_alpha_mc_dynamics( double, const double*, double*, void* );
59
60
61/* BeginUserDocs: neuron, integrate-and-fire, conductance-based, hard threshold
62
63Short description
64+++++++++++++++++
65
66Multi-compartment conductance-based leaky integrate-and-fire neuron model
67
68Description
69+++++++++++
70
71.. admonition:: Deprecated model
72
73 ``iaf_cond_alpha_mc`` is deprecated because ``cm_default`` is an improved
74 implementation of compartmental models in NEST (see :doc:`cm_default`).
75
76THIS MODEL IS A PROTOTYPE FOR ILLUSTRATION PURPOSES. IT IS NOT YET
77FULLY TESTED. USE AT YOUR OWN PERIL!
78
79``iaf_cond_alpha_mc`` is an implementation of a multi-compartment spiking
80neuron using IAF dynamics with conductance-based synapses. It serves
81mainly to illustrate the implementation of :ref:`multicompartment models
82<multicompartment-models>` in NEST.
83
84The model has three compartments: soma, proximal and distal dendrite,
85labeled as s, p, and d, respectively. Compartments are connected through
86passive conductances as follows
87
88.. math::
89
90 C_{m.s} d/dt V_{m.s} = \ldots - g_{sp} ( V_{m.s} - V_{m.p} ) \\
91
92 C_{m.p} d/dt V_{m.p} = \ldots - g_{sp} ( V_{m.p} - V_{m.s} )
93 - g_{pd} ( V_{m.p} - V_{m.d} ) \\
94
95 C_{m.d} d/dt V_{m.d} = \ldots \qquad - g_{pd} ( V_{m.d} - V_{m.p} )
96
97A spike is fired when the somatic membrane potential exceeds threshold,
98:math:`V_{m.s} >= V_{th}`. After a spike, somatic membrane potential is
99clamped to a reset potential, :math:` V_{m.s} == V_{reset}`, for the refractory
100period. Dendritic membrane potentials are not manipulated after a spike.
101
102There is one excitatory and one inhibitory conductance-based synapse
103onto each compartment, with alpha-function time course. The alpha
104function is normalized such that an event of weight 1.0 results in a
105peak current of 1 nS at :math:`t = \tau_{syn}`. Each compartment can also
106receive current input from a current generator, and an external (rheobase)
107current can be set for each compartment.
108
109Synapses, including those for injection external currents, are addressed through
110the receptor types given in the ``receptor_types`` entry of the state Dictionary.
111Note that in contrast to the single-compartment ``iaf_cond_alpha`` model, all
112synaptic weights must be positive numbers!
113
114See also :footcite:p:`Meffin2004`, :footcite:p:`Bernander1991`.
115
116Parameters
117++++++++++
118
119The following parameters can be set in the status Dictionary. Parameters
120for each compartment are collected in a sub-Dictionary; these sub-dictionaries
121are called "soma", "proximal", and "distal", respectively. In the list below,
122these parameters are marked with an asterisk.
123
124============ ======= ==========================================================
125 V_m* mV Membrane potential
126 E_L* mV Leak reversal potential
127 C_m* pF Capacity of the membrane
128 E_ex* mV Excitatory reversal potential
129 E_in* mV Inhibitory reversal potential
130 g_L* nS Leak conductance
131 tau_syn_ex* ms Rise time of the excitatory synaptic conductance
132 (alpha function)
133 tau_syn_in* ms Rise time of the inhibitory synaptic conductance
134 (alpha function)
135 I_e* pA Constant input current
136 g_sp nS Conductance connecting soma and proximal dendrite
137 g_pd nS Conductance connecting proximal and distal dendrite
138 t_ref ms Duration of refractory period
139 V_th mV Spike threshold in mV
140 V_reset mV Reset potential of the membrane
141============ ======= ==========================================================
142
143Sends
144+++++
145
146SpikeEvent
147
148Receives
149++++++++
150
151SpikeEvent, CurrentEvent, DataLoggingRequest
152
153References
154++++++++++
155
156
157.. footbibliography::
158
159See also
160++++++++
161
162iaf_cond_alpha
163
164Examples using this model
165+++++++++++++++++++++++++
166
167.. listexamples:: iaf_cond_alpha_mc
168
169EndUserDocs */
170
171void register_iaf_cond_alpha_mc( const std::string& name );
172
173class iaf_cond_alpha_mc : public ArchivingNode
174{
175
176 // Boilerplate function declarations --------------------------------
177
178public:
179 iaf_cond_alpha_mc();
180 iaf_cond_alpha_mc( const iaf_cond_alpha_mc& );
181 ~iaf_cond_alpha_mc() override;
182
188 using Node::handle;
189 using Node::handles_test_event;
190
191 size_t send_test_event( Node&, size_t, synindex, bool ) override;
192
193 void handle( SpikeEvent& ) override;
194 void handle( CurrentEvent& ) override;
195 void handle( DataLoggingRequest& ) override;
196
197 size_t handles_test_event( SpikeEvent&, size_t ) override;
198 size_t handles_test_event( CurrentEvent&, size_t ) override;
199 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
200
201 void get_status( Dictionary& ) const override;
202 void set_status( const Dictionary& ) override;
203
204private:
205 void init_buffers_() override;
206 void pre_run_hook() override;
207 void update( Time const&, const long, const long ) override;
208
209 // Enumerations and constants specifying structure and properties ----
210
212 enum Compartments_
213 {
214 SOMA = 0,
215 PROX,
216 DIST,
217 NCOMP
218 };
219
225 static const size_t MIN_SPIKE_RECEPTOR = 1;
226
230 enum SpikeSynapseTypes
231 {
232 SOMA_EXC = MIN_SPIKE_RECEPTOR,
233 SOMA_INH,
234 PROX_EXC,
235 PROX_INH,
236 DIST_EXC,
237 DIST_INH,
238 SUP_SPIKE_RECEPTOR
239 };
240
241 static const size_t NUM_SPIKE_RECEPTORS = SUP_SPIKE_RECEPTOR - MIN_SPIKE_RECEPTOR;
242
248 static const size_t MIN_CURR_RECEPTOR = SUP_SPIKE_RECEPTOR;
249
253 enum CurrentSynapseTypes
254 {
255 I_SOMA = MIN_CURR_RECEPTOR,
256 I_PROX,
257 I_DIST,
258 SUP_CURR_RECEPTOR
259 };
260
261 static const size_t NUM_CURR_RECEPTORS = SUP_CURR_RECEPTOR - MIN_CURR_RECEPTOR;
262
263 // Friends --------------------------------------------------------
264
265 friend int iaf_cond_alpha_mc_dynamics( double, const double*, double*, void* );
266
267 friend class RecordablesMap< iaf_cond_alpha_mc >;
268 friend class UniversalDataLogger< iaf_cond_alpha_mc >;
269
270
271 // Parameters ------------------------------------------------------
272
291 struct Parameters_
292 {
293 double V_th;
294 double V_reset;
295 double t_ref;
296 double g_conn[ NCOMP - 1 ];
298 double g_L[ NCOMP ];
299 double C_m[ NCOMP ];
300 double E_ex[ NCOMP ];
301 double E_in[ NCOMP ];
302 double E_L[ NCOMP ];
304 double tau_synE[ NCOMP ];
306 double tau_synI[ NCOMP ];
308 double I_e[ NCOMP ];
309
310 Parameters_();
311 Parameters_( const Parameters_& );
312 Parameters_& operator=( const Parameters_& );
313
314 void get( Dictionary& ) const;
315 void set( const Dictionary&, Node* node );
316 };
317
318
319 // State variables ------------------------------------------------------
320
325public:
326 struct State_
327 {
334 enum StateVecElems_
335 {
336 V_M = 0,
337 DG_EXC,
338 G_EXC,
339 DG_INH,
340 G_INH,
341 STATE_VEC_COMPS
342 };
343
345 static const size_t STATE_VEC_SIZE = to_underlying( STATE_VEC_COMPS ) * to_underlying( NCOMP );
346
348 double y_[ STATE_VEC_SIZE ];
349 int r_;
350
351 State_( const Parameters_& );
352 State_( const State_& );
353
354 State_& operator=( const State_& );
355
356 void get( Dictionary& ) const;
357 void set( const Dictionary&, const Parameters_&, Node* );
358
366 static size_t
367 idx( size_t comp, StateVecElems_ elem )
368 {
369 return comp * STATE_VEC_COMPS + elem;
370 }
371 };
372
373private:
374 // Internal buffers --------------------------------------------------------
375
379 struct Buffers_
380 {
381 Buffers_( iaf_cond_alpha_mc& );
383 Buffers_( const Buffers_&, iaf_cond_alpha_mc& );
384
386 UniversalDataLogger< iaf_cond_alpha_mc > logger_;
387
391 std::vector< RingBuffer > spikes_;
392 std::vector< RingBuffer > currents_;
393
395 gsl_odeiv_step* s_;
396 gsl_odeiv_control* c_;
397 gsl_odeiv_evolve* e_;
398 gsl_odeiv_system sys_;
399
400 // Since IntegrationStep_ is initialized with step_, and the resolution
401 // cannot change after nodes have been created, it is safe to place both
402 // here.
403 double step_;
404 double IntegrationStep_;
405
413 double I_stim_[ NCOMP ];
414 };
415
416 // Internal variables ---------------------------------------------
417
421 struct Variables_
422 {
424 double PSConInit_E_[ NCOMP ];
425
427 double PSConInit_I_[ NCOMP ];
428
429 int RefractoryCounts_;
430 };
431
432 // Access functions for UniversalDataLogger -------------------------------
433
438 template < State_::StateVecElems_ elem, Compartments_ comp >
439 double
440 get_y_elem_() const
441 {
442 return S_.y_[ S_.idx( comp, elem ) ];
443 }
444
446 double
447 get_r_() const
448 {
449 return Time::get_resolution().get_ms() * S_.r_;
450 }
451
452 // Data members ----------------------------------------------------
453
454 Parameters_ P_;
455 State_ S_;
456 Variables_ V_;
457 Buffers_ B_;
458
460 static std::vector< std::string > comp_names_;
461
462 // Dictionary of receptor types, leads to seg fault on exit, see #328
463
465 static RecordablesMap< iaf_cond_alpha_mc > recordablesMap_;
466};
467
468inline size_t
469iaf_cond_alpha_mc::send_test_event( Node& target, size_t receptor_type, synindex, bool )
470{
472 e.set_sender( *this );
473 return target.handles_test_event( e, receptor_type );
474}
475
476inline size_t
477iaf_cond_alpha_mc::handles_test_event( SpikeEvent&, size_t receptor_type )
478{
479 if ( receptor_type < MIN_SPIKE_RECEPTOR or receptor_type >= SUP_SPIKE_RECEPTOR )
480 {
481 if ( receptor_type >= SUP_CURR_RECEPTOR )
482 {
483 throw UnknownReceptorType( receptor_type, get_name() );
484 }
485 else
486 {
487 throw IncompatibleReceptorType( receptor_type, get_name(), "SpikeEvent" );
488 }
489 }
490 return receptor_type - MIN_SPIKE_RECEPTOR;
491}
492
493inline size_t
494iaf_cond_alpha_mc::handles_test_event( CurrentEvent&, size_t receptor_type )
495{
496 if ( receptor_type < MIN_CURR_RECEPTOR or receptor_type >= SUP_CURR_RECEPTOR )
497 {
498 if ( receptor_type < MIN_CURR_RECEPTOR )
499 {
500 throw IncompatibleReceptorType( receptor_type, get_name(), "CurrentEvent" );
501 }
502 else
503 {
504 throw UnknownReceptorType( receptor_type, get_name() );
505 }
506 }
507 return receptor_type - MIN_CURR_RECEPTOR;
508}
509
510inline size_t
511iaf_cond_alpha_mc::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
512{
513 if ( receptor_type != 0 )
514 {
515 if ( receptor_type >= SUP_CURR_RECEPTOR )
516 {
517 throw UnknownReceptorType( receptor_type, get_name() );
518 }
519 else
520 {
521 throw IncompatibleReceptorType( receptor_type, get_name(), "DataLoggingRequest" );
522 }
523 }
524 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
525}
526
527inline void
528iaf_cond_alpha_mc::get_status( Dictionary& d ) const
529{
530 P_.get( d );
531 S_.get( d );
533
534 d[ names::recordables ] = recordablesMap_.get_list();
535
541 Dictionary receptor_dict_;
542 receptor_dict_[ names::soma_exc ] = static_cast< long >( SOMA_EXC );
543 receptor_dict_[ names::soma_inh ] = static_cast< long >( SOMA_INH );
544 receptor_dict_[ names::soma_curr ] = static_cast< long >( I_SOMA );
545
546 receptor_dict_[ names::proximal_exc ] = static_cast< long >( PROX_EXC );
547 receptor_dict_[ names::proximal_inh ] = static_cast< long >( PROX_INH );
548 receptor_dict_[ names::proximal_curr ] = static_cast< long >( I_PROX );
549
550 receptor_dict_[ names::distal_exc ] = static_cast< long >( DIST_EXC );
551 receptor_dict_[ names::distal_inh ] = static_cast< long >( DIST_INH );
552 receptor_dict_[ names::distal_curr ] = static_cast< long >( I_DIST );
553
554 d[ names::receptor_types ] = receptor_dict_;
555}
556
557inline void
558iaf_cond_alpha_mc::set_status( const Dictionary& d )
559{
560 Parameters_ ptmp = P_; // temporary copy in case of errors
561 ptmp.set( d, this ); // throws if BadProperty
562 State_ stmp = S_; // temporary copy in case of errors
563 stmp.set( d, ptmp, this ); // throws if BadProperty
564
565 // We now know that (ptmp, stmp) are consistent. We do not
566 // write them back to (P_, S_) before we are also sure that
567 // the properties to be set in the parent class are internally
568 // consistent.
570
571 // if we get here, temporaries contain consistent set of properties
572 P_ = ptmp;
573 S_ = stmp;
574}
575
576} // namespace
577
578#endif // HAVE_GSL
579
580#endif // IAF_COND_ALPHA_MC_H
A node which archives spike history for the purposes of spike-timing dependent plasticity (STDP).
Definition archiving_node.h:49
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition archiving_node.cpp:249
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition archiving_node.cpp:265
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
const std::string t_ref("t_ref")
const std::string E_L("E_L")
const std::string I_e("I_e")
const std::string V_reset("V_reset")
const std::string recordables("recordables")
const std::string C_m("C_m")
const std::string d("d")
const std::string V_th("V_th")
const std::string receptor_types("receptor_types")
const std::string proximal_curr("proximal_curr")
const std::string receptor_type("receptor_type")
const std::string E_in("E_in")
const std::string soma_exc("soma_exc")
const std::string distal_inh("distal_inh")
const std::string target("target")
const std::string distal_curr("distal_curr")
const std::string proximal_inh("proximal_inh")
const std::string soma_curr("soma_curr")
const std::string distal_exc("distal_exc")
const std::string E_ex("E_ex")
const std::string proximal_exc("proximal_exc")
const std::string soma_inh("soma_inh")
const std::string g_L("g_L")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
constexpr auto to_underlying(E e) noexcept
Cast enum value to underlying integer type.
Definition nest_types.h:188
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