NEST  2.6.0,not_revisioned_source_dir@0
aeif_cond_alpha_multisynapse.h
Go to the documentation of this file.
1 /*
2  * aeif_cond_alpha_multisynapse.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 AEIF_COND_ALPHA_MULTISYNAPSE_H
24 #define AEIF_COND_ALPHA_MULTISYNAPSE_H
25 
26 #include "nest.h"
27 #include "event.h"
28 #include "archiving_node.h"
29 #include "ring_buffer.h"
30 #include "connection.h"
31 #include "universal_data_logger.h"
32 
33 /* BeginDocumentation
34  Name: aeif_cond_alpha_multisynapse - Conductance based exponential integrate-and-fire neuron model according to Brette and Gerstner (2005) with multiple synaptic time constants.
35 
36  Description:
37 
38  aeif_cond_alpha_multisynapse is a direct extension of
39  aeif_cond_alpha_RK5. In contrast to most other neuron models, this
40  one allow an arbitrary number of synaptic time constant.
41 
42  The time constants are supplied by two arrays tau_ex and tau_in for
43  the excitatory and inhibitory synapses, respectively. Port numbers
44  are then automatically assigned and there range is from 1 to n. (n
45  being the index of the last element of the tau_ex and tau_in
46  arrays).
47  During connection, the ports are selected with the property "receptor_type".
48 
49  Examples:
50  % PyNEST example, of how to assign a synaptic time constant to a receptor type.
51 
52  nest.SetDefaults('aeif_cond_alpha_multisynapse', {'HMIN':0.001})
53  nest.SetDefaults('aeif_cond_alpha_multisynapse', {'MAXERR':1e-10})
54 
55  neuron = nest.Create('aeif_cond_alpha_multisynapse')
56  nest.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5})
57  nest.SetStatus(neuron, {'taus_syn':[0.2,2.0,20.0,20.0]})
58 
59  spike = nest.Create('spike_generator', params = {'spike_times': np.array([100.0])})
60  voltmeter = nest.Create('voltmeter', 1, {'withgid': True})
61 
62  nest.CopyModel("static_synapse", "synapse1", {"weight":1.0, "delay":1.0, 'receptor_type': 1})
63  nest.CopyModel("static_synapse", "synapse2", {"weight":1.0, "delay":100.0, 'receptor_type': 2})
64  nest.CopyModel("static_synapse", "synapse3", {"weight":1.0, "delay":300.0, 'receptor_type': 3})
65  nest.CopyModel("static_synapse", "synapse4", {"weight":-1.0, "delay":500.0, 'receptor_type': 4})
66 
67  nest.Connect(spike, neuron, model="synapse1")
68  nest.Connect(spike, neuron, model="synapse2")
69  nest.Connect(spike, neuron, model="synapse3")
70  nest.Connect(spike, neuron, model="synapse4")
71 
72  nest.Connect(voltmeter, neuron)
73 
74  Sends: SpikeEvent
75 
76  Receives: SpikeEvent, CurrentEvent, DataLoggingRequest
77 
78  Author: Daniel Peppicelli, adapted from aeif_cond_alpha_RK5
79  SeeAlso: aeif_cond_alpha_RK5
80  */
81 
82 namespace nest
83 {
84  class Network;
85 
90  {
91 
92  public:
93 
96  virtual
98 
103  using Node::handle;
105 
107 
108  void handle(SpikeEvent &);
109  void handle(CurrentEvent &);
110  void handle(DataLoggingRequest &);
111 
115 
116  void get_status(DictionaryDatum &) const;
117  void set_status(const DictionaryDatum &);
118 
119  private:
120 
121  void init_state_(const Node& proto);
122  void init_buffers_();
123  void calibrate();
124  void update(Time const&, const long_t, const long_t);
125 
127  const std::vector<double_t>& y, std::vector<double_t>& f);
128 
129  // The next two classes need to be friends to access the State_ class/member
131  friend class UniversalDataLogger<aeif_cond_alpha_multisynapse> ;
132 
133  // ----------------------------------------------------------------
134 
138  struct Parameters_
139  {
143 
155  std::vector<double_t> taus_syn;
159 
160  // type is long because other types are not put through in GetStatus
161  std::vector<long> receptor_types_;
163 
164  // boolean flag which indicates whether the neuron has connections
166 
167  Parameters_();
168 
169  void get(DictionaryDatum&) const;
170  void set(const DictionaryDatum&);
171 
172  };
173 
174  // ----------------------------------------------------------------
175 
181  struct State_
182  {
183 
192  {
193  V_M = 0, W, // 1
194  DG_EXC, // 2
195  G_EXC, // 3
196  DG_INH, // 4
197  G_INH, // 5
199  };
200 
201  static const size_t NUMBER_OF_FIXED_STATES_ELEMENTS = 2; // V_M, W
202  static const size_t NUMBER_OF_STATES_ELEMENTS_PER_RECEPTOR = 4; // DG_EXC, G_EXC, DG_INH, G_INH
203 
204  std::vector<double_t> y_;
205  std::vector<double_t> k1;
206  std::vector<double_t> k2;
207  std::vector<double_t> k3;
208  std::vector<double_t> k4;
209  std::vector<double_t> k5;
210  std::vector<double_t> k6;
211  std::vector<double_t> k7;
212  std::vector<double_t> yin;
213  std::vector<double_t> ynew;
214  std::vector<double_t> yref;
216 
217  State_(const Parameters_&);
218  State_(const State_&);
219  State_& operator=(const State_&);
220 
221  void get(DictionaryDatum&) const;
222  void set(const DictionaryDatum&);
223 
224  }; // State_
225 
226  // ----------------------------------------------------------------
227 
231  struct Buffers_
232  {
235 
238 
240  std::vector<RingBuffer> spike_exc_;
241  std::vector<RingBuffer> spike_inh_;
243 
244  // IntergrationStep_ should be reset with the neuron on ResetNetwork,
245  // but remain unchanged during calibration. Since it is initialized with
246  // step_, and the resolution cannot change after nodes have been created,
247  // it is safe to place both here.
250 
259  };
260 
261  // ----------------------------------------------------------------
262 
266  struct Variables_
267  {
268 
270  std::vector<double_t> g0_ex_;
271 
273  std::vector<double_t> g0_in_;
274 
276  };
277 
278  // Access functions for UniversalDataLogger -------------------------------
279 
281  template<State_::StateVecElems elem> double_t get_y_elem_() const
282  {
283  return S_.y_[elem];
284  }
285 
286  // Data members -----------------------------------------------------------
287 
303 
304  };
305 
306  inline
309  {
310  SpikeEvent e;
311  e.set_sender(*this);
312 
313  return target.handles_test_event(e, receptor_type);
314  }
315 
316  inline
319  {
320  if (receptor_type != 0)
321  throw UnknownReceptorType(receptor_type, get_name());
322  return 0;
323  }
324 
325  inline
328  {
329  if (receptor_type != 0)
330  throw UnknownReceptorType(receptor_type, get_name());
331  return B_.logger_.connect_logging_device(dlr, recordablesMap_);
332  }
333 
334  inline
336  {
337  P_.get(d);
338  S_.get(d);
340 
341  (*d)[names::recordables] = recordablesMap_.get_list();
342  }
343 
344  inline
346  {
347  Parameters_ ptmp = P_; // temporary copy in case of errors
348  ptmp.set(d); // throws if BadProperty
349  State_ stmp = S_; // temporary copy in case of errors
350  stmp.set(d); // throws if BadProperty
351 
352  // We now know that (ptmp, stmp) are consistent. We do not
353  // write them back to (P_, S_) before we are also sure that
354  // the properties to be set in the parent class are internally
355  // consistent.
357 
358  // if we get here, temporaries contain consistent set of properties
359  P_ = ptmp;
360  S_ = stmp;
361  }
362 
368  inline
370  const std::vector<double_t>& y, std::vector<double_t>& f)
371  {
372  // a shorthand
374 
375  // y[] is the current internal state of the integrator (yin), not the state vector in the node, node.S_.y[].
376 
377  // The following code is verbose for the sake of clarity. We assume that a
378  // good compiler will optimize the verbosity away ...
379 
380  // This constant is used below as the largest admissible value for the exponential spike upstroke
381  static const double_t largest_exp = std::exp(10.);
382 
383  // shorthand for state variables
384  const double_t& V = y[S::V_M];
385  const double_t& w = y[S::W];
386 
387  double_t I_syn_exc = 0.0;
388  double_t I_syn_inh = 0.0;
389 
390  for (size_t i = 0;
391  i < (P_.num_of_receptors_ * S::NUMBER_OF_STATES_ELEMENTS_PER_RECEPTOR);
392  i += S::NUMBER_OF_STATES_ELEMENTS_PER_RECEPTOR)
393  {
394  I_syn_exc += y[S::G_EXC + i] * (V - P_.E_ex);
395  I_syn_inh += y[S::G_INH + i] * (V - P_.E_in);
396  }
397 
398  // We pre-compute the argument of the exponential
399  const double_t exp_arg = (V - P_.V_th) / P_.Delta_T;
400  // If the argument is too large, we clip it.
401  const double_t I_spike =
402  (exp_arg > 10.) ? largest_exp : P_.Delta_T * std::exp(exp_arg);
403 
404  // dv/dt
405  f[S::V_M] = (-P_.g_L * ((V - P_.E_L) - I_spike) - I_syn_exc - I_syn_inh - w
406  + P_.I_e + B_.I_stim_) / P_.C_m;
407 
408  // Adaptation current w.
409  f[S::W] = (P_.a * (V - P_.E_L) - w) / P_.tau_w;
410 
411  size_t j = 0;
412  for (size_t i = 0; i < P_.num_of_receptors_; ++i)
413  {
414  j = i * S::NUMBER_OF_STATES_ELEMENTS_PER_RECEPTOR;
415  f[S::DG_EXC + j] = -y[S::DG_EXC + j] / P_.taus_syn[i];
416  f[S::G_EXC + j] = y[S::DG_EXC + j] - y[S::G_EXC + j] / P_.taus_syn[i]; // Synaptic Conductance (nS)
417 
418  f[S::DG_INH + j] = -y[S::DG_INH + j] / P_.taus_syn[i];
419  f[S::G_INH + j] = y[S::DG_INH + j] - y[S::G_INH + j] / P_.taus_syn[i]; // Synaptic Conductance (nS)
420  }
421 
422  }
423 
424 } // namespace
425 
426 #endif /* #ifndef AEIF_COND_ALPHA_MULTISYNAPSE_H */
const Name recordables("recordables")
List of recordable state data (Device parameters)
Definition: nest_names.h:244
void init_state_(const Node &proto)
Private function to initialize the state of a node to model defaults.
Definition: aeif_cond_alpha_multisynapse.cpp:360
Definition: aeif_cond_alpha_multisynapse.h:196
Internal variables of the model.
Definition: aeif_cond_alpha_multisynapse.h:266
double_t t_ref
Refractory period in ms.
Definition: aeif_cond_alpha_multisynapse.h:154
std::vector< double_t > yref
4th order update
Definition: aeif_cond_alpha_multisynapse.h:214
int int_t
Integer number with at least 16 bit.
Definition: nest.h:95
Definition of Archiving_Node which is capable of recording and managing a spike history.
std::vector< double_t > k3
Runge-Kutta variable.
Definition: aeif_cond_alpha_multisynapse.h:207
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
std::vector< double_t > k2
Runge-Kutta variable.
Definition: aeif_cond_alpha_multisynapse.h:206
double IntegrationStep_
current integration time step, updated by solver
Definition: aeif_cond_alpha_multisynapse.h:249
int_t r_
number of refractory steps remaining
Definition: aeif_cond_alpha_multisynapse.h:215
friend class UniversalDataLogger< aeif_cond_alpha_multisynapse >
Definition: aeif_cond_alpha_multisynapse.h:131
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
RingBuffer currents_
Definition: aeif_cond_alpha_multisynapse.h:242
std::vector< double_t > k6
Runge-Kutta variable.
Definition: aeif_cond_alpha_multisynapse.h:210
std::vector< long > receptor_types_
Definition: aeif_cond_alpha_multisynapse.h:161
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: aeif_cond_alpha_multisynapse.cpp:633
static const size_t NUMBER_OF_STATES_ELEMENTS_PER_RECEPTOR
Definition: aeif_cond_alpha_multisynapse.h:202
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: aeif_cond_alpha_multisynapse.cpp:644
double_t step_
simulation step size in ms
Definition: aeif_cond_alpha_multisynapse.h:248
double_t g_L
Leak Conductance in nS.
Definition: aeif_cond_alpha_multisynapse.h:144
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: aeif_cond_alpha_multisynapse.cpp:367
double_t E_in
Inhibitory reversal Potential in mV.
Definition: aeif_cond_alpha_multisynapse.h:147
std::vector< RingBuffer > spike_exc_
buffers and sums up incoming spikes/currents
Definition: aeif_cond_alpha_multisynapse.h:240
double_t tau_w
adaptation time-constant in ms.
Definition: aeif_cond_alpha_multisynapse.h:150
double_t C_m
Membrane Capacitance in pF.
Definition: aeif_cond_alpha_multisynapse.h:145
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: aeif_cond_alpha_multisynapse.cpp:134
double_t t_ref_
Refractory period in ms.
Definition: aeif_cond_alpha_multisynapse.h:142
size_t num_of_receptors_
Definition: aeif_cond_alpha_multisynapse.h:162
Parameters_ P_
Definition: aeif_cond_alpha_multisynapse.h:295
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
Conductance based exponential integrate-and-fire neuron model according to Brette and Gerstner (2005)...
Definition: aeif_cond_alpha_multisynapse.h:89
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: aeif_cond_alpha_multisynapse.h:307
double_t V_peak_
Spike detection threshold in mV.
Definition: aeif_cond_alpha_multisynapse.h:140
Independent parameters of the model.
Definition: aeif_cond_alpha_multisynapse.h:138
Buffers of the model.
Definition: aeif_cond_alpha_multisynapse.h:231
std::vector< double_t > k7
Runge-Kutta variable.
Definition: aeif_cond_alpha_multisynapse.h:211
State_ & operator=(const State_ &)
Definition: aeif_cond_alpha_multisynapse.cpp:111
std::vector< double_t > ynew
5th order update
Definition: aeif_cond_alpha_multisynapse.h:213
Map names of recordables to data access functions.
Definition: recordables_map.h:58
const Name w("w")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:343
const Name y("y")
Definition: topology_names.h:52
Definition: nest_time.h:130
static const size_t NUMBER_OF_FIXED_STATES_ELEMENTS
Definition: aeif_cond_alpha_multisynapse.h:201
virtual ~aeif_cond_alpha_multisynapse()
Definition: aeif_cond_alpha_multisynapse.cpp:352
void set(const DictionaryDatum &)
Definition: aeif_cond_alpha_multisynapse.cpp:280
std::string get_name() const
Return class name.
Definition: node.cpp:83
Variables_ V_
Definition: aeif_cond_alpha_multisynapse.h:297
const Name S("S")
Binary state (output) of neuron (Ginzburg neuron)
Definition: nest_names.h:255
void set_status(const DictionaryDatum &d)
Definition: archiving_node.cpp:185
double_t I_stim_
Input current injected by CurrentEvent.
Definition: aeif_cond_alpha_multisynapse.h:258
std::vector< double_t > g0_in_
initial value to normalise inhibitory synaptic conductance
Definition: aeif_cond_alpha_multisynapse.h:273
State_ S_
Definition: aeif_cond_alpha_multisynapse.h:296
Definition: aeif_cond_alpha_multisynapse.h:194
Exception to be thrown if the specified receptor type does not exist in the node. ...
Definition: exceptions.h:254
std::vector< double_t > taus_syn
Time constants of synaptic currents in ms..
Definition: aeif_cond_alpha_multisynapse.h:155
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
void get(DictionaryDatum &) const
Definition: aeif_cond_alpha_multisynapse.cpp:244
double_t V_th
Spike threshold in mV.
Definition: aeif_cond_alpha_multisynapse.h:153
Buffers_(aeif_cond_alpha_multisynapse &)
Definition: aeif_cond_alpha_multisynapse.cpp:324
State variables of the model.
Definition: aeif_cond_alpha_multisynapse.h:181
double_t V_reset_
Reset Potential in mV.
Definition: aeif_cond_alpha_multisynapse.h:141
std::vector< double_t > k5
Runge-Kutta variable.
Definition: aeif_cond_alpha_multisynapse.h:209
void calibrate()
Re-calculate dependent parameters of the node.
Definition: aeif_cond_alpha_multisynapse.cpp:384
int_t RefractoryCounts_
Definition: aeif_cond_alpha_multisynapse.h:275
Parameters_()
Sets default parameter values.
Definition: aeif_cond_alpha_multisynapse.cpp:62
void get_status(DictionaryDatum &) const
Definition: aeif_cond_alpha_multisynapse.h:335
a node which archives spike history for the purposes of timing dependent plasticity ...
Definition: archiving_node.h:50
static RecordablesMap< aeif_cond_alpha_multisynapse > recordablesMap_
Mapping of recordables names to access functions.
Definition: aeif_cond_alpha_multisynapse.h:302
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
std::vector< double_t > k1
Runge-Kutta variable.
Definition: aeif_cond_alpha_multisynapse.h:205
double_t E_L
Leak reversal Potential (aka resting potential) in mV.
Definition: aeif_cond_alpha_multisynapse.h:148
double_t I_e
Intrinsic current in pA.
Definition: aeif_cond_alpha_multisynapse.h:156
aeif_cond_alpha_multisynapse()
Definition: aeif_cond_alpha_multisynapse.cpp:340
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
std::vector< double_t > y_
neuron state
Definition: aeif_cond_alpha_multisynapse.h:204
double double_t
Double precision floating point numbers.
Definition: nest.h:93
std::vector< double_t > g0_ex_
initial value to normalise excitatory synaptic conductance
Definition: aeif_cond_alpha_multisynapse.h:270
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
std::vector< RingBuffer > spike_inh_
Definition: aeif_cond_alpha_multisynapse.h:241
Buffers_ B_
Definition: aeif_cond_alpha_multisynapse.h:298
Request data to be logged/logged data to be sent.
Definition: event.h:486
Definition: aeif_cond_alpha_multisynapse.h:195
double_t E_ex
Excitatory reversal Potential in mV.
Definition: aeif_cond_alpha_multisynapse.h:146
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
std::vector< double_t > k4
Runge-Kutta variable.
Definition: aeif_cond_alpha_multisynapse.h:208
void aeif_cond_alpha_multisynapse_dynamics(const std::vector< double_t > &y, std::vector< double_t > &f)
Function computing right-hand side of ODE for the ODE solver.
Definition: aeif_cond_alpha_multisynapse.h:369
bool has_connections_
Definition: aeif_cond_alpha_multisynapse.h:165
Default types used by the NEST kernel.
void get_status(DictionaryDatum &d) const
Definition: archiving_node.cpp:175
std::vector< double_t > yin
Runge-Kutta variable.
Definition: aeif_cond_alpha_multisynapse.h:212
double_t b
Spike-triggered adaptation in pA.
Definition: aeif_cond_alpha_multisynapse.h:152
Event for spike information.
Definition: event.h:320
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: aeif_cond_alpha_multisynapse.cpp:453
Base class for all NEST network objects.
Definition: node.h:96
Definition: aeif_cond_alpha_multisynapse.h:197
double_t HMIN
Smallest permissible stepsize in ms.
Definition: aeif_cond_alpha_multisynapse.h:158
State_(const Parameters_ &)
Default initialization.
Definition: aeif_cond_alpha_multisynapse.cpp:84
Definition: aeif_cond_alpha_multisynapse.h:198
Definition: aeif_cond_alpha_multisynapse.h:193
StateVecElems
Enumeration identifying elements in state vector State_::y_.
Definition: aeif_cond_alpha_multisynapse.h:191
Definition: aeif_cond_alpha_multisynapse.h:193
double_t MAXERR
Maximal error for adaptive stepsize solver.
Definition: aeif_cond_alpha_multisynapse.h:157
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
double_t get_y_elem_() const
Read out state vector elements, used by UniversalDataLogger.
Definition: aeif_cond_alpha_multisynapse.h:281
const double e
Definition: numerics.cpp:62
void set_status(const DictionaryDatum &)
Definition: aeif_cond_alpha_multisynapse.h:345
double_t a
Subthreshold adaptation in nS.
Definition: aeif_cond_alpha_multisynapse.h:151
UniversalDataLogger< aeif_cond_alpha_multisynapse > logger_
Logger for all analog data.
Definition: aeif_cond_alpha_multisynapse.h:237
double_t Delta_T
Slope faktor in ms.
Definition: aeif_cond_alpha_multisynapse.h:149
Buffer Layout.
Definition: ring_buffer.h:77
void set(const DictionaryDatum &)
Set values from dictionary.
Definition: aeif_cond_alpha_multisynapse.cpp:158