this->SetInitValue( v );
}
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+unsigned long fpa::Base::Mori< _TAlgorithm >::
+GetSignalKernelSize( ) const
+{
+ return( this->m_PeakDetector.GetKernelSize( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+double fpa::Base::Mori< _TAlgorithm >::
+GetSignalThreshold( ) const
+{
+ return( this->m_PeakDetector.GetThreshold( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+double fpa::Base::Mori< _TAlgorithm >::
+GetSignalInfluence( ) const
+{
+ return( this->m_PeakDetector.GetInfluence( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::Mori< _TAlgorithm >::
+SetSignalKernelSize( unsigned long k )
+{
+ this->m_PeakDetector.SetKernelSize( k );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::Mori< _TAlgorithm >::
+SetSignalThreshold( double t )
+{
+ this->m_PeakDetector.SetThreshold( t );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::Mori< _TAlgorithm >::
+SetSignalInfluence( double i )
+{
+ this->m_PeakDetector.SetInfluence( i );
+ this->Modified( );
+}
+
// -------------------------------------------------------------------------
template< class _TAlgorithm >
void fpa::Base::Mori< _TAlgorithm >::
SetThresholds(
const TInputValue& init,
const TInputValue& end,
- unsigned long number_of_thresholds
+ const TInputValue& delta
)
{
- double i = double( init );
- double e = double( end );
- double n = double( number_of_thresholds );
- double d = ( e - i ) / n;
- for( unsigned long c = 0; c <= number_of_thresholds; ++c )
- this->AddThreshold( TInputValue( i + ( d * double( c ) ) ) );
+ for( TInputValue thr = init; thr <= end; thr += delta )
+ this->AddThreshold( thr );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+const typename fpa::Base::Mori< _TAlgorithm >::
+TThresholds& fpa::Base::Mori< _TAlgorithm >::
+GetThresholds( ) const
+{
+ return( this->m_Thresholds );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+unsigned long fpa::Base::Mori< _TAlgorithm >::
+GetNumberOfEvaluatedThresholds( ) const
+{
+ return( this->m_PeakDetector.GetNumberOfSamples( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+typename fpa::Base::Mori< _TAlgorithm >::
+TInputValue fpa::Base::Mori< _TAlgorithm >::
+GetOptimumThreshold( ) const
+{
+ TInputValue thr = TInputValue( 0 );
+ unsigned long n = this->m_PeakDetector.GetNumberOfSamples( );
+ if( n > 1 )
+ thr = TInputValue( this->m_PeakDetector.GetXValues( )[ n - 2 ] );
+ return( thr );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::Mori< _TAlgorithm >::
+GetSignalValues( unsigned long i, double& x, double& y, TPeak& p ) const
+{
+ if( i < this->m_PeakDetector.GetNumberOfSamples( ) )
+ {
+ x = this->m_PeakDetector.GetXValues( )[ i ];
+ y = this->m_PeakDetector.GetYValues( )[ i ];
+ p = this->m_PeakDetector.GetPeaks( )[ i ];
+
+ } // fi
}
// -------------------------------------------------------------------------
fpa::Base::Mori< _TAlgorithm >::
Mori( )
: Superclass( ),
- m_InsideValue( TOutputValue( 1 ) )
+ m_InsideValue( TOutputValue( 1 ) )
{
this->SetInitValue( TOutputValue( 0 ) );
this->m_Predicate = TPredicate::New( );
+ this->m_Predicate->StrictOff( );
+ if( std::numeric_limits< TInputValue >::is_integer )
+ this->m_MinimumThreshold = std::numeric_limits< TInputValue >::min( );
+ else
+ this->m_MinimumThreshold = -std::numeric_limits< TInputValue >::max( );
+ this->m_PeakDetector.SetKernelSize( 20 );
+ this->m_PeakDetector.SetThreshold( 500 );
+ this->m_PeakDetector.SetInfluence( 0.5 );
}
// -------------------------------------------------------------------------
{
this->Superclass::_BeforeGenerateData( );
+ // Prepare queues
this->_QueueClear( );
- this->m_CurrentQueue = 0;
+ this->m_CurrQueue = 0;
+
+ // Prepare iteration over all thresholds
+ this->m_CurrThr = this->m_Thresholds.begin( );
+ this->m_Predicate->SetLower( *( this->m_CurrThr ) );
+ this->m_CurrThr++;
+ this->m_Predicate->SetUpper( *( this->m_CurrThr ) );
+
+ // Prepare counting signal
+ this->m_CurrCount = double( 0 );
+ this->m_PeakDetector.Clear( );
}
// -------------------------------------------------------------------------
template< class _TAlgorithm >
void fpa::Base::Mori< _TAlgorithm >::
-_AfterGenerateData( )
+_FinishOneLoop( )
{
- this->Superclass::_AfterGenerateData( );
+ if( this->m_Queues[ this->m_CurrQueue ].size( ) == 0 )
+ {
+ // Update peak detector
+ TPeak p = this->m_PeakDetector.AddValue(
+ *this->m_CurrThr, this->m_CurrCount
+ );
+ std::cout << *( this->m_CurrThr ) << " " << this->m_CurrCount << std::endl;
+ this->m_CurrThr++;
+ if( this->m_CurrThr != this->m_Thresholds.end( ) )
+ {
+ // Update predicate and counting value
+ this->m_Predicate->SetUpper( *( this->m_CurrThr ) );
+ this->m_CurrCount = double( 0 );
+
+ // Peak detected? -> stop!
+ if(
+ p == TPeakDetector::PosPeak &&
+ this->m_MinimumThreshold < *( this->m_CurrThr )
+ )
+ this->_QueueClear( );
+ }
+ else
+ this->_QueueClear( );
+
+ } // fi
}
// -------------------------------------------------------------------------
template< class _TAlgorithm >
-typename fpa::Base::Mori< _TAlgorithm >::
-TOutputValue fpa::Base::Mori< _TAlgorithm >::
-_ComputeOutputValue( const TNode& n )
+void fpa::Base::Mori< _TAlgorithm >::
+_ComputeOutputValue( TNode& n )
+{
+ // Do nothing!!!
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::Mori< _TAlgorithm >::
+_UpdateOutputValue( TNode& n )
{
TInputValue value = this->_GetInputValue( n.Vertex );
bool inside = this->m_Predicate->Evaluate( value );
if( !inside )
{
- // TODO: Update new queue
- return( this->m_InitValue );
+ n.Value = this->m_InitValue;
+ n.FrontId++;
+ this->m_Queues[ ( this->m_CurrQueue + 1 ) % 2 ].push_back( n );
+ n.FrontId = 0;
}
else
- return( this->m_InsideValue );
+ {
+ n.Value = this->m_InsideValue;
+ this->m_CurrCount += double( 1 );
+
+ } // fi
+ this->Superclass::_UpdateOutputValue( n );
}
-
+
// -------------------------------------------------------------------------
template< class _TAlgorithm >
void fpa::Base::Mori< _TAlgorithm >::
TNode fpa::Base::Mori< _TAlgorithm >::
_QueuePop( )
{
- TNode n = this->m_Queues[ this->m_CurrentQueue ].front( );
- this->m_Queues[ this->m_CurrentQueue ].pop_front( );
+ TNode n = this->m_Queues[ this->m_CurrQueue ].front( );
+ this->m_Queues[ this->m_CurrQueue ].pop_front( );
return( n );
}
void fpa::Base::Mori< _TAlgorithm >::
_QueuePush( const TNode& node )
{
- // TODO: Update mark
- this->m_Queues[ this->m_CurrentQueue ].push_back( node );
+ this->m_Queues[ this->m_CurrQueue ].push_back( node );
}
// -------------------------------------------------------------------------
unsigned long fpa::Base::Mori< _TAlgorithm >::
_QueueSize( ) const
{
- return( this->m_Queues[ this->m_CurrentQueue ].size( ) );
+ return( this->m_Queues[ this->m_CurrQueue ].size( ) );
}
// -------------------------------------------------------------------------
{
typename TNodes::iterator nIt = nodes.begin( );
for( ; nIt != nodes.end( ); ++nIt )
- nIt->Value = this->m_InsideValue;
+ nIt->Value = this->m_InitValue;
}
-/* TODO
- typename TPredicate::Pointer m_Predicate;
- TThresholds m_Thresholds;
- TQueue m_Queues[ 2 ];
- unsigned int m_CurrentQueue;
- TOutputValue m_InsideValue;
-*/
-
#endif // __fpa__Base__Mori__hxx__
// eof - $RCSfile$