Find peaks from noisy data
Show older comments
I am trying to find the method of locating the gaussian peaks.
I used findpeaks function to find peaks. The solid line is created by sgolayfilt.
hgcs = sgolayfilt(hgc, 10, 41);
findpeaks(hgc, 'MinPeakDistance', 20)
Question1: Are there any functions or algorithms that can determine the number of peaks and the locations?
Question2: After 160, there are small features. Some of them may be still peaks following the first four peaks. At least, we know that the locations of peaks are quasi-periodic. Could we also find more peaks?
Accepted Answer
More Answers (1)
Image Analyst
on 16 Feb 2021
0 votes
I'm attaching a demo where you can specify how many Gaussians are in your signal and it will find them. If you don't know how many there are then you can maybe specify more and take the 4 with the largest area under the curve. Adap the demo to use 4 instead of 6, and to read in your actual data instead of using made up data.
5 Comments
photoon
on 16 Feb 2021
Image Analyst
on 17 Feb 2021
If you have nice peaks already, then you can use findpeaks() in the Signal Processing Toolbox. It's kind of complicated but with the right selection of parameters you should be able to home in on the peaks you want.
You might want to use sgolayfilt() instead of movmean(). Use a polynomial order of 2 then try narrowing and widening the framelength. Wider gives more smoothing and narrower will let it follow your data more closely. The Saivtzky-Golay filter is like movmean() but it fits the data to a sliding polynomial instead of a line (which is what movmean does by taking the average). This will keep the peaks sharp and not blunt their tops or bottoms.
photoon
on 17 Feb 2021
Image Analyst
on 17 Feb 2021
If using a linear filter like movmean() or fft() followed by a low pass filter, works better than a non-linear filter like sgolayfilt() that's fine (though I'm surprised).
But you still need to find the locations, regardless of what method you use to smooth the signal. So you can either use findpeaks(), or my Gaussian fitting code. findpeaks() will give you every peak and you don't need to know how many there are in advance, while the Guassian fitting code requires you to specify how many Gaussians your signal should be fit to.
photoon
on 17 Feb 2021
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!