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

Monitor class to record population firing rates. More...

#include <BurstRateMonitor.h>

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

Public Member Functions

 BurstRateMonitor (SpikingGroup *source, string filename="", AurynDouble binsize=0.1)
 Default Constructor. More...
 
virtual ~BurstRateMonitor ()
 Default Destructor. More...
 
void set_tau (double tau)
 Sets burst detector time constant. More...
 
void execute ()
 Implementation of necessary execute() function. More...
 

Public Attributes

AurynStateVectorburst_state
 Burst state. More...
 

Protected Member Functions

void init (SpikingGroup *source, string filename, AurynDouble binsize)
 Default init method. More...
 
virtual void virtual_serialize (boost::archive::binary_oarchive &ar, const unsigned int version)
 
virtual void virtual_serialize (boost::archive::binary_iarchive &ar, const unsigned int version)
 
- Protected Member Functions inherited from auryn::Monitor
virtual void open_output_file (std::string filename)
 
virtual void flush ()
 Flush to file. More...
 
 Monitor (std::string filename, std::string default_extension="dat")
 Standard constructor with file name. More...
 
 Monitor ()
 Constructor which does not open a text file for output. More...
 
std::string generate_filename (std::string name_hint="")
 Generates a default filename from the device ID. More...
 
virtual ~Monitor ()
 Standard destructor. More...
 
- Protected Member Functions inherited from auryn::Device
void init ()
 Standard initializer to be called by the constructor. More...
 
 Device ()
 Standard constructor. More...
 
void set_name (std::string s)
 Set device name. More...
 
std::string get_name ()
 Get device name. More...
 
int get_id ()
 Get numeric device id. More...
 
virtual ~Device ()
 Standard destructor. More...
 
virtual void evolve ()
 

Protected Attributes

SpikingGroupsrc
 The source SpikingGroup. More...
 
- Protected Attributes inherited from auryn::Monitor
std::ofstream outfile
 
std::string fname
 
std::string default_file_extension
 
bool active
 Standard active switch. More...
 
- Protected Attributes inherited from auryn::Device
std::string device_name
 Identifying name for device. More...
 
bool active
 Standard active switch. More...
 

Detailed Description

Monitor class to record population firing rates.

Instances of this class record the population firing rate of the src SpikingGroup assigned. Binning is done discretely in bins of size bsize that is directly transformed in discrete AurynTime steps. The default

Constructor & Destructor Documentation

◆ BurstRateMonitor()

BurstRateMonitor::BurstRateMonitor ( SpikingGroup source,
std::string  filename = "",
AurynDouble  binsize = 0.1 
)

Default Constructor.

Parameters
30  : Monitor(filename)
31 {
32  init(source,filename,binsize);
33 }
void init()
Standard initializer to be called by the constructor.
Definition: Device.cpp:32
Monitor()
Constructor which does not open a text file for output.
Definition: Monitor.cpp:47
Here is the call graph for this function:

◆ ~BurstRateMonitor()

BurstRateMonitor::~BurstRateMonitor ( )
virtual

Default Destructor.

61 {
62 }

Member Function Documentation

◆ execute()

void BurstRateMonitor::execute ( )
virtual

Implementation of necessary execute() function.

Reimplemented from auryn::Device.

