NEST main@caf0ae8
 
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
156 std::string
157 get_element_type() const override
158 {
159 return names::recorder;
160 }
161
167 using Node::handle;
169 using Node::sends_signal;
170
171 size_t send_test_event( Node&, size_t, synindex, bool ) override;
172
173 void handle( DataLoggingReply& ) override;
174
175 SignalType sends_signal() const override;
176
177 Type get_type() const override;
178 void get_status( Dictionary& ) const override;
179 void set_status( const Dictionary& ) override;
180
181 void calibrate_time( const TimeConverter& tc ) override;
182
183protected:
184 void pre_run_hook() override;
185
193 void update( Time const&, const long, const long ) override;
194
195private:
196 struct Buffers_;
197
199 {
202 std::vector< std::string > record_from_;
203
204 Parameters_();
205 Parameters_( const Parameters_& );
207 void get( Dictionary& ) const;
208 void set( const Dictionary&, const Buffers_&, Node* node );
209 };
210
211 // ------------------------------------------------------------
212
213
214 struct Buffers_
215 {
220 Buffers_();
221
223 };
224
225 // ------------------------------------------------------------
226
227
230};
231
232
233inline void
235{
237 P_.get( d );
238
239 if ( is_model_prototype() )
240 {
241 return; // no data to collect
242 }
243
244 // if we are the device on thread 0, also get the data from the
245 // siblings on other threads
246 if ( get_thread() == 0 )
247 {
248 const std::vector< Node* > siblings = kernel().node_manager.get_thread_siblings( get_node_id() );
249 std::vector< Node* >::const_iterator s;
250 for ( s = siblings.begin() + 1; s != siblings.end(); ++s )
251 {
252 ( *s )->get_status( d );
253 }
254 }
255}
256
257inline void
259{
260 // protect multimeter from being frozen
261 bool freeze = false;
262 if ( d.update_value( names::frozen, freeze ) and freeze )
263 {
264 throw BadProperty( "multimeter cannot be frozen." );
265 }
266
267 Parameters_ ptmp = P_;
268 ptmp.set( d, B_, this );
269
271 P_ = ptmp;
272}
273
274inline SignalType
276{
277 return ALL;
278}
279
280inline void
286
287
288//
289// Declaration of voltmeter subclass
290//
291
292class voltmeter : public multimeter
293{
294public:
295 voltmeter();
296 voltmeter( const voltmeter& );
297};
298
299} // namespace nest
300
301#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:234
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:275
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:281
std::string get_element_type() const override
Return the element type of the node.
Definition multimeter.h:157
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:229
Parameters_ P_
Definition multimeter.h:228
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition multimeter.h:258
void update(Time const &, const long, const long) override
Collect and output membrane potential information.
Definition multimeter.cpp:173
bool has_proxies() const override
Definition multimeter.h:151
Definition multimeter.h:293
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:215
Buffers_()
Does this multimeter have targets? Placed here since it is implementation detail.
Definition multimeter.cpp:103
bool has_targets_
Definition multimeter.h:222
Definition multimeter.h:199
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:202
Parameters_()
Definition multimeter.cpp:76
Time offset_
offset relative to 0, in ms
Definition multimeter.h:201
Parameters_ & operator=(const Parameters_ &)
Definition multimeter.cpp:92
Time interval_
recording interval, in ms
Definition multimeter.h:200