Signal Processing Algorithms

raw JSON →
2.1.6 verified Fri May 01 auth: no python

A library for signal processing algorithms, originally developed at MongoDB, including peak detection using the 'peak_shapes' algorithm and related utilities. Current version 2.1.6 requires Python <3.12,>=3.11. Maintained by MongoDB.

pip install signal-processing-algorithms
error ModuleNotFoundError: No module named 'signal_processing_algorithms'
cause Installed with hyphenated name but imported with hyphen.
fix
Replace import signal-processing-algorithms with import signal_processing_algorithms
error AttributeError: module 'signal_processing_algorithms' has no attribute 'peak_shapes'
cause Trying to import peak_shapes as a top-level attribute instead of submodule.
fix
Use from signal_processing_algorithms.peak_shapes import peak_shapes
gotcha The import path uses underscores: `signal_processing_algorithms` not `signal-processing-algorithms`. The hyphenated name is only for pip install.
fix Use `from signal_processing_algorithms.peak_shapes import peak_shapes`
deprecated The `peak_shapes` function has been renamed to `find_peaks` in version 2.0.0. The old name still works but may be removed in future.
fix Use `from signal_processing_algorithms.peak_shapes import find_peaks`
gotcha The `Signal` class requires a numpy array. Passing a list will raise a TypeError.
fix Convert list to numpy array: `signal = Signal(np.array([...]))`

Detect peaks in a sine wave using the peak_shapes algorithm.

from signal_processing_algorithms.peak_shapes import peak_shapes
from signal_processing_algorithms.peak_shapes import Signal
import numpy as np

signal = Signal(np.sin(np.linspace(0, 10, 1000)))
results = peak_shapes(signal, threshold=0.5)
print(results)