61 monitorId_ = monitorId;
66 grpMonLastUpdated_ = 0;
68 persistentData_ =
false;
70 needToWriteFileHeader_ =
true;
71 groupFileSignature_ = 206661989;
72 groupFileVersion_ = 0.2f;
78 void GroupMonitorCore::init() {
94 if (groupFileId_ != NULL) {
118 timeVector_.push_back(time);
119 dataVector_.push_back(data);
125 timeVector_.push_back(time);
126 data4Vector_[0].push_back(_DA);
127 data4Vector_[1].push_back(_5HT);
128 data4Vector_[2].push_back(_ACh);
129 data4Vector_[3].push_back(_NE);
137 return data4Vector_[transmitter];
145 std::vector<int> peakTimeVector;
147 int size = dataVector_.size() - 1;
148 for (
int i = 1; i < size; i++) {
149 if (dataVector_[i-1] < dataVector_[i] && dataVector_[i] > dataVector_[i+1])
150 peakTimeVector.push_back(timeVector_[i]);
153 return peakTimeVector;
157 std::vector<int> sortedPeakTimeVector;
159 int size = dataVector_.size() - 1;
160 for (
int i = 1; i < size; i++) {
161 if (dataVector_[i-1] < dataVector_[i] && dataVector_[i] > dataVector_[i+1])
162 sortedPeakTimeVector.push_back(timeVector_[i]);
165 std::sort(sortedPeakTimeVector.begin(), sortedPeakTimeVector.end());
166 std::reverse(sortedPeakTimeVector.begin(), sortedPeakTimeVector.end());
168 return sortedPeakTimeVector;
172 std::vector<float> peakValueVector;
174 int size = dataVector_.size() - 1;
175 for (
int i = 1; i < size; i++) {
176 if (dataVector_[i-1] < dataVector_[i] && dataVector_[i] > dataVector_[i+1])
177 peakValueVector.push_back(dataVector_[i]);
180 return peakValueVector;
184 std::vector<float> sortedPeakValueVector;
186 int size = dataVector_.size() - 1;
187 for (
int i = 1; i < size; i++) {
188 if (dataVector_[i-1] < dataVector_[i] && dataVector_[i] > dataVector_[i+1])
189 sortedPeakValueVector.push_back(dataVector_[i]);
192 std::sort(sortedPeakValueVector.begin(), sortedPeakValueVector.end());
193 std::reverse(sortedPeakValueVector.begin(), sortedPeakValueVector.end());
195 return sortedPeakValueVector;
199 if (!persistentData_) {
211 if (persistentData_) {
214 startTime_ = (startTime_<0) ? currentTime : startTime_;
215 startTimeLast_ = currentTime;
216 accumTime_ = (totalTime_>0) ? totalTime_ : 0;
219 startTime_ = currentTime;
220 startTimeLast_ = currentTime;
227 assert(startTime_>-1 && startTimeLast_>-1 && accumTime_>-1);
237 totalTime_ = stopTime_-startTimeLast_ + accumTime_;
238 assert(totalTime_>=0);
245 if (groupFileId_ != NULL)
246 KERNEL_ERROR(
"GroupMonitorCore: setGroupFileId() has already been called.");
248 groupFileId_ = groupFileId;
250 if (groupFileId_ == NULL)
251 needToWriteFileHeader_ =
false;
254 needToWriteFileHeader_ =
true;
255 writeGroupFileHeader();
261 void GroupMonitorCore::writeGroupFileHeader() {
262 if (!needToWriteFileHeader_)
266 if (!fwrite(&groupFileSignature_,
sizeof(
int), 1, groupFileId_))
267 KERNEL_ERROR(
"GroupMonitorCore: writeSpikeFileHeader has fwrite error");
270 if (!fwrite(&groupFileVersion_,
sizeof(
float), 1, groupFileId_))
271 KERNEL_ERROR(
"GroupMonitorCore: writeGroupFileHeader has fwrite error");
275 int tmpInt = grid.
numX;
276 if (!fwrite(&tmpInt,
sizeof(
int), 1, groupFileId_))
277 KERNEL_ERROR(
"GroupMonitorCore: writeGroupFileHeader has fwrite error");
281 if (!fwrite(&tmpInt,
sizeof(
int),1,groupFileId_))
282 KERNEL_ERROR(
"GroupMonitorCore: writeGroupFileHeader has fwrite error");
286 if (!fwrite(&tmpInt,
sizeof(
int),1,groupFileId_))
287 KERNEL_ERROR(
"GroupMonitorCore: writeGroupFileHeader has fwrite error");
306 if (!fwrite(&tmpInt,
sizeof(
int),1,groupFileId_))
307 KERNEL_ERROR(
"ConnectionMonitor: writeConnectFileHeader has fwrite error");
312 needToWriteFileHeader_ =
false;
std::vector< float > getDataVector()
get the group data
std::vector< int > getSortedPeakTimeVector()
get the sorted timestamps for peak values
bool isRecording()
returns recording status
void updateGroupMonitor(int grpId=ALL)
access group status (currently the concentration of neuromodulator)
~GroupMonitorCore()
destructor, cleans up all the memory upon object deletion
std::vector< int > getTimeVector()
get the timestamps for group data
std::vector< float > getPeakValueVector()
get the peak values of group data
#define KERNEL_ERROR(formatc,...)
void setGroupFileId(FILE *groupFileId)
sets pointer to group data file
void pushData(int time, float data)
inserts group data (time, value) into the vectors , if monitor is in DA_MODE
Grid3D getGroupGrid3D(int grpId)
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)...
const FILE * getLogFpLog()
returns file pointer to log file
void startRecording()
starts recording group data
std::vector< float > getSortedPeakValueVector()
get the sorted peak values of group data
void clear()
deletes the data vector
const FILE * getLogFpErr()
returns file pointer to error log
Contains all of CARLsim's core functionality.
GroupMonitorCore(SNN *snn, int monitorId, int grpId, int mode=DA_MODE)
constructor (called by CARLsim::setGroupMonitor)
const FILE * getLogFpDeb()
returns file pointer to debug log
void stopRecording()
stops recording group data
std::vector< int > getPeakTimeVector()
get the timestamps for peak values
int getGroupNumNeurons(int gGrpId)
const FILE * getLogFpInf()
function writes population weights from gIDpre to gIDpost to file fname in binary.