Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
auryn::SpikeTimingStimGroup Class Reference

#include <SpikeTimingStimGroup.h>

Inheritance diagram for auryn::SpikeTimingStimGroup:
Inheritance graph
[legend]
Collaboration diagram for auryn::SpikeTimingStimGroup:
Collaboration graph
[legend]

Public Member Functions

 SpikeTimingStimGroup (NeuronID n, string filename, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat timeframe=0.0)
 Default constructor. More...
 
 SpikeTimingStimGroup (NeuronID n, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat timeframe=0.0)
 Constructor without stimfile. Patterns can be loaded afterwards using the load_patterns method. More...
 
virtual ~SpikeTimingStimGroup ()
 
virtual void evolve ()
 
- Public Member Functions inherited from auryn::StimulusGroup
virtual unsigned int get_num_stimuli ()
 Returns number of stimuli. More...
 
 StimulusGroup (NeuronID n, string filename, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat baserate=1.0)
 Default constructor. More...
 
 StimulusGroup (NeuronID n, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat baserate=1.0)
 Constructor without pattern file. Patterns can be loaded afterwards using the load_patterns method. More...
 
virtual ~StimulusGroup ()
 
void set_baserate (AurynFloat baserate)
 Sets the baserate that is the rate at 1 activity. More...
 
void set_maxrate (AurynFloat baserate)
 TODO. More...
 
void set_stimulation_mode (StimulusGroupModeType mode)
 Sets the stimulation mode. Can be any of StimulusGroupModeType (MANUAL,RANDOM,SEQUENTIAL,SEQUENTIAL_REV). More...
 
void set_all (AurynFloat val=0.0)
 Sets sets the activity of all units. More...
 
void seed (int rndseed)
 Seeds the random number generator for all stimulus groups of the simulation. More...
 
AurynFloat get_activity (NeuronID i)
 Gets the activity of unit i. More...
 
virtual void load_patterns (string filename)
 Loads stimulus patterns from a designated pat file given. More...
 
virtual void clear_patterns ()
 Clear stimulus patterns. More...
 
void set_mean_off_period (AurynFloat period)
 Set mean quiet interval between consecutive stimuli. More...
 
void set_mean_on_period (AurynFloat period)
 Set mean on period. More...
 
void set_pattern_activity (unsigned int i)
 Function that loops over the stimulus/pattern vector and sets the activity verctor to the gamma values given with the pattern. More...
 
void set_pattern_activity (unsigned int i, AurynFloat setval)
 Function that loops over the stimulus/pattern vector and sets the activity verctor to the given value. More...
 
virtual void set_active_pattern (unsigned int i)
 This function is called internally and sets the activity level to a given active stimulus. More...
 
void set_active_pattern (unsigned int i, AurynFloat default_value)
 This function is called internally and sets the activity level to a given active stimulus. More...
 
void set_next_action_time (double time)
 
void set_distribution (std::vector< double > probs)
 Setter for pattern probability distribution. More...
 
std::vector< double > get_distribution ()
 Getter for pattern probability distribution. More...
 
double get_distribution (int i)
 Getter for pattern i of the probability distribution. More...
 
unsigned int get_stim_count ()
 Returns number of stimuli shown. More...
 
AurynTime get_last_action_time ()
 returns the last action (stim on/off) time in units of AurynTime More...
 
AurynTime get_last_onset_time ()
 returns the last stimulus onset time in units of AurynTime More...
 
AurynTime get_last_offset_time ()
 returns the last stimulus offset time in units of AurynTime More...
 
AurynTime get_next_action_time ()
 returns the next action (stim on/off) time in units of AurynTime More...
 
unsigned int get_cur_stim ()
 returns the index of the current (or last – if not active anymore) active stimulus More...
 
bool get_stim_active ()
 Returns true if currently a stimulus is active and false otherwise. More...
 
void flat_distribution ()
 
void normalize_distribution ()
 
std::vector< type_pattern > * get_patterns ()
 
- Public Member Functions inherited from auryn::SpikingGroup
void add_state_vector (std::string key, AurynStateVector *state_vector)
 Adds a state vector passed as an argument to the dictinary. More...
 
void remove_state_vector (std::string key)
 Removes a state vector passed as an argument to the dictinary. More...
 
