NEST main@a355080
 
Loading...
Searching...
No Matches
multimeter.h
Go to the documentation of this file.
1/*
2 * multimeter.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 MULTIMETER_H
24#define MULTIMETER_H
25
26// C++ includes:
27#include <vector>
28
29// Includes from nestkernel:
30#include "connection.h"
31#include "device_node.h"
32#include "exceptions.h"
33#include "kernel_manager.h"
34#include "nest_timeconverter.h"
35#include "recording_device.h"
36
37/* BeginUserDocs: device, recorder
38
39Short description
40+++++++++++++++++
41
42Sampling continuous quantities from neurons
43
44Description
45+++++++++++
46
47Most sampling use cases are covered by the ``multimeter``, which
48allows to record analog values from neurons. Models which have such
49values expose a ``recordables`` property that lists all recordable
50quantities. This property can be inspected using ``GetDefaults`` on
51the model class or ``GetStatus`` on a model instance. It cannot be
52changed by the user.
53
54::
55
56 >>> nest.GetDefaults('iaf_cond_alpha')['recordables']
57 ['g_ex', 'g_in', 't_ref_remaining', 'V_m']
58
59The ``record_from`` property of a ``multimeter`` (a list, empty by
60default) can be set to contain the name(s) of one or more of these
61recordables to have them sampled during simulation.
62
63::
64
65 mm = nest.Create('multimeter', 1, {'record_from': ['V_m', 'g_ex'],
66 'record_to': 'memory'})
67
68The sampling interval for recordings (given in ms) can be controlled
69using the ``multimeter`` parameter ``interval``. The default value of
701.0 ms can be changed by supplying a new value either in the call to
71``Create`` or by using ``SetStatus`` on the model instance. To sample
72values at every simulation time step, use
73
74::
75
76 nest.SetStatus(mm, {'interval': nest.resolution})
77
78The recording interval must be greater than or equal to the
79:ref:`simulation resolution <simulation_resolution>`, which defaults
80to 0.1 ms.
81
82.. warning::
83
84 The set of variables to record from and the recording interval must
85 be set **before** the ``multimeter`` is connected to any neuron.
86 These properties cannot be changed afterwards.
87
88After configuration, a ``multimeter`` can be connected to the neurons
89it should record from by using the standard ``Connect`` routine.
90
91::
92
93 neurons = nest.Create('iaf_psc_alpha', 100)
94 nest.Connect(mm, neurons)
95
96To learn more about possible connection patterns and additional
97options when using ``Connect``, see the guide on :ref:`connectivity
98concepts <connectivity_concepts>`.
99
100The above call to ``Connect`` would fail if the neurons would not
101support the sampling of the values ``V_m`` and ``g_ex``. It would also
102fail if carried out in the wrong direction, that is , trying to connect the
103neurons to `mm`.
104
105.. note::
106
107 A pre-configured ``multimeter`` is available under the name ``voltmeter``. Its
108 ``record_from`` property is already set to record the variable ``V_m``
109 from the neurons it is connected to.
110
111.. include:: ../models/recording_device.rst
112
113record_from
114 A list (default: `[]`) of parameters and state variables to sample
115 from the nodes, the multimeter is connected to. Potential
116 recordables are given in the corresponding model documentation.
117
118interval
119 A float (default: 1.0) specifying the interval in ms, at which
120 data is collected from the nodes, the multimeter is connected to.
121 Must be a multiple of the resolution.
122
123See also
124++++++++
125
126Examples using this model
127+++++++++++++++++++++++++
128
129.. listexamples:: multimeter
130
131EndUserDocs */
132
133namespace nest
134{
135
136void register_multimeter( const std::string& name );
137void register_voltmeter( const std::string& name );
138
140{
141
142public:
143 multimeter();
144 multimeter( const multimeter& );
145
150 bool
151 has_proxies() const override
152 {
153 return false;
154 }
155
159 bool
160 local_receiver() const override
161 {
162 return true;
163 }
164
165 std::string
166 get_element_type() const override
167 {
168 return names::recorder;
169 }
170
176 using Node::handle;
178 using Node::sends_signal;
179
180 size_t send_test_event( Node&, size_t, synindex, bool ) override;
181
182 void handle( DataLoggingReply& ) override;
183
184 SignalType sends_signal() const override;
185
186 Type get_type() const override;
187 void get_status( Dictionary& ) const override;
188 void set_status( const Dictionary& ) override;
189
190 void calibrate_time( const TimeConverter& tc ) override;
191
192protected:
193 void pre_run_hook() override;
194
202 void update( Time const&, const long, const long ) override;
203
204private:
205 struct Buffers_;
206
208 {
211 std::vector< std::string > record_from_;
212
213 Parameters_();
214 Parameters_( const Parameters_& );
216 void get( Dictionary& ) const;
217 void set( const Dictionary&, const Buffers_&, Node* node );
218 };
219
220 // ------------------------------------------------------------
221
222
223 struct Buffers_
224 {
229 Buffers_();
230
232 };
233
234 // ------------------------------------------------------------
235
236
239};
240
241
242inline void
244{
246 P_.get( d );
247
248 if ( is_model_prototype() )
249 {
250 return; // no data to collect
251 }
252
253 // if we are the device on thread 0, also get the data from the
254 // siblings on other threads
255 if ( get_thread() == 0 )
256 {
257 const std::vector< Node* > siblings = kernel().node_manager.get_thread_siblings( get_node_id() );
258 std::vector< Node* >::const_iterator s;
259 for ( s = siblings.begin() + 1; s != siblings.end(); ++s )
260 {
261 ( *s )->get_status( d );
262 }
263 }
264}
265
266inline void
268{
269 // protect multimeter from being frozen
270 bool freeze = false;
271 if ( d.update_value( names::frozen, freeze ) and freeze )
272 {
273 throw BadProperty( "multimeter cannot be frozen." );
274 }
275
276 Parameters_ ptmp = P_;
277 ptmp.set( d, B_, this );
278
280 P_ = ptmp;
281}
282
283inline SignalType
285{
286 return ALL;
287}
288
289inline void
295
296
297//
298// Declaration of voltmeter subclass
299//
300
301class voltmeter : public multimeter
302{
303public:
304 voltmeter();
305 voltmeter( const voltmeter& );
306};
307
308} // namespace nest
309
310#endif
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
Provide logged data through request transmitting reference.
Definition event.h:740
std::vector< Node * > get_thread_siblings(size_t n) const
Return a vector that contains the thread siblings.
Definition node_manager.cpp:484
Base class for all NEST network objects.
Definition node.h:99
size_t get_thread() const
Retrieve the number of the thread to which the node is assigned.
Definition node.h:1238
virtual SignalType sends_signal() const
Definition node.h:963
size_t get_node_id() const
Return global Network ID.
Definition node.h:1200
bool is_model_prototype() const
Returns true if node is model prototype.
Definition node.h:1226
Base class for all recording devices.
Definition recording_device.h:157
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition recording_device.cpp:130
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition recording_device.cpp:182
Type
Definition recording_device.h:169
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
Time from_old_tics(tic_t t_old) const
Converts a given number of tics with respect to old representation into a time object in current repr...
Definition nest_timeconverter.cpp:49
Definition nest_time.h:135
tic_t get_tics() const
Definition nest_time.h:474
Definition multimeter.h:140
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition multimeter.h:243
multimeter()
Definition multimeter.cpp:49
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition multimeter.cpp:167
SignalType sends_signal() const override
Definition multimeter.h:284
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition multimeter.cpp:64
void calibrate_time(const TimeConverter &tc) override
Re-calculate time-based properties of the node.
Definition multimeter.h:290
std::string get_element_type() const override
Return the element type of the node.
Definition multimeter.h:166
Type get_type() const override
Definition multimeter.cpp:222
void handle(DataLoggingReply &) override
Handler for universal data logging request.
Definition multimeter.cpp:197
Buffers_ B_
Definition multimeter.h:238
Parameters_ P_
Definition multimeter.h:237
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition multimeter.h:267
void update(Time const &, const long, const long) override
Collect and output membrane potential information.
Definition multimeter.cpp:173
bool local_receiver() const override
Definition multimeter.h:160
bool has_proxies() const override
Definition multimeter.h:151
Definition multimeter.h:302
voltmeter()
Definition multimeter.cpp:227
NodeManager node_manager
Definition kernel_manager.h:245
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
const std::string frozen("frozen")
const std::string recorder("recorder")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_voltmeter(const std::string &name)
Definition multimeter.cpp:43
void register_multimeter(const std::string &name)
Definition multimeter.cpp:37
KernelManager & kernel()
Definition kernel_manager.h:311
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:165
@ ALL
Definition nest_types.h:169
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Definition multimeter.h:224
Buffers_()
Does this multimeter have targets? Placed here since it is implementation detail.
Definition multimeter.cpp:103
bool has_targets_
Definition multimeter.h:231
Definition multimeter.h:208
void set(const Dictionary &, const Buffers_ &, Node *node)
Definition multimeter.cpp:117
void get(Dictionary &) const
Definition multimeter.cpp:109
std::vector< std::string > record_from_
which data to record
Definition multimeter.h:211
Parameters_()
Definition multimeter.cpp:76
Time offset_
offset relative to 0, in ms
Definition multimeter.h:210
Parameters_ & operator=(const Parameters_ &)
Definition multimeter.cpp:92
Time interval_
recording interval, in ms
Definition multimeter.h:209