NEST  2.6.0,not_revisioned_source_dir@0
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 #include "config.h"
27 
28 #ifdef HAVE_GSL
29 
30 #include "nest.h"
31 #include "event.h"
32 #include "archiving_node.h"
33 #include "ring_buffer.h"
34 #include "connection.h"
35 #include "universal_data_logger.h"
36 #include "recordables_map.h"
37 #include "dictdatum.h"
38 #include "name.h"
39 
40 #include <vector>
41 
42 #include <gsl/gsl_errno.h>
43 #include <gsl/gsl_matrix.h>
44 #include <gsl/gsl_odeiv.h>
45 
46 /* BeginDocumentation
47 Name: iaf_cond_alpha_mc - PROTOTYPE Multi-compartment conductance-based leaky integrate-and-fire neuron model.
48 
49 Description:
50 THIS MODEL IS A PROTOTYPE FOR ILLUSTRATION PURPOSES. IT IS NOT YET
51 FULLY TESTED. USE AT YOUR OWN PERIL!
52 
53 iaf_cond_alpha_mc is an implementation of a multi-compartment spiking
54 neuron using IAF dynamics with conductance-based synapses. It serves
55 mainly to illustrate the implementation of multicompartment models in
56 NEST.
57 
58 The model has three compartments: soma, proximal and distal dendrite,
59 labeled as s, p, and d, respectively. Compartments are connected through
60 passive conductances as follows
61 
62 C_m.s d/dt V_m.s = ... - g_sp ( V_m.s - V_m.p )
63 
64 C_m.p d/dt V_m.p = ... - g_sp ( V_m.p - V_m.s ) - g_pd ( V_m.p - V_m.d )
65 
66 C_m.d d/dt V_m.d = ... - g_pd ( V_m.d - V_m.p )
67 
68 A spike is fired when the somatic membrane potential exceeds threshold,
69 V_m.s >= V_th. After a spike, somatic membrane potential is clamped to
70 a reset potential, V_m.s == V_reset, for the refractory period. Dendritic
71 membrane potentials are not manipulated after a spike.
72 
73 There is one excitatory and one inhibitory conductance-based synapse
74 onto each compartment, with alpha-function time course. The alpha
75 function is normalised such that an event of weight 1.0 results in a
76 peak current of 1 nS at t = tau_syn. Each compartment can also receive
77 current input from a current generator, and an external (rheobase)
78 current can be set for each compartment.
79 
80 Synapses, including those for injection external currents, are addressed through
81 the receptor types given in the receptor_types entry of the state dictionary. Note
82 that in contrast to the single-compartment iaf_cond_alpha model, all synaptic
83 weights must be positive numbers!
84 
85 
86 Parameters:
87 The following parameters can be set in the status dictionary. Parameters
88 for each compartment are collected in a sub-dictionary; these sub-dictionaries
89 are called "soma", "proximal", and "distal", respectively. In the list below,
90 these parameters are marked with an asterisk.
91 
92 V_m* double - Membrane potential in mV
93 E_L* double - Leak reversal potential in mV.
94 C_m* double - Capacity of the membrane in pF
95 E_ex* double - Excitatory reversal potential in mV.
96 E_in* double - Inhibitory reversal potential in mV.
97 g_L* double - Leak conductance in nS;
98 tau_syn_ex* double - Rise time of the excitatory synaptic alpha function in ms.
99 tau_syn_in* double - Rise time of the inhibitory synaptic alpha function in ms.
100 I_e* double - Constant input current in pA.
101 
102 g_sp double - Conductance connecting soma and proximal dendrite, in nS.
103 g_pd double - Conductance connecting proximal and distal dendrite, in nS.
104 t_ref double - Duration of refractory period in ms.
105 V_th double - Spike threshold in mV.
106 V_reset double - Reset potential of the membrane in mV.
107 
108 Example:
109 See examples/nest/mc_neuron.py.
110 
111 Remark:
112 This is a prototype for illustration which has undergone only limited testing.
113 Details of the implementation and user-interface will likely change.
114 USE AT YOUR OWN PERIL!
115 
116 Sends: SpikeEvent
117 
118 Receives: SpikeEvent, CurrentEvent, DataLoggingRequest
119 
120 References:
121 
122 Meffin, H., Burkitt, A. N., & Grayden, D. B. (2004). An analytical
123 model for the large, fluctuating synaptic conductance state typical of
124 neocortical neurons in vivo. J. Comput. Neurosci., 16, 159–175.
125 
126 Bernander, O ., Douglas, R. J., Martin, K. A. C., & Koch, C. (1991).
127 Synaptic background activity influences spatiotemporal integration in
128 single pyramidal cells. Proc. Natl. Acad. Sci. USA, 88(24),
129 11569–11573.
130 
131 Author: Plesser
132 
133 SeeAlso: iaf_cond_alpha
134 */
135 
136 namespace nest
137 {
145  extern "C"
146  int iaf_cond_alpha_mc_dynamics (double, const double*, double*, void*);
147 
153  {
154 
155  // Boilerplate function declarations --------------------------------
156 
157  public:
158 
162 
167  using Node::handle;
169 
171 
172  void handle(SpikeEvent &);
173  void handle(CurrentEvent &);
174  void handle(DataLoggingRequest &);
175 
179 
180  void get_status(DictionaryDatum &) const;
181  void set_status(const DictionaryDatum &);
182 
183  private:
184  void init_state_(const Node& proto);
185  void init_buffers_();
186  void calibrate();
187  void update(Time const &, const long_t, const long_t);
188 
189  // Enumerations and constants specifying structure and properties ----
190 
192  enum Compartments_ { SOMA = 0, PROX, DIST, NCOMP };
193 
199  static const port MIN_SPIKE_RECEPTOR = 1;
200 
208 
210 
217 
223 
225 
226  // Friends --------------------------------------------------------
227 
228  friend int iaf_cond_alpha_mc_dynamics (double, const double*, double*, void*);
229 
231  friend class UniversalDataLogger<iaf_cond_alpha_mc>;
232 
233 
234  // Parameters ------------------------------------------------------
235 
254  struct Parameters_ {
267 
268  Parameters_();
269  Parameters_(const Parameters_&);
271 
272  void get(DictionaryDatum&) const;
273  void set(const DictionaryDatum&);
274  };
275 
276 
277  // State variables ------------------------------------------------------
278 
284  public:
285  struct State_ {
286 
293  enum StateVecElems_ { V_M = 0,
297 
299  static const size_t STATE_VEC_SIZE = STATE_VEC_COMPS * NCOMP;
300 
304 
305  State_(const Parameters_&);
306  State_(const State_&);
307  State_& operator=(const State_&);
308 
309  void get(DictionaryDatum&) const;
310  void set(const DictionaryDatum&, const Parameters_&);
311 
319  static size_t idx(size_t comp, StateVecElems_ elem)
320  { return comp * STATE_VEC_COMPS + elem; }
321 
322  };
323  private:
324 
325  // Internal buffers --------------------------------------------------------
326 
330  struct Buffers_ {
333 
336 
340  std::vector<RingBuffer> spikes_;
341  std::vector<RingBuffer> currents_;
342 
344  gsl_odeiv_step* s_;
345  gsl_odeiv_control* c_;
346  gsl_odeiv_evolve* e_;
347  gsl_odeiv_system sys_;
348 
349  // IntergrationStep_ should be reset with the neuron on ResetNetwork,
350  // but remain unchanged during calibration. Since it is initialized with
351  // step_, and the resolution cannot change after nodes have been created,
352  // it is safe to place both here.
355 
364  };
365 
366  // Internal variables ---------------------------------------------
367 
371  struct Variables_ {
374 
377 
379  };
380 
381  // Access functions for UniversalDataLogger -------------------------------
382 
387  template <State_::StateVecElems_ elem, Compartments_ comp>
388  double_t get_y_elem_() const { return S_.y_[S_.idx(comp, elem)]; }
389 
391  double_t get_r_() const { return Time::get_resolution().get_ms() * S_.r_; }
392 
393  // Data members ----------------------------------------------------
394 
399 
401  static std::vector<Name> comp_names_;
402 
404  // static DictionaryDatum receptor_dict_;
405 
408  };
409 
410  inline
412  {
413  SpikeEvent e;
414  e.set_sender(*this);
415  return target.handles_test_event(e, receptor_type);
416  }
417 
418  inline
420  {
421  if ( receptor_type < MIN_SPIKE_RECEPTOR || receptor_type >= SUP_SPIKE_RECEPTOR )
422  {
423  if ( receptor_type < 0 || receptor_type >= SUP_CURR_RECEPTOR )
424  throw UnknownReceptorType(receptor_type, get_name());
425  else
426  throw IncompatibleReceptorType(receptor_type, get_name(), "SpikeEvent");
427  }
428  return receptor_type - MIN_SPIKE_RECEPTOR;
429  }
430 
431  inline
433  {
434  if ( receptor_type < MIN_CURR_RECEPTOR || receptor_type >= SUP_CURR_RECEPTOR )
435  {
436  if ( receptor_type >= 0 && receptor_type < MIN_CURR_RECEPTOR )
437  throw IncompatibleReceptorType(receptor_type, get_name(), "CurrentEvent");
438  else
439  throw UnknownReceptorType(receptor_type, get_name());
440  }
441  return receptor_type - MIN_CURR_RECEPTOR;
442  }
443 
444  inline
447  {
448  if ( receptor_type != 0 )
449  {
450  if ( receptor_type < 0 || receptor_type >= SUP_CURR_RECEPTOR )
451  throw UnknownReceptorType(receptor_type, get_name());
452  else
453  throw IncompatibleReceptorType(receptor_type, get_name(), "DataLoggingRequest");
454  }
455  return B_.logger_.connect_logging_device(dlr, recordablesMap_);
456  }
457 
458  inline
460  {
461  P_.get(d);
462  S_.get(d);
464 
465  (*d)[names::recordables] = recordablesMap_.get_list();
466 
472  DictionaryDatum receptor_dict_ = new Dictionary();
473  (*receptor_dict_)[Name("soma_exc")] = SOMA_EXC;
474  (*receptor_dict_)[Name("soma_inh")] = SOMA_INH;
475  (*receptor_dict_)[Name("soma_curr")] = I_SOMA;
476 
477  (*receptor_dict_)[Name("proximal_exc")] = PROX_EXC;
478  (*receptor_dict_)[Name("proximal_inh")] = PROX_INH;
479  (*receptor_dict_)[Name("proximal_curr")] = I_PROX;
480 
481  (*receptor_dict_)[Name("distal_exc")] = DIST_EXC;
482  (*receptor_dict_)[Name("distal_inh")] = DIST_INH;
483  (*receptor_dict_)[Name("distal_curr")] = I_DIST;
484 
485  (*d)[names::receptor_types] = receptor_dict_;
486  }
487 
488  inline
490  {
491  Parameters_ ptmp = P_; // temporary copy in case of errors
492  ptmp.set(d); // throws if BadProperty
493  State_ stmp = S_; // temporary copy in case of errors
494  stmp.set(d, ptmp); // throws if BadProperty
495 
496  // We now know that (ptmp, stmp) are consistent. We do not
497  // write them back to (P_, S_) before we are also sure that
498  // the properties to be set in the parent class are internally
499  // consistent.
501 
502  // if we get here, temporaries contain consistent set of properties
503  P_ = ptmp;
504  S_ = stmp;
505  }
506 
507 } // namespace
508 
509 
510 #endif //HAVE_GSL
511 #endif //IAF_COND_ALPHA_MC_H
const Name recordables("recordables")
List of recordable state data (Device parameters)
Definition: nest_names.h:244
iaf_cond_alpha_mc()
Definition: iaf_cond_alpha_mc.cpp:408
static const size_t NUM_SPIKE_RECEPTORS
Definition: iaf_cond_alpha_mc.h:209
Definition: iaf_cond_alpha_mc.h:192
Variables_ V_
Definition: iaf_cond_alpha_mc.h:397
double_t C_m[NCOMP]
Membrane Capacitance in pF.
Definition: iaf_cond_alpha_mc.h:260
int int_t
Integer number with at least 16 bit.
Definition: nest.h:95
Independent parameters of the model.
Definition: iaf_cond_alpha_mc.h:254
Definition of Archiving_Node which is capable of recording and managing a spike history.
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: iaf_cond_alpha_mc.cpp:307
State_ S_
Definition: iaf_cond_alpha_mc.h:396
Buffers_ B_
Definition: iaf_cond_alpha_mc.h:398
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
static RecordablesMap< iaf_cond_alpha_mc > recordablesMap_
Dictionary of receptor types, leads to seg fault on exit, see #328.
Definition: iaf_cond_alpha_mc.h:407
double_t get_r_() const
Read out number of refractory steps, used by UniversalDataLogger.
Definition: iaf_cond_alpha_mc.h:391
static std::vector< Name > comp_names_
Table of compartment names.
Definition: iaf_cond_alpha_mc.h:401
double_t V_reset
Reset Potential in mV.
Definition: iaf_cond_alpha_mc.h:256
Definition: iaf_cond_alpha_mc.h:294
double_t t_ref
Refractory period in ms.
Definition: iaf_cond_alpha_mc.h:257
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Exception to be thrown if the specified receptor type does not accept the event type.
Definition: exceptions.h:273
double_t tau_synI[NCOMP]
Synaptic Time Constant for Inhibitory Synapse in ms.
Definition: iaf_cond_alpha_mc.h:265
double_t I_stim_[NCOMP]
Input currents injected by CurrentEvent.
Definition: iaf_cond_alpha_mc.h:363
~iaf_cond_alpha_mc()
Definition: iaf_cond_alpha_mc.cpp:430
static const port MIN_CURR_RECEPTOR
Minimal current receptor type.
Definition: iaf_cond_alpha_mc.h:216
Parameters_ & operator=(const Parameters_ &)
needed to copy C-arrays
Definition: iaf_cond_alpha_mc.cpp:226
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
static const port MIN_SPIKE_RECEPTOR
Minimal spike receptor type.
Definition: iaf_cond_alpha_mc.h:199
double_t tau_synE[NCOMP]
Synaptic Time Constant Excitatory Synapse in ms.
Definition: iaf_cond_alpha_mc.h:264
Definition: iaf_cond_alpha_mc.h:222
double_t g_L[NCOMP]
Leak Conductance in nS.
Definition: iaf_cond_alpha_mc.h:259
double_t get_y_elem_() const
Read out state vector elements, used by UniversalDataLogger First template argument is component "nam...
Definition: iaf_cond_alpha_mc.h:388
Definition: iaf_cond_alpha_mc.h:192
Represent strings by ints to facilitate fast comparison.
Definition: name.h:53
gsl_odeiv_control * c_
adaptive stepsize control function
Definition: iaf_cond_alpha_mc.h:345
gsl_odeiv_system sys_
struct describing system
Definition: iaf_cond_alpha_mc.h:347
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: iaf_cond_alpha_mc.h:411
Event for electrical currents.
Definition: event.h:420
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
Definition: iaf_cond_alpha_mc.h:205
Definition: iaf_cond_alpha_mc.h:293
double IntegrationStep_
current integration time step, updated by GSL
Definition: iaf_cond_alpha_mc.h:354
Definition: iaf_cond_alpha_mc.h:206
int iaf_cond_alpha_mc_dynamics(double, const double *, double *, void *)
Function computing right-hand side of ODE for GSL solver.
std::vector< RingBuffer > spikes_
buffers and sums up incoming spikes/currents
Definition: iaf_cond_alpha_mc.h:340
double_t y_[STATE_VEC_SIZE]
neuron state, must be C-array for GSL solver
Definition: iaf_cond_alpha_mc.h:302
void init_state_(const Node &proto)
Private function to initialize the state of a node to model defaults.
Definition: iaf_cond_alpha_mc.cpp:442
Definition: iaf_cond_alpha_mc.h:295
static const size_t NUM_CURR_RECEPTORS
Definition: iaf_cond_alpha_mc.h:224
A class that associates names and tokens.
Definition: dict.h:45
Map names of recordables to data access functions.
Definition: recordables_map.h:58
double_t g_conn[NCOMP-1]
Conductances connecting compartments, in nS.
Definition: iaf_cond_alpha_mc.h:258
Definition: iaf_cond_alpha_mc.h:152
Buffers_(iaf_cond_alpha_mc &)
Sets buffer pointers to 0.
Definition: iaf_cond_alpha_mc.cpp:283
void get(DictionaryDatum &) const
Definition: iaf_cond_alpha_mc.cpp:379
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: iaf_cond_alpha_mc.cpp:584
Definition: iaf_cond_alpha_mc.h:296
Definition: nest_time.h:130
Definition: iaf_cond_alpha_mc.h:221
State variables of the model.
Definition: iaf_cond_alpha_mc.h:285
friend class UniversalDataLogger< iaf_cond_alpha_mc >
Definition: iaf_cond_alpha_mc.h:231
std::string get_name() const
Return class name.
Definition: node.cpp:83
const Name receptor_types("receptor_types")
Connection parameters.
Definition: nest_names.h:241
Definition: iaf_cond_alpha_mc.h:294
void set(const DictionaryDatum &)
Set values from dicitonary.
Definition: iaf_cond_alpha_mc.cpp:334
void set_status(const DictionaryDatum &d)
Definition: archiving_node.cpp:185
void get_status(DictionaryDatum &) const
Definition: iaf_cond_alpha_mc.h:459
int_t RefractoryCounts_
Definition: iaf_cond_alpha_mc.h:378
Exception to be thrown if the specified receptor type does not exist in the node. ...
Definition: exceptions.h:254
Definition: iaf_cond_alpha_mc.h:205
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
Internal variables of the model.
Definition: iaf_cond_alpha_mc.h:371
double_t E_L[NCOMP]
Leak reversal Potential (aka resting potential) in mV.
Definition: iaf_cond_alpha_mc.h:263
gsl_odeiv_evolve * e_
evolution function
Definition: iaf_cond_alpha_mc.h:346
Definition: iaf_cond_alpha_mc.h:192
int_t r_
number of refractory steps remaining
Definition: iaf_cond_alpha_mc.h:303
double_t V_th
Threshold Potential in mV.
Definition: iaf_cond_alpha_mc.h:255
static size_t idx(size_t comp, StateVecElems_ elem)
Compute linear index into state array from compartment and element.
Definition: iaf_cond_alpha_mc.h:319
Parameters_ P_
Definition: iaf_cond_alpha_mc.h:395
SpikeSynapseTypes
Spike receptors.
Definition: iaf_cond_alpha_mc.h:204
StateVecElems_
Elements of state vector.
Definition: iaf_cond_alpha_mc.h:293
a node which archives spike history for the purposes of timing dependent plasticity ...
Definition: archiving_node.h:50
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
double_t step_
step size in ms
Definition: iaf_cond_alpha_mc.h:353
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: iaf_cond_alpha_mc.cpp:510
double_t I_e[NCOMP]
Constant Current in pA.
Definition: iaf_cond_alpha_mc.h:266
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
Definition: iaf_cond_alpha_mc.h:204
Definition: iaf_cond_alpha_mc.h:204
double double_t
Double precision floating point numbers.
Definition: nest.h:93
void set_status(const DictionaryDatum &)
Definition: iaf_cond_alpha_mc.h:489
double_t E_in[NCOMP]
Inhibitory reversal Potential in mV.
Definition: iaf_cond_alpha_mc.h:262
Compartments_
Compartments, NCOMP is number.
Definition: iaf_cond_alpha_mc.h:192
virtual port handles_test_event(SpikeEvent &, rport receptor_type)
Check if the node can handle a particular event and receptor type.
Definition: node.cpp:203
UniversalDataLogger< iaf_cond_alpha_mc > logger_
Logger for all analog data.
Definition: iaf_cond_alpha_mc.h:335
Parameters_()
Sets default parameter values.
Definition: iaf_cond_alpha_mc.cpp:164
double_t get_ms() const
Definition: nest_time.h:389
Request data to be logged/logged data to be sent.
Definition: event.h:486
static Time get_resolution()
Definition: nest_time.h:303
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
Buffers of the model.
Definition: iaf_cond_alpha_mc.h:330
friend int iaf_cond_alpha_mc_dynamics(double, const double *, double *, void *)
Function computing right-hand side of ODE for GSL solver.
Default types used by the NEST kernel.
void get_status(DictionaryDatum &d) const
Definition: archiving_node.cpp:175
double_t PSConInit_E_[NCOMP]
initial value to normalise excitatory synaptic conductance
Definition: iaf_cond_alpha_mc.h:373
Definition: iaf_cond_alpha_mc.h:192
Event for spike information.
Definition: event.h:320
double_t E_ex[NCOMP]
Excitatory reversal Potential in mV.
Definition: iaf_cond_alpha_mc.h:261
Base class for all NEST network objects.
Definition: node.h:96
CurrentSynapseTypes
Current receptors.
Definition: iaf_cond_alpha_mc.h:221
void calibrate()
Re-calculate dependent parameters of the node.
Definition: iaf_cond_alpha_mc.cpp:490
Definition: iaf_cond_alpha_mc.h:221
double_t PSConInit_I_[NCOMP]
initial value to normalise inhibitory synaptic conductance
Definition: iaf_cond_alpha_mc.h:376
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: iaf_cond_alpha_mc.h:419
static const size_t STATE_VEC_SIZE
total size of state vector
Definition: iaf_cond_alpha_mc.h:299
std::vector< RingBuffer > currents_
Definition: iaf_cond_alpha_mc.h:341
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
State_(const Parameters_ &)
Default initialization.
Definition: iaf_cond_alpha_mc.cpp:254
const double e
Definition: numerics.cpp:62
gsl_odeiv_step * s_
GSL ODE stuff.
Definition: iaf_cond_alpha_mc.h:344
State_ & operator=(const State_ &)
Definition: iaf_cond_alpha_mc.cpp:273
Definition: iaf_cond_alpha_mc.h:221
Definition: iaf_cond_alpha_mc.h:207
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: iaf_cond_alpha_mc.cpp:448
Definition: iaf_cond_alpha_mc.h:206
Definition: iaf_cond_alpha_mc.h:295
void set(const DictionaryDatum &, const Parameters_ &)
Definition: iaf_cond_alpha_mc.cpp:392