CARLsim  4.1.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 *
45 * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
46 * Ver 12/31/2016
47 */
48 
49 // paradigm shift: run this on spikes.
50 
51 #ifndef _SPIKE_MON_H_
52 #define _SPIKE_MON_H_
53 
54 #include <carlsim_datastructures.h> // SpikeMonMode
55 #include <vector> // std::vector
56 
57 class SNN; // forward declaration of SNN class
58 class SpikeMonitorCore; // forward declaration of implementation
59 
120  public:
127  SpikeMonitor(SpikeMonitorCore* spikeMonitorCorePtr);
128 
135  ~SpikeMonitor();
136 
137 
138  // +++++ PUBLIC METHODS: +++++++++++++++++++++++++++++++++++++++++++++++//
139 
149  void clear();
150 
162  std::vector<float> getAllFiringRates();
163 
175  std::vector<float> getAllFiringRatesSorted();
176 
186  float getMaxFiringRate();
187 
197  float getMinFiringRate();
198 
211  float getNeuronMeanFiringRate(int neurId);
212 
225  int getNeuronNumSpikes(int neurId);
226 
236  int getNumNeuronsWithFiringRate(float min, float max);
237 
247  int getNumSilentNeurons();
248 
261  float getPercentNeuronsWithFiringRate(float min, float max);
262 
272  float getPercentSilentNeurons();
273 
285  float getPopMeanFiringRate();
286 
298  float getPopStdFiringRate();
299 
311  int getPopNumSpikes();
312 
325  std::vector<std::vector<int> > getSpikeVector2D();
326 
333  bool isRecording();
334 
341  void print(bool printSpikeTimes=true);
342 
356  void startRecording();
357 
371  void stopRecording();
372 
383  long int getRecordingTotalTime();
384 
392  long int getRecordingLastStartTime();
393 
401  long int getRecordingStartTime();
402 
409  long int getRecordingStopTime();
410 
419  bool getPersistentData();
420 
430  void setPersistentData(bool persistentData);
431 
443 
454  void setMode(SpikeMonMode mode=AER);
455 
472  void setLogFile(const std::string& logFileName);
473 
474  private:
476  SpikeMonitorCore* spikeMonitorCorePtr_;
477 
478 };
479 
480 #endif
AER
@ AER
mode in which spike information is collected in AER format
Definition: carlsim_datastructures.h:202
SpikeMonitorCore
Definition: spike_monitor_core.h:70
SpikeMonitor
Class SpikeMonitor.
Definition: spike_monitor.h:119
SpikeMonitor::clear
void clear()
Truncates the 2D spike vector.
Definition: spike_monitor.cpp:69
SpikeMonitor::getPercentSilentNeurons
float getPercentSilentNeurons()
returns the percentage of total neurons in group that are silent.
Definition: spike_monitor.cpp:167
SpikeMonitor::setPersistentData
void setPersistentData(bool persistentData)
Sets PersistentMode either on (true) or off (false)
Definition: spike_monitor.cpp:246
SpikeMonitor::~SpikeMonitor
~SpikeMonitor()
SpikeMonitor destructor.
Definition: spike_monitor.cpp:63
carlsim_datastructures.h
SpikeMonitor::isRecording
bool isRecording()
Recording status (true=recording, false=not recording)
Definition: spike_monitor.cpp:189
SpikeMonitor::getPopNumSpikes
int getPopNumSpikes()
Returns the total number of spikes in the group.
Definition: spike_monitor.cpp:90
SpikeMonitor::getMinFiringRate
float getMinFiringRate()
returns the smallest neuronal mean firing rate in the group
Definition: spike_monitor.cpp:108
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:115
SpikeMonitor::print
void print(bool printSpikeTimes=true)
prints the 2D spike vector.
Definition: spike_monitor.cpp:193
SpikeMonitor::stopRecording
void stopRecording()
Ends a recording period.
Definition: spike_monitor.cpp:207
SpikeMonitor::getRecordingLastStartTime
long int getRecordingLastStartTime()
Returns the simulation time (ms) of the last call to startRecording()
Definition: spike_monitor.cpp:221
SpikeMonitor::SpikeMonitor
SpikeMonitor(SpikeMonitorCore *spikeMonitorCorePtr)
SpikeMonitor constructor.
Definition: spike_monitor.cpp:58
SpikeMonitor::getMode
SpikeMonMode getMode()
Returns the current SpikeMonitor mode.
Definition: spike_monitor.cpp:250
SpikeMonitor::getPopStdFiringRate
float getPopStdFiringRate()
Returns the standard deviation of firing rates in the entire neuronal population.
Definition: spike_monitor.cpp:83
SpikeMonitor::getRecordingStartTime
long int getRecordingStartTime()
Returns the simulation time (ms) of the first call to startRecording()
Definition: spike_monitor.cpp:228
SpikeMonitor::getPopMeanFiringRate
float getPopMeanFiringRate()
Returns the mean firing rate of the entire neuronal population.
Definition: spike_monitor.cpp:76
SpikeMonitor::getSpikeVector2D
std::vector< std::vector< int > > getSpikeVector2D()
returns the 2D spike vector
Definition: spike_monitor.cpp:174
SpikeMonitor::getPersistentData
bool getPersistentData()
Returns a flag that indicates whether PersistentMode is on (true) or off (false)
Definition: spike_monitor.cpp:242
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:150
SpikeMonitor::getNeuronMeanFiringRate
float getNeuronMeanFiringRate(int neurId)
returns the mean firing rate of a specific neuron in the group
Definition: spike_monitor.cpp:122
SpikeMonitor::getNumSilentNeurons
int getNumSilentNeurons()
returns the number of neurons that are silent.
Definition: spike_monitor.cpp:160
SpikeMonitor::getRecordingStopTime
long int getRecordingStopTime()
Returns the simulation time (ms) of the last call to stopRecording()
Definition: spike_monitor.cpp:235
SpikeMonMode
SpikeMonMode
SpikeMonitor mode.
Definition: carlsim_datastructures.h:200
SpikeMonitor::startRecording
void startRecording()
Starts a new recording period.
Definition: spike_monitor.cpp:200
SpikeMonitor::setLogFile
void setLogFile(const std::string &logFileName)
Sets the name of the spike file binary.
Definition: spike_monitor.cpp:262
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:142
SpikeMonitor::getNeuronNumSpikes
int getNeuronNumSpikes(int neurId)
returns the total number of spikes of a specific neuron in the group
Definition: spike_monitor.cpp:130
SpikeMonitor::getRecordingTotalTime
long int getRecordingTotalTime()
Returns the total recording time (ms)
Definition: spike_monitor.cpp:214
SNN
Contains all of CARLsim's core functionality.
Definition: snn.h:114
SpikeMonitor::getAllFiringRatesSorted
std::vector< float > getAllFiringRatesSorted()
Returns all the neuronal mean firing rates in ascending order.
Definition: spike_monitor.cpp:182
SpikeMonitor::getMaxFiringRate
float getMaxFiringRate()
returns the largest neuronal mean firing rate in the group
Definition: spike_monitor.cpp:101
SpikeMonitor::setMode
void setMode(SpikeMonMode mode=AER)
Sets the current SpikeMonitor mode.
Definition: spike_monitor.cpp:254