NEST main@caf0ae8
 
Loading...
Searching...
No Matches
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// Includes from nestkernel:
27#include "connection.h"
28#include "device_node.h"
29#include "event.h"
30#include "nest_types.h"
31#include "random_generators.h"
32#include "stimulation_device.h"
34
35namespace nest
36{
37
38/* BeginUserDocs: device, generator
39
40Short description
41+++++++++++++++++
42
43Generate sinusoidally modulated Poisson spike trains
44
45Description
46+++++++++++
47
48``sinusoidal_poisson_generator`` generates sinusoidally modulated Poisson spike
49trains. By default, each target of the generator will receive a different
50spike train.
51
52The instantaneous rate of the process is given by
53
54.. math::
55
56 f(t) = \mathrm{max} \left(0, \mathrm{rate} + \mathrm{amplitude} \cdot \sin
57 \left( 2 \pi \cdot \mathrm{frequency} \cdot t + \mathrm{phase}
58 \cdot \frac{\pi}{180} \right) \right) >= 0
59
60.. note::
61
62 - If :math:`\mathrm{amplitude} > \mathrm{rate}`, firing rate is cut off
63 at zero. In this case, the mean firing rate will be less than rate.
64 - The state of the generator is reset on calibration.
65 - The generator does not support precise spike timing.
66 - You can use the multimeter to sample the rate of the generator.
67 - The generator will create different trains if run at different
68 temporal resolutions.
69
70By default, the generator sends a different spike train to each of its
71targets. If ``individual_spike_trains`` is set to ``False`` using either
72:py:func:`.SetDefaults` or :py:func:`.CopyModel` before a generator node
73is created, the generator will send the same spike train to all of its targets.
74
75.. include:: ../models/stimulation_device.rst
76
77rate
78 Mean firing rate in spikes/second. Default: ``0.0``.
79
80amplitude
81 Firing rate modulation amplitude in spikes/second. Default: ``0.0``.
82
83frequency
84 Modulation frequency in Hz. Default: ``0.0``.
85
86phase
87 Modulation phase in degree [0-360]. Default: ``0.0``.
88
89individual_spike_trains
90 See note above. Default: ``True``.
91
92
93Setting parameters from a stimulation backend
94~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95
96The parameters in this stimulation device can be updated with input
97coming from a stimulation backend. The data structure used for the
98update holds one value for each of the parameters mentioned above.
99The indexing is as follows:
100
101 0. rate
102 1. frequency
103 2. phase
104 3. amplitude
105 4. individual_spike_trains
106
107Receives
108++++++++
109
110DataLoggingRequest
111
112Sends
113+++++
114
115SpikeEvent
116
117See also
118++++++++
119
120poisson_generator, sinusoidal_gamma_generator
121
122
123Examples using this model
124+++++++++++++++++++++++++
125
126.. listexamples:: sinusoidal_poisson_generator
127
128EndUserDocs */
129
130void register_sinusoidal_poisson_generator( const std::string& name );
131
133{
134
135public:
138
139 size_t send_test_event( Node&, size_t, synindex, bool ) override;
140
146 using Node::event_hook;
147 using Node::handle;
149
150 void handle( DataLoggingRequest& ) override;
151
152 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
153
154 void get_status( Dictionary& ) const override;
155 void set_status( const Dictionary& ) override;
156
158 bool
159 has_proxies() const override
160 {
161 return not P_.individual_spike_trains_;
162 }
163
165 bool
166 local_receiver() const override
167 {
168 return true;
169 }
170
171 std::string
172 get_element_type() const override
173 {
174 return names::stimulator;
175 }
176
178 get_type() const override
179 {
181 };
182
183 void set_data_from_stimulation_backend( std::vector< double >& input_param ) override;
184
185private:
186 void init_state_() override;
187 void init_buffers_() override;
188 void pre_run_hook() override;
189 void event_hook( DSSpikeEvent& ) override;
190
191 void update( Time const&, const long, const long ) override;
192
194 {
196 double om_;
197
199 double phi_;
200
202 double rate_;
203
206
209
210 Parameters_();
211 Parameters_( const Parameters_& );
212 Parameters_& operator=( const Parameters_& p );
213
214 void get( Dictionary& ) const;
215
221 void set( const Dictionary&, const sinusoidal_poisson_generator&, Node* );
222 };
223
224 struct State_
225 {
227 double y_0_;
228 double y_1_;
229
230 double rate_;
231
232 State_();
233
234 void get( Dictionary& ) const;
235 };
236
237 // ------------------------------------------------------------
238
239 // The next two classes need to be friends to access the State_ class/member
241 friend class UniversalDataLogger< sinusoidal_poisson_generator >;
242
243 // ----------------------------------------------------------------
244
254
255 // ------------------------------------------------------------
256
258 {
260
261 double h_;
262 double sin_;
263 double cos_;
264 };
265
266 double
267 get_rate_() const
268 {
269 return 1000.0 * S_.rate_;
270 }
271
272 // ------------------------------------------------------------
273
275
280};
281
282inline size_t
283sinusoidal_poisson_generator::send_test_event( Node& target, size_t receptor_type, synindex syn_id, bool dummy_target )
284{
286
287 // to ensure correct overloading resolution, we need explicit event types
288 // therefore, we need to duplicate the code here
289 if ( dummy_target )
290 {
291 DSSpikeEvent e;
292 e.set_sender( *this );
293 return target.handles_test_event( e, receptor_type );
294 }
295 else
296 {
297 SpikeEvent e;
298 e.set_sender( *this );
299 return target.handles_test_event( e, receptor_type );
300 }
301}
302
303inline size_t
305{
306 if ( receptor_type != 0 )
307 {
308 throw UnknownReceptorType( receptor_type, get_name() );
309 }
310 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
311}
312
313inline void
315{
316 P_.get( d );
317 S_.get( d );
319 d[ names::recordables ] = recordablesMap_.get_list();
320}
321
322inline void
324{
325 Parameters_ ptmp = P_; // temporary copy in case of errors
326
327 ptmp.set( d, *this, this ); // throws if BadProperty
328 // We now know that ptmp is consistent. We do not write it back
329 // to P_ before we are also sure that the properties to be set
330 // in the parent class are internally consistent.
332
333 // if we get here, temporaries contain consistent set of properties
334 P_ = ptmp;
335}
336
337} // namespace
338
339#endif // SINUSOIDAL_POISSON_GENERATOR_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
"Callback request event" for use in Device.
Definition event.h:521
Request data to be logged/logged data to be sent.
Definition event.h:636
Base class for all NEST network objects.
Definition node.h:99
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition node.cpp:586
std::string get_name() const
Return class name.
Definition node.cpp:105
Map names of recordables to data access functions.
Definition recordables_map.h:61
Event for spike information.
Definition event.h:418
Base class for common properties of StimulationDevices.
Definition stimulation_device.h:154
void enforce_single_syn_type(synindex)
Throws IllegalConnection if synapse id differs from initial synapse id.
Definition stimulation_device.cpp:62
Type
Device type.
Definition stimulation_device.h:187
@ CURRENT_GENERATOR
Definition stimulation_device.h:188
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition stimulation_device.cpp:125
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition stimulation_device.cpp:168
Definition nest_time.h:135
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
Definition sinusoidal_poisson_generator.h:133
void init_buffers_() override
Configure persistent internal data structures.
Definition sinusoidal_poisson_generator.cpp:202
void event_hook(DSSpikeEvent &) override
Modify Event object parameters during event delivery.
Definition sinusoidal_poisson_generator.cpp:282
Buffers_ B_
Definition sinusoidal_poisson_generator.h:279
void set_data_from_stimulation_backend(std::vector< double > &input_param) override
Definition sinusoidal_poisson_generator.cpp:305
std::string get_element_type() const override
Return the element type of the node.
Definition sinusoidal_poisson_generator.h:172
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition sinusoidal_poisson_generator.h:314
void init_state_() override
Configure state variables depending on runtime information.
Definition sinusoidal_poisson_generator.cpp:196
double get_rate_() const
Definition sinusoidal_poisson_generator.h:267
sinusoidal_poisson_generator()
Definition sinusoidal_poisson_generator.cpp:174
bool local_receiver() const override
Allow multimeter to connect to local instances.
Definition sinusoidal_poisson_generator.h:166
void handle(DataLoggingRequest &) override
Handler for universal data logging request.
Definition sinusoidal_poisson_generator.cpp:295
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition sinusoidal_poisson_generator.cpp:209
StimulationDevice::Type get_type() const override
Definition sinusoidal_poisson_generator.h:178
bool has_proxies() const override
Model can be switched between proxies (single spike train) and not.
Definition sinusoidal_poisson_generator.h:159
friend class UniversalDataLogger< sinusoidal_poisson_generator >
Definition sinusoidal_poisson_generator.h:241
size_t handles_test_event(DataLoggingRequest &, size_t) override
Definition sinusoidal_poisson_generator.h:304
Variables_ V_
Definition sinusoidal_poisson_generator.h:278
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition sinusoidal_poisson_generator.cpp:229
Parameters_ P_
Definition sinusoidal_poisson_generator.h:276
static RecordablesMap< sinusoidal_poisson_generator > recordablesMap_
Definition sinusoidal_poisson_generator.h:274
State_ S_
Definition sinusoidal_poisson_generator.h:277
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition sinusoidal_poisson_generator.h:323
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition sinusoidal_poisson_generator.h:283
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 recordables("recordables")
const std::string stimulator("stimulator")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_sinusoidal_poisson_generator(const std::string &name)
Definition sinusoidal_poisson_generator.cpp:44
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Buffers of the model.
Definition sinusoidal_poisson_generator.h:249
UniversalDataLogger< sinusoidal_poisson_generator > logger_
Definition sinusoidal_poisson_generator.h:252
Definition sinusoidal_poisson_generator.h:194
void get(Dictionary &) const
Store current values in dictionary.
Definition sinusoidal_poisson_generator.cpp:121
void set(const Dictionary &, const sinusoidal_poisson_generator &, Node *)
Set values from dictionary.
Definition sinusoidal_poisson_generator.cpp:138
double phi_
Phase in radian.
Definition sinusoidal_poisson_generator.h:199
double om_
Temporal frequency in radian/ms.
Definition sinusoidal_poisson_generator.h:196
double amplitude_
Firing rate modulation amplitude in spikes/ms.
Definition sinusoidal_poisson_generator.h:205
Parameters_ & operator=(const Parameters_ &p)
Definition sinusoidal_poisson_generator.cpp:81
double rate_
Mean firing rate in spikes/ms.
Definition sinusoidal_poisson_generator.h:202
Parameters_()
Sets default parameter values.
Definition sinusoidal_poisson_generator.cpp:62
bool individual_spike_trains_
Emit individual spike trains for each target, or same for all?
Definition sinusoidal_poisson_generator.h:208
Definition sinusoidal_poisson_generator.h:225
State_()
Sets default state value.
Definition sinusoidal_poisson_generator.cpp:97
void get(Dictionary &) const
Store current values in dictionary.
Definition sinusoidal_poisson_generator.cpp:131
double rate_
current rate, kept for recording
Definition sinusoidal_poisson_generator.h:230
double y_0_
Two-component oscillator state vector, see Rotter&Diesmann.
Definition sinusoidal_poisson_generator.h:227
double y_1_
Definition sinusoidal_poisson_generator.h:228
Definition sinusoidal_poisson_generator.h:258
poisson_distribution poisson_dist_
poisson distribution
Definition sinusoidal_poisson_generator.h:259
double h_
Definition sinusoidal_poisson_generator.h:261
double cos_
cos(h om) in propagator
Definition sinusoidal_poisson_generator.h:263
double sin_
time resolution (ms)
Definition sinusoidal_poisson_generator.h:262