CARLsim
3.1.3
CARLsim: a GPU-accelerated SNN simulator
|
Class SpikeMonitor. More...
#include <spike_monitor.h>
Public Member Functions | |
SpikeMonitor (SpikeMonitorCore *spikeMonitorCorePtr) | |
SpikeMonitor constructor. More... | |
~SpikeMonitor () | |
SpikeMonitor destructor. More... | |
void | clear () |
Truncates the 2D spike vector. More... | |
std::vector< float > | getAllFiringRates () |
Returns the average firing rate of all the neurons in the group as a vector of floats. More... | |
std::vector< float > | getAllFiringRatesSorted () |
Returns all the neuronal mean firing rates in ascending order. More... | |
float | getMaxFiringRate () |
returns the largest neuronal mean firing rate in the group More... | |
float | getMinFiringRate () |
returns the smallest neuronal mean firing rate in the group More... | |
spikeMonMode_t | getMode () |
Returns the current SpikeMonitor mode. More... | |
float | getNeuronMeanFiringRate (int neurId) |
returns the mean firing rate of a specific neuron in the group More... | |
int | getNeuronNumSpikes (int neurId) |
returns the total number of spikes of a specific neuron in the group More... | |
int | getNumNeuronsWithFiringRate (float min, float max) |
Returns the number of neurons that fall within this particular min/max range (inclusive). More... | |
int | getNumSilentNeurons () |
returns the number of neurons that are silent. More... | |
float | getPercentNeuronsWithFiringRate (float min, float max) |
returns the percentage of total neurons in that are in the range specified by the user, min/max (inclusive). More... | |
float | getPercentSilentNeurons () |
returns the percentage of total neurons in group that are silent. More... | |
bool | getPersistentData () |
Returns a flag that indicates whether PersistentMode is on (true) or off (false) More... | |
float | getPopMeanFiringRate () |
Returns the mean firing rate of the entire neuronal population. More... | |
int | getPopNumSpikes () |
Returns the total number of spikes in the group. More... | |
float | getPopStdFiringRate () |
Returns the standard deviation of firing rates in the entire neuronal population. More... | |
int64_t | getRecordingLastStartTime () |
Returns the simulation time (ms) of the last call to startRecording() More... | |
int64_t | getRecordingStartTime () |
Returns the simulation time (ms) of the first call to startRecording() More... | |
int64_t | getRecordingStopTime () |
Returns the simulation time (ms) of the last call to stopRecording() More... | |
int64_t | getRecordingTotalTime () |
Returns the total recording time (ms) More... | |
std::vector< std::vector< int > > | getSpikeVector2D () |
returns the 2D spike vector More... | |
bool | isRecording () |
Recording status (true=recording, false=not recording) More... | |
void | print (bool printSpikeTimes=true) |
prints the 2D spike vector. More... | |
void | setLogFile (const std::string &logFileName) |
Sets the name of the spike file binary. More... | |
void | setMode (spikeMonMode_t mode=AER) |
Sets the current SpikeMonitor mode. More... | |
void | setPersistentData (bool persistentData) |
Sets PersistentMode either on (true) or off (false) More... | |
void | startRecording () |
Starts a new recording period. More... | |
void | stopRecording () |
Ends a recording period. More... | |
The SpikeMonitor class allows a user record spike data from a particular neuron group. First the method CARLsim::setSpikeMonitor must be called with the group ID of the desired group as an argument. The setSpikeMonitor call returns a pointer to a SpikeMonitor object which can be queried for spike data.
There are two different modes that define what information is collected exactly.
Spike data will not be recorded until the SpikeMonitor member function startRecording() is called. Before any metrics can be computed, the user must call stopRecording(). In general, a new recording period (the time period between startRecording and stopRecording calls) can be started at any point in time, and can last any number of milliseconds. The SpikeMonitor has a PersistentMode, which is off by default. When PersistentMode is off, only the last recording period will be considered. When PersistentMode is on, all the recording periods will be considered. By default, PersistentMode can be switched on/off by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
The above configurations do not affect the generation of the .dat spike file. That file will always contain all the spikes of all the neurons in the group, for the entire simulation.
SpikeMonitor objects should only be used after setupNetwork has been called. SpikeMonitor objects will be deallocated automatically.
Example usage:
For additional information on how to use the SpikeMonitor object, please see Examples/spikeInfo.
Definition at line 113 of file spike_monitor.h.
SpikeMonitor | ( | SpikeMonitorCore * | spikeMonitorCorePtr | ) |
Creates a new instance of the SpikeMonitor class.
~SpikeMonitor | ( | ) |
Cleans up all the memory upon object deletion.
void clear | ( | ) |
This function truncates all the data found in the 2D spike vector. If PersistentMode is off, this function will be called automatically in startRecording(), such that all spikes from previous recording periods will be discarded. By default, PersistentMode is off. If PersistentMode is on, the user can call this function after any number of recordings. However, isRecording() must always be off.
std::vector<float> getAllFiringRates | ( | ) |
This function returns the average firing rate for each neuron in the group. If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime(). Use getGroupFiringRate() to get the mean firing rate of the entire group.
std::vector<float> getAllFiringRatesSorted | ( | ) |
This function returns a vector of neuronal mean firing rates, sorted in ascending order. The size of the vector is the same as the number of neurons in the group. Firing rates are converted to spikes/sec (Hz). If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
float getMaxFiringRate | ( | ) |
If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
float getMinFiringRate | ( | ) |
If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
spikeMonMode_t getMode | ( | ) |
This function returns the current SpikeMonitor mode. COUNT: Will collect only spike count information (such as number of spikes per neuron), not the explicit spike times. COUNT mode cannot retrieve exact spike times per neuron, and is thus not capable of computing spike train correlation etc. AER: Will collect spike information in AER format (will collect both neuron IDs and spike times).
float getNeuronMeanFiringRate | ( | int | neurId | ) |
This function returns the average firing rate of a specific neuron in the group in spikes/sec (Hz), averaged over the recording time window. If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime(). Use getPopMeanFiringRate to find the population mean firing rate.
[in] | neurId | the neuron ID (0-indexed, must be smaller than getNumNeurons) |
int getNeuronNumSpikes | ( | int | neurId | ) |
This function returns the total number of spikes emitted by a specific neuron in the recording period, which is equal to the number of elements in the 2D spike vector. If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime(). Use getGroupNumSpikes to find the number of spikes of all the neurons in the group.
[in] | neurId | the neuron ID (0-indexed, must be smaller than getNumNeurons) |
int getNumNeuronsWithFiringRate | ( | float | min, |
float | max | ||
) |
If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
int getNumSilentNeurons | ( | ) |
If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
float getPercentNeuronsWithFiringRate | ( | float | min, |
float | max | ||
) |
If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
min | minimum value of range (inclusive) to be searched. |
max | maximum value of range (inclusive) to be searched. |
float getPercentSilentNeurons | ( | ) |
If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
bool getPersistentData | ( | ) |
This function returns a flag that indicates whether PersistentMode is currently on (true) or off (false). If PersistentMode is off, only the last recording period will be considered for calculating metrics. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, but can be switched on at any point in time by calling setPersistentData(bool).
float getPopMeanFiringRate | ( | ) |
This function returns the average firing rate of all the neurons in the group in spikes/sec (Hz), averaged over the recording time window. If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
int getPopNumSpikes | ( | ) |
This function returns the total number of spikes in the group, which is equal to the number of elements in the 2D spike vector. If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime(). Use getNeuronNumSpikes to find the number of spikes of a specific neuron in the group.
float getPopStdFiringRate | ( | ) |
This function returns the standard deviation of firing rates of all the neurons in the group in spikes/sec (Hz), averaged over the recording time window. If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
int64_t getRecordingLastStartTime | ( | ) |
This function returns the simulation time (timestamp) of the last call to startRecording(). If PersistentMode is off, this number is equivalent to getRecordingStartTime().
int64_t getRecordingStartTime | ( | ) |
This function returns the simulation time (timestamp) of the first call to startRecording(). If PersistentMode is off, this number is equivalent to getRecordingLastStartTime().
int64_t getRecordingStopTime | ( | ) |
This function returns the simulation time (timestamp) of the last call to stopRecording().
int64_t getRecordingTotalTime | ( | ) |
This function returns the total amount of recording time upon which the calculated metrics are based. If PersistentMode is off, this number is equivalent to getRecordingStopTime()-getRecordingStartTime(). If PersistentMode is on, this number is equivalent to the total time accumulated over all past recording periods. Note that this is not necessarily equivalent to getRecordingStopTime()-getRecordingStartTime(), as there might have been periods in between where recording was off.
std::vector<std::vector<int> > getSpikeVector2D | ( | ) |
This function returns a 2D spike vector containing all the spikes of all the neurons in the group. The first dimension of the vector is neurons, the second dimension is spike times. Each element spkVector[i] is thus a vector of all spike times for the i-th neuron in the group. If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
bool isRecording | ( | ) |
Gets record status as a bool. True means it is recording, false means it is not recording.
void print | ( | bool | printSpikeTimes = true | ) |
This function prints all the spiking information in the group in legible format.
[in] | printSpikeTimes | whether to print the list of spike times for each neuron |
void setLogFile | ( | const std::string & | logFileName | ) |
This function sets the name of the spike file binary. It can be called at any time during the simulation, but must be called outside of startRecording / stopRecording periods. The function will close the previous file stream (the one that was set in CARLsim::setSpikeMonitor), and from that moment on direct new incoming spikes into a new file. This allows a user to record spikes to different files during a simulation, for example to "training.dat" and "testing.dat". In order to stop recording to file, pass string "NULL".
[in] | logFileName | path to binary file or "NULL" (for not recording to file at all) |
void setMode | ( | spikeMonMode_t | mode = AER | ) |
This function returns the current SpikeMonitor mode. COUNT: Will collect only spike count information (such as number of spikes per neuron), not the explicit spike times. COUNT mode cannot retrieve exact spike times per neuron, and is thus not capable of computing spike train correlation etc. AER: Will collect spike information in AER format (will collect both neuron IDs and spike times).
void setPersistentData | ( | bool | persistentData | ) |
This function sets PersistentMode either on (true) or off (false). If PersistentMode is off, only the last recording period will be considered for calculating metrics. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, but can be switched on at any point in time. The current state of PersistentMode can be retrieved by calling getPersistentData().
void startRecording | ( | ) |
This function starts a new recording period. From that moment onward, the 2D spike vector will be populated with all the spikes of all the neurons in the group. Before any metrics can be computed, the user must call stopRecording(). Recording periods must be ended with stopRecording(). In general, a new recording period can be started at any point in time, and can last any number of milliseconds. If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().
void stopRecording | ( | ) |
This function ends a recording period, at which point the 2D spike vector will no longer be populated with spikes. In general, a recording period can be ended at any point in time, and last any number of milliseconds. From this moment onward, a variety of metrics can be computed, which are based on the spikes found in the 2D spike vector. It is also possible to retrieve the raw spike vector itself by calling getSpikeVector2D(). If PersistentMode is off, only the last recording period will be considered. If PersistentMode is on, all the recording periods will be considered. By default, PersistentMode is off, and can be switched on by calling setPersistentData(bool). The total time over which the metric is calculated can be retrieved by calling getRecordingTotalTime().