70 {
71  if ( src->evolve_locally() ) {
72 
73  // loop over all spikes to separate events from bursts
74  SpikeContainer::const_iterator spk;
75  for ( spk = src->get_spikes_immediate()->begin() ;
76  spk < src->get_spikes_immediate()->end() ;
77  ++spk ) {
78 
79  const NeuronID s = src->global2rank(*spk);
80 
81  // detect first spike in bursts and non-burst spikes
82  if ( post_trace->get(s) < thr ) {
83  ++event_counter;
84  burst_state->set(s,-1.0);
85  } else // detect second spike in burst
86  if ( burst_state->get(s) < 0.0 ) {
87  ++burst_counter;
88  burst_state->set(s,1);
89  }
90  }
91 
92 
93  // record to file every now and then
94  if (auryn::sys->get_clock()%ssize==0) {
95  const double burst_rate = scaleconst*burst_counter;
96  const double event_rate = scaleconst*event_counter;
97  burst_counter = 0;
98  event_counter = 0;
99  // outfile << std::setiosflags(ios::fixed) << std::setprecision(3);
101  << " " << burst_rate
102  << " " << event_rate << "\n";
103  }
104 
105  // last_post_val->copy(post_trace);
106  }
107 }
NeuronID global2rank(NeuronID i)
Converts global NeuronID within the SpikingGroup to the local NeuronID on this rank.
Definition: SpikingGroup.h:446
AurynStateVector * burst_state
Burst state.
Definition: BurstRateMonitor.h:73
void set(IndexType i, T value)
Sets element i in vector to value.
Definition: AurynVector.h:224
bool evolve_locally()
Returns true if the calling instance has units which are integrated on the current rank...
Definition: SpikingGroup.cpp:323
T get(IndexType i)
Gets element i from vector.
Definition: AurynVector.h:207
std::ofstream outfile
Definition: Monitor.h:58
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
SpikingGroup * src
The source SpikingGroup.
Definition: BurstRateMonitor.h:64
AurynDouble get_time()
Gets the current system time in [s].
Definition: System.cpp:226
SpikeContainer * get_spikes_immediate()
Returns pointer to SpikeContainer of spikes generated during the last evolve() step.
Definition: SpikingGroup.cpp:250
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:

◆ init()

void BurstRateMonitor::init ( SpikingGroup source,
std::string  filename,
AurynDouble  binsize 
)
protected

Default init method.

36 {
38 
39  src = source;
40  scaleconst = 1.0/binsize/src->get_rank_size();
41  ssize = (1.0*binsize/auryn_timestep);
42  if ( ssize < 1 ) ssize = 1;
43  event_counter = 0;
44  burst_counter = 0;
45 
46  const double default_tau = 16e-3;
47  post_trace = src->get_post_trace(default_tau);
48  burst_state = src->get_state_vector("_burst_state");
49 
50  set_tau(default_tau);
51  thr = 1.0+std::exp(-1.0);
52 
53 
54  std::stringstream oss;
55  oss << "BurstRateMonitor:: Setting binsize " << binsize << "s";
56  auryn::logger->msg(oss.str(),NOTIFICATION);
57 
58 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
void set_tau(double tau)
Sets burst detector time constant.
Definition: BurstRateMonitor.cpp:64
Definition: Logger.h:41
AurynStateVector * get_state_vector(std::string key)
Creates a new or returns an existing state vector by name.
Definition: SpikingGroup.cpp:781
AurynStateVector * burst_state
Burst state.
Definition: BurstRateMonitor.h:73
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void register_device(Device *device)
Registers an instance of Device to the devices vector.
Definition: System.cpp:272
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
SpikingGroup * src
The source SpikingGroup.
Definition: BurstRateMonitor.h:64
Trace * get_post_trace(AurynFloat x)
Returns a post trace with time constant x.
Definition: SpikingGroup.cpp:390
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
Here is the call graph for this function:

◆ set_tau()

void BurstRateMonitor::set_tau ( double  tau)

Sets burst detector time constant.

65 {
66  post_trace->set_timeconstant(tau);
67 }
virtual void set_timeconstant(AurynFloat timeconstant)
Set the time constant of the trace.
Definition: Trace.cpp:41
Here is the call graph for this function:

◆ virtual_serialize() [1/2]

void BurstRateMonitor::virtual_serialize ( boost::archive::binary_oarchive &  ar,
const unsigned int  version 
)
protectedvirtual

Functions necesssary for serialization and loading saving to netstate files.

Reimplemented from auryn::Monitor.

110 {
111  ar & burst_counter ;
112  ar & event_counter ;
113 }

◆ virtual_serialize() [2/2]

void BurstRateMonitor::virtual_serialize ( boost::archive::binary_iarchive &  ar,
const unsigned int  version 
)
protectedvirtual

Reimplemented from auryn::Monitor.

116 {
117  ar & burst_counter ;
118  ar & event_counter ;
119 }

Member Data Documentation

◆ burst_state

AurynStateVector* auryn::BurstRateMonitor::burst_state

Burst state.

◆ src

SpikingGroup* auryn::BurstRateMonitor::src
protected

The source SpikingGroup.


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