NEST  2.6.0,not_revisioned_source_dir@0
pulsepacket_generator.h
Go to the documentation of this file.
1 /*
2  * pulsepacket_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 PULSEPACKET_GENERATOR_H
24 #define PULSEPACKET_GENERATOR_H
25 
26 #include <vector>
27 #include <deque>
28 
29 #include "nest.h"
30 #include "event.h"
31 #include "node.h"
32 #include "stimulating_device.h"
33 #include "connection.h"
34 #include "normal_randomdev.h"
35 
36 namespace nest
37 {
39 
44 /*BeginDocumentation
45 Name: pulsepacket_generator - Generate sequence of Gaussian pulse packets.
46 Description:
47  The pulsepacket_generator produces a spike train contains Gaussian pulse
48  packets centered about given times. A Gaussian pulse packet is
49  a given number of spikes with normal distributed random displacements
50  from the center time of the pulse.
51  It resembles the output of synfire groups of neurons.
52 
53 Parameters:
54  pulse_times double - Times of the centers of pulses in ms
55  activity int - Number of spikes per pulse
56  sdev double - Standard deviation of spike times in each pulse in ms
57 
58 Remarks:
59  - All targets receive identical spike trains.
60  - New pulse packets are generated when activity or sdev are changed.
61  - Gaussian pulse are independently generated for each given
62  pulse-center time.
63  - Both standard deviation and number of spikes may be set at any time.
64  Pulses are then re-generated with the new values.
65 
66 Sends: SpikeEvent
67 
68 SeeAlso: spike_generator, StimulatingDevice
69 */
70 
71  class pulsepacket_generator : public Node
72  {
73 
74  public:
75 
78 
79  // behaves like normal node, since it must provide identical
80  // output to all targets
81  bool has_proxies() const {return true;}
82 
84 
85  void get_status(DictionaryDatum &) const;
86  void set_status(const DictionaryDatum &) ;
87 
88  private:
89 
90  void init_state_(const Node&);
91  void init_buffers_();
92  void calibrate();
93 
94  void create_pulse();
95  void update(Time const &, const long_t, const long_t);
96 
97  struct Buffers_;
98 
99  // ------------------------------------------------------------
100 
101  struct Parameters_ {
102 
103  std::vector<double_t> pulse_times_;
106 
108 
109  Parameters_();
110 
111  void get(DictionaryDatum&) const;
112 
119  };
120 
121  // ------------------------------------------------------------
122 
123  struct Buffers_ {
124  std::deque<long_t> spiketimes_;
125  };
126 
127  // ------------------------------------------------------------
128 
129  struct Variables_ {
130 
132 
144 
145  Variables_();
146 
147  };
148 
149  // ------------------------------------------------------------
150 
152 
156  };
157 
158  inline
160 {
161  device_.enforce_single_syn_type(syn_id);
162 
163  SpikeEvent e;
164  e.set_sender(*this);
165 
166  return target.handles_test_event(e, receptor_type);
167 }
168 
169  inline
171  {
172  P_.get(d);
173  device_.get_status(d);
174  }
175 
176  inline
178  {
179  Parameters_ ptmp = P_; // temporary copy in case of errors
180  ptmp.set(d, *this); // throws if BadProperty
181 
182  // We now know that ptmp is consistent. We do not write it back
183  // to P_ before we are also sure that the properties to be set
184  // in the parent class are internally consistent.
185  device_.set_status(d);
186 
187  // if we get here, temporaries contain consistent set of properties
188  P_ = ptmp;
189  }
190 
191 } // namespace nest
192 
193 #endif
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
Definition: lockptrdatum.h:40
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Declarations for base class Node.
void calibrate()
Re-calculate dependent parameters of the node.
Definition: pulsepacket_generator.cpp:118
librandom::NormalRandomDev norm_dev_
random deviate generator
Definition: pulsepacket_generator.h:131
Variables_ V_
Definition: pulsepacket_generator.h:155
Base class for common properties of Stimulating Devices.
Definition: stimulating_device.h:117
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: pulsepacket_generator.h:159
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
pulsepacket_generator()
Definition: pulsepacket_generator.cpp:90
double_t sdev_
standard deviation of the packet
Definition: pulsepacket_generator.h:105
Create normal (Gaussian) random numbers with uniform variance.
Definition: normal_randomdev.h:59
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
std::deque< long_t > spiketimes_
Definition: pulsepacket_generator.h:124
std::vector< double_t > pulse_times_
times of pulses
Definition: pulsepacket_generator.h:103
Parameters_()
Sets default parameter values.
Definition: pulsepacket_generator.cpp:39
bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: pulsepacket_generator.h:81
Parameters_ P_
Definition: pulsepacket_generator.h:153
class pulsepacket_generator
Definition: pulsepacket_generator.h:71
StimulatingDevice< SpikeEvent > device_
Definition: pulsepacket_generator.h:151
size_t stop_center_idx_
Definition: pulsepacket_generator.h:142
Variables_()
Definition: pulsepacket_generator.cpp:46
void init_state_(const Node &)
Private function to initialize the state of a node to model defaults.
Definition: pulsepacket_generator.cpp:106
Definition: nest_time.h:130
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: pulsepacket_generator.cpp:113
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
void set_status(const DictionaryDatum &)
Definition: pulsepacket_generator.h:177
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: pulsepacket_generator.cpp:145
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: pulsepacket_generator.cpp:56
double_t sdev_tolerance_
Definition: pulsepacket_generator.h:107
double_t tolerance
Definition: pulsepacket_generator.h:143
Buffers_ B_
Definition: pulsepacket_generator.h:154
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
size_t start_center_idx_
Indices into sorted vector of sorted pulse-center times (P_.pulse_times_).
Definition: pulsepacket_generator.h:141
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
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
void get_status(DictionaryDatum &) const
Definition: pulsepacket_generator.h:170
Definition: pulsepacket_generator.h:123
Default types used by the NEST kernel.
Event for spike information.
Definition: event.h:320
long_t a_
number of pulses in a packet
Definition: pulsepacket_generator.h:104
void set(const DictionaryDatum &, pulsepacket_generator &)
Set values from dicitonary.
Definition: pulsepacket_generator.cpp:63
Base class for all NEST network objects.
Definition: node.h:96
Definition: pulsepacket_generator.h:129
Definition: pulsepacket_generator.h:101
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
const double e
Definition: numerics.cpp:62