finding the start and end points of a unimodal peak
3 views (last 30 days)
I am trying to automate the finding of the start and end of a peak. Many of the peaks I am looking at are gaussian. However, some of them are not.
Below are some of the results of using the findpeaks() function, using the width of the peak to deduce the start and end positions. As you can see, the results are not very promising!
More Answers (1)
John D'Errico on 31 Jan 2022
Edited: John D'Errico on 31 Jan 2022
Wait a second! You are using findpeaks. It returns as one argument the peaks it finds, as well as the associated width. But you are using it on asymmetric peaks. Simply assuming that taking the peak, plus or minus half the width is silly if that peak is not a nice, symmetric curve.
x = linspace(0,1.25,1000);
y = sin(x.^10).^2;
[peaks,locs,w] = findpeaks(y,x)
So it found a peaks at x= 1.1717, with a width of 0.4073.
Now are you seriously going to claim it is a good idea to use that width, as if the peak was symmetric?
xline(locs(1) + w(1)/2*[-1,1],'g')
The peaks you show are strongly asymmetric. They do not look even remotely look like a gaussian. I would expect something silly to happen if you arbitraily treat the peak as symmetric when you use the width returned.
Far more logical might be, since these seem to be unimodal curves, is to use findpeaks only to locate the peak location itself.
Now, since you know the baseline. Find the point where an interpolated approximation of that curve crosses the 10% point, thus a level at 10% of the difference from the baseline to the peak. There should be two such locations. I chose the 10% point arbitrarily, so it will be sufficiently above any baseline junk, yet reasnably close to the baseline.