| Crates.io | sci-find-peaks |
| lib.rs | sci-find-peaks |
| version | 0.1.0 |
| created_at | 2025-11-24 14:01:20.148964+00 |
| updated_at | 2025-11-24 14:01:20.148964+00 |
| description | A Rust port of SciPy's find_peaks function, designed to match SciPy's behavior exactly. |
| homepage | |
| repository | https://github.com/beneficial01/sci-find-peaks |
| max_upload_size | |
| id | 1947912 |
| size | 14,223,468 |
A Rust port of SciPy's find_peaks function, designed to match SciPy's behavior exactly.
This crate provides a signal processing utility for finding peaks in 1D data. It is a direct port of the scipy.signal.find_peaks function from the SciPy library.
Why use this crate?
FindPeaksOptions struct mirrors the arguments of the Python function (height, threshold, distance, prominence, width, etc.).Add this to your Cargo.toml:
[dependencies]
sci-find-peaks = "0.1.0"
Here is a simple example of how to use the library:
use sci_find_peaks::{find_peaks, FindPeaksOptions};
fn main() {
// 1. Define your signal
let x = vec![0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 1.0, 0.0];
// 2. Configure options (mimics scipy.signal.find_peaks arguments)
let options = FindPeaksOptions {
height: Some((Some(1.0), None)), // Min height of 1.0
distance: Some(2), // Min distance of 2 samples
..FindPeaksOptions::default()
};
// 3. Run the algorithm
let result = find_peaks(&x, &options).unwrap();
// 4. Access results
println!("Found {} peaks at indices: {:?}", result.peaks.len(), result.peaks);
if let Some(heights) = result.properties.peak_heights {
println!("Peak heights: {:?}", heights);
}
}
To see the library in action and verify the output visually, you can run the included example which generates a plot using the plotters crate.
cargo run --example visualize
This will generate a file named peaks_plot.png showing the signal, detected peaks, and calculated widths.

This project is licensed under the MIT License.