]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Common/PeakDetector.h
...
[FrontAlgorithms.git] / lib / fpa / Common / PeakDetector.h
diff --git a/lib/fpa/Common/PeakDetector.h b/lib/fpa/Common/PeakDetector.h
new file mode 100644 (file)
index 0000000..8796cc3
--- /dev/null
@@ -0,0 +1,75 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Common__PeakDetector__h__
+#define __fpa__Common__PeakDetector__h__
+
+#include <vector>
+#include <fpa/fpa_export.h>
+#include <fpa/Common/IncrementalMeanAndVariance.h>
+
+namespace fpa
+{
+  namespace Common
+  {
+    /**
+     */
+    /**
+     * https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data
+     */
+    class FPA_EXPORT PeakDetector
+    {
+    public:
+      typedef PeakDetector Self;
+
+      enum TPeak
+      {
+        NoPeak = 0,
+        PosPeak,
+        NegPeak
+      };
+
+    public:
+      PeakDetector( );
+      virtual ~PeakDetector( );
+
+      unsigned long GetKernelSize( ) const;
+      double GetThreshold( ) const;
+      double GetInfluence( ) const;
+
+      void SetKernelSize( unsigned long k );
+      void SetThreshold( double t );
+      void SetInfluence( double i );
+
+      const std::vector< double >& GetXValues( ) const;
+      const std::vector< double >& GetYValues( ) const;
+      const std::vector< double >& GetFilteredYValues( ) const;
+      const std::vector< double >& GetAverages( ) const;
+      const std::vector< double >& GetDeviations( ) const;
+      const std::vector< TPeak >& GetPeaks( ) const;
+
+      void Clear( );
+      unsigned long GetNumberOfSamples( ) const;
+      TPeak AddValue( double x, double y );
+
+    protected:
+      unsigned long m_K;
+      double m_T;
+      double m_I;
+
+      std::vector< double > m_X;
+      std::vector< double > m_Y;
+      std::vector< double > m_YF;
+      std::vector< double > m_Avg;
+      std::vector< double > m_STD;
+      std::vector< TPeak >  m_Peaks;
+      fpa::Common::IncrementalMeanAndVariance m_MeanAndVar;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Common__PeakDetector__h__
+// eof - $RCSfile$