Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
StimulusGroup.h
Go to the documentation of this file.
1 /*
2 * Copyright 2014-2018 Friedemann Zenke
3 *
4 * This file is part of Auryn, a simulation package for plastic
5 * spiking neural networks.
6 *
7 * Auryn is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Auryn is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Auryn. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * If you are using Auryn or parts of it for your work please cite:
21 * Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations
22 * of spiking neural networks using general-purpose computers.
23 * Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076
24 */
25 
26 #ifndef STIMULUSGROUP_H_
27 
28 #define STIMULUSGROUP_H_
29 
30 #include "auryn_definitions.h"
31 #include "AurynVector.h"
32 #include "System.h"
33 #include "SpikingGroup.h"
34 
35 #include <boost/random/mersenne_twister.hpp>
36 #include <boost/random/uniform_01.hpp>
37 #include <boost/random/uniform_real.hpp>
38 #include <boost/random/uniform_int.hpp>
39 #include <boost/random/exponential_distribution.hpp>
40 #include <boost/random/normal_distribution.hpp>
41 #include <boost/random/variate_generator.hpp>
42 
43 #define SOFTSTARTTIME 0.1
44 
45 namespace auryn {
46 
47 
51 {
52 private:
53  AurynTime * clk;
54 
56  std::fstream tiserfile;
57 
58  AurynFloat base_rate;
59 
60  int off_pattern;
61 
62 
63 
64 protected:
66 
68 
71 
72 
74  unsigned int stimulation_count;
75 
78 
81 
83  std::vector<double> probabilities ;
84 
86  static boost::mt19937 poisson_gen;
87 
89  static boost::mt19937 order_gen;
90  static boost::uniform_01<boost::mt19937> order_die;
91 
92 
93 
96 
99 
102 
105 
107  void init(StimulusGroupModeType stimulusmode, string stimfile, AurynFloat baserate);
108 
110  virtual void redraw();
111 
113  void write_stimulus_file(AurynDouble time);
114 
116  void read_next_stimulus_from_file(AurynDouble &time, int &active, int &stimulusid );
117 
119  void set_activity( NeuronID i, AurynFloat val=0.0 );
120 
123 
126 
128 
129 public:
134 
139 
140 
142  std::vector<type_pattern> stimuli;
143 
145  virtual unsigned int get_num_stimuli();
146 
149 
152 
155 
158 
161 
165 
168 
177  StimulusGroup(NeuronID n, string filename, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat baserate=1.0 );
178 
189  StimulusGroup(NeuronID n, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat baserate=1.0 );
190 
191  virtual ~StimulusGroup();
192 
194  virtual void evolve();
195 
197  void set_baserate(AurynFloat baserate);
198  void set_maxrate(AurynFloat baserate);
199 
202 
204  void set_all( AurynFloat val=0.0 );
205 
207  void seed( int rndseed );
208 
211 
216  virtual void load_patterns( string filename );
217 
219  virtual void clear_patterns( );
220 
222  void set_mean_off_period(AurynFloat period);
223 
225  void set_mean_on_period(AurynFloat period);
226 
228  void set_pattern_activity( unsigned int i );
229 
231  void set_pattern_activity( unsigned int i, AurynFloat setval );
232 
237  virtual void set_active_pattern( unsigned int i );
238 
245  void set_active_pattern( unsigned int i, AurynFloat default_value);
246 
247  void set_next_action_time(double time);
248 
250  void set_distribution ( std::vector<double> probs );
251 
253  std::vector<double> get_distribution ( );
254 
256  double get_distribution ( int i );
257 
259  unsigned int get_stim_count();
260 
261 
264 
267 
270 
273 
275  unsigned int get_cur_stim();
276 
278  bool get_stim_active();
279 
281  void flat_distribution( );
282 
284  void normalize_distribution( );
285 
286  std::vector<type_pattern> * get_patterns();
287 
288 };
289 
290 }
291 
292 #endif /*STIMULUSGROUP_H_*/
unsigned int get_stim_count()
Returns number of stimuli shown.
Definition: StimulusGroup.cpp:623
void set_stimulation_mode(StimulusGroupModeType mode)
Sets the stimulation mode. Can be any of StimulusGroupModeType (MANUAL,RANDOM,SEQUENTIAL,SEQUENTIAL_REV).
Definition: StimulusGroup.cpp:563
void write_stimulus_file(AurynDouble time)
Definition: StimulusGroup.cpp:162
virtual void load_patterns(string filename)
Loads stimulus patterns from a designated pat file given.
Definition: StimulusGroup.cpp:378
NeuronID bgx
Definition: StimulusGroup.h:80
int cur_stim_index
Current stimulus index.
Definition: StimulusGroup.h:133
AurynTime next_action_time
next stimulus time requiring change in rates
Definition: StimulusGroup.h:95
Definition: auryn_definitions.h:148
void set_mean_on_period(AurynFloat period)
Set mean on period.
Definition: StimulusGroup.cpp:156
std::vector< double > get_distribution()
Getter for pattern probability distribution.
Definition: StimulusGroup.cpp:518
void set_baserate(AurynFloat baserate)
Sets the baserate that is the rate at 1 activity.
Definition: StimulusGroup.cpp:138
AurynFloat * activity
Definition: StimulusGroup.h:67
static boost::mt19937 order_gen
Definition: StimulusGroup.h:89
void seed(int rndseed)
Seeds the random number generator for all stimulus groups of the simulation.
Definition: StimulusGroup.cpp:567
void set_pattern_activity(unsigned int i)
Function that loops over the stimulus/pattern vector and sets the activity verctor to the gamma value...
Definition: StimulusGroup.cpp:448
StimulusGroup(NeuronID n, string filename, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat baserate=1.0)
Default constructor.
Definition: StimulusGroup.cpp:110
virtual unsigned int get_num_stimuli()
Returns number of stimuli.
Definition: StimulusGroup.cpp:618
Abstract base class of all objects producing spikes.
Definition: SpikingGroup.h:67
static boost::uniform_01< boost::mt19937 > order_die
Definition: StimulusGroup.h:90
AurynFloat mean_on_period
Definition: StimulusGroup.h:125
AurynTime last_stim_offset_time
last stimulus offset time
Definition: StimulusGroup.h:104
AurynTime refractory_period
Enables a finite refractory time specified in AurynTime (only works for non-binary-pattern mode...
Definition: StimulusGroup.h:154
double AurynDouble
Higher precision floating point datatype.
Definition: auryn_definitions.h:158
StimulusGroupModeType stimulus_order
Definition: StimulusGroup.h:70
std::vector< type_pattern > * get_patterns()
Definition: StimulusGroup.cpp:554
int n
Definition: mkpat.py:5
static boost::mt19937 poisson_gen
Definition: StimulusGroup.h:86
bool stimulus_active
Current stimulus active.
Definition: StimulusGroup.h:138
AurynTime * ttl
Definition: StimulusGroup.h:65
void flat_distribution()
Definition: StimulusGroup.cpp:528
AurynTime get_last_offset_time()
returns the last stimulus offset time in units of AurynTime
Definition: StimulusGroup.cpp:603
bool active
Toggles group active.
Definition: SpikingGroup.h:149
bool randomintensities
Determines if the Group is using random activation intensities.
Definition: StimulusGroup.h:160
Definition: ABSConnection.h:38
void set_next_action_time(double time)
Definition: StimulusGroup.cpp:559
AurynFloat mean_off_period
Definition: StimulusGroup.h:122
virtual void clear_patterns()
Clear stimulus patterns.
Definition: StimulusGroup.cpp:372
AurynTime get_last_action_time()
returns the last action (stim on/off) time in units of AurynTime
Definition: StimulusGroup.cpp:588
void set_activity(NeuronID i, AurynFloat val=0.0)
Definition: StimulusGroup.cpp:353
StimulusGroupModeType
Specifies stimulus order used in StimulusGroup.
Definition: auryn_definitions.h:148
void normalize_distribution()
Definition: StimulusGroup.cpp:535
AurynTime get_last_onset_time()
returns the last stimulus onset time in units of AurynTime
Definition: StimulusGroup.cpp:598
void init(StimulusGroupModeType stimulusmode, string stimfile, AurynFloat baserate)
Definition: StimulusGroup.cpp:34
float AurynFloat
Low precision floating point datatype.
Definition: auryn_definitions.h:157
Provides a poisson stimulus at random intervals in one or more predefined subsets of the group that a...
Definition: StimulusGroup.h:50
void set_maxrate(AurynFloat baserate)
TODO.
Definition: StimulusGroup.cpp:145
AurynTime last_stim_onset_time
last stimulus onset time
Definition: StimulusGroup.h:101
AurynTime get_next_action_time()
returns the next action (stim on/off) time in units of AurynTime
Definition: StimulusGroup.cpp:593
unsigned int get_cur_stim()
returns the index of the current (or last – if not active anymore) active stimulus ...
Definition: StimulusGroup.cpp:613
AurynFloat get_activity(NeuronID i)
Gets the activity of unit i.
Definition: StimulusGroup.cpp:364
std::vector< double > probabilities
Definition: StimulusGroup.h:83
virtual void set_active_pattern(unsigned int i)
This function is called internally and sets the activity level to a given active stimulus.
Definition: StimulusGroup.cpp:495
virtual ~StimulusGroup()
Definition: StimulusGroup.cpp:121
void read_next_stimulus_from_file(AurynDouble &time, int &active, int &stimulusid)
Definition: StimulusGroup.cpp:174
std::vector< type_pattern > stimuli
Vector containing all the stimuli.
Definition: StimulusGroup.h:142
NeuronID fgx
Definition: StimulusGroup.h:77
AurynTime last_action_time
last stimulus time requiring change in rates
Definition: StimulusGroup.h:98
void set_all(AurynFloat val=0.0)
Sets sets the activity of all units.
Definition: StimulusGroup.cpp:358
bool binary_patterns
Switches to more efficient algorithm which ignores the gamma value.
Definition: StimulusGroup.h:151
bool randomintervals
Determines if the Group is using random activation intervals.
Definition: StimulusGroup.h:157
bool get_stim_active()
Returns true if currently a stimulus is active and false otherwise.
Definition: StimulusGroup.cpp:608
AurynDouble background_rate
Play random Poisson noise with this rate on all channels when no stim is active.
Definition: StimulusGroup.h:164
void set_distribution(std::vector< double > probs)
Setter for pattern probability distribution.
Definition: StimulusGroup.cpp:501
unsigned int stimulation_count
Counter variable for number of stimuli shown.
Definition: StimulusGroup.h:74
bool background_during_stimulus
Switch for background firing during stimulus.
Definition: StimulusGroup.h:167
NeuronID AurynTime
Defines Auryns discrete time unit of the System clock. Change to AurynLong if 120h of simtime are not...
Definition: auryn_definitions.h:155
virtual void redraw()
Definition: StimulusGroup.cpp:127
AurynFloat curscale
Definition: StimulusGroup.h:127
void set_mean_off_period(AurynFloat period)
Set mean quiet interval between consecutive stimuli.
Definition: StimulusGroup.cpp:150
virtual void evolve()
Standard virtual evolve function.
Definition: StimulusGroup.cpp:185
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
AurynFloat scale
This is by how much the pattern gamma value is multiplied. The resulting value gives the x-times base...
Definition: StimulusGroup.h:148