NEST main@f146f75
Loading...
Searching...
No Matches
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// Generated includes:
27#include "config.h"
28
29#ifdef HAVE_GSL
30
31// External includes:
32#include <gsl/gsl_errno.h>
33#include <gsl/gsl_matrix.h>
34#include <gsl/gsl_odeiv.h>
35#include <gsl/gsl_sf_exp.h>
36
37// Includes from nestkernel:
38#include "archiving_node.h"
39#include "connection.h"
40#include "event.h"
41#include "nest_types.h"
42#include "recordables_map.h"
43#include "ring_buffer.h"
45
46namespace nest
47{
58extern "C" int hh_psc_alpha_dynamics( double, const double*, double*, void* );
59
60// Disable clang-formatting for documentation due to over-wide tables.
61// clang-format off
62/* BeginUserDocs: neuron, Hodgkin-Huxley, current-based, soft threshold
63
64Short description
65+++++++++++++++++
66
67Hodgkin-Huxley neuron model
68
69Description
70+++++++++++
71
72``hh_psc_alpha`` is an implementation of a spiking neuron using the Hodgkin-Huxley
73formalism :footcite:p:`Hodgkin1952`, with
74
75* membrane dynamics governed by sodium, potassium, and leak currents,
76* :math:`\alpha`-shaped synaptic input currents,
77* spike detection by a combined threshold-and-local-maximum search.
78
79The Hodgkin-Huxley formalism is also described in standard textbooks
80:footcite:p:`Gerstner2002`, :footcite:p:`Dayan2001`.
81
82Membrane potential and channel dynamics
83.......................................
84
85The membrane potential evolves according to
86
87.. math::
88
89 C_{\text{m}} \frac{dV_\text{m}}{dt} = -(I_{\text{Na}} + I_{\text{K}} + I_{\text{L}}) + I_{\text{syn}} + I_\text{e}
90
91with the voltage-gated sodium current, the delayed-rectifier potassium current, and the
92leak current
93
94.. math::
95
96 I_{\text{Na}} &= g_{\text{Na}} \, m^3 h \, (V_\text{m} - E_{\text{Na}}) \\
97 I_{\text{K}} &= g_{\text{K}} \, n^4 \, (V_\text{m} - E_{\text{K}}) \\
98 I_{\text{L}} &= g_{\text{L}} \, (V_\text{m} - E_{\text{L}}) \;.
99
100The gating variables :math:`m`, :math:`h`, and :math:`n` follow
101
102.. math::
103
104 \frac{dx}{dt} = \alpha_x(V_\text{m}) (1 - x) - \beta_x(V_\text{m}) \, x, \quad x \in \{m, h, n\} \;,
105
106with voltage-dependent rates (:math:`V_\text{m}` in mV)
107
108.. math::
109
110 \alpha_m &= \frac{0.1 (V_\text{m} + 40)}{1 - e^{-(V_\text{m} + 40)/10}} \\
111 \beta_m &= 4 \, e^{-(V_\text{m} + 65)/18} \\
112 \alpha_h &= 0.07 \, e^{-(V_\text{m} + 65)/20} \\
113 \beta_h &= \frac{1}{1 + e^{-(V_\text{m} + 35)/10}} \\
114 \alpha_n &= \frac{0.01 (V_\text{m} + 55)}{1 - e^{-(V_\text{m} + 55)/10}} \\
115 \beta_n &= 0.125 \, e^{-(V_\text{m} + 65)/80} \;.
116
117Spike detection is done by a combined threshold-and-local-maximum search: if there is a
118local maximum of the membrane potential above a certain threshold, it is considered a spike.
119
120Synaptic input
121..............
122
123The total synaptic input current :math:`I_{\text{syn}}` entering the voltage equation above has an
124excitatory and an inhibitory component,
125
126.. math::
127
128 I_{\text{syn}}(t) = I_{\text{syn, ex}}(t) + I_{\text{syn, in}}(t) \;.
129
130Each incoming spike evokes an :math:`\alpha`-shaped post-synaptic current
131
132.. math::
133
134 i_{\text{syn, X}}(t) = \frac{e}{\tau_{\text{syn, X}}} t e^{-\frac{t}{\tau_{\text{syn, X}}}} \Theta(t) \;,
135
136for :math:`\text{X} \in \{\text{ex}, \text{in}\}`, with :math:`\Theta(x)` the Heaviside step function. The
137currents are normalized such that an event of weight 1.0 evokes a peak current of 1 pA at
138:math:`t = \tau_{\text{syn, X}}`.
139
140Each channel current is the sum of these single-spike responses over
141all presynaptic neurons :math:`j` and their spike times :math:`t_j^k`, weighted by the synaptic weights
142:math:`w_j` and :math:`d_j` is the delay from neuron :math:`j`:
143
144.. math::
145
146 I_{\text{syn, X}}(t) = \sum_j w_j \sum_k i_{\text{syn, X}}(t - t_j^k-d_j) \;.
147
148Excitatory and inhibitory inputs are distinguished by the sign of the synaptic weight.
149
150For details on asynchronicity in spike and firing events with Hodgkin Huxley models
151see :ref:`here <hh_details>`.
152
153.. note::
154
155 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
156 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
157 the inhibitory one, and also sets the direction of the post-synaptic current.
158 Spike connections must use the default ``receptor_type`` of 0.
159
160 See :ref:`synapse_selection` for the conventions used by other models.
161
162Parameters
163++++++++++
164
165The following parameters can be set in the status dictionary.
166
167============== =========== ============================= ===================================================
168**Parameter** **Default** **Math equivalent** **Description**
169============== =========== ============================= ===================================================
170``E_L`` -54.402 mV :math:`E_\text{L}` Leak reversal potential
171``C_m`` 100 pF :math:`C_{\text{m}}` Capacity of the membrane
172``t_ref`` 2 ms :math:`t_{\text{ref}}` Duration of refractory period
173``g_L`` 30 nS :math:`g_\text{L}` Leak conductance
174``E_Na`` 50 mV :math:`E_{\text{Na}}` Sodium reversal potential
175``g_Na`` 12000 nS :math:`g_{\text{Na}}` Sodium peak conductance
176``E_K`` -77 mV :math:`E_{\text{K}}` Potassium reversal potential
177``g_K`` 3600 nS :math:`g_{\text{K}}` Potassium peak conductance
178``tau_syn_ex`` 0.2 ms :math:`\tau_{\text{syn, ex}}` Rise time of the excitatory input current
179``tau_syn_in`` 2.0 ms :math:`\tau_{\text{syn, in}}` Rise time of the inhibitory input current
180``I_e`` 0 pA :math:`I_\text{e}` Constant input current
181============== =========== ============================= ===================================================
182
183The following state variables evolve during simulation and are available either as neuron properties or as recordables.
184
185================== =========================== ========================== =================================
186**State variable** **Initial value** **Math equivalent** **Description**
187================== =========================== ========================== =================================
188``V_m`` -65 mV :math:`V_{\text{m}}` Membrane potential
189``Act_m`` :math:`m_\infty` [#steady]_ :math:`m` Sodium activation variable
190``Inact_h`` :math:`h_\infty` [#steady]_ :math:`h` Sodium inactivation variable
191``Act_n`` :math:`n_\infty` [#steady]_ :math:`n` Potassium activation variable
192``I_syn_ex`` 0 pA :math:`I_{\text{syn, ex}}` Excitatory synaptic input current
193``I_syn_in`` 0 pA :math:`I_{\text{syn, in}}` Inhibitory synaptic input current
194================== =========================== ========================== =================================
195
196.. [#steady] The gating variables are initialized to their steady-state values
197 :math:`x_\infty = \alpha_x / (\alpha_x + \beta_x)` at :math:`V_\text{m} = -65` mV.
198
199Problems/Todo
200+++++++++++++
201
202- better spike detection
203- initial wavelet/spike at simulation onset
204
205References
206++++++++++
207
208
209.. footbibliography::
210
211Sends
212+++++
213
214SpikeEvent
215
216Receives
217++++++++
218
219SpikeEvent, CurrentEvent, DataLoggingRequest
220
221See also
222++++++++
223
224hh_cond_exp_traub
225
226Examples using this model
227+++++++++++++++++++++++++
228
229.. listexamples:: hh_psc_alpha
230
231EndUserDocs */
232// clang-format on
233
234void register_hh_psc_alpha( const std::string& name );
235
236class hh_psc_alpha : public ArchivingNode
237{
238
239public:
240 hh_psc_alpha();
241 hh_psc_alpha( const hh_psc_alpha& );
242 ~hh_psc_alpha() override;
243
249 using Node::handle;
250 using Node::handles_test_event;
251
252 size_t send_test_event( Node&, size_t, synindex, bool ) override;
253
254 void handle( SpikeEvent& ) override;
255 void handle( CurrentEvent& ) override;
256 void handle( DataLoggingRequest& ) override;
257
258 size_t handles_test_event( SpikeEvent&, size_t ) override;
259 size_t handles_test_event( CurrentEvent&, size_t ) override;
260 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
261
262 void get_status( Dictionary& ) const override;
263 void set_status( const Dictionary& ) override;
264
265private:
266 void init_buffers_() override;
267 void pre_run_hook() override;
268 void update( Time const&, const long, const long ) override;
269
270 // END Boilerplate function declarations ----------------------------
271
272 // Friends --------------------------------------------------------
273
274 // make dynamics function quasi-member
275 friend int hh_psc_alpha_dynamics( double, const double*, double*, void* );
276
277 // The next two classes need to be friend to access the State_ class/member
278 friend class RecordablesMap< hh_psc_alpha >;
279 friend class UniversalDataLogger< hh_psc_alpha >;
280
281private:
282 // ----------------------------------------------------------------
283
285 struct Parameters_
286 {
287 double t_ref_;
288 double g_Na;
289 double g_K;
290 double g_L;
291 double C_m;
292 double E_Na;
293 double E_K;
294 double E_L;
295 double tau_synE;
296 double tau_synI;
297 double I_e;
298
299 Parameters_();
300
301 void get( Dictionary& ) const;
302 void set( const Dictionary&, Node* node );
303 };
304
305public:
306 // ----------------------------------------------------------------
307
312 struct State_
313 {
320 enum StateVecElems
321 {
322 V_M = 0,
323 HH_M, // 1
324 HH_H, // 2
325 HH_N, // 3
326 DI_EXC, // 4
327 I_EXC, // 5
328 DI_INH, // 6
329 I_INH, // 7
330 STATE_VEC_SIZE
331 };
332
333
335 double y_[ STATE_VEC_SIZE ];
336 int r_;
337
338 State_( const Parameters_& );
339 State_( const State_& );
340
341 State_& operator=( const State_& );
342
343 void get( Dictionary& ) const;
344 void set( const Dictionary&, Node* node );
345 };
346
347 // ----------------------------------------------------------------
348
349private:
353 struct Buffers_
354 {
355 Buffers_( hh_psc_alpha& );
356 Buffers_( const Buffers_&, hh_psc_alpha& );
357
359 UniversalDataLogger< hh_psc_alpha > logger_;
360
362 RingBuffer spike_exc_;
363 RingBuffer spike_inh_;
364 RingBuffer currents_;
365
367 gsl_odeiv_step* s_;
368 gsl_odeiv_control* c_;
369 gsl_odeiv_evolve* e_;
370 gsl_odeiv_system sys_;
371
372 // Since IntegrationStep_ is initialized with step_, and the resolution
373 // cannot change after nodes have been created, it is safe to place both
374 // here.
375 double step_;
376 double IntegrationStep_;
377
385 double I_stim_;
386 };
387
388 // ----------------------------------------------------------------
389
393 struct Variables_
394 {
396 double PSCurrInit_E_;
397
399 double PSCurrInit_I_;
400
401 int RefractoryCounts_;
402 };
403
404 // Access functions for UniversalDataLogger -------------------------------
405
407 template < State_::StateVecElems elem >
408 double
409 get_y_elem_() const
410 {
411 return S_.y_[ elem ];
412 }
413
414 // ----------------------------------------------------------------
415
416 Parameters_ P_;
417 State_ S_;
418 Variables_ V_;
419 Buffers_ B_;
420
422 static RecordablesMap< hh_psc_alpha > recordablesMap_;
423};
424
425
426inline size_t
427hh_psc_alpha::send_test_event( Node& target, size_t receptor_type, synindex, bool )
428{
430 e.set_sender( *this );
431
432 return target.handles_test_event( e, receptor_type );
433}
434
435
436inline size_t
437hh_psc_alpha::handles_test_event( SpikeEvent&, size_t receptor_type )
438{
439 if ( receptor_type != 0 )
440 {
441 throw UnknownReceptorType( receptor_type, get_name() );
442 }
443 return 0;
444}
445
446inline size_t
447hh_psc_alpha::handles_test_event( CurrentEvent&, size_t receptor_type )
448{
449 if ( receptor_type != 0 )
450 {
451 throw UnknownReceptorType( receptor_type, get_name() );
452 }
453 return 0;
454}
455
456inline size_t
457hh_psc_alpha::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
458{
459 if ( receptor_type != 0 )
460 {
461 throw UnknownReceptorType( receptor_type, get_name() );
462 }
463 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
464}
465
466inline void
467hh_psc_alpha::get_status( Dictionary& d ) const
468{
469 P_.get( d );
470 S_.get( d );
472
473 d[ names::recordables ] = recordablesMap_.get_list();
474}
475
476inline void
477hh_psc_alpha::set_status( const Dictionary& d )
478{
479 Parameters_ ptmp = P_; // temporary copy in case of errors
480 ptmp.set( d, this ); // throws if BadProperty
481 State_ stmp = S_; // temporary copy in case of errors
482 stmp.set( d, this ); // throws if BadProperty
483
484 // We now know that (ptmp, stmp) are consistent. We do not
485 // write them back to (P_, S_) before we are also sure that
486 // the properties to be set in the parent class are internally
487 // consistent.
489
490 // if we get here, temporaries contain consistent set of properties
491 P_ = ptmp;
492 S_ = stmp;
493}
494
495} // namespace
496
497#endif // HAVE_GSL
498#endif // HH_PSC_ALPHA_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
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 E_L("E_L")
const std::string I_e("I_e")
const std::string E_K("E_K")
const std::string recordables("recordables")
const std::string C_m("C_m")
const std::string d("d")
const std::string g_Na("g_Na")
const std::string E_Na("E_Na")
const std::string g_K("g_K")
const std::string target("target")
const std::string g_L("g_L")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
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