AurynStateVectorfind_state_vector (std::string key)
 Returns existing state vector by name or NULL if it does not exist. More...
 
AurynStateVectorget_state_vector (std::string key)
 Creates a new or returns an existing state vector by name. More...
 
AurynStateVectorget_existing_state_vector (std::string key)
 Returns an existing state with the supplied name. More...
 
AurynStateVectorcreate_state_vector (std::string key)
 Creates a new state vector and throws an exception if a vector with the same name exists. More...
 
AurynStateget_state_variable (std::string key)
 Creates a new group-wide state variable or returns an existing group-wide variable by name then returns a pointer to it. More...
 
void randomize_state_vector_gauss (std::string state_vector_name, AurynState mean, AurynState sigma, int seed=12239)
 Randomizes the content of a state vector with Gaussian random numbers. Seeding is MPI save. More...
 
 SpikingGroup (NeuronID size, NodeDistributionMode mode=AUTO)
 Default constructor. More...
 
virtual ~SpikingGroup ()
 Default destructor. More...
 
virtual void evolve_traces ()
 Evolves traces. More...
 
void set_name (std::string s)
 Set connection name. More...
 
std::string get_name ()
 Retrieves the groups name. More...
 
std::string get_file_name ()
 Extracts the class name of the connection from the file name. More...
 
std::string get_log_name ()
 Returns a string which is the combination of file and connection name for logging. More...
 
void inc_num_spike_attributes (int x)
 Instructs SpikingGroup to increase the number of spike attributes by x. More...
 
int get_num_spike_attributes ()
 
void conditional_evolve ()
 Conditional evolve functino which is called by System. More...
 
unsigned int get_locked_rank ()
 Returns locked rank for SpikingGroups which are not distributed across all ranks. More...
 
unsigned int get_locked_range ()
 Returns locked range of ranks for SpikingGroups which are not distributed across all ranks. More...
 
SpikeContainerget_spikes ()
 Returns pointer to a spike container that contains spikes which arrive in this timestep from all neurons in this group. More...
 
SpikeContainerget_spikes_immediate ()
 Returns pointer to SpikeContainer of spikes generated during the last evolve() step. More...
 
AttributeContainerget_attributes ()
 Returns pointer to Attributecontainer for usage in propagating Connection objects. Same as get_spikes_immediate(), however might be overwritten to contain Spikes that have been delayed. More...
 
AttributeContainerget_attributes_immediate ()
 Returns pointer to Attributecontainer of spikes generated during the last evolve() step. More...
 
NeuronID get_size ()
 Returns the size of the group. More...
 
NeuronID get_pre_size ()
 Returns the size of the group. More...
 
NeuronID calculate_rank_size (int rank=-1)
 Determines rank size and stores it in local variable. More...
 
NeuronID get_rank_size ()
 Returns the size on this rank. More...
 
NeuronID get_post_size ()
 Returns the size on this rank. More...
 
void set_clock_ptr (AurynTime *clock)
 
bool evolve_locally ()
 Returns true if the calling instance has units which are integrated on the current rank. More...
 
NeuronID get_uid ()
 Get the unique ID of the class. More...
 
Traceget_pre_trace (AurynFloat x)
 Returns a pre trace with time constant x. More...
 
void add_pre_trace (Trace *tr)
 Adds trace to pretrace stack of a connection. More...
 
Traceget_post_trace (AurynFloat x)
 Returns a post trace with time constant x. More...
 
void add_post_trace (Trace *tr)
 Adds trace to posttrace stack of a connection. More...
 
void push_spike (NeuronID spike)
 Pushes a local NeuronID as spike into the axonal SpikeDelay buffer. More...
 
void push_attribute (AurynFloat attrib)
 Pushes a spike attribute into the axonal SpikeDelay buffer. More...
 
void clear_spikes ()
 Clears all spikes stored in the delays which is useful to reset a network during runtime. More...
 
Traceget_post_state_trace (std::string state_name="mem", AurynFloat tau=10e-3, AurynFloat b=0.0)
 Returns a post trace of a neuronal state variable e.g. the membrane potential with time constant tau. More...
 
Traceget_post_state_trace (AurynStateVector *state, AurynFloat tau=10e-3, AurynFloat b=0.0)
 Returns a post trace of a neuronal state variable specified by pointer. More...
 
void set_delay (int d)
 Sets axonal delay for this SpikingGroup. More...
 
