Giter VIP home page Giter VIP logo

pyampd's Introduction

PyPI version Build Status Coverage Status

AMPD algorithm in Python

Implements a function find_peaks based on the Automatic Multi-scale Peak Detection algorithm proposed by Felix Scholkmann et al. in "An Efficient Algorithm for Automatic Peak Detection in Noisy Periodic and Quasi-Periodic Signals", Algorithms 2012, 5, 588-603

Peak finding

Usage

Install from PyPI:

pip install pyampd

Or install from source:

pip install git+https://github.com/ig248/pyampd

Import function:

from pyampd.ampd import find_peaks

See notebooks/ampd.ipynb for usage examples.

Specifying maximum scale

To improve run-time on large time-series, it is possible to specify the maximum scale to consider:

peaks = find_peaks(x, scale=100)

will only consider windows up to +-100 point either side of peak candidates.

Adaptive Scale Selection

If the characteristic scale of the signal changes over time, a new algorithm called Adaptive Scale Selection can track the changes in optimal scales and detect peaks accordingly:

peaks = find_peaks_adaptive(x, window=200)

will select the optimal scale at each point using a 200-point running window.

Original implementation

find_peaks is not identical to the algorithm proposed in the original paper (especially near start and end of time series). A performance-optimized version of the original implementation is provided in find_peaks_original.

Tests

Run

pytest

Other implementations

Improvements

This Python implementation provides significant speed-ups in two areas:

  1. Efficient tracking of local minima without using random numbers
  2. Introduction of maximum window size, reducing algorithm run-time from quadratic to linear in the number of samples.
  3. Better handling of peaks near start/end of the series
  4. Addition of new Adaptive Scale Selection

ToDo

  • It may be possible to avoid repeated comparisons, and reduce worst-case runtime from O(n^2) to O(n log(n)).
  • find_peaks_adaptive could benefit from specifying both window and max_scale

References

Original paper: https://doi.org/10.1109/ICRERA.2016.7884365

pyampd's People

Contributors

ig248 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.