NEST main@caf0ae8
 
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// clang-format off
61/* BeginUserDocs: neuron, Hodgkin-Huxley, current-based, soft threshold
62
63Short description
64+++++++++++++++++
65
66Hodgkin-Huxley neuron model
67
68Description
69+++++++++++
70
71``hh_psc_alpha`` is an implementation of a spiking neuron using the Hodgkin-Huxley
72formalism.
73
741. Postsynaptic currents
75Incoming spike events induce a postsynaptic change of current modelled
76by an alpha function. The alpha function is normalized such that an event of
77weight 1.0 results in a peak current of 1 pA.
78
79
802. Spike Detection
81Spike detection is done by a combined threshold-and-local-maximum search: if
82there is a local maximum above a certain threshold of the membrane potential,
83it is considered a spike.
84
85See also :footcite:p:`Gerstner2002`, :footcite:p:`Dayan2001`, :footcite:p:`Hodgkin1952`.
86
87For details on asynchronicity in spike and firing events with Hodgkin Huxley models
88see :ref:`here <hh_details>`.
89
90Parameters
91++++++++++
92
93The following parameters can be set in the status Dictionary.
94
95======== ====== ============================================================
96V_m mV Membrane potential
97E_L mV Leak reversal potential
98C_m pF Capacity of the membrane
99t_ref ms Duration of refractory period
100g_L nS Leak conductance
101tau_ex ms Rise time of the excitatory synaptic alpha function
102tau_in ms Rise time of the inhibitory synaptic alpha function
103E_Na mV Sodium reversal potential
104g_Na nS Sodium peak conductance
105E_K mV Potassium reversal potential
106g_K nS Potassium peak conductance
107Act_m real Activation variable m
108Inact_h real Inactivation variable h
109Act_n real Activation variable n
110I_e pA External input current
111======== ====== ============================================================
112
113Problems/Todo
114+++++++++++++
115
116- better spike detection
117- initial wavelet/spike at simulation onset
118
119References
120++++++++++
121
122
123.. footbibliography::
124
125Sends
126+++++
127
128SpikeEvent
129
130Receives
131++++++++
132
133SpikeEvent, CurrentEvent, DataLoggingRequest
134
135See also
136++++++++
137
138hh_cond_exp_traub
139
140Examples using this model
141+++++++++++++++++++++++++
142
143.. listexamples:: hh_psc_alpha
144
145EndUserDocs */
146// clang-format on
147
148void register_hh_psc_alpha( const std::string& name );
149
150class hh_psc_alpha : public ArchivingNode
151{
152
153public:
154 hh_psc_alpha();
155 hh_psc_alpha( const hh_psc_alpha& );
156 ~hh_psc_alpha() override;
157
163 using Node::handle;
164 using Node::handles_test_event;
165
166 size_t send_test_event( Node&, size_t, synindex, bool ) override;
167
168 void handle( SpikeEvent& ) override;
169 void handle( CurrentEvent& ) override;
170 void handle( DataLoggingRequest& ) override;
171
172 size_t handles_test_event( SpikeEvent&, size_t ) override;
173 size_t handles_test_event( CurrentEvent&, size_t ) override;
174 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
175
176 void get_status( Dictionary& ) const override;
177 void set_status( const Dictionary& ) override;
178
179private:
180 void init_buffers_() override;
181 void pre_run_hook() override;
182 void update( Time const&, const long, const long ) override;
183
184 // END Boilerplate function declarations ----------------------------
185
186 // Friends --------------------------------------------------------
187
188 // make dynamics function quasi-member
189 friend int hh_psc_alpha_dynamics( double, const double*, double*, void* );
190
191 // The next two classes need to be friend to access the State_ class/member
192 friend class RecordablesMap< hh_psc_alpha >;
193 friend class UniversalDataLogger< hh_psc_alpha >;
194
195private:
196 // ----------------------------------------------------------------
197
199 struct Parameters_
200 {
201 double t_ref_;
202 double g_Na;
203 double g_K;
204 double g_L;
205 double C_m;
206 double E_Na;
207 double E_K;
208 double E_L;
209 double tau_synE;
210 double tau_synI;
211 double I_e;
212
213 Parameters_();
214
215 void get( Dictionary& ) const;
216 void set( const Dictionary&, Node* node );
217 };
218
219public:
220 // ----------------------------------------------------------------
221
226 struct State_
227 {
234 enum StateVecElems
235 {
236 V_M = 0,
237 HH_M, // 1
238 HH_H, // 2
239 HH_N, // 3
240 DI_EXC, // 4
241 I_EXC, // 5
242 DI_INH, // 6
243 I_INH, // 7
244 STATE_VEC_SIZE
245 };
246
247
249 double y_[ STATE_VEC_SIZE ];
250 int r_;
251
252 State_( const Parameters_& );
253 State_( const State_& );
254
255 State_& operator=( const State_& );
256
257 void get( Dictionary& ) const;
258 void set( const Dictionary&, Node* node );
259 };
260
261 // ----------------------------------------------------------------
262
263private:
267 struct Buffers_
268 {
269 Buffers_( hh_psc_alpha& );
270 Buffers_( const Buffers_&, hh_psc_alpha& );
271
273 UniversalDataLogger< hh_psc_alpha > logger_;
274
276 RingBuffer spike_exc_;
277 RingBuffer spike_inh_;
278 RingBuffer currents_;
279
281 gsl_odeiv_step* s_;
282 gsl_odeiv_control* c_;
283 gsl_odeiv_evolve* e_;
284 gsl_odeiv_system sys_;
285
286 // Since IntegrationStep_ is initialized with step_, and the resolution
287 // cannot change after nodes have been created, it is safe to place both
288 // here.
289 double step_;
290 double IntegrationStep_;
291
299 double I_stim_;
300 };
301
302 // ----------------------------------------------------------------
303
307 struct Variables_
308 {
310 double PSCurrInit_E_;
311
313 double PSCurrInit_I_;
314
315 int RefractoryCounts_;
316 };
317
318 // Access functions for UniversalDataLogger -------------------------------
319
321 template < State_::StateVecElems elem >
322 double
323 get_y_elem_() const
324 {
325 return S_.y_[ elem ];
326 }
327
328 // ----------------------------------------------------------------
329
330 Parameters_ P_;
331 State_ S_;
332 Variables_ V_;
333 Buffers_ B_;
334
336 static RecordablesMap< hh_psc_alpha > recordablesMap_;
337};
338
339
340inline size_t
341hh_psc_alpha::send_test_event( Node& target, size_t receptor_type, synindex, bool )
342{
343 SpikeEvent e;
344 e.set_sender( *this );
345
346 return target.handles_test_event( e, receptor_type );
347}
348
349
350inline size_t
351hh_psc_alpha::handles_test_event( SpikeEvent&, size_t receptor_type )
352{
353 if ( receptor_type != 0 )
354 {
355 throw UnknownReceptorType( receptor_type, get_name() );
356 }
357 return 0;
358}
359
360inline size_t
361hh_psc_alpha::handles_test_event( CurrentEvent&, size_t receptor_type )
362{
363 if ( receptor_type != 0 )
364 {
365 throw UnknownReceptorType( receptor_type, get_name() );
366 }
367 return 0;
368}
369
370inline size_t
371hh_psc_alpha::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
372{
373 if ( receptor_type != 0 )
374 {
375 throw UnknownReceptorType( receptor_type, get_name() );
376 }
377 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
378}
379
380inline void
381hh_psc_alpha::get_status( Dictionary& d ) const
382{
383 P_.get( d );
384 S_.get( d );
386
387 d[ names::recordables ] = recordablesMap_.get_list();
388}
389
390inline void
391hh_psc_alpha::set_status( const Dictionary& d )
392{
393 Parameters_ ptmp = P_; // temporary copy in case of errors
394 ptmp.set( d, this ); // throws if BadProperty
395 State_ stmp = S_; // temporary copy in case of errors
396 stmp.set( d, this ); // throws if BadProperty
397
398 // We now know that (ptmp, stmp) are consistent. We do not
399 // write them back to (P_, S_) before we are also sure that
400 // the properties to be set in the parent class are internally
401 // consistent.
403
404 // if we get here, temporaries contain consistent set of properties
405 P_ = ptmp;
406 S_ = stmp;
407}
408
409} // namespace
410
411#endif // HAVE_GSL
412#endif // HH_PSC_ALPHA_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition archiving_node.cpp:220
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition archiving_node.cpp:236
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
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
const double e
Definition numerics.cpp:32