]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Common/PeakDetector.h
...
[FrontAlgorithms.git] / lib / fpa / Common / PeakDetector.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Common__PeakDetector__h__
6 #define __fpa__Common__PeakDetector__h__
7
8 #include <vector>
9 #include <fpa/fpa_export.h>
10 #include <fpa/Common/IncrementalMeanAndVariance.h>
11
12 namespace fpa
13 {
14   namespace Common
15   {
16     /**
17      */
18     /**
19      * https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data
20      */
21     class FPA_EXPORT PeakDetector
22     {
23     public:
24       typedef PeakDetector Self;
25
26       enum TPeak
27       {
28         NoPeak = 0,
29         PosPeak,
30         NegPeak
31       };
32
33     public:
34       PeakDetector( );
35       virtual ~PeakDetector( );
36
37       unsigned long GetKernelSize( ) const;
38       double GetThreshold( ) const;
39       double GetInfluence( ) const;
40
41       void SetKernelSize( unsigned long k );
42       void SetThreshold( double t );
43       void SetInfluence( double i );
44
45       const std::vector< double >& GetXValues( ) const;
46       const std::vector< double >& GetYValues( ) const;
47       const std::vector< double >& GetFilteredYValues( ) const;
48       const std::vector< double >& GetAverages( ) const;
49       const std::vector< double >& GetDeviations( ) const;
50       const std::vector< TPeak >& GetPeaks( ) const;
51
52       void Clear( );
53       unsigned long GetNumberOfSamples( ) const;
54       TPeak AddValue( double x, double y );
55
56     protected:
57       unsigned long m_K;
58       double m_T;
59       double m_I;
60
61       std::vector< double > m_X;
62       std::vector< double > m_Y;
63       std::vector< double > m_YF;
64       std::vector< double > m_Avg;
65       std::vector< double > m_STD;
66       std::vector< TPeak >  m_Peaks;
67       fpa::Common::IncrementalMeanAndVariance m_MeanAndVar;
68     };
69
70   } // ecapseman
71
72 } // ecapseman
73
74 #endif // __fpa__Common__PeakDetector__h__
75 // eof - $RCSfile$