NEST  2.6.0,not_revisioned_source_dir@0
noise_generator.h
Go to the documentation of this file.
1 /*
2  * noise_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 NOISE_GENERATOR_H
24 #define NOISE_GENERATOR_H
25 
26 
27 #include <vector>
28 #include "nest.h"
29 #include "event.h"
30 #include "node.h"
31 #include "stimulating_device.h"
32 #include "connection.h"
33 #include "normal_randomdev.h"
34 
35 namespace nest
36 {
37 
38 /* BeginDocumentation
39 Name: noise_generator - Device to generate Gaussian white noise current.
40 Description:
41 This device can be used to inject a Gaussian "white" noise current into a node.
42 The current is not really white, but a piecewise constant current with Gaussian
43 distributed amplitude. The current changes at intervals of dt. dt must be a
44 multiple of the simulation step size, the default is 1.0ms,
45 corresponding to a 1kHz cut-off.
46 Additionally a second sinusodial modulated term can be added to the standard deviation of the noise.
47 
48 The current generated is given by
49 
50  I(t) = mean + std * N_j for t_0 + j dt <= t < t_0 + (j-1) dt
51 
52 where N_j are Gaussian random numbers with unit standard deviation and t_0 is
53 the device onset time.
54 If the modulation is added the current is given by
55 
56  I(t) = mean + sqrt(std^2 + std_mod^2 * sin(omega * t + phase)) * N_j for t_0 + j dt <= t < t_0 + (j-1) dt
57 
58 Parameters:
59 The following parameters can be set in the status dictionary:
60 
61 mean double - mean value of the noise current in pA
62 std double - standard deviation of noise current in pA
63 dt double - interval between changes in current in ms, default 1.0ms
64 std_mod double - modulated standard deviation of noise current in pA
65 phase double - Phase of sine modulation (0-360 deg)
66 frequency double - Frequency of sine modulation in Hz
67 
68 Remarks:
69  - All targets receive different currents.
70  - The currents for all targets change at the same points in time.
71  - The effect of this noise current on a neuron DEPENDS ON DT. Consider
72  the membrane potential fluctuations evoked when a noise current is
73  injected into a neuron. The standard deviation of these fluctuations
74  across an ensemble will increase with dt for a given value of std.
75  For the leaky integrate-and-fire neuron with time constant tau_m,
76  membrane potential fluctuations at times t_j+delay are given by
77 
78  Sigma = std * sqrt( (1-x) / (1+x) ) where x = exp(-dt/tau_m)
79 
80  for large t_j. In the white noise limit, dt -> 0, one has
81 
82  Sigma -> std * sqrt(dt / tau).
83 
84  To obtain comparable results for different values of dt, you must
85  adapt std.
86 
87 Sends: CurrentEvent
88 
89 SeeAlso: Device
90 
91 Author: Ported to NEST2 API 08/2007 by Jochen Eppler, updated 07/2008 by HEP
92 */
93 
98  class noise_generator: public Node
99  {
100 
101  public:
102 
103  noise_generator();
105 
106  bool has_proxies() const {return false;}
107 
112  using Node::event_hook;
113 
115 
116  void get_status(DictionaryDatum &) const;
117  void set_status(const DictionaryDatum &) ;
118 
119  private:
120 
121  void init_state_(const Node&);
122  void init_buffers_();
123 
128  void calibrate();
129 
130  void update(Time const &, const long_t, const long_t);
131  void event_hook(DSCurrentEvent&);
132 
133  // ------------------------------------------------------------
134 
135  typedef std::vector<double_t> AmpVec_;
136 
140  struct Parameters_ {
147 
154  size_t num_targets_;
155 
156  Parameters_();
157  Parameters_(const Parameters_&);
158 
159  void get(DictionaryDatum&) const;
160  void set(const DictionaryDatum&, const noise_generator&);
161  };
162 
163  // ------------------------------------------------------------
164 
165  struct State_ {
168 
169  State_();
170 
171  void get(DictionaryDatum&) const;
172  };
173 
174  // ------------------------------------------------------------
175 
176  struct Buffers_ {
179  };
180 
181  // ------------------------------------------------------------
182 
183  struct Variables_ {
188 
189  // The exact integration matrix
194  };
195 
196  // ------------------------------------------------------------
197 
203  };
204 
205 
206  inline
208  {
209  P_.get(d);
210  S_.get(d);
211  device_.get_status(d);
212  }
213 
214  inline
216  {
217  Parameters_ ptmp = P_; // temporary copy in case of errors
218  ptmp.num_targets_= P_.num_targets_; // Copy Constr. does not copy connections
219  ptmp.set(d, *this); // throws if BadProperty
220 
221  // We now know that ptmp is consistent. We do not write it back
222  // to P_ before we are also sure that the properties to be set
223  // in the parent class are internally consistent.
224  device_.set_status(d);
225 
226  // if we get here, temporaries contain consistent set of properties
227  P_ = ptmp;
229  }
230 
231 }
232 #endif //NOISE_GENERATOR_H
233 
double_t A_11_
Definition: noise_generator.h:193
double_t std_mod_
standard deviation of current modulation, in pA
Definition: noise_generator.h:143
Parameters_ P_
Definition: noise_generator.h:199
double_t phi_rad_
Phase of sine current (0-2Pi rad)
Definition: noise_generator.h:187
Definition: lockptrdatum.h:40
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
Declarations for base class Node.
State_ S_
Definition: noise_generator.h:202
Parameters_()
Sets default parameter values.
Definition: noise_generator.cpp:35
bool has_proxies() const
Returns true if the node has proxies on remote threads.
Definition: noise_generator.h:106
Base class for common properties of Stimulating Devices.
Definition: stimulating_device.h:117
double_t std_
standard deviation of current, in pA
Definition: noise_generator.h:142
librandom::NormalRandomDev normal_dev_
random deviate generator
Definition: noise_generator.h:185
Create normal (Gaussian) random numbers with uniform variance.
Definition: normal_randomdev.h:59
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: noise_generator.cpp:189
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
Time dt_
time interval between updates
Definition: noise_generator.h:146
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: noise_generator.cpp:79
double_t y_1_
Definition: noise_generator.h:167
Buffers_ B_
Definition: noise_generator.h:201
Store independent parameters of the model.
Definition: noise_generator.h:140
long_t dt_steps_
update interval in steps
Definition: noise_generator.h:184
noise_generator()
Definition: noise_generator.cpp:115
std::vector< double_t > AmpVec_
Definition: noise_generator.h:135
Definition: noise_generator.h:165
Definition: nest_time.h:130
double_t freq_
Standard frequency in Hz.
Definition: noise_generator.h:144
void set_status(const DictionaryDatum &)
Definition: noise_generator.h:215
double_t mean_
mean current, in pA
Definition: noise_generator.h:141
size_t num_targets_
Number of targets.
Definition: noise_generator.h:154
void init_state_(const Node &)
Private function to initialize the state of a node to model defaults.
Definition: noise_generator.cpp:138
long_t next_step_
time step of next change in current
Definition: noise_generator.h:177
double_t A_01_
Definition: noise_generator.h:191
void event_hook(DSCurrentEvent &)
Definition: noise_generator.cpp:250
Definition: noise_generator.h:183
double_t y_0_
Definition: noise_generator.h:166
State_()
Sets default parameter values.
Definition: noise_generator.cpp:45
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: noise_generator.cpp:69
void set(const DictionaryDatum &, const noise_generator &)
Set values from dicitonary.
Definition: noise_generator.cpp:85
double double_t
Double precision floating point numbers.
Definition: nest.h:93
double_t A_00_
Definition: noise_generator.h:190
void calibrate()
Recalculates parameters and forces reinitialization of amplitudes if number of targets has changed...
Definition: noise_generator.cpp:154
StimulatingDevice< CurrentEvent > device_
Definition: noise_generator.h:198
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
double_t phi_deg_
Phase of sinusodial noise modulation (0-360 deg)
Definition: noise_generator.h:145
Gaussian white noise generator.
Definition: noise_generator.h:98
Default types used by the NEST kernel.
Base class for all NEST network objects.
Definition: node.h:96
void update(Time const &, const long_t, const long_t)
Bring the node from state $t$ to $t+n*dt$.
Definition: noise_generator.cpp:213
double_t A_10_
Definition: noise_generator.h:192
AmpVec_ amps_
amplitudes, one per target
Definition: noise_generator.h:178
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: noise_generator.cpp:145
virtual void event_hook(DSSpikeEvent &)
Modify Event object parameters during event delivery.
Definition: node.cpp:301
void get_status(DictionaryDatum &) const
Definition: noise_generator.h:207
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
double_t omega_
Angelfrequency i rad/s.
Definition: noise_generator.h:186
"Callback request event" for use in Device.
Definition: event.h:465
Variables_ V_
Definition: noise_generator.h:200
Definition: noise_generator.h:176