NEST main@f146f75
Loading...
Searching...
No Matches
hh_psc_alpha_gap.h
Go to the documentation of this file.
1/*
2 * hh_psc_alpha_gap.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_GAP_H
24#define HH_PSC_ALPHA_GAP_H
25
26#include "config.h"
27
28#ifdef HAVE_GSL
29
30// C includes:
31#include <gsl/gsl_errno.h>
32#include <gsl/gsl_matrix.h>
33#include <gsl/gsl_odeiv.h>
34#include <gsl/gsl_sf_exp.h>
35
36// Includes from nestkernel:
37#include "archiving_node.h"
38#include "connection.h"
39#include "event.h"
40#include "nest_types.h"
41#include "node.h"
42#include "recordables_map.h"
43#include "ring_buffer.h"
45
46namespace nest
47{
48
59extern "C" int hh_psc_alpha_gap_dynamics( double, const double*, double*, void* );
60
61/* BeginUserDocs: neuron, current-based, Hodgkin-Huxley, electrical, soft threshold
62
63Short description
64+++++++++++++++++
65
66Hodgkin-Huxley neuron model with gap-junction support
67
68Description
69+++++++++++
70
71``hh_psc_alpha_gap`` is an implementation of a spiking neuron using the
72Hodgkin-Huxley formalism. In contrast to ``hh_psc_alpha`` the implementation
73additionally supports gap junctions.
74
751. Postsynaptic currents
76Incoming spike events induce a postsynaptic change of current modelled
77by an alpha function. The alpha function is normalized such that an event of
78weight 1.0 results in a peak current of 1 pA.
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
853. Gap Junctions
86Gap Junctions are implemented by a gap current of the form
87:math:`g_{ij}( V_i - V_j)`.
88
89See also :footcite:p:`Gerstner2002`, :footcite:p:`Mancilla2007`, :footcite:p:`Hodgkin1952`, :footcite:p:`Hahne2015`.
90
91For details on asynchronicity in spike and firing events with Hodgkin Huxley models
92see :ref:`here <hh_details>`.
93
94.. note::
95
96 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
97 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
98 the inhibitory one, and also sets the direction of the post-synaptic current.
99 Spike connections must use the default ``receptor_type`` of 0.
100
101 See :ref:`synapse_selection` for the conventions used by other models.
102
103Parameters
104++++++++++
105
106The following parameters can be set in the status Dictionary.
107
108=========== ====== ============================================================
109g_K nS Potassium peak conductance
110V_m mV Membrane potential
111E_L mV Leak reversal potential
112g_L nS Leak conductance
113C_m pF Capacity of the membrane
114t_ref ms Duration of refractory period
115tau_syn_ex ms Rise time of the excitatory postsynaptic current
116 (alpha function)
117tau_syn_in ms Rise time of the inhibitory postsynaptic current
118 (alpha function)
119E_Na mV Sodium reversal potential
120g_Na nS Sodium peak conductance
121E_K mV Potassium reversal potential
122g_Kv1 nS Potassium peak conductance
123g_Kv3 nS Potassium peak conductance
124Act_m real Activation variable m
125Inact_h real Inactivation variable h
126Act_n real Activation variable n
127I_e pA External input current
128=========== ====== ============================================================
129
130References
131++++++++++
132
133.. footbibliography::
134
135Sends
136+++++
137
138SpikeEvent, GapJunctionEvent
139
140Receives
141++++++++
142
143SpikeEvent, GapJunctionEvent, CurrentEvent, DataLoggingRequest
144
145See also
146++++++++
147
148hh_psc_alpha, hh_cond_exp_traub, gap_junction
149
150Examples using this model
151+++++++++++++++++++++++++
152
153.. listexamples:: hh_psc_alpha_gap
154
155EndUserDocs */
156
157void register_hh_psc_alpha_gap( const std::string& name );
158
159class hh_psc_alpha_gap : public ArchivingNode
160{
161
162public:
163 typedef Node base;
164
165 hh_psc_alpha_gap();
166 hh_psc_alpha_gap( const hh_psc_alpha_gap& );
167 ~hh_psc_alpha_gap() override;
168
174 using Node::handle;
175 using Node::handles_test_event;
176 using Node::sends_secondary_event;
177
178 size_t send_test_event( Node& target, size_t receptor_type, synindex, bool ) override;
179
180 void handle( SpikeEvent& ) override;
181 void handle( CurrentEvent& ) override;
182 void handle( DataLoggingRequest& ) override;
183 void handle( GapJunctionEvent& ) override;
184
185 size_t handles_test_event( SpikeEvent&, size_t ) override;
186 size_t handles_test_event( CurrentEvent&, size_t ) override;
187 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
188 size_t handles_test_event( GapJunctionEvent&, size_t ) override;
189
190 void
191 sends_secondary_event( GapJunctionEvent& ) override
192 {
193 }
194
195 void get_status( Dictionary& ) const override;
196 void set_status( const Dictionary& ) override;
197
198private:
199 void init_buffers_() override;
200 void pre_run_hook() override;
201
205 bool update_( Time const&, const long, const long, const bool );
206
207 void update( Time const&, const long, const long ) override;
208 bool wfr_update( Time const&, const long, const long ) override;
209
210 // END Boilerplate function declarations ----------------------------
211
212 // Friends --------------------------------------------------------
213
214 // make dynamics function quasi-member
215 friend int hh_psc_alpha_gap_dynamics( double, const double*, double*, void* );
216
217 // The next two classes need to be friend to access the State_ class/member
218 friend class RecordablesMap< hh_psc_alpha_gap >;
219 friend class UniversalDataLogger< hh_psc_alpha_gap >;
220
221private:
222 // ----------------------------------------------------------------
223
225 struct Parameters_
226 {
227 double t_ref_;
228 double g_Na;
229 double g_Kv1;
230 double g_Kv3;
231 double g_L;
232 double C_m;
233 double E_Na;
234 double E_K;
235 double E_L;
236 double tau_synE;
237 double tau_synI;
238 double I_e;
239
240 Parameters_();
241
242 void get( Dictionary& ) const;
243 void set( const Dictionary&, Node* node );
244 };
245
246public:
247 // ----------------------------------------------------------------
248
253 struct State_
254 {
261 enum StateVecElems
262 {
263 V_M = 0,
264 HH_M, // 1
265 HH_H, // 2
266 HH_N, // 3
267 HH_P, // 4
268 DI_EXC, // 5
269 I_EXC, // 6
270 DI_INH, // 7
271 I_INH, // 8
272 STATE_VEC_SIZE
273 };
274
276 double y_[ STATE_VEC_SIZE ];
277 int r_;
278
279 State_( const Parameters_& );
280 State_( const State_& );
281
282 State_& operator=( const State_& );
283
284 void get( Dictionary& ) const;
285 void set( const Dictionary&, Node* node );
286 };
287
288 // ----------------------------------------------------------------
289
290private:
294 struct Buffers_
295 {
296 Buffers_( hh_psc_alpha_gap& );
298 Buffers_( const Buffers_&, hh_psc_alpha_gap& );
299
301 UniversalDataLogger< hh_psc_alpha_gap > logger_;
302
304 RingBuffer spike_exc_;
305 RingBuffer spike_inh_;
306 RingBuffer currents_;
307
309 gsl_odeiv_step* s_;
310 gsl_odeiv_control* c_;
311 gsl_odeiv_evolve* e_;
312 gsl_odeiv_system sys_;
313
314 // Since IntegrationStep_ is initialized with step_, and the resolution
315 // cannot change after nodes have been created, it is safe to place both
316 // here.
317 double step_;
318 double IntegrationStep_;
319
320 // remembers current lag for piecewise interpolation
321 long lag_;
322 // remembers y_values from last wfr_update
323 std::vector< double > last_y_values;
324 // summarized gap weight
325 double sumj_g_ij_;
326 // summarized coefficients of the interpolation polynomial
327 std::vector< double > interpolation_coefficients;
328
336 double I_stim_;
337 };
338
339 // ----------------------------------------------------------------
340
344 struct Variables_
345 {
347 double PSCurrInit_E_;
348
350 double PSCurrInit_I_;
351
352 int RefractoryCounts_;
353 };
354
355 // Access functions for UniversalDataLogger -------------------------------
356
358 template < State_::StateVecElems elem >
359 double
360 get_y_elem_() const
361 {
362 return S_.y_[ elem ];
363 }
364
365 // ----------------------------------------------------------------
366
367 Parameters_ P_;
368 State_ S_;
369 Variables_ V_;
370 Buffers_ B_;
371
373 static RecordablesMap< hh_psc_alpha_gap > recordablesMap_;
374};
375
376inline void
377hh_psc_alpha_gap::update( Time const& origin, const long from, const long to )
378{
379 update_( origin, from, to, false );
380}
381
382inline bool
383hh_psc_alpha_gap::wfr_update( Time const& origin, const long from, const long to )
384{
385 State_ old_state = S_; // save state before wfr_update
386 const bool wfr_tol_exceeded = update_( origin, from, to, true );
387 S_ = old_state; // restore old state
388
389 return not wfr_tol_exceeded;
390}
391
392inline size_t
393hh_psc_alpha_gap::send_test_event( Node& target, size_t receptor_type, synindex, bool )
394{
395 SpikeEvent se;
396 se.set_sender( *this );
397 return target.handles_test_event( se, receptor_type );
398}
399
400
401inline size_t
402hh_psc_alpha_gap::handles_test_event( SpikeEvent&, size_t receptor_type )
403{
404 if ( receptor_type != 0 )
405 {
406 throw UnknownReceptorType( receptor_type, get_name() );
407 }
408 return 0;
409}
410
411inline size_t
412hh_psc_alpha_gap::handles_test_event( CurrentEvent&, size_t receptor_type )
413{
414 if ( receptor_type != 0 )
415 {
416 throw UnknownReceptorType( receptor_type, get_name() );
417 }
418 return 0;
419}
420
421inline size_t
422hh_psc_alpha_gap::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
423{
424 if ( receptor_type != 0 )
425 {
426 throw UnknownReceptorType( receptor_type, get_name() );
427 }
428 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
429}
430
431inline size_t
432hh_psc_alpha_gap::handles_test_event( GapJunctionEvent&, size_t receptor_type )
433{
434 if ( receptor_type != 0 )
435 {
436 throw UnknownReceptorType( receptor_type, get_name() );
437 }
438 return 0;
439}
440
441inline void
442hh_psc_alpha_gap::get_status( Dictionary& d ) const
443{
444 P_.get( d );
445 S_.get( d );
447
448 d[ names::recordables ] = recordablesMap_.get_list();
449}
450
451inline void
452hh_psc_alpha_gap::set_status( const Dictionary& d )
453{
454 Parameters_ ptmp = P_; // temporary copy in case of errors
455 ptmp.set( d, this ); // throws if BadProperty
456 State_ stmp = S_; // temporary copy in case of errors
457 stmp.set( d, this ); // throws if BadProperty
458
459 // We now know that (ptmp, stmp) are consistent. We do not
460 // write them back to (P_, S_) before we are also sure that
461 // the properties to be set in the parent class are internally
462 // consistent.
464
465 // if we get here, temporaries contain consistent set of properties
466 P_ = ptmp;
467 S_ = stmp;
468}
469
470} // namespace
471
472#endif // HAVE_GSL
473#endif // HH_PSC_ALPHA_GAP_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
void set_sender(Node &)
Change pointer to sending Node.
Definition event.h:959
Event for gap-junction information.
Definition secondary_event.h:299
Base class for all NEST network objects.
Definition node.h:99
Event for spike information.
Definition event.h:420
Definition nest_time.h:135
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_Kv3("g_Kv3")
const std::string target("target")
const std::string g_Kv1("g_Kv1")
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
Declarations for base class Node.