virtual bool write_to_file (const char *filename)
 Writes current states of SpikingGroup to human-readible textfile if implemented in derived class. More...
 
virtual bool load_from_file (const char *filename)
 Reads current states of SpikingGroup to human-readible textfile if implemented in derived class. More...
 
NeuronID ranksize ()
 Returns size (num of neurons) on the current rank. More...
 
NeuronID global2rank (NeuronID i)
 Converts global NeuronID within the SpikingGroup to the local NeuronID on this rank. More...
 
NeuronID rank2global (NeuronID i)
 Converts local NeuronID from the local rank to a global NeuronID. More...
 
bool localrank (NeuronID i)
 Checks if the global NeuronID i is integrated on this MPI rank. More...
 
NeuronID get_vector_size ()
 Rank size but rounded up to multiples of 4 (or potentially some other and larger number in future versions) for SSE compatibility. More...
 

Public Attributes

AurynDouble refractory_period
 Refractory period. More...
 
- Public Attributes inherited from auryn::StimulusGroup
int cur_stim_index
 Current stimulus index. More...
 
bool stimulus_active
 Current stimulus active. More...
 
std::vector< type_patternstimuli
 Vector containing all the stimuli. More...
 
AurynFloat scale
 This is by how much the pattern gamma value is multiplied. The resulting value gives the x-times baseline activation. More...
 
bool binary_patterns
 Switches to more efficient algorithm which ignores the gamma value. More...
 
