X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FCommon%2FPeakDetector.h;fp=lib%2Ffpa%2FCommon%2FPeakDetector.h;h=8796cc33de8ca98493afbede9976ea2bb2a8fd9d;hb=2047276c8f1a02432fbcc7014722d460d6c1e60f;hp=0000000000000000000000000000000000000000;hpb=3c639e5da479c7216a0a302ffa156ac6762caeed;p=FrontAlgorithms.git diff --git a/lib/fpa/Common/PeakDetector.h b/lib/fpa/Common/PeakDetector.h new file mode 100644 index 0000000..8796cc3 --- /dev/null +++ b/lib/fpa/Common/PeakDetector.h @@ -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 +#include +#include + +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$