Class PeakFinderLocalMaximum

  • All Implemented Interfaces:
    ca.uqac.lif.azrael.Printable, ca.uqac.lif.azrael.Readable, ca.uqac.lif.cep.Contextualizable, ca.uqac.lif.cep.Duplicable, ca.uqac.lif.cep.DuplicableProcessor

    public class PeakFinderLocalMaximum
    extends WindowProcessor
    Finds a peak in a data stream using the local maximum algorithm.

    The local maximum method is a brute force searching algorithm which finds the local maximum in a moving window. The window size is determined by a predefined a number of local points.

    Initially, an n-point window is placed at the start point of data stream. The maximum in this window, as well as its index, is recorded. Then the window is moved one step further. If the new maximun is greater than the saved maximum, update both the maximum value and index value and then move forward. If the maximum moves out of the window, i.e. all points in the window are less than the maximum, a peak is found an the whole window configuration is reconstructed for the next peak.

    For each input event, the processor outputs the height of the peak, or the value 0 if this event is not a peak. Since an event needs to be out of the window to determine that it is a peak, the emission of output events is delayed with respect to the consumption of input events.

    By default, the window is of width 5.

    • Nested Class Summary

      • Nested classes/interfaces inherited from class ca.uqac.lif.cep.SynchronousProcessor

        ca.uqac.lif.cep.SynchronousProcessor.InputPushable, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable
      • Nested classes/interfaces inherited from class ca.uqac.lif.cep.Processor

        ca.uqac.lif.cep.Processor.InternalProcessorState
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean m_invert
      Whether to invert the values before computing.
      protected int m_numSincePeak
      The number of events that went out of the window since the last peak was seen.
      protected int m_peakPosition
      The position in the window where the highest value is
      • Fields inherited from class ca.uqac.lif.cep.SynchronousProcessor

        m_inputPushables, m_outputPullables, m_tempQueue
      • Fields inherited from class ca.uqac.lif.cep.Processor

        m_context, m_eventTracker, m_hasBeenNotifiedOfEndOfTrace, m_inputArity, m_inputCount, m_inputPullables, m_inputQueues, m_notifiedEndOfTraceDownstream, m_outputArity, m_outputCount, m_outputPushables, m_outputQueues, MAX_PULL_RETRIES, s_versionString
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean compute​(java.lang.Object[] inputs, java.util.Queue<java.lang.Object[]> outputs)  
      java.lang.Float computeOutputValue()  
      PeakFinderLocalMaximum duplicate​(boolean with_state)  
      PeakFinderLocalMaximum findDrops​(boolean b)
      Sets whether the peak finder detects drops or peaks.
      int getPeakPosition()  
      void reset()  
      • Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor

        getPullableOutput, getPushableInput, setEventTracker
      • Methods inherited from class ca.uqac.lif.cep.Processor

        allNotifiedEndOfTrace, allNull, associateTo, associateToInput, associateToOutput, copyInputQueue, copyOutputQueue, duplicate, duplicateInto, equals, getAt, getContext, getContext, getEmptyQueue, getEventTracker, getId, getInputArity, getInputCount, getInputQueue, getInputType, getInputTypesFor, getLeaves, getLeaves, getOutputArity, getOutputCount, getOutputQueue, getOutputType, getPullableInput, getPullableOutput, getPushableInput, getPushableOutput, hashCode, leftShift, newContext, onEndOfTrace, or, or, print, printState, read, readState, rightShift, setContext, setContext, setPullableInput, setPushableOutput, start, startAll, stop, stopAll
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_peakPosition

        protected int m_peakPosition
        The position in the window where the highest value is
      • m_numSincePeak

        protected int m_numSincePeak
        The number of events that went out of the window since the last peak was seen.
      • m_invert

        protected boolean m_invert
        Whether to invert the values before computing. Setting this to true will make the processor detect drops (sudden decreases) instead of peaks.
    • Constructor Detail

      • PeakFinderLocalMaximum

        public PeakFinderLocalMaximum()
      • PeakFinderLocalMaximum

        public PeakFinderLocalMaximum​(int width)
    • Method Detail

      • findDrops

        public PeakFinderLocalMaximum findDrops​(boolean b)
        Sets whether the peak finder detects drops or peaks.
        Parameters:
        b - Set to true to detect drops
        Returns:
        This processor
      • compute

        protected boolean compute​(java.lang.Object[] inputs,
                                  java.util.Queue<java.lang.Object[]> outputs)
        Specified by:
        compute in class ca.uqac.lif.cep.SynchronousProcessor
      • getPeakPosition

        public int getPeakPosition()
      • duplicate

        public PeakFinderLocalMaximum duplicate​(boolean with_state)
        Specified by:
        duplicate in interface ca.uqac.lif.cep.Duplicable
        Specified by:
        duplicate in class ca.uqac.lif.cep.Processor