NEST main@caf0ae8
 
Loading...
Searching...
No Matches
cm_default.h
Go to the documentation of this file.
1/*
2 * cm_default.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 CM_DEFAULT_H
24#define CM_DEFAULT_H
25
26// Includes from nestkernel:
27#include "archiving_node.h"
28#include "event.h"
29#include "nest_types.h"
31
33#include "cm_tree.h"
34
35namespace nest
36{
37
38/* BeginUserDocs: neuron, compartmental model
39
40Short description
41+++++++++++++++++
42
43A neuron model with user-defined dendrite structure.
44Currently, AMPA, GABA or AMPA+NMDA receptors.
45
46Description
47+++++++++++
48
49``cm_default`` is an implementation of a compartmental model :footcite:p:`Wybo2021`. The structure of the
50neuron -- soma, dendrites, axon -- is user-defined at runtime by adding
51compartments through ``nest.SetStatus()``. Each compartment can be assigned
52receptors, also through ``nest.SetStatus()``.
53
54The default model is passive, but sodium and potassium currents can be added
55by passing non-zero conductances ``g_Na`` and ``g_K`` with the parameter dictionary
56when adding compartments. Receptors can be AMPA and/or NMDA (excitatory), and
57GABA (inhibitory). Ion channel and receptor currents to the compartments can be
58customized through NESTML
59
60Usage
61+++++
62
63The structure of the dendrite is user defined. Thus after creation of the neuron
64in the standard manner:
65
66.. code-block:: Python
67
68 cm = nest.Create('cm_default')
69
70compartments can be added as follows:
71
72.. code-block:: Python
73
74 cm.compartments = [
75 {"parent_idx": -1, "params": {"e_L": -65.}},
76 {"parent_idx": 0, "params": {"e_L": -60., "g_C": 0.02}}
77 ]
78
79Each compartment is assigned an index, corresponding to the order in which they
80were added. Subsequently, compartment indices are used to specify parent
81compartments in the tree or are used to assign receptors to the compartments.
82By convention, the first compartment is the root (soma), which has no parent.
83In this case, ``parent_index`` is -1.
84
85Synaptic receptors can be added as follows:
86
87.. code-block:: Python
88
89 cm.receptors = [{
90 "comp_idx": 1,
91 "receptor_type": "AMPA",
92 "params": {"e_AMPA": 0., "tau_AMPA": 3.}
93 }]
94
95Similar to compartments, each receptor is assigned an index, starting at 0 and
96corresponding to the order in which they are added. This index is used
97subsequently to connect synapses to the receptor:
98
99.. code-block:: Python
100
101 nest.Connect(pre, cm_model, syn_spec={
102 'synapse_model': 'static_synapse', 'weight': 5., 'delay': 0.5,
103 'receptor_type': 2})
104
105.. note::
106
107 In the ``nest.SetStatus()`` call, the ``receptor_type`` entry is a string
108 that specifies the type of receptor. In the ``nest.Connect()`` call, the
109 ``receptor_type`` entry is an integer that specifies the receptor index.
110
111.. note::
112
113 Each compartments' respective "receptors" entries can be a dictionary or a list
114 of dictionaries containing receptor details. When a dictionary is provided,
115 a single compartment receptor is added to the model. When a list of dicts
116 is provided, multiple compartments' receptors are added with a single
117 ``nest.SetStatus()`` call.
118
119Compartment voltages can be recorded. To do so, create a multimeter in the
120standard manner but specify the recorded voltages as
121``v_comp{compartment_index}``. State variables for ion channels can be recorded as well,
122using the syntax ``{state_variable_name}{compartment_index}``. For receptor state
123variables, use the receptor index ``{state_variable_name}{receptor_index}``:
124
125.. code-block:: Python
126
127 mm = nest.Create('multimeter', 1, {'record_from': ['v_comp0', ...]})
128
129Current generators can be connected to the model. In this case, the receptor
130type is the compartment index:
131
132.. code-block:: Python
133
134 dc = nest.Create('dc_generator', {...})
135 nest.Connect(dc, cm, syn_spec={..., 'receptor_type': 0})
136
137Parameters
138++++++++++
139
140Note that the compartmental model does not explicitly ensure that units are consistent.
141Therefore, it is on the user to ensure that units are consistent throughout the model.
142The quantities that have fixed units are membrane voltage [mV] and time [ms].
143Other units need to be consistent: if e.g. conductances are in uS, that means
144that the associated currents will be uS*mV = nA. By consequence, the capacitance needs to
145be in nF to ensure that the capacitive current is also in nA. This further means
146that the connection weights to receptors are in uS, and that the amplitudes of current
147injectors are in nA.
148
149The following parameters can be set in the status dictionary.
150
151=========== ======= ===========================================================
152 V_th mV Spike threshold (default: -55.0 mV)
153=========== ======= ===========================================================
154
155The following parameters can be used when adding compartments using ``SetStatus()``
156
157=========== ======= ===============================================================
158 C_m nF Capacitance of compartment (default: 1 nF)
159 g_C uS Coupling conductance with parent compartment (default: 0.01 uS)
160 g_L uS Leak conductance of the compartment (default: 0.1 uS)
161 e_L mV Leak reversal of the compartment (default: -70. mV)
162 v_comp mV Initialization voltage of the compartment (default: -75. mV)
163=========== ======= ===============================================================
164
165Ion channels and receptor types for the default model are hardcoded.
166For ion channels, there is a Na-channel and a K-channel. Parameters can be set
167by specifying the following entries in the ``SetStatus`` dictionary argument:
168
169=========== ======= ===========================================================
170 gbar_Na uS Maximal conductance Na channel (default: 0 uS)
171 e_Na mV Reversal Na channel default (default: 50 mV)
172 gbar_K uS Maximal conductance K channel (default: 0 uS)
173 e_K mV Reversal K channel (default: -85 mV)
174=========== ======= ===========================================================
175
176For receptors, the choice is ``AMPA``, ``GABA`` or ``NMDA`` or ``AMPA_NMDA``.
177Ion channels and receptor types can be customized with :doc:`NESTML <nestml:index>`.
178
179If ``receptor_type`` is AMPA
180
181=========== ======= ===========================================================
182 e_AMPA mV AMPA reversal (default 0 mV)
183 tau_r_AMPA ms AMPA rise time (default .2 ms)
184 tau_d_AMPA ms AMPA decay time (default 3. ms)
185=========== ======= ===========================================================
186
187If ``receptor_type`` is GABA
188
189=========== ======= ===========================================================
190 e_GABA mV GABA reversal (default -80 mV)
191 tau_r_GABA ms GABA rise time (default .2 ms)
192 tau_d_GABA ms GABA decay time (default 10. ms)
193=========== ======= ===========================================================
194
195If ``receptor_type`` is NMDA
196
197=========== ======= ===========================================================
198 e_NMDA mV NMDA reversal (default 0 mV)
199 tau_r_NMDA ms NMDA rise time (default .2 ms)
200 tau_d_NMDA ms NMDA decay time (default 43. ms)
201=========== ======= ===========================================================
202
203If ``receptor_type`` is AMPA_NMDA
204
205============ ======= ===========================================================
206 e_AMPA_NMDA mV NMDA reversal (default 0 mV)
207 tau_r_AMPA ms AMPA rise time (default .2 ms)
208 tau_d_AMPA ms AMPA decay time (default 3. ms)
209 tau_r_NMDA ms NMDA rise time (default .2 ms)
210 tau_d_NMDA ms NMDA decay time (default 43. ms)
211 NMDA_ratio (1) Ratio of NMDA versus AMPA channels
212============ ======= ===========================================================
213
214Sends
215+++++
216
217SpikeEvent
218
219Receives
220++++++++
221
222SpikeEvent, CurrentEvent, DataLoggingRequest
223
224References
225++++++++++
226
227.. footbibliography::
228
229See also
230++++++++
231
232NEURON simulator ;-D
233
234Examples using this model
235+++++++++++++++++++++++++
236
237.. listexamples:: cm_default
238
239EndUserDocs*/
240
241void register_cm_default( const std::string& name );
242
244{
245
246public:
247 cm_default();
248 cm_default( const cm_default& );
249
250 using Node::handle;
252
253 size_t send_test_event( Node&, size_t, synindex, bool ) override;
254
255 void handle( SpikeEvent& ) override;
256 void handle( CurrentEvent& ) override;
257 void handle( DataLoggingRequest& ) override;
258
259 size_t handles_test_event( SpikeEvent&, size_t ) override;
260 size_t handles_test_event( CurrentEvent&, size_t ) override;
261 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
262
263 void get_status( Dictionary& ) const override;
264 void set_status( const Dictionary& ) override;
265
266private:
267 void add_compartment_( const Dictionary& dd );
268 void add_receptor_( const Dictionary& dd );
269
271 void pre_run_hook() override;
272
273 void update( Time const&, const long, const long ) override;
274
276 std::vector< RingBuffer > syn_buffers_;
277
278 // To record variables with DataAccessFunctor
279 double
280 get_state_element( size_t elem )
281 {
282 return *recordables_values[ elem ];
283 };
284
285 // The next classes need to be friends to access the State_ class/member
286 friend class DataAccessFunctor< cm_default >;
287 friend class DynamicRecordablesMap< cm_default >;
288 friend class DynamicUniversalDataLogger< cm_default >;
289
290 /*
291 internal ordering of all recordables in a vector
292 the vector 'recordables_values' stores pointers to all state variables
293 present in the model
294 */
295 std::vector< std::string > recordables_names;
296 std::vector< double* > recordables_values;
297
302
303 double V_th_;
304};
305
306
307inline size_t
308cm_default::send_test_event( Node& target, size_t receptor_type, synindex, bool )
309{
310 SpikeEvent e;
311 e.set_sender( *this );
312 return target.handles_test_event( e, receptor_type );
313}
314
315inline size_t
317{
318 if ( receptor_type >= syn_buffers_.size() )
319 {
320 std::ostringstream msg;
321 msg << "Valid spike receptor ports for " << get_name() << " are in ";
322 msg << "[" << 0 << ", " << syn_buffers_.size() << "[";
323 throw UnknownPort( receptor_type, msg.str() );
324 }
325 return receptor_type;
326}
327
328inline size_t
330{
331 // if get_compartment returns nullptr, raise the error
332 if ( not c_tree_.get_compartment( long( receptor_type ), c_tree_.get_root(), 0 ) )
333 {
334 std::ostringstream msg;
335 msg << "Valid current receptor ports for " << get_name() << " are in ";
336 msg << "[" << 0 << ", " << c_tree_.get_size() << "[";
337 throw UnknownPort( receptor_type, msg.str() );
338 }
339 return receptor_type;
340}
341
342inline size_t
344{
345 if ( receptor_type != 0 )
346 {
347 throw UnknownReceptorType( receptor_type, get_name() );
348 }
349 return logger_.connect_logging_device( dlr, recordablesMap_ );
350}
351
352} // namespace
353
354#endif /* #ifndef CM_DEFAULT_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
A node which archives spike history for the purposes of spike-timing dependent plasticity (STDP)
Definition archiving_node.h:49
Definition cm_tree.h:147
Compartment * get_compartment(const long compartment_index) const
get a compartment pointer from the tree
Definition cm_tree.cpp:230
long get_size() const
get tree size (number of compartments)
Definition cm_tree.h:202
Compartment * get_root() const
Definition cm_tree.h:195
Event for electrical currents.
Definition event.h:569
Class that reads out state vector elements, used by UniversalDataLogger.
Definition recordables_map.h:136
Request data to be logged/logged data to be sent.
Definition event.h:636
Map names of recordables to DataAccessFunctors.
Definition recordables_map.h:170
Base class for all NEST network objects.
Definition node.h:99
std::string get_name() const
Return class name.
Definition node.cpp:105
Event for spike information.
Definition event.h:418
Definition nest_time.h:135
To be thrown if a port does not exists.
Definition exceptions.h:461
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
Definition cm_default.h:244
DynamicUniversalDataLogger< cm_default > logger_
Logger for all analog data.
Definition cm_default.h:301
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition cm_default.cpp:111
void add_compartment_(const Dictionary &dd)
Definition cm_default.cpp:216
void update(Time const &, const long, const long) override
Update and spike handling functions.
Definition cm_default.cpp:313
double get_state_element(size_t elem)
Definition cm_default.h:280
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition cm_default.cpp:80
double V_th_
Definition cm_default.h:303
friend class DynamicUniversalDataLogger< cm_default >
Definition cm_default.h:288
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition cm_default.cpp:295
std::vector< std::string > recordables_names
Definition cm_default.h:295
void handle(SpikeEvent &) override
Handle incoming spike events.
Definition cm_default.cpp:336
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition cm_default.h:308
std::vector< RingBuffer > syn_buffers_
Definition cm_default.h:276
cm_default()
Definition cm_default.cpp:54
CompTree c_tree_
Definition cm_default.h:275
void add_receptor_(const Dictionary &dd)
Definition cm_default.cpp:233
std::vector< double * > recordables_values
Definition cm_default.h:296
void init_recordables_pointers_()
Definition cm_default.cpp:262
DynamicRecordablesMap< cm_default > recordablesMap_
Mapping of recordables names to access functions.
Definition cm_default.h:299
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition cm_default.h:316
virtual size_t handles_test_event(SpikeEvent &, size_t receptor_type)
Check if the node can handle a particular event and receptor type.
Definition node.cpp:271
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:265
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_cm_default(const std::string &name)
Definition cm_default.cpp:32
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115