00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef STATISTICSOUTPUT_H
00019 #define STATISTICSOUTPUT_H
00020
00021 using namespace std;
00022 #include <amygdala/types.h>
00023 #if GCC_VERSION >= 30000
00024 #include <ext/hash_map>
00025 #else
00026 #include <hash_map>
00027 #endif
00028 #include <vector>
00029 #include <set>
00030 #include <string>
00031 #include <amygdala/spikeoutput.h>
00032
00033 #include <stdio.h>
00034
00042 class StatisticsOutput : public SpikeOutput {
00043 public:
00044 StatisticsOutput();
00045 virtual ~StatisticsOutput();
00046
00051 virtual void OutputEvent(AmIdInt neuronId, AmTimeInt eventTime);
00052
00058 virtual void OutputCache() {};
00059
00065 void SetStepSize(AmTimeInt step);
00066
00070 AmTimeInt GetStepSize() const { return stepSize; }
00071
00079 void ClearHistory();
00080
00086 vector<unsigned int>& Histogram();
00087
00092 vector<unsigned int>& Histogram(AmIdInt neuronId);
00093
00099 vector<unsigned int> Histogram(AmTimeInt start, AmTimeInt end);
00100
00105 vector<unsigned int> Histogram(AmIdInt neuronId, AmTimeInt start, AmTimeInt end);
00106
00111 float PeakSpikeRate();
00112
00116 float PeakSpikeRate(AmIdInt neuronId);
00117
00122 AmTimeInt PeakRateTime();
00123
00127 AmTimeInt PeakRateTime(AmIdInt neuronId);
00128
00132 AmIdInt PeakNeuron();
00133
00138 AmIdInt MostActiveNeuron();
00139
00144 unsigned int TotalOutputSpikes();
00145
00149 unsigned int TotalOutputSpikes(AmIdInt neuronId);
00150
00155 float MeanSpikeRate();
00156
00161 float MeanSpikeRate(AmIdInt neuronId);
00162
00168 void LogSpikeTimes(string filename, AmTimeInt start=0, AmTimeInt end=~0);
00173 void AddTrace(AmIdInt nId);
00175 void CloseLog();
00176
00177 protected:
00179 void Log(AmIdInt neuronId, AmTimeInt eventTime);
00180
00181 protected:
00182 hash_map< AmIdInt, vector<AmTimeInt> > outputHistory;
00183
00186 hash_map< AmIdInt, vector<unsigned int> > histogram;
00187 vector<unsigned int> combinedHistogram;
00188
00189 AmIdInt maxPeakId;
00190 AmTimeInt maxPeakTime;
00191
00192 AmIdInt mostActiveId;
00193 unsigned int mostActiveCount;
00194
00195 float combinedPeakRate;
00196 AmTimeInt combinedPeakTime;
00197 float meanRate;
00198 unsigned int totalSpikeCount;
00199
00201 AmTimeInt stepSize;
00203 AmTimeInt beginTime;
00205 AmTimeInt calcTime;
00207 AmTimeInt lastCalcTime;
00209 set <AmIdInt> traceNeurons;
00210 bool logging;
00211 AmTimeInt logStart;
00212 AmTimeInt logEnd;
00213 FILE *logFd;
00214
00215 };
00216
00217 #endif