CARLsim  3.1.3
CARLsim: a GPU-accelerated SNN simulator
spike_monitor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Regents of the University of California. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * 3. The names of its contributors may not be used to endorse or promote
16  * products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * *************************************************************************
32  * CARLsim
33  * created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
34  * maintained by: (MA) Mike Avery <averym@uci.edu>, (MB) Michael Beyeler <mbeyeler@uci.edu>,
35  * (KDC) Kristofor Carlson <kdcarlso@uci.edu>
36  * (TSC) Ting-Shuo Chou <tingshuc@uci.edu>
37  *
38  * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
39  * Ver 7/29/2014
40  */
41 
42 // paradigm shift: run this on spikes.
43 
44 #ifndef _SPIKE_MON_H_
45 #define _SPIKE_MON_H_
46 
47 #include <carlsim_datastructures.h> // spikeMonMode_t
48 #include <vector> // std::vector
49 #include <stdint.h>
50 
51 class CpuSNN; // forward declaration of CpuSNN class
52 class SpikeMonitorCore; // forward declaration of implementation
53 
114  public:
121  SpikeMonitor(SpikeMonitorCore* spikeMonitorCorePtr);
122 
129  ~SpikeMonitor();
130 
131 
132  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
133 
143  void clear();
144 
156  std::vector<float> getAllFiringRates();
157 
169  std::vector<float> getAllFiringRatesSorted();
170 
180  float getMaxFiringRate();
181 
191  float getMinFiringRate();
192 
205  float getNeuronMeanFiringRate(int neurId);
206 
219  int getNeuronNumSpikes(int neurId);
220 
230  int getNumNeuronsWithFiringRate(float min, float max);
231 
241  int getNumSilentNeurons();
242 
255  float getPercentNeuronsWithFiringRate(float min, float max);
256 
266  float getPercentSilentNeurons();
267 
279  float getPopMeanFiringRate();
280 
292  float getPopStdFiringRate();
293 
305  int getPopNumSpikes();
306 
319  std::vector<std::vector<int> > getSpikeVector2D();
320 
327  bool isRecording();
328 
335  void print(bool printSpikeTimes=true);
336 
350  void startRecording();
351 
365  void stopRecording();
366 
377  int64_t getRecordingTotalTime();
378 
386  int64_t getRecordingLastStartTime();
387 
395  int64_t getRecordingStartTime();
396 
403  int64_t getRecordingStopTime();
404 
413  bool getPersistentData();
414 
424  void setPersistentData(bool persistentData);
425 
437 
448  void setMode(spikeMonMode_t mode=AER);
449 
466  void setLogFile(const std::string& logFileName);
467 
468  private:
470  SpikeMonitorCore* spikeMonitorCorePtr_;
471 
472 };
473 
474 #endif
float getNeuronMeanFiringRate(int neurId)
returns the mean firing rate of a specific neuron in the group
void startRecording()
Starts a new recording period.
std::vector< float > getAllFiringRates()
Returns the average firing rate of all the neurons in the group as a vector of floats.
int getNumSilentNeurons()
returns the number of neurons that are silent.
float getPopMeanFiringRate()
Returns the mean firing rate of the entire neuronal population.
spikeMonMode_t
SpikeMonitor mode.
float getPercentSilentNeurons()
returns the percentage of total neurons in group that are silent.
int getNeuronNumSpikes(int neurId)
returns the total number of spikes of a specific neuron in the group
float getMinFiringRate()
returns the smallest neuronal mean firing rate in the group
int64_t getRecordingLastStartTime()
Returns the simulation time (ms) of the last call to startRecording()
Class SpikeMonitor.
SpikeMonitor(SpikeMonitorCore *spikeMonitorCorePtr)
SpikeMonitor constructor.
int64_t getRecordingStopTime()
Returns the simulation time (ms) of the last call to stopRecording()
spikeMonMode_t getMode()
Returns the current SpikeMonitor mode.
void stopRecording()
Ends a recording period.
float getPopStdFiringRate()
Returns the standard deviation of firing rates in the entire neuronal population. ...
int getNumNeuronsWithFiringRate(float min, float max)
Returns the number of neurons that fall within this particular min/max range (inclusive).
float getMaxFiringRate()
returns the largest neuronal mean firing rate in the group
void print(bool printSpikeTimes=true)
prints the 2D spike vector.
int getPopNumSpikes()
Returns the total number of spikes in the group.
~SpikeMonitor()
SpikeMonitor destructor.
bool isRecording()
Recording status (true=recording, false=not recording)
mode in which spike information is collected in AER format
int64_t getRecordingTotalTime()
Returns the total recording time (ms)
std::vector< float > getAllFiringRatesSorted()
Returns all the neuronal mean firing rates in ascending order.
float getPercentNeuronsWithFiringRate(float min, float max)
returns the percentage of total neurons in that are in the range specified by the user...
std::vector< std::vector< int > > getSpikeVector2D()
returns the 2D spike vector
void setMode(spikeMonMode_t mode=AER)
Sets the current SpikeMonitor mode.
void setLogFile(const std::string &logFileName)
Sets the name of the spike file binary.
void setPersistentData(bool persistentData)
Sets PersistentMode either on (true) or off (false)
int64_t getRecordingStartTime()
Returns the simulation time (ms) of the first call to startRecording()
void clear()
Truncates the 2D spike vector.
bool getPersistentData()
Returns a flag that indicates whether PersistentMode is on (true) or off (false)