Class PeakFinderLocalMaximum

java.lang.Object
ca.uqac.lif.cep.Processor
ca.uqac.lif.cep.SynchronousProcessor
ca.uqac.lif.cep.signal.WindowProcessor
ca.uqac.lif.cep.signal.PeakFinderLocalMaximum
All Implemented Interfaces:
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
    Whether to invert the values before computing.
    protected int
    The number of events that went out of the window since the last peak was seen.
    protected int
    The position in the window where the highest value is

    Fields inherited from class ca.uqac.lif.cep.signal.WindowProcessor

    m_maxValue, m_minValue, m_values, m_windowWidth, s_precision

    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_hasBeenNotifiedOfEndOfTrace, m_inputArity, m_inputPullables, m_inputQueues, m_notifiedEndOfTraceDownstream, m_outputArity, m_outputPushables, m_outputQueues, MAX_PULL_RETRIES, s_versionString
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    compute(Object[] inputs, Queue<Object[]> outputs)
     
     
    duplicate(boolean with_state)
     
    findDrops(boolean b)
    Sets whether the peak finder detects drops or peaks.
    int
     
    void
     

    Methods inherited from class ca.uqac.lif.cep.signal.WindowProcessor

    doubleEquals, getMaxValue, getMinValue

    Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor

    getPullableOutput, getPushableInput

    Methods inherited from class ca.uqac.lif.cep.Processor

    allNotifiedEndOfTrace, allNull, copyInputQueue, copyOutputQueue, duplicate, duplicateInto, equals, getAt, getContext, getContext, getEmptyQueue, getId, getInputArity, getInputQueue, getInputType, getInputTypesFor, getOutputArity, getOutputQueue, getOutputType, getPullableInput, getPullableOutput, getPushableInput, getPushableOutput, hashCode, leftShift, newContext, onEndOfTrace, or, or, or, printState, 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 Details

    • 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 Details

    • PeakFinderLocalMaximum

      public PeakFinderLocalMaximum()
    • PeakFinderLocalMaximum

      public PeakFinderLocalMaximum(int width)
  • Method Details

    • 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
    • reset

      public void reset()
      Overrides:
      reset in class WindowProcessor
    • compute

      protected boolean compute(Object[] inputs, Queue<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
    • computeOutputValue

      public Float computeOutputValue()
      Specified by:
      computeOutputValue in class WindowProcessor