All Classes Namespaces Files Functions Variables Typedefs Macros
clizDectector.h
Go to the documentation of this file.
1 // clizDetector.h - ClusterLizard header file - Module: Detector
2 
3 // Copyright (C) 2013, 2014 Simeon Knieling, M.Sc.
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 //
9 
10 //Detector Class
11 
12 #pragma once
13 #ifndef _INCLUDE_CLIZDETECTOR
14 #define _INCLUDE_CLIZDETECTOR
15 
16 #include "clizSave.h"
17 
20 namespace cliz
21 {
22 
26  {
27  unsigned int filterCutOffBack;
28  unsigned int procChunkSize;
29  unsigned int detection;
30  unsigned int ref;
31  unsigned int stdmax;
32  unsigned int stdmin;
33  unsigned int w_pre;
34  unsigned int w_post;
35  unsigned int valuesperspike;
36  unsigned int maxNoiseTraces;
38  };
39 
56  class Detector
57  {
58  private:
59  DetectorHandle handle; //Parameter handle
60  std::vector<IndicesStruct> indicesOut; //Which Modules that receive output from this module need which output?
61  std::vector<Save*> inputSaveVec; //Input Saves
62  std::vector<Save*> outputSaveVec; //Output Saves
63 
64 
65  unsigned int numNoiseTraces; //Current number of noise traces in buffer
66 
67  float *spikes; //Spike buffer
68  float *noise; //Noise buffer
69  float *tempDataDetect; //Temporary data buffer
70  float *tempData; //Temporary data buffer
71 
72  float thr, thrMax; //Detection thresholds
73  float chunkRatio;
74  unsigned int nspk; //Number of spikes detected in internal data chunk
75  unsigned int gNspk; //Number of all spikes detected so far (only relevant for test datasets)
76  uint64_t *timestamps; //Timestamp buffer
77  uint64_t *externalTimestamps; //external timestamp buffer (only relevant for test datasets)
78  uint64_t lastChunkTimestamp; //Timestamp of first data point in last chunk
79  uint64_t lastSpikeTimestamp; //Timestamp of last spike
80  uint64_t lastNoiseTimestamp; //Timestamp of last noise trace
81  arma::Mat<float> whiteningMat; //Whitening matrix
82 
83  uint64_t currentTime; //Current time
84  MemoryManager memMan;
85 
86  public:
90  Detector(DetectorHandle iHandle, std::vector<Save*> &iInputSaveVec, std::vector<Save*> &iOutputSaveVec, std::vector<IndicesStruct> &iIndicesOut);
91 
95  Detector(DetectorHandle iHandle, std::vector<Save*> &iInputSaveVec, std::vector<Save*> &iOutputSaveVec, std::vector<IndicesStruct> &iIndicesOut, uint64_t initialTimeStamp);
96 
100  Detector(DetectorHandle iHandle, std::vector<Save*> &iInputSaveVec, std::vector<Save*> &iOutputSaveVec, std::vector<IndicesStruct> &iIndicesOut, uint64_t initialTimeStamp, uint64_t *externallyDetectedTS, unsigned int spikeCount);
101 
107  void detection(float *data, float *dataDetect);
108 
114  void externalDetection(float *data, float *dataDetect);
115 
119  void makeWhiteningMat();
120 
124  void threadFunc();
125 
127  {
128  memMan.free(tempDataDetect);
129  memMan.free(tempData);
130  memMan.free(noise);
131  memMan.free(timestamps);
132  memMan.free(spikes);
133  };
134  };
135 }
136 
137 #endif
void detection(float *data, float *dataDetect)
Definition: clizDetector.cpp:304
Definition: cliz.h:55
unsigned int valuesperspike
Definition: clizDectector.h:35
unsigned int maxNoiseTraces
Definition: clizDectector.h:36
unsigned int procChunkSize
Definition: clizDectector.h:28
Detector(DetectorHandle iHandle, std::vector< Save * > &iInputSaveVec, std::vector< Save * > &iOutputSaveVec, std::vector< IndicesStruct > &iIndicesOut)
Definition: clizDetector.cpp:22
void threadFunc()
Definition: clizDetector.cpp:152
void externalDetection(float *data, float *dataDetect)
Definition: clizDetector.cpp:483
Definition: clizDectector.h:56
unsigned int filterCutOffBack
Definition: clizDectector.h:27
Definition: clizDectector.h:25
unsigned int stdmax
Definition: clizDectector.h:31
Definition: clizFunctions.h:268
void free(memPtr *memAdr)
Definition: clizFunctions.h:331
void makeWhiteningMat()
Definition: clizDetector.cpp:263
unsigned int w_post
Definition: clizDectector.h:34
unsigned int detection
Definition: clizDectector.h:29
unsigned int stdmin
Definition: clizDectector.h:32
unsigned int ref
Definition: clizDectector.h:30
~Detector()
Definition: clizDectector.h:126
unsigned int w_pre
Definition: clizDectector.h:33
bool externalDetection
Definition: clizDectector.h:37