timeflux / timeflux_dsp

Timeflux DSP plugin
MIT License
8 stars 4 forks source link

What's the differenence between LocalDetect and RollingDetect? #15

Open jonathanjfshaw opened 4 years ago

jonathanjfshaw commented 4 years ago

The docs for LocalDetect say:

    """ Detect peaks and valleys in live 1D signal
    This node uses a simple algorithm to detect peaks in real time.

        This peak detection is considered real-time since it does not require buffering the data. However, the detection
        method necessarily involve a lag between the actual peak and its detection.
        Indeed, the internal state of the node is either "looking for a peak" or "looking for a valley".
        The "last local extrema" is set to a peak (resp. valley) as soon as the signal drops (resp. rises) significantly.

Those for RollingDetect say:

    """ Detect peaks and valleys on a rolling window of analysis in  1D signal
    This node uses a buffer to compute local extrema and detect peaks in real time.

I've read the code for RollingDetect more than once, but I don't find it easy to see how it works and how it is different to LocalDetect.

If someone can tell me, I can improve the docs.

bertrandlalo commented 4 years ago

Local detect This algo handles each sample individually with internal states (last_peak, last_valley and whereas it is "looking for a peak"). peak_algo_illustration

Rolling Detect This algo is actually equivalent to the local max function of scipy. It needs to buffer values over a window to decide on a local extrema.

Tell me if it makes sense and what you suggest for the doc. Otherwise, I'd close this issue, since it's not quite one.