X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FBase%2FMori.h;h=d1774d708dcc3da8aca409fd4018666d691b6fbf;hb=5c78aecb0f5a207ff020e24f99d1e9bd8c388ad1;hp=430ff03ae5bc222da3ac1547efab3e0074554006;hpb=479d85a44365c8aa01976ffb9c7d67d3e9e52b63;p=FrontAlgorithms.git diff --git a/lib/fpa/Base/Mori.h b/lib/fpa/Base/Mori.h index 430ff03..d1774d7 100644 --- a/lib/fpa/Base/Mori.h +++ b/lib/fpa/Base/Mori.h @@ -3,13 +3,19 @@ // @email florez-l@javeriana.edu.co // ========================================================================= +// https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data + + #ifndef __fpa__Base__Mori__h__ #define __fpa__Base__Mori__h__ #include #include +#include #include #include + +#include #include namespace fpa @@ -37,6 +43,10 @@ namespace fpa typedef std::deque< TNode > TQueue; typedef std::set< TInputValue > TThresholds; + typedef std::pair< TInputValue, unsigned long > TSignalData; + typedef std::vector< TSignalData > TSignal; + + typedef fpa::Generic::PeakDetector TPeakDetector; typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TPredicate; public: @@ -46,7 +56,19 @@ namespace fpa ); itkGetConstMacro( InsideValue, TOutputValue ); + itkGetConstMacro( MinimumThreshold, TInputValue ); + itkSetMacro( InsideValue, TOutputValue ); + itkSetMacro( MinimumThreshold, TInputValue ); + + itkGetConstReferenceMacro( Signal, TSignal ); + itkGetConstMacro( SignalLag, unsigned long ); + itkGetConstMacro( SignalThreshold, double ); + itkGetConstMacro( SignalInfluence, double ); + + itkSetMacro( SignalLag, unsigned long ); + itkSetMacro( SignalThreshold, double ); + itkSetMacro( SignalInfluence, double ); public: virtual itk::ModifiedTimeType GetMTime( ) const override; @@ -59,14 +81,19 @@ namespace fpa void SetThresholds( const TInputValue& init, const TInputValue& end, - unsigned long number_of_thresholds + const TInputValue& delta ); + unsigned long GetNumberOfEvaluatedThresholds( ) const; + TInputValue GetOptimumThreshold( ) const; protected: Mori( ); virtual ~Mori( ); - virtual TOutputValue _ComputeOutputValue( const TNode& n ) override; + virtual void _BeforeGenerateData( ) override; + virtual void _FinishOneLoop( ) override; + virtual void _ComputeOutputValue( TNode& n ) override; + virtual void _UpdateOutputValue( TNode& n ) override; virtual void _QueueClear( ) override; virtual TNode _QueuePop( ) override; virtual void _QueuePush( const TNode& node ) override; @@ -81,9 +108,25 @@ namespace fpa protected: typename TPredicate::Pointer m_Predicate; TThresholds m_Thresholds; + typename TThresholds::const_iterator m_CurrentThreshold; TQueue m_Queues[ 2 ]; unsigned int m_CurrentQueue; - + unsigned long m_Count; + + TPeakDetector m_PeakDetector; + + TSignal m_Signal; + unsigned long m_SignalLag; + double m_SignalThreshold; + double m_SignalInfluence; + std::vector< double > m_FilteredSignal; + std::vector< double > m_SignalAverages; + std::vector< double > m_SignalDeviations; + std::vector< short > m_SignalPeaks; + double m_CurrentAverage; + double m_CurrentVariance; + + TInputValue m_MinimumThreshold; TOutputValue m_InsideValue; }; @@ -91,11 +134,9 @@ namespace fpa } // ecapseman -/* TODO - #ifndef ITK_MANUAL_INSTANTIATION - # include - #endif // ITK_MANUAL_INSTANTIATION -*/ +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION #endif // __fpa__Base__Mori__h__