NEST  2.6.0,not_revisioned_source_dir@0
sinusoidal_gamma_generator.h
Go to the documentation of this file.
1 /*
2  * sinusoidal_gamma_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_GAMMA_GENERATOR_H
24 #define SINUSOIDAL_GAMMA_GENERATOR_H
25 
26 #include "config.h"
27 
28 #ifdef HAVE_GSL
29 
30 #include "nest.h"
31 #include "randomgen.h"
32 #include "event.h"
33 #include "node.h"
34 #include "stimulating_device.h"
35 #include "connection.h"
36 #include "universal_data_logger.h"
37 
38 #include <vector>
39 
40 namespace nest{
41 
42  class Network;
43 
44  /* BeginDocumentation
45  Name: sinusoidal_gamma_generator - Generates sinusoidally modulated gamma spike trains.
46 
47  Description:
48  sinusoidal_gamma_generator generates sinusoidally modulated gamma spike trains. By default,
49  each target of the generator will receive a different spike train.
50 
51  The instantaneous rate of the process is given by
52 
53  f(t) = dc + ac sin ( 2 pi freq t + phi ) >= 0
54 
55  Parameters:
56  The following parameters can be set in the status dictionary:
57 
58  dc double - Mean firing rate in spikes/second, default: 0 s^-1
59  ac double - Firing rate modulation amplitude in spikes/second, default: 0 s^-1
60  freq double - Modulation frequency in Hz, default: 0 Hz
61  phi double - Modulation phase in radian, default: 0
62  order double - Gamma order (>= 1), default: 1
63 
64  individual_spike_trains bool - See note below, default: true
65 
66  Remarks:
67  - The gamma generator requires 0 <= ac <= dc.
68  - The state of the generator is reset on calibration.
69  - The generator does not support precise spike timing.
70  - You can use the multimeter to sample the rate of the generator.
71  - The generator will create different trains if run at different
72  temporal resolutions.
73 
74  - Individual spike trains vs single spike train:
75  By default, the generator sends a different spike train to each of its targets.
76  If /individual_spike_trains is set to false using either SetDefaults or CopyModel
77  before a generator node is created, the generator will send the same spike train
78  to all of its targets.
79 
80  Receives: DataLoggingRequest
81 
82  Sends: SpikeEvent
83 
84  References: Barbieri et al, J Neurosci Methods 105:25-37 (2001)
85  FirstVersion: October 2007, May 2013
86  Author: Hans E Plesser, Thomas Heiberg
87 
88  SeeAlso: sinusoidal_poisson_generator, gamma_sup_generator
89  */
90 
91 
121  {
122 
123  public:
124 
127 
129 
134  using Node::handle;
136  using Node::event_hook;
137 
138  void handle(DataLoggingRequest &);
139 
141 
142  void get_status(DictionaryDatum &) const;
143  void set_status(const DictionaryDatum &);
144 
146  bool has_proxies() const { return not P_.individual_spike_trains_; }
147 
149  bool local_receiver() const { return true; }
150 
151  private:
152  void init_state_(const Node&);
153  void init_buffers_();
154  void calibrate();
155  void event_hook(DSSpikeEvent&);
156 
157  void update(Time const &, const long_t, const long_t);
158 
159  struct Parameters_ {
162 
165 
168 
171 
174 
177 
187  size_t num_trains_;
188 
189  Parameters_();
190  Parameters_(const Parameters_& );
191  Parameters_& operator=(const Parameters_& p); // Copy constructor EN
192 
193  void get(DictionaryDatum&) const;
194 
200  void set(const DictionaryDatum&, const sinusoidal_gamma_generator&);
201  };
202 
203  struct State_ {
204 
206 
207  State_();
208 
209  void get(DictionaryDatum&) const;
210  void set(const DictionaryDatum&, const Parameters_&);
211  };
212 
213  // ------------------------------------------------------------
214 
215  // These friend declarations must be precisely here.
217  friend class UniversalDataLogger<sinusoidal_gamma_generator>;
218 
219  // ----------------------------------------------------------------
220 
224  struct Buffers_ {
228 
237  std::vector<double> t0_ms_;
238 
243  std::vector<double> Lambda_t0_;
244 
246  };
247 
248  // ------------------------------------------------------------
249 
250  struct Variables_ {
255  };
256 
257  double_t get_rate_() const { return 1000.0 * S_.rate_; }
258 
260  double_t deltaLambda_(const Parameters_&, double_t, double_t) const;
261 
263  double_t hazard_(port) const;
264 
267 
272  };
273 
274  inline
276  {
277  device_.enforce_single_syn_type(syn_id);
278 
279  // to ensure correct overloading resolution, we need explicit event types
280  // therefore, we need to duplicate the code here
282  {
283  if ( dummy_target )
284  {
285  DSSpikeEvent e;
286  e.set_sender(*this);
287  return target.handles_test_event(e, receptor_type);
288  }
289  else
290  {
291  SpikeEvent e;
292  e.set_sender(*this);
293  const rport r = target.handles_test_event(e, receptor_type);
294  if ( r != invalid_port_ and not is_model_prototype() )
295  ++P_.num_trains_;
296  return r;
297  }
298  }
299  else
300  {
301  // We do not count targets here, since connections may be created through
302  // proxies. Instead, we set P_.num_trains_ to 1 in Parameters_::set().
303  SpikeEvent e;
304  e.set_sender(*this);
305  return target.handles_test_event(e, receptor_type);
306  }
307  }
308 
309  inline
311  {
312  if (receptor_type != 0)
313  throw UnknownReceptorType(receptor_type, get_name());
314  return B_.logger_.connect_logging_device(dlr, recordablesMap_);
315  }
316 
317  inline
319  {
320  P_.get(d);
321  S_.get(d);
322  device_.get_status(d);
323  (*d)[names::recordables] = recordablesMap_.get_list();
324  }
325 
326  inline
328  {
329  Parameters_ ptmp = P_; // temporary copy in case of errors
330 
331  ptmp.set(d, *this); // throws if BadProperty
332  // We now know that ptmp is consistent. We do not write it back
333  // to P_ before we are also sure that the properties to be set
334  // in the parent class are internally consistent.
335  device_.set_status(d);
336 
337  // if we get here, temporaries contain consistent set of properties
338  P_ = ptmp;
339  }
340 
341 } // namespace
342 
343 #endif // SINUSOIDAL_GAMMA_GENERATOR_H
344 
345 #endif //HAVE_GSL
AC Gamma Generator.
Definition: sinusoidal_gamma_generator.h:120
const Name recordables("recordables")
List of recordable state data (Device parameters)
Definition: nest_names.h:244
double_t t_ms_
current time in ms, for communication with event_hook()
Definition: sinusoidal_gamma_generator.h:252
librandom::RngPtr rng_
thread-specific random generator
Definition: sinusoidal_gamma_generator.h:254
bool local_receiver() const
Allow multimeter to connect to local instances.
Definition: sinusoidal_gamma_generator.h:149
State_()
Sets default state value.
Definition: sinusoidal_gamma_generator.cpp:90
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
bool is_model_prototype() const
Returns true if node is model prototype.
Definition: node.h:795
void calibrate()
Re-calculate dependent parameters of the node.
Definition: sinusoidal_gamma_generator.cpp:235
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Declarations for base class Node.
void set(const DictionaryDatum &, const Parameters_ &)
Set values from dicitonary.
"Callback request event" for use in Device.
Definition: event.h:374
Base class for common properties of Stimulating Devices.
Definition: stimulating_device.h:117
bool individual_spike_trains_
Emit individual spike trains for each target, or same for all?
Definition: sinusoidal_gamma_generator.h:176
const rport invalid_port_
Value for invalid connection port number.
Definition: nest.h:160
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
static RecordablesMap< sinusoidal_gamma_generator > recordablesMap_
Definition: sinusoidal_gamma_generator.h:266
double_t h_
time resolution (ms)
Definition: sinusoidal_gamma_generator.h:251
UniversalDataLogger< sinusoidal_gamma_generator > logger_
Definition: sinusoidal_gamma_generator.h:227
double_t order_
gamma order
Definition: sinusoidal_gamma_generator.h:167
Buffers_(sinusoidal_gamma_generator &)
Definition: sinusoidal_gamma_generator.cpp:95
std::vector< double > Lambda_t0_
Integral Lambda from most recent spike up to t0_.
Definition: sinusoidal_gamma_generator.h:243
size_t num_trains_
Number of targets.
Definition: sinusoidal_gamma_generator.h:187
double_t om_
Frequency in radian.
Definition: sinusoidal_gamma_generator.h:161
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: sinusoidal_gamma_generator.cpp:113
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
State_ S_
Definition: sinusoidal_gamma_generator.h:269
Parameters_()
Sets default parameter values.
Definition: sinusoidal_gamma_generator.cpp:53
StimulatingDevice< SpikeEvent > device_
Definition: sinusoidal_gamma_generator.h:265
std::vector< double > t0_ms_
Beginning of current integration interval in ms.
Definition: sinusoidal_gamma_generator.h:237
void set_status(const DictionaryDatum &)
Definition: sinusoidal_gamma_generator.h:327
double_t phi_
phase in radian
Definition: sinusoidal_gamma_generator.h:164
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: sinusoidal_gamma_generator.h:275
Map names of recordables to data access functions.
Definition: recordables_map.h:58
friend class UniversalDataLogger< sinusoidal_gamma_generator >
Definition: sinusoidal_gamma_generator.h:217
Definition: sinusoidal_gamma_generator.h:159
void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition: sinusoidal_gamma_generator.cpp:310
Definition: nest_time.h:130
Buffers of the model.
Definition: sinusoidal_gamma_generator.h:224
void set(const DictionaryDatum &, const sinusoidal_gamma_generator &)
Set values from dicitonary.
Definition: sinusoidal_gamma_generator.cpp:127
std::string get_name() const
Return class name.
Definition: node.cpp:83
double_t rate_
current rate, kept for recording
Definition: sinusoidal_gamma_generator.h:205
long_t t_steps_
current time in steps, for communication with event_hook()
Definition: sinusoidal_gamma_generator.h:253
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
double_t hazard_(port) const
compute hazard for given target index, including time-step factor
Definition: sinusoidal_gamma_generator.cpp:260
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: sinusoidal_gamma_generator.cpp:271
void handle(DataLoggingRequest &)
Handler for universal data logging request.
Definition: sinusoidal_gamma_generator.cpp:324
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
double_t dc_
DC amplitude.
Definition: sinusoidal_gamma_generator.h:170
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
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
port handles_test_event(DataLoggingRequest &, rport)
Definition: sinusoidal_gamma_generator.h:310
Request data to be logged/logged data to be sent.
Definition: event.h:486
double_t get_rate_() const
Definition: sinusoidal_gamma_generator.h:257
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
double_t ac_
AC amplitude.
Definition: sinusoidal_gamma_generator.h:173
Buffers_ B_
Definition: sinusoidal_gamma_generator.h:271
sinusoidal_gamma_generator()
Definition: sinusoidal_gamma_generator.cpp:174
Parameters_ P_prev_
parameter values prior to last SetStatus
Definition: sinusoidal_gamma_generator.h:245
Default types used by the NEST kernel.
Event for spike information.
Definition: event.h:320
Parameters_ P_
Definition: sinusoidal_gamma_generator.h:268
Base class for all NEST network objects.
Definition: node.h:96
double_t deltaLambda_(const Parameters_ &, double_t, double_t) const
compute deltaLambda for given parameters from ta to tb
Definition: sinusoidal_gamma_generator.cpp:218
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: sinusoidal_gamma_generator.cpp:123
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: sinusoidal_gamma_generator.cpp:205
Variables_ V_
Definition: sinusoidal_gamma_generator.h:270
void init_state_(const Node &)
Private function to initialize the state of a node to model defaults.
Definition: sinusoidal_gamma_generator.cpp:197
bool has_proxies() const
Model can be switched between proxies (single spike train) and not.
Definition: sinusoidal_gamma_generator.h:146
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
Definition: sinusoidal_gamma_generator.h:203
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
const double e
Definition: numerics.cpp:62
Parameters_ & operator=(const Parameters_ &p)
Definition: sinusoidal_gamma_generator.cpp:74
void get_status(DictionaryDatum &) const
Definition: sinusoidal_gamma_generator.h:318
Definition: sinusoidal_gamma_generator.h:250