NEST  2.6.0,not_revisioned_source_dir@0
sinusoidal_poisson_generator.h
Go to the documentation of this file.
1 /*
2  * sinusoidal_poisson_generator.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 SINUSOIDAL_POISSON_GENERATOR_H
24 #define SINUSOIDAL_POISSON_GENERATOR_H
25 
26 #include "nest.h"
27 #include "event.h"
28 #include "node.h"
29 #include "stimulating_device.h"
30 #include "poisson_randomdev.h"
31 #include "connection.h"
32 #include "universal_data_logger.h"
33 
34 namespace nest {
35 
36  class Network;
37 
38  /* BeginDocumentation
39  Name: sinusoidal_poisson_generator - Generates sinusoidally modulated Poisson spike trains.
40 
41  Description:
42  sinusoidal_poisson_generator generates sinusoidally modulated Poisson spike trains. By default,
43  each target of the generator will receive a different spike train.
44 
45  The instantaneous rate of the process is given by
46 
47  f(t) = max(0, dc + ac sin ( 2 pi freq t + phi )) >= 0
48 
49  Parameters:
50  The following parameters can be set in the status dictionary:
51 
52  dc double - Mean firing rate in spikes/second, default: 0 s^-1
53  ac double - Firing rate modulation amplitude in spikes/second, default: 0 s^-1
54  freq double - Modulation frequency in Hz, default: 0 Hz
55  phi double - Modulation phase in radian, default: 0
56 
57  individual_spike_trains bool - See note below, default: true
58 
59  Remarks:
60  - If ac > dc, firing rate is cut off at zero. In this case, the mean
61  firing rate will be less than dc.
62  - The state of the generator is reset on calibration.
63  - The generator does not support precise spike timing.
64  - You can use the multimeter to sample the rate of the generator.
65  - The generator will create different trains if run at different
66  temporal resolutions.
67 
68  - Individual spike trains vs single spike train:
69  By default, the generator sends a different spike train to each of its targets.
70  If /individual_spike_trains is set to false using either SetDefaults or CopyModel
71  before a generator node is created, the generator will send the same spike train
72  to all of its targets.
73 
74  Receives: DataLoggingRequest
75 
76  Sends: SpikeEvent
77 
78  FirstVersion: July 2006, Oct 2009, May 2013
79  Author: Hans Ekkehard Plesser
80  SeeAlso: poisson_generator, sinusoidal_gamma_generator
81  */
82 
84  {
85 
86  public:
87 
90 
92 
97  using Node::handle;
99  using Node::event_hook;
100 
101  void handle(DataLoggingRequest &);
102 
104 
105  void get_status(DictionaryDatum &) const;
106  void set_status(const DictionaryDatum &);
107 
109  bool has_proxies() const { return not P_.individual_spike_trains_; }
110 
112  bool local_receiver() const { return true; }
113 
114  private:
115  void init_state_(const Node&);
116  void init_buffers_();
117  void calibrate();
118  void event_hook(DSSpikeEvent&);
119 
120  void update(Time const &, const long_t, const long_t);
121 
122  struct Parameters_ {
125 
128 
131 
134 
137 
138  Parameters_();
139  Parameters_(const Parameters_& );
140  Parameters_& operator=(const Parameters_& p); // Copy constructor EN
141 
142  void get(DictionaryDatum&) const;
143 
149  void set(const DictionaryDatum&, const sinusoidal_poisson_generator&);
150  };
151 
152  struct State_ {
153 
156 
158 
159  State_();
160 
161  void get(DictionaryDatum&) const;
162  void set(const DictionaryDatum&, const Parameters_&);
163  };
164 
165  // ------------------------------------------------------------
166 
167  // These friend declarations must be precisely here.
169  friend class UniversalDataLogger<sinusoidal_poisson_generator>;
170 
171  // ----------------------------------------------------------------
172 
176  struct Buffers_ {
180  };
181 
182  // ------------------------------------------------------------
183 
184  struct Variables_ {
186 
190  };
191 
192  double_t get_rate_() const { return 1000.0 * S_.rate_; }
193 
194  // ------------------------------------------------------------
195 
198 
203 
204  };
205 
206  inline
208  {
209  device_.enforce_single_syn_type(syn_id);
210 
211  // to ensure correct overloading resolution, we need explicit event types
212  // therefore, we need to duplicate the code here
213  if ( dummy_target )
214  {
215  DSSpikeEvent e;
216  e.set_sender(*this);
217  return target.handles_test_event(e, receptor_type);
218  }
219  else
220  {
221  SpikeEvent e;
222  e.set_sender(*this);
223  return target.handles_test_event(e, receptor_type);
224  }
225  }
226 
227  inline
229  {
230  if (receptor_type != 0)
231  throw UnknownReceptorType(receptor_type, get_name());
232  return B_.logger_.connect_logging_device(dlr, recordablesMap_);
233  }
234 
235  inline
237  {
238  P_.get(d);
239  S_.get(d);
240  device_.get_status(d);
241  (*d)[names::recordables] = recordablesMap_.get_list();
242  }
243 
244  inline
246  {
247  Parameters_ ptmp = P_; // temporary copy in case of errors
248 
249  ptmp.set(d, *this); // throws if BadProperty
250  // We now know that ptmp is consistent. We do not write it back
251  // to P_ before we are also sure that the properties to be set
252  // in the parent class are internally consistent.
253  device_.set_status(d);
254 
255  // if we get here, temporaries contain consistent set of properties
256  P_ = ptmp;
257  }
258 
259 } // namespace
260 
261 #endif // SINUSOIDAL_POISSON_GENERATOR_H
const Name recordables("recordables")
List of recordable state data (Device parameters)
Definition: nest_names.h:244
Buffers_(sinusoidal_poisson_generator &)
Definition: sinusoidal_poisson_generator.cpp:87
Buffers of the model.
Definition: sinusoidal_poisson_generator.h:176
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: sinusoidal_poisson_generator.cpp:169
void get_status(DictionaryDatum &) const
Definition: sinusoidal_poisson_generator.h:236
void handle(DataLoggingRequest &)
Handler for universal data logging request.
Definition: sinusoidal_poisson_generator.cpp:263
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Declarations for base class Node.
double_t rate_
current rate, kept for recording
Definition: sinusoidal_poisson_generator.h:157
Parameters_ P_
Definition: sinusoidal_poisson_generator.h:199
Definition: sinusoidal_poisson_generator.h:83
friend class UniversalDataLogger< sinusoidal_poisson_generator >
Definition: sinusoidal_poisson_generator.h:169
"Callback request event" for use in Device.
Definition: event.h:374
Definition: sinusoidal_poisson_generator.h:184
Base class for common properties of Stimulating Devices.
Definition: stimulating_device.h:117
void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition: sinusoidal_poisson_generator.cpp:250
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
void init_state_(const Node &)
Private function to initialize the state of a node to model defaults.
Definition: sinusoidal_poisson_generator.cpp:161
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: sinusoidal_poisson_generator.cpp:195
Buffers_ B_
Definition: sinusoidal_poisson_generator.h:202
double_t cos_
cos(h om) in propagator
Definition: sinusoidal_poisson_generator.h:189
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: sinusoidal_poisson_generator.h:207
double_t phi_
phase in radian
Definition: sinusoidal_poisson_generator.h:127
void set(const DictionaryDatum &, const sinusoidal_poisson_generator &)
Set values from dicitonary.
Definition: sinusoidal_poisson_generator.cpp:113
double_t ac_
AC amplitude in spikes/s.
Definition: sinusoidal_poisson_generator.h:133
bool local_receiver() const
Allow multimeter to connect to local instances.
Definition: sinusoidal_poisson_generator.h:112
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
StimulatingDevice< SpikeEvent > device_
Definition: sinusoidal_poisson_generator.h:196
port handles_test_event(DataLoggingRequest &, rport)
Definition: sinusoidal_poisson_generator.h:228
double_t dc_
DC amplitude in spikes/s.
Definition: sinusoidal_poisson_generator.h:130
librandom::PoissonRandomDev poisson_dev_
random deviate generator
Definition: sinusoidal_poisson_generator.h:185
State_()
Sets default state value.
Definition: sinusoidal_poisson_generator.cpp:82
double_t sin_
time resolution (ms)
Definition: sinusoidal_poisson_generator.h:188
double_t y_1_
Definition: sinusoidal_poisson_generator.h:155
UniversalDataLogger< sinusoidal_poisson_generator > logger_
Definition: sinusoidal_poisson_generator.h:179
Map names of recordables to data access functions.
Definition: recordables_map.h:58
double_t om_
temporal frequency in radian/ms.
Definition: sinusoidal_poisson_generator.h:124
Definition: nest_time.h:130
static RecordablesMap< sinusoidal_poisson_generator > recordablesMap_
Definition: sinusoidal_poisson_generator.h:197
double_t h_
Definition: sinusoidal_poisson_generator.h:187
std::string get_name() const
Return class name.
Definition: node.cpp:83
void set(const DictionaryDatum &, const Parameters_ &)
Set values from dicitonary.
Exception to be thrown if the specified receptor type does not exist in the node. ...
Definition: exceptions.h:254
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
Class PoissonRandomDev Create Poisson distributed random numbers.
Definition: poisson_randomdev.h:103
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: sinusoidal_poisson_generator.cpp:100
double_t get_rate_() const
Definition: sinusoidal_poisson_generator.h:192
Variables_ V_
Definition: sinusoidal_poisson_generator.h:201
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
double double_t
Double precision floating point numbers.
Definition: nest.h:93
Parameters_ & operator=(const Parameters_ &p)
Definition: sinusoidal_poisson_generator.cpp:68
double_t y_0_
Two-component oscillator state vector, see Rotter&Diesmann.
Definition: sinusoidal_poisson_generator.h:154
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
State_ S_
Definition: sinusoidal_poisson_generator.h:200
sinusoidal_poisson_generator()
Definition: sinusoidal_poisson_generator.cpp:138
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: sinusoidal_poisson_generator.cpp:109
Request data to be logged/logged data to be sent.
Definition: event.h:486
void calibrate()
Re-calculate dependent parameters of the node.
Definition: sinusoidal_poisson_generator.cpp:175
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
Default types used by the NEST kernel.
Definition: sinusoidal_poisson_generator.h:152
Event for spike information.
Definition: event.h:320
Base class for all NEST network objects.
Definition: node.h:96
bool has_proxies() const
Model can be switched between proxies (single spike train) and not.
Definition: sinusoidal_poisson_generator.h:109
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition: node.cpp:301
const Name p("p")
current release probability (Tsodyks2_connection)
Definition: nest_names.h:218
void set_status(const DictionaryDatum &)
Definition: sinusoidal_poisson_generator.h:245
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
Definition: sinusoidal_poisson_generator.h:122
Parameters_()
Sets default parameter values.
Definition: sinusoidal_poisson_generator.cpp:51
const double e
Definition: numerics.cpp:62
bool individual_spike_trains_
Emit individual spike trains for each target, or same for all?
Definition: sinusoidal_poisson_generator.h:136