CARLsim  5.0.0
CARLsim: a GPU-accelerated SNN simulator
spike_monitor.h
Go to the documentation of this file.
1 /* * Copyright (c) 2016 Regents of the University of California. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * 3. The names of its contributors may not be used to endorse or promote
15 * products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * *********************************************************************************************** *
31 * CARLsim
32 * created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
33 * maintained by:
34 * (MA) Mike Avery <averym@uci.edu>
35 * (MB) Michael Beyeler <mbeyeler@uci.edu>,
36 * (KDC) Kristofor Carlson <kdcarlso@uci.edu>
37 * (TSC) Ting-Shuo Chou <tingshuc@uci.edu>
38 * (HK) Hirak J Kashyap <kashyaph@uci.edu>
39 *
40 * CARLsim v1.0: JM, MDR
41 * CARLsim v2.0/v2.1/v2.2: JM, MDR, MA, MB, KDC
42 * CARLsim3: MB, KDC, TSC
43 * CARLsim4: TSC, HK
44 * CARLsim5: HK, JX, KC
45 *
46 * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
47 * Ver 12/31/2016
48 */
49 
50 // paradigm shift: run this on spikes.
51 
52 #ifndef _SPIKE_MON_H_
53 #define _SPIKE_MON_H_
54 
55 #include <carlsim_datastructures.h> // SpikeMonMode
56 #include <vector> // std::vector
57 
58 class SNN; // forward declaration of SNN class
59 class SpikeMonitorCore; // forward declaration of implementation
60 
121  public:
128  SpikeMonitor(SpikeMonitorCore* spikeMonitorCorePtr);
129 
136  ~SpikeMonitor();
137 
138 
139  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
140 
150  void clear();
151 
163  std::vector<float> getAllFiringRates();
164 
176  std::vector<float> getAllFiringRatesSorted();
177 
187  float getMaxFiringRate();
188 
198  float getMinFiringRate();
199 
212  float getNeuronMeanFiringRate(int neurId);
213 
226  int getNeuronNumSpikes(int neurId);
227 
237  int getNumNeuronsWithFiringRate(float min, float max);
238 
248  int getNumSilentNeurons();
249 
262  float getPercentNeuronsWithFiringRate(float min, float max);
263 
273  float getPercentSilentNeurons();
274 
286  float getPopMeanFiringRate();
287 
299  float getPopStdFiringRate();
300 
312  int getPopNumSpikes();
313 
326  std::vector<std::vector<int> > getSpikeVector2D();
327 
334  bool isRecording();
335 
342  void print(bool printSpikeTimes=true);
343 
357  void startRecording();
358 
372  void stopRecording();
373 
384  long int getRecordingTotalTime();
385 
393  long int getRecordingLastStartTime();
394 
402  long int getRecordingStartTime();
403 
410  long int getRecordingStopTime();
411 
420  bool getPersistentData();
421 
431  void setPersistentData(bool persistentData);
432 
444 
455  void setMode(SpikeMonMode mode=AER);
456 
473  void setLogFile(const std::string& logFileName);
474 
475  private:
477  SpikeMonitorCore* spikeMonitorCorePtr_;
478 
479 };
480 
481 #endif
AER
@ AER
mode in which spike information is collected in AER format
Definition: carlsim_datastructures.h:203
SpikeMonitorCore
Definition: spike_monitor_core.h:71
SpikeMonitor
Class SpikeMonitor.
Definition: spike_monitor.h:120
SpikeMonitor::clear
void clear()
Truncates the 2D spike vector.
Definition: spike_monitor.cpp:70
SpikeMonitor::getPercentSilentNeurons
float getPercentSilentNeurons()
returns the percentage of total neurons in group that are silent.
Definition: spike_monitor.cpp:168
SpikeMonitor::setPersistentData
void setPersistentData(bool persistentData)
Sets PersistentMode either on (true) or off (false)
Definition: spike_monitor.cpp:247
SpikeMonitor::~SpikeMonitor
~SpikeMonitor()
SpikeMonitor destructor.
Definition: spike_monitor.cpp:64
carlsim_datastructures.h
SpikeMonitor::isRecording
bool isRecording()
Recording status (true=recording, false=not recording)
Definition: spike_monitor.cpp:190
SpikeMonitor::getPopNumSpikes
int getPopNumSpikes()
Returns the total number of spikes in the group.
Definition: spike_monitor.cpp:91
SpikeMonitor::getMinFiringRate
float getMinFiringRate()
returns the smallest neuronal mean firing rate in the group
Definition: spike_monitor.cpp:109
SpikeMonitor::getAllFiringRates
std::vector< float > getAllFiringRates()
Returns the average firing rate of all the neurons in the group as a vector of floats.
Definition: spike_monitor.cpp:116
SpikeMonitor::print
void print(bool printSpikeTimes=true)
prints the 2D spike vector.
Definition: spike_monitor.cpp:194
SpikeMonitor::stopRecording
void stopRecording()
Ends a recording period.
Definition: spike_monitor.cpp:208
SpikeMonitor::getRecordingLastStartTime
long int getRecordingLastStartTime()
Returns the simulation time (ms) of the last call to startRecording()
Definition: spike_monitor.cpp:222
SpikeMonitor::SpikeMonitor
SpikeMonitor(SpikeMonitorCore *spikeMonitorCorePtr)
SpikeMonitor constructor.
Definition: spike_monitor.cpp:59
SpikeMonitor::getMode
SpikeMonMode getMode()
Returns the current SpikeMonitor mode.
Definition: spike_monitor.cpp:251
SpikeMonitor::getPopStdFiringRate
float getPopStdFiringRate()
Returns the standard deviation of firing rates in the entire neuronal population.
Definition: spike_monitor.cpp:84
SpikeMonitor::getRecordingStartTime
long int getRecordingStartTime()
Returns the simulation time (ms) of the first call to startRecording()
Definition: spike_monitor.cpp:229
SpikeMonitor::getPopMeanFiringRate
float getPopMeanFiringRate()
Returns the mean firing rate of the entire neuronal population.
Definition: spike_monitor.cpp:77
SpikeMonitor::getSpikeVector2D
std::vector< std::vector< int > > getSpikeVector2D()
returns the 2D spike vector
Definition: spike_monitor.cpp:175
SpikeMonitor::getPersistentData
bool getPersistentData()
Returns a flag that indicates whether PersistentMode is on (true) or off (false)
Definition: spike_monitor.cpp:243
SpikeMonitor::getPercentNeuronsWithFiringRate
float getPercentNeuronsWithFiringRate(float min, float max)
returns the percentage of total neurons in that are in the range specified by the user,...
Definition: spike_monitor.cpp:151
SpikeMonitor::getNeuronMeanFiringRate
float getNeuronMeanFiringRate(int neurId)
returns the mean firing rate of a specific neuron in the group
Definition: spike_monitor.cpp:123
SpikeMonitor::getNumSilentNeurons
int getNumSilentNeurons()
returns the number of neurons that are silent.
Definition: spike_monitor.cpp:161
SpikeMonitor::getRecordingStopTime
long int getRecordingStopTime()
Returns the simulation time (ms) of the last call to stopRecording()
Definition: spike_monitor.cpp:236
SpikeMonMode
SpikeMonMode
SpikeMonitor mode.
Definition: carlsim_datastructures.h:201
SpikeMonitor::startRecording
void startRecording()
Starts a new recording period.
Definition: spike_monitor.cpp:201
SpikeMonitor::setLogFile
void setLogFile(const std::string &logFileName)
Sets the name of the spike file binary.
Definition: spike_monitor.cpp:263
SpikeMonitor::getNumNeuronsWithFiringRate
int getNumNeuronsWithFiringRate(float min, float max)
Returns the number of neurons that fall within this particular min/max range (inclusive).
Definition: spike_monitor.cpp:143
SpikeMonitor::getNeuronNumSpikes
int getNeuronNumSpikes(int neurId)
returns the total number of spikes of a specific neuron in the group
Definition: spike_monitor.cpp:131
SpikeMonitor::getRecordingTotalTime
long int getRecordingTotalTime()
Returns the total recording time (ms)
Definition: spike_monitor.cpp:215
SNN
Contains all of CARLsim's core functionality.
Definition: snn.h:115
SpikeMonitor::getAllFiringRatesSorted
std::vector< float > getAllFiringRatesSorted()
Returns all the neuronal mean firing rates in ascending order.
Definition: spike_monitor.cpp:183
SpikeMonitor::getMaxFiringRate
float getMaxFiringRate()
returns the largest neuronal mean firing rate in the group
Definition: spike_monitor.cpp:102
SpikeMonitor::setMode
void setMode(SpikeMonMode mode=AER)
Sets the current SpikeMonitor mode.
Definition: spike_monitor.cpp:255