Skip to main content

Peak detection using AMPD and ASS-AMPD algorithms

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyampd-0.0.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

pyampd-0.0.1-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyampd-0.0.1.tar.gz.

File metadata

  • Download URL: pyampd-0.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for pyampd-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e333d00b61d2844b0ed0383b010394e0a0cb384a036dd83960cdc647cf71a755
MD5 48da763e6ab7df22347212859589d051
BLAKE2b-256 51976a56d7ed7d1ed5cb25c4643cb327a1903438587991fe364ac6042c2b837d

See more details on using hashes here.

File details

Details for the file pyampd-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pyampd-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for pyampd-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d923a4372308d447b98cd80f935a059e29323777dd26c0ac131945ad84f5f89c
MD5 89da3b6ba286573eec3062f713b83c6b
BLAKE2b-256 53b5587d52d43aa803c20743fd23e2bcbb454a06694c5645de741311678c8750

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page