AurynTime refractory_period
 Enables a finite refractory time specified in AurynTime (only works for non-binary-pattern mode. More...
 
bool randomintervals
 Determines if the Group is using random activation intervals. More...
 
bool randomintensities
 Determines if the Group is using random activation intensities. More...
 
AurynDouble background_rate
 Play random Poisson noise with this rate on all channels when no stim is active. More...
 
bool background_during_stimulus
 Switch for background firing during stimulus. More...
 
- Public Attributes inherited from auryn::SpikingGroup
SpikeDelaydelay
 
bool active
 Toggles group active. More...
 
std::map< std::string, AurynStateVector * > state_vectors
 
std::map< std::string, AurynStatestate_variables
 

Protected Member Functions

virtual void redraw ()
 
- Protected Member Functions inherited from auryn::StimulusGroup
void init (StimulusGroupModeType stimulusmode, string stimfile, AurynFloat baserate)
 
void write_stimulus_file (AurynDouble time)
 
void read_next_stimulus_from_file (AurynDouble &time, int &active, int &stimulusid)
 
void set_activity (NeuronID i, AurynFloat val=0.0)
 
- Protected Member Functions inherited from auryn::SpikingGroup
virtual void load_input_line (NeuronID i, const char *buf)
 
virtual std::string get_output_line (NeuronID i)
 
virtual void virtual_serialize (boost::archive::binary_oarchive &ar, const unsigned int version)
 Implementatinon of serialize function for writing. More...
 
virtual void virtual_serialize (boost::archive::binary_iarchive &ar, const unsigned int version)
 Implementatinon of serialize function for reading. More...
 
void free ()
 Frees potentially allocated memory. More...
 

Additional Inherited Members

- Protected Attributes inherited from auryn::StimulusGroup
AurynTimettl
 
AurynFloatactivity
 
StimulusGroupModeType stimulus_order
 
unsigned int stimulation_count
 Counter variable for number of stimuli shown. More...
 
NeuronID fgx
 
NeuronID bgx
 
std::vector< double > probabilities
 
AurynTime next_action_time
 next stimulus time requiring change in rates More...
 
AurynTime last_action_time
 last stimulus time requiring change in rates More...
 
AurynTime last_stim_onset_time
 last stimulus onset time More...
 
AurynTime last_stim_offset_time
 last stimulus offset time More...
 
AurynFloat mean_off_period
 
AurynFloat mean_on_period
 
AurynFloat curscale
 
- Protected Attributes inherited from auryn::SpikingGroup
std::vector< Trace * > pretraces
 Pretraces. More...
 
std::vector< Trace * > posttraces
 Posttraces. More...
 
std::vector< Trace * > post_state_traces
 Post state traces. More...
 
std::vector< AurynFloatpost_state_traces_spike_biases
 
std::vector< AurynStateVector * > post_state_traces_states
 
std::string group_name
 Identifying name for object. More...
 
NeuronID size
 Stores the size of the group. More...
 
NeuronID rank_size
 Stores the size of the group on this rank. More...
 
SpikeContainerspikes
 SpikeContainers to store spikes produced during one step of evolve. More...
 
AttributeContainerattribs
 
- Static Protected Attributes inherited from auryn::StimulusGroup
static boost::mt19937 poisson_gen = boost::mt19937()
 
static boost::mt19937 order_gen = boost::mt19937()
 
static boost::uniform_01< boost::mt19937 > order_die = boost::uniform_01<boost::mt19937> (order_gen)
 
- Static Protected Attributes inherited from auryn::SpikingGroup
static AurynTimeclock_ptr = NULL
 

Constructor & Destructor Documentation

◆ SpikeTimingStimGroup() [1/2]

SpikeTimingStimGroup::SpikeTimingStimGroup ( NeuronID  n,
std::string  filename,
std::string  stimfile,
StimulusGroupModeType  stimulusmode = RANDOM,
AurynFloat  timeframe = 0.0 
)

Default constructor.

31  : StimulusGroup( n, filename, stimfile, stimulusmode, timeframe )
32 {
33  init();
34 }
StimulusGroup(NeuronID n, string filename, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat baserate=1.0)
Default constructor.
Definition: StimulusGroup.cpp:110
int n
Definition: mkpat.py:5

◆ SpikeTimingStimGroup() [2/2]

SpikeTimingStimGroup::SpikeTimingStimGroup ( NeuronID  n,
std::string  stimfile,
StimulusGroupModeType  stimulusmode = RANDOM,
AurynFloat  timeframe = 0.0 
)

Constructor without stimfile. Patterns can be loaded afterwards using the load_patterns method.

36  : StimulusGroup( n, stimfile, stimulusmode, timeframe )
37 {
38  init();
39 }
StimulusGroup(NeuronID n, string filename, string stimfile, StimulusGroupModeType stimulusmode=RANDOM, AurynFloat baserate=1.0)
Default constructor.
Definition: StimulusGroup.cpp:110
int n
Definition: mkpat.py:5

◆ ~SpikeTimingStimGroup()

SpikeTimingStimGroup::~SpikeTimingStimGroup ( )
virtual
42 {
43 }

Member Function Documentation

◆ evolve()

void SpikeTimingStimGroup::evolve ( )
virtual

Standard virtual evolve function

Reimplemented from auryn::StimulusGroup.

59 {
60  if ( !active ) return;
61 
62  if ( stimulus_active ) { // during active stimulation
63 
64  for ( NeuronID i = 0; i < get_rank_size() ; ++i ) {
65  // if ( ttl[i] ) { // DEBUG
66  // std::cout << ttl[i] << " " << sys->get_clock() << std::endl;
67  // }
68  if ( ttl[i] == sys->get_clock() ) {
69  push_spike(i);
70  }
71  }
72 
73  } else { // while stimulation is off
74  if ( background_rate ) {
75  boost::exponential_distribution<> dist(background_rate);
76  boost::variate_generator<boost::mt19937&, boost::exponential_distribution<> > die(poisson_gen, dist);
77 
78  while ( bgx < get_rank_size() ) {
79  push_spike ( bgx );
80  AurynDouble r = die();
81  bgx += 1+(NeuronID)(r/auryn_timestep);
82  }
83  bgx -= get_rank_size();
84  }
85  }
86 
87  // update stimulus properties
88  if ( auryn::sys->get_clock() >= next_action_time ) { // action required
89  last_action_time = next_action_time; // store last time before updating next_action_time
90 
91  if ( stimuli.size() == 0 ) {
92  set_next_action_time(10); // TODO make this a bit smarter at some point -- i.e. could send this to the end of time
93  return;
94  }
95 
97 
98  if ( stimulus_order == STIMFILE ) {
99  AurynDouble t = 0.0;
100  int a,i;
101  while ( t <= auryn::sys->get_time() ) {
104  if (a==0) stimulus_active = true;
105  else stimulus_active = false;
106  cur_stim_index = i;
107  // std::cout << auryn::sys->get_time() << " " << t << " " << a << " " << i << std::endl;
108  }
109  } else { // we have to generate stimulus times
110 
111  if ( stimulus_active ) { // stimulus was active and going inactive now
112 
113  set_all( 0.0 ); // turns off currently active stimulus
114  stimulus_active = false ;
116 
117  if ( randomintervals ) {
118  boost::exponential_distribution<> dist(1./mean_off_period);
119  boost::variate_generator<boost::mt19937&, boost::exponential_distribution<> > die(order_gen, dist);
121  } else {
123  }
124  } else { // stimulus was not active and is going active now
125  if ( active && stimuli.size() ) { // the group is active and there are stimuli in the array
126 
127  // chooses stimulus according to schema specified in stimulusmode
128  double draw, cummulative;
129  switch ( stimulus_order ) {
130  case RANDOM:
131  // TODO make this less greedy
132  // and do not compute this every draw
133  draw = order_die();
134  cummulative = 0;
136  cur_stim_index = 0;
137  // std::cout.precision(5);
138  // std::cout << " draw " << draw << std::endl;
139  for ( unsigned int i = 0 ; i < probabilities.size() ; ++i ) {
140  cummulative += probabilities[i];
141  // std::cout << cummulative << std::endl;
142  if ( draw <= cummulative ) {
143  cur_stim_index = i;
144  break;
145  }
146  }
147  break;
148  case SEQUENTIAL:
150  break;
151  case SEQUENTIAL_REV:
152  --cur_stim_index;
153  if ( cur_stim_index <= 0 )
154  cur_stim_index = stimuli.size() - 1 ;
155  break;
156  case MANUAL:
157  default:
158  break;
159  }
160 
161  // sets the activity
162  set_active_pattern( cur_stim_index, 1e20 ); // puts default spikes into the not forseeable future
163  stimulus_active = true;
165 
167  }
168  }
170  }
171  }
172 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
void write_stimulus_file(AurynDouble time)
Definition: StimulusGroup.cpp:162
r
Definition: mkpat.py:9
NeuronID bgx
Definition: StimulusGroup.h:80
AurynDouble refractory_period
Refractory period.
Definition: SpikeTimingStimGroup.h:58
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
static boost::mt19937 order_gen
Definition: StimulusGroup.h:89
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
double AurynDouble
Higher precision floating point datatype.
Definition: auryn_definitions.h:158
StimulusGroupModeType stimulus_order
Definition: StimulusGroup.h:70
Definition: auryn_definitions.h:148
Definition: auryn_definitions.h:148
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
bool active
Toggles group active.
Definition: SpikingGroup.h:149
void set_next_action_time(double time)
Definition: StimulusGroup.cpp:559
AurynFloat mean_off_period
Definition: StimulusGroup.h:122
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
Definition: auryn_definitions.h:148
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
void push_spike(NeuronID spike)
Pushes a local NeuronID as spike into the axonal SpikeDelay buffer.
Definition: SpikingGroup.cpp:270
AurynTime last_stim_onset_time
last stimulus onset time
Definition: StimulusGroup.h:101
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
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
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
AurynTime get_clock()
Gets the current clock value in AurynTime.
Definition: System.cpp:231
bool randomintervals
Determines if the Group is using random activation intervals.
Definition: StimulusGroup.h:157
AurynDouble background_rate
Play random Poisson noise with this rate on all channels when no stim is active.
Definition: StimulusGroup.h:164
Definition: auryn_definitions.h:148
unsigned int stimulation_count
Counter variable for number of stimuli shown.
Definition: StimulusGroup.h:74
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
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ redraw()

void SpikeTimingStimGroup::redraw ( )
protectedvirtual

Draw all Time-To-Live (ttls) typically after changing the any of the activiteis

Reimplemented from auryn::StimulusGroup.

52 {
53  for ( NeuronID i = 0; i < get_rank_size() ; ++i ) {
55  }
56 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
AurynFloat * activity
Definition: StimulusGroup.h:67
AurynTime * ttl
Definition: StimulusGroup.h:65
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
AurynTime get_clock()
Gets the current clock value in AurynTime.
Definition: System.cpp:231
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

Member Data Documentation

◆ refractory_period

AurynDouble auryn::SpikeTimingStimGroup::refractory_period

Refractory period.

Refractory period in seconds gets adde to the potentially stochastic off time and ensures a minimum interval between stimuli.


The documentation for this class was generated from the following files: