NEST  2.6.0,not_revisioned_source_dir@0
spike_detector.h
Go to the documentation of this file.
1 /*
2  * spike_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 SPIKE_DETECTOR_H
24 #define SPIKE_DETECTOR_H
25 
26 
27 #include <vector>
28 #include "nest.h"
29 #include "event.h"
30 #include "node.h"
31 #include "recording_device.h"
32 #include "exceptions.h"
33 
34 /* BeginDocumentation
35 
36 Name: spike_detector - Device for detecting single spikes.
37 
38 Description:
39 The spike_detector device is a recording device. It is used to record
40 spikes from a single neuron, or from multiple neurons at once. Data
41 is recorded in memory or to file as for all RecordingDevices.
42 By default, GID and time of each spike is recorded.
43 
44 The spike detector can also record spike times with full precision
45 from neurons emitting precisely timed spikes. Set /precise_times to
46 achieve this.
47 
48 Any node from which spikes are to be recorded, must be connected to
49 the spike detector using a normal connect command. Any connection weight
50 and delay will be ignored for that connection.
51 
52 Simulations progress in cycles defined by the minimum delay. During each
53 cycle, the spike detector records (stores in memory or writes to screen/file)
54 the spikes generated during the previous cycle. As a consequence, any
55 spikes generated during the cycle immediately preceding the end of the simulation
56 time will not be recorded. Setting the /stop parameter to at the latest one
57 min_delay period before the end of the simulation time ensures that all spikes
58 desired to be recorded, are recorded.
59 
60 Spike are not necessarily written to file in chronological order.
61 
62 Receives: SpikeEvent
63 
64 SeeAlso: spike_detector, Device, RecordingDevice
65 */
66 
67 
68 namespace nest
69 {
70 
71  class Network;
72 
96  class spike_detector : public Node
97  {
98 
99  public:
100 
101  spike_detector();
103 
104  void set_has_proxies(const bool hp);
105  bool has_proxies() const { return has_proxies_; }
106  bool potential_global_receiver() const {return true;}
107  void set_local_receiver(const bool lr);
108  bool local_receiver() const {return local_receiver_;}
109 
114  using Node::handle;
116 
117  void handle(SpikeEvent &);
118 
120 
121  void get_status(DictionaryDatum &) const;
122  void set_status(const DictionaryDatum &) ;
123 
124  private:
125  void init_state_(Node const&);
126  void init_buffers_();
127  void calibrate();
128  void finalize();
129 
139  void update(Time const &, const long_t, const long_t);
140 
160  struct Buffers_ {
161  std::vector<std::vector<Event*> > spikes_;
162  };
163 
166 
170  };
171 
172  inline
174  {
175  has_proxies_ = hp;
176  }
177 
178  inline
180  {
181  local_receiver_ = lr;
182  }
183 
184  inline
186  {
187  if (receptor_type != 0)
188  throw UnknownReceptorType(receptor_type, get_name());
189  return 0;
190  }
191 
192  inline
194  {
195  device_.finalize();
196  }
197 
198 } // namespace
199 
200 #endif /* #ifndef SPIKE_DETECTOR_H */
void finalize()
Finalize node.
Definition: spike_detector.h:193
bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: spike_detector.h:105
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
bool local_receiver_
Definition: spike_detector.h:169
void init_state_(Node const &)
Private function to initialize the state of a node to model defaults.
Definition: spike_detector.cpp:50
Definition: lockptrdatum.h:40
Declarations for base class Node.
void set_status(const DictionaryDatum &)
Definition: spike_detector.cpp:112
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: spike_detector.cpp:120
void set_has_proxies(const bool hp)
Sets has_proxies_ member variable (to switch to global spike detection mode)
Definition: spike_detector.h:173
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
void get_status(DictionaryDatum &) const
Definition: spike_detector.cpp:96
bool has_proxies_
Definition: spike_detector.h:168
bool potential_global_receiver() const
Returns true for potential global receivers (e.g.
Definition: spike_detector.h:106
Base class for all recording devices.
Definition: recording_device.h:214
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: spike_detector.cpp:57
Definition: nest_time.h:130
std::string get_name() const
Return class name.
Definition: node.cpp:83
Exception to be thrown if the specified receptor type does not exist in the node. ...
Definition: exceptions.h:254
void calibrate()
Re-calculate dependent parameters of the node.
Definition: spike_detector.cpp:65
RecordingDevice device_
Definition: spike_detector.h:164
Spike detector class.
Definition: spike_detector.h:96
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
Buffer for incoming spikes.
Definition: spike_detector.h:160
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
std::vector< std::vector< Event * > > spikes_
Definition: spike_detector.h:161
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: spike_detector.h:185
virtual port handles_test_event(SpikeEvent &, rport receptor_type)
Check if the node can handle a particular event and receptor type.
Definition: node.cpp:203
bool user_set_precise_times_
Definition: spike_detector.h:167
spike_detector()
Definition: spike_detector.cpp:34
void update(Time const &, const long_t, const long_t)
Update detector by recording spikes.
Definition: spike_detector.cpp:80
Default types used by the NEST kernel.
Buffers_ B_
Definition: spike_detector.h:165
Event for spike information.
Definition: event.h:320
void finalize()
Flush output stream if requested.
Definition: recording_device.cpp:456
Base class for all NEST network objects.
Definition: node.h:96
void set_local_receiver(const bool lr)
Sets local_receiver_ member variable (to switch to global spike detection mode)
Definition: spike_detector.h:179
bool local_receiver() const
Returns true if the node only receives events from nodes/devices on the same thread.
Definition: spike_detector.h:108
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96