-
-
Notifications
You must be signed in to change notification settings - Fork 43
Peak & Trough Detection and Filtering
Sambit Paul edited this page Dec 2, 2023
·
10 revisions
In the context of Peak Detection, a peak or local maximum is defined as any sample whose two direct neighbours have a smaller amplitude and a trough or local minimum is defined as any sample whose two direct neighbours have a larger amplitude. Peak detection is often used for identifying certain events which cause undulations in the signal which are recognised as peaks.
In this library, we are able to identify peaks and filter them based on these properties:
- Peak Height: The point in the signal corresponding to the peak.
- Plateau Size: The number of samples for which a peak spreads. "Flat peaks" tend to spread for more than 1 sample point.
- Peak Distance: Number of samples between a peak and the peak to its right.
- Peak Sharpness: Height difference between the peak and its neighbouring samples to its left and right.
- Peak Prominence: The prominence of a peak measures how much a peak stands out from the surrounding baseline of the signal.
- Peak Width: The width of a peak in samples at a relative distance to the peak’s height and prominence.
This library also allows computation of these properties for specific peaks.
double[] data = UtilMethods.splitByIndex(UtilMethods.electrocardiogram(), 3200, 4200);
Smooth sObj = new Smooth(data, 15, "rectangular");
double[] ecgSignal = sObj.smoothSignal("same");
The first step of peak detection is to identify all the peaks in the signal. Filtering can only be done on the identified peaks.
FindPeak fp = new FindPeak(this.highResSignal);
Peak out = fp.detectPeaks();
int[] peaks = out.getPeaks();
Peak out2 = fp.detectTroughs();
int[] troughs = out2.getPeaks();
double[] outHeight = out.getHeights();
double[] height = out.findPeakHeights(peaks);
int[] filteredPeaks1 = out.filterByHeight(0.02, 1.0);
int[] outPlateau = out.getPlateauSize();
int[] outPlateau = out.findPlateauSize(peaks);
int[] outFilteredPS1 = out.filterByPlateauSize(2.0, 4.0);
int[] outDistance = out.getPeakDistance();
int[] distance = out.findPeakDistance(peaks);
int[] outFilteredDistance1 = out.filterByPeakDistance(12);
double[][] outSharpness = out.getPeakSharpness();
double[][] sharpness = out.findPeakSharpness(peaks);
int[] filteredSharp1 = out.filterBySharpness(0.002, 0.005);
double[][] outPromData = out.getProminenceData(); // To get the prominence, left base and right base
double[] outProminence = out.getProminence();
double[][] promData = out.findPeakProminence(peaks); // To get the prominence, left base and right base
double[] prominence = promData[0];
int[] filteredProm1 = out.filterByProminence(0.2, 0.6);
double[][] outWidthData = out.getWidthData(); // To get the width, left base and right base at a relative height of 0.5
double[] outWidth = out.getWidth();
double[][] widthData = out.findPeakWidth(peaks, 0.5); // To get the width, left base and right base at a relative height of 0.5
double[] width = widthData[0];
int[] filteredWidth1 = out.filterByWidth(5.0, 20.0);
Wiki
-
Filters
- IIR Filters
- FIR Filters
- Kernel-Based Filter
- Adaptive Filters
-
Signals
-
Peak Detection
-
Transformations
-
Speech
-
Windowing