NEST  2.6.0,not_revisioned_source_dir@0
hh_psc_alpha.h
Go to the documentation of this file.
1 /*
2  * hh_psc_alpha.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 HH_PSC_ALPHA_H
24 #define HH_PSC_ALPHA_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 
36 #include "universal_data_logger.h"
37 #include "recordables_map.h"
38 
39 #include <gsl/gsl_errno.h>
40 #include <gsl/gsl_matrix.h>
41 #include <gsl/gsl_odeiv.h>
42 #include <gsl/gsl_sf_exp.h>
43 
44 namespace nest{
45 
46  using std::vector;
47 
58  extern "C"
59  int hh_psc_alpha_dynamics(double, const double*, double*, void*);
60 
61  /* BeginDocumentation
62 Name: hh_psc_alpha - Hodgkin Huxley neuron model.
63 
64 Description:
65 
66  hh_psc_alpha is an implementation of a spiking neuron using the Hodkin-Huxley formalism.
67 
68  (1) Post-syaptic currents
69  Incoming spike events induce a post-synaptic change of current modelled
70  by an alpha function. The alpha function is normalised such that an event of
71  weight 1.0 results in a peak current of 1 pA.
72 
73 
74  (2) Spike Detection
75  Spike detection is done by a combined threshold-and-local-maximum search: if there
76  is a local maximum above a certain threshold of the membrane potential, it is considered a spike.
77 
78 Parameters:
79 
80  The following parameters can be set in the status dictionary.
81 
82  V_m double - Membrane potential in mV
83  E_L double - Resting membrane potential in mV.
84  g_L double - Leak conductance in nS.
85  C_m double - Capacity of the membrane in pF.
86  tau_ex double - Rise time of the excitatory synaptic alpha function in ms.
87  tau_in double - Rise time of the inhibitory synaptic alpha function in ms.
88  E_Na double - Sodium reversal potential in mV.
89  g_Na double - Sodium peak conductance in nS.
90  E_K double - Potassium reversal potential in mV.
91  g_K double - Potassium peak conductance in nS.
92  Act_m double - Activation variable m
93  Act_h double - Activation variable h
94  Inact_n double - Inactivation variable n
95  I_e double - Constant external input current in pA.
96 
97 Problems/Todo:
98 
99  better spike detection
100  initial wavelet/spike at simulation onset
101 
102 References:
103 
104  Spiking Neuron Models:
105  Single Neurons, Populations, Plasticity
106  Wulfram Gerstner, Werner Kistler, Cambridge University Press
107 
108  Theoretical Neuroscience:
109  Computational and Mathematical Modeling of Neural Systems
110  Peter Dayan, L. F. Abbott, MIT Press (parameters taken from here)
111 
112  Hodgkin, A. L. and Huxley, A. F.,
113  A Quantitative Description of Membrane Current
114  and Its Application to Conduction and Excitation in Nerve,
115  Journal of Physiology, 117, 500-544 (1952)
116 
117 Sends: SpikeEvent
118 
119 Receives: SpikeEvent, CurrentEvent, DataLoggingRequest
120 
121 Authors: Schrader
122 SeeAlso: hh_cond_exp_traub
123 */
124 
126  public Archiving_Node
127  {
128 
129  public:
130 
131  hh_psc_alpha();
132  hh_psc_alpha(const hh_psc_alpha&);
133  ~hh_psc_alpha();
134 
139  using Node::handle;
141 
143 
144  void handle(SpikeEvent &);
145  void handle(CurrentEvent &);
146  void handle(DataLoggingRequest &);
147 
151 
160  double_t get_potential(Time const &) const;
161 
170  void set_potential(Time const &, double_t);
171 
172  void get_status(DictionaryDatum &) const;
173  void set_status(const DictionaryDatum &);
174 
175  private:
176  void init_state_(const Node& proto);
177  void init_buffers_();
178  void calibrate();
179  void update(Time const &, const long_t, const long_t);
180 
181  // END Boilerplate function declarations ----------------------------
182 
183  // Friends --------------------------------------------------------
184 
185  // make dynamics function quasi-member
186  friend int hh_psc_alpha_dynamics(double, const double*, double*, void*);
187 
188  // The next two classes need to be friend to access the State_ class/member
190  friend class UniversalDataLogger<hh_psc_alpha>;
191 
192  private:
193 
194  // ----------------------------------------------------------------
195 
197  struct Parameters_ {
209 
210  Parameters_();
211 
212  void get(DictionaryDatum&) const;
213  void set(const DictionaryDatum&);
214  };
215 
216  public:
217  // ----------------------------------------------------------------
218 
224  struct State_ {
225 
233  {
234  V_M = 0,
235  HH_M , // 1
236  HH_H , // 2
237  HH_N , // 3
238  DI_EXC , // 4
239  I_EXC , // 5
240  DI_INH , // 6
241  I_INH , // 7
243  };
244 
245 
248 
249  State_(const Parameters_&);
250  State_(const State_&);
251  State_& operator=(const State_&);
252 
253  void get(DictionaryDatum&) const;
254  void set(const DictionaryDatum&);
255  };
256 
257  // ----------------------------------------------------------------
258 
259  private:
263  struct Buffers_ {
265  Buffers_(const Buffers_&, hh_psc_alpha&);
266 
269 
274 
276  gsl_odeiv_step* s_;
277  gsl_odeiv_control* c_;
278  gsl_odeiv_evolve* e_;
279  gsl_odeiv_system sys_;
280 
281  // IntergrationStep_ should be reset with the neuron on ResetNetwork,
282  // but remain unchanged during calibration. Since it is initialized with
283  // step_, and the resolution cannot change after nodes have been created,
284  // it is safe to place both here.
287 
296  };
297 
298  // ----------------------------------------------------------------
299 
303  struct Variables_ {
306 
309 
311  };
312 
313  // Access functions for UniversalDataLogger -------------------------------
314 
316  template <State_::StateVecElems elem>
317  double_t get_y_elem_() const { return S_.y_[elem]; }
318 
319  // ----------------------------------------------------------------
320 
325 
328  };
329 
330 
331 inline
333 {
334  SpikeEvent e;
335  e.set_sender(*this);
336 
337  return target.handles_test_event(e, receptor_type);
338 }
339 
340 
341 inline
343 {
344  if (receptor_type != 0)
345  throw UnknownReceptorType(receptor_type, get_name());
346  return 0;
347 }
348 
349 inline
351 {
352  if (receptor_type != 0)
353  throw UnknownReceptorType(receptor_type, get_name());
354  return 0;
355 }
356 
357 inline
360 {
361  if (receptor_type != 0)
362  throw UnknownReceptorType(receptor_type, get_name());
363  return B_.logger_.connect_logging_device(dlr, recordablesMap_);
364 }
365 
366  inline
368  {
369  P_.get(d);
370  S_.get(d);
372 
373  (*d)[names::recordables] = recordablesMap_.get_list();
374  }
375 
376  inline
378  {
379  Parameters_ ptmp = P_; // temporary copy in case of errors
380  ptmp.set(d); // throws if BadProperty
381  State_ stmp = S_; // temporary copy in case of errors
382  stmp.set(d); // throws if BadProperty
383 
384  // We now know that (ptmp, stmp) are consistent. We do not
385  // write them back to (P_, S_) before we are also sure that
386  // the properties to be set in the parent class are internally
387  // consistent.
389 
390  // if we get here, temporaries contain consistent set of properties
391  P_ = ptmp;
392  S_ = stmp;
393  }
394 
395 } // namespace
396 
397 #endif //HAVE_GSL
398 #endif //HH_PSC_ALPHA_H
State_ & operator=(const State_ &)
Definition: hh_psc_alpha.cpp:168
const Name recordables("recordables")
List of recordable state data (Device parameters)
Definition: nest_names.h:244
void calibrate()
Re-calculate dependent parameters of the node.
Definition: hh_psc_alpha.cpp:341
int int_t
Integer number with at least 16 bit.
Definition: nest.h:95
~hh_psc_alpha()
Definition: hh_psc_alpha.cpp:286
Definition of Archiving_Node which is capable of recording and managing a spike history.
double_t I_stim_
Input current injected by CurrentEvent.
Definition: hh_psc_alpha.h:295
double_t g_Na
Sodium Conductance in nS.
Definition: hh_psc_alpha.h:199
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
Definition: hh_psc_alpha.h:238
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: hh_psc_alpha.cpp:355
double_t y_[STATE_VEC_SIZE]
neuron state, must be C-array for GSL solver
Definition: hh_psc_alpha.h:246
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Buffers_(hh_psc_alpha &)
Sets buffer pointers to 0.
Definition: hh_psc_alpha.cpp:245
Internal variables of the model.
Definition: hh_psc_alpha.h:303
double_t step_
step size in ms
Definition: hh_psc_alpha.h:285
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
Definition: hh_psc_alpha.h:125
Definition: hh_psc_alpha.h:239
double_t E_K
Potassium Reversal Potential in mV.
Definition: hh_psc_alpha.h:204
void set_potential(Time const &, double_t)
Define current membrane potential.
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: hh_psc_alpha.h:332
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: hh_psc_alpha.cpp:304
void init_state_(const Node &proto)
Private function to initialize the state of a node to model defaults.
Definition: hh_psc_alpha.cpp:298
Definition: hh_psc_alpha.h:236
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
StateVecElems
Enumeration identifying elements in state array State_::y_.
Definition: hh_psc_alpha.h:232
State variables of the model.
Definition: hh_psc_alpha.h:224
double_t get_potential(Time const &) const
Return membrane potential at time t.
gsl_odeiv_system sys_
struct describing system
Definition: hh_psc_alpha.h:279
Map names of recordables to data access functions.
Definition: recordables_map.h:58
double_t PSCurrInit_I_
initial value to normalise inhibitory synaptic current
Definition: hh_psc_alpha.h:308
Definition: nest_time.h:130
std::string get_name() const
Return class name.
Definition: node.cpp:83
Definition: hh_psc_alpha.h:240
RingBuffer spike_exc_
buffers and sums up incoming spikes/currents
Definition: hh_psc_alpha.h:271
void set_status(const DictionaryDatum &d)
Definition: archiving_node.cpp:185
Definition: hh_psc_alpha.h:237
friend class UniversalDataLogger< hh_psc_alpha >
Definition: hh_psc_alpha.h:190
int hh_psc_alpha_dynamics(double, const double y[], double f[], void *pnode)
Definition: hh_psc_alpha.cpp:68
Exception to be thrown if the specified receptor type does not exist in the node. ...
Definition: exceptions.h:254
Variables_ V_
Definition: hh_psc_alpha.h:323
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
double IntegrationStep_
current integration time step, updated by GSL
Definition: hh_psc_alpha.h:286
double_t g_L
Leak Conductance in nS.
Definition: hh_psc_alpha.h:201
void set_status(const DictionaryDatum &)
Definition: hh_psc_alpha.h:377
Parameters_ P_
Definition: hh_psc_alpha.h:321
RingBuffer spike_inh_
Definition: hh_psc_alpha.h:272
Definition: hh_psc_alpha.h:235
double_t C_m
Membrane Capacitance in pF.
Definition: hh_psc_alpha.h:202
RingBuffer currents_
Definition: hh_psc_alpha.h:273
gsl_odeiv_evolve * e_
evolution function
Definition: hh_psc_alpha.h:278
a node which archives spike history for the purposes of timing dependent plasticity ...
Definition: archiving_node.h:50
State_(const Parameters_ &)
Default initialization.
Definition: hh_psc_alpha.cpp:141
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
int_t RefractoryCounts_
Definition: hh_psc_alpha.h:310
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
State_ S_
Definition: hh_psc_alpha.h:322
gsl_odeiv_step * s_
GSL ODE stuff.
Definition: hh_psc_alpha.h:276
double double_t
Double precision floating point numbers.
Definition: nest.h:93
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: hh_psc_alpha.cpp:182
Definition: hh_psc_alpha.h:241
double_t get_y_elem_() const
Read out state vector elements, used by UniversalDataLogger.
Definition: hh_psc_alpha.h:317
double_t I_e
Constant Current in pA.
Definition: hh_psc_alpha.h:208
double_t E_Na
Sodium Reversal Potential in mV.
Definition: hh_psc_alpha.h:203
static RecordablesMap< hh_psc_alpha > recordablesMap_
Mapping of recordables names to access functions.
Definition: hh_psc_alpha.h:327
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
Definition: hh_psc_alpha.h:234
Request data to be logged/logged data to be sent.
Definition: event.h:486
void set(const DictionaryDatum &)
Definition: hh_psc_alpha.cpp:234
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
Buffers of the model.
Definition: hh_psc_alpha.h:263
UniversalDataLogger< hh_psc_alpha > logger_
Logger for all analog data.
Definition: hh_psc_alpha.h:268
Default types used by the NEST kernel.
void get_status(DictionaryDatum &d) const
Definition: archiving_node.cpp:175
Event for spike information.
Definition: event.h:320
Buffers_ B_
Definition: hh_psc_alpha.h:324
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: hh_psc_alpha.h:342
Independent parameters.
Definition: hh_psc_alpha.h:197
hh_psc_alpha()
Definition: hh_psc_alpha.cpp:269
Base class for all NEST network objects.
Definition: node.h:96
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: hh_psc_alpha.cpp:420
double_t tau_synI
Synaptic Time Constant for Inhibitory Synapse in ms.
Definition: hh_psc_alpha.h:207
double_t t_ref_
refractory time in ms
Definition: hh_psc_alpha.h:198
void get(DictionaryDatum &) const
Definition: hh_psc_alpha.cpp:226
double_t E_L
Leak reversal Potential (aka resting potential) in mV.
Definition: hh_psc_alpha.h:205
Parameters_()
Sets default parameter values.
Definition: hh_psc_alpha.cpp:126
Definition: hh_psc_alpha.h:242
double_t g_K
Potassium Conductance in nS.
Definition: hh_psc_alpha.h:200
double_t PSCurrInit_E_
initial value to normalise excitatory synaptic current
Definition: hh_psc_alpha.h:305
double_t tau_synE
Synaptic Time Constant Excitatory Synapse in ms.
Definition: hh_psc_alpha.h:206
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
void set(const DictionaryDatum &)
Set values from dicitonary.
Definition: hh_psc_alpha.cpp:197
const double e
Definition: numerics.cpp:62
int_t r_
number of refractory steps remaining
Definition: hh_psc_alpha.h:247
Buffer Layout.
Definition: ring_buffer.h:77
friend int hh_psc_alpha_dynamics(double, const double *, double *, void *)
Function computing right-hand side of ODE for GSL solver.
gsl_odeiv_control * c_
adaptive stepsize control function
Definition: hh_psc_alpha.h:277
void get_status(DictionaryDatum &) const
Definition: hh_psc_alpha.h:367