NEST main@caf0ae8
 
Loading...
Searching...
No Matches
spin_detector.h
Go to the documentation of this file.
1/*
2 * spin_detector.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 SPIN_DETECTOR_H
24#define SPIN_DETECTOR_H
25
26
27// C++ includes:
28#include <vector>
29
30// Includes from nestkernel:
31#include "device_node.h"
32#include "event.h"
33#include "exceptions.h"
34#include "nest_timeconverter.h"
35#include "nest_types.h"
36#include "recording_device.h"
37
38namespace nest
39{
40
41/* BeginUserDocs: device, detector
42
43Short description
44+++++++++++++++++
45
46Device for detecting binary states in neurons
47
48Description
49+++++++++++
50
51The ``spin_detector`` is a recording device. It is used to decode and
52record binary states from spiking activity from a single neuron, or
53from multiple neurons at once. A single spike signals the 0 state, two
54spikes at the same time signal the 1 state. If a neuron is in the 0 or
551 state and emits the spiking activity corresponding to the same
56state, the same state is recorded again. Therefore, it is not only
57the transitions that are recorded. Data is recorded in memory or to
58file as for all RecordingDevices. By default, node ID, time, and binary
59state (0 or 1) for each decoded state is recorded. The state can be
60accessed by calling ``detector.events["weight"]``.
61
62The ``spin_detector`` will record binary state times with full
63precision from neurons emitting precisely timed spikes.
64
65Any node from which binary states are to be recorded, must be
66connected to the ``spin_detector`` using the Connect command. Any
67connection weight and delay will be ignored for that connection.
68
69Simulations progress in cycles defined by the minimum delay. During
70each cycle, the ``spin_detector`` records (stores in memory or writes to
71screen/file) the states during the previous cycle. As a consequence,
72any state information that was decoded during the cycle immediately
73preceding the end of the simulation time will not be recorded. Setting
74the /stop parameter to at the latest one ``min_delay`` period before the
75end of the simulation time ensures that all binary states desired to
76be recorded, are recorded.
77
78States are not necessarily written to file in chronological order.
79
80Receives
81++++++++
82
83SpikeEvent
84
85Examples using this model
86+++++++++++++++++++++++++
87
88.. listexamples:: spin_detector
89
90EndUserDocs */
91
100void register_spin_detector( const std::string& name );
101
103{
104
105public:
108
109 bool
110 has_proxies() const override
111 {
112 return false;
113 }
114 bool
115 local_receiver() const override
116 {
117 return true;
118 }
119
120 std::string
121 get_element_type() const override
122 {
123 return names::recorder;
124 }
125
131 using Node::handle;
134
135 void handle( SpikeEvent& ) override;
136
137 size_t handles_test_event( SpikeEvent&, size_t ) override;
138
139 Type get_type() const override;
140 SignalType receives_signal() const override;
141
142 void get_status( Dictionary& ) const override;
143 void set_status( const Dictionary& ) override;
144
145 void calibrate_time( const TimeConverter& tc ) override;
146
147private:
148 void init_buffers_() override;
149 void pre_run_hook() override;
150
159 void update( Time const&, const long, const long ) override;
160
164};
165
166inline size_t
168{
169 if ( receptor_type != 0 )
170 {
171 throw UnknownReceptorType( receptor_type, get_name() );
172 }
173 return 0;
174}
175
176inline SignalType
178{
179 return BINARY;
180}
181
182inline void
187
188} // namespace
189
190#endif /* #ifndef SPIN_DETECTOR_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
virtual SignalType receives_signal() const
Definition node.h:974
std::string get_name() const
Return class name.
Definition node.cpp:105
Base class for all recording devices.
Definition recording_device.h:157
Type
Definition recording_device.h:169
Event for spike information.
Definition event.h:418
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
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
Definition spin_detector.h:103
void handle(SpikeEvent &) override
Handle incoming spike events.
Definition spin_detector.cpp:117
SpikeEvent last_event_
Definition spin_detector.h:162
spin_detector()
Definition spin_detector.cpp:45
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition spin_detector.cpp:86
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition spin_detector.cpp:110
std::string get_element_type() const override
Return the element type of the node.
Definition spin_detector.h:121
Type get_type() const override
Definition spin_detector.cpp:80
size_t handles_test_event(SpikeEvent &, size_t) override
Check if the node can handle a particular event and receptor type.
Definition spin_detector.h:167
Time t_last_in_spike_
Definition spin_detector.h:163
bool has_proxies() const override
Returns true if the node has proxies on remote threads.
Definition spin_detector.h:110
size_t last_in_node_id_
Definition spin_detector.h:161
bool local_receiver() const override
Returns true if the node only receives events from nodes/devices on the same thread.
Definition spin_detector.h:115
SignalType receives_signal() const override
Definition spin_detector.h:177
void calibrate_time(const TimeConverter &tc) override
Re-calculate time-based properties of the node.
Definition spin_detector.h:183
void update(Time const &, const long, const long) override
Update detector by recording spikes.
Definition spin_detector.cpp:70
void init_buffers_() override
Configure persistent internal data structures.
Definition spin_detector.cpp:59
void pre_run_hook() override
Set internal variables before calls to SimulationManager::run()
Definition spin_detector.cpp:64
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 recorder("recorder")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_spin_detector(const std::string &name)
Spin detector class.
Definition spin_detector.cpp:39
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:165
@ BINARY
Definition nest_types.h:168