MATLAB: How to detect shoulder peaks in a signal

peakpeak analysispeak detectionpeaksshouldershoulder peakshoulder peakssideways peaksSignal Processing Toolbox

Hello,
I am trying to detect subtle, "shoulder" peaks in a signal, which do not fit the usual peak definition and are not found by findpeaks. They definitely can be seen in the gradient, but so can other wider peaks that are not so prominent in the original signal. I'm guessing there is a specific threshold that makes these shoulder peaks stand out in the gradient, but I can't think of how to find it. Are there any ideas on how to detect those peaks?
Thanks in advance
P.S. Below is a signal with 2 shoulder peaks (left) and its gradient (right)

Best Answer

The gradient is definitely the way to go. If you have the Signal Processing Toolbox, use the findpeaks (link) function on the gradient vector. This will find the peaks. In order to find the ‘valleys’, negate your original signal and find the peaks on the negated (inverted) signal. Use the second output (the indices of the peaks/valleys), since they will be correct without transformation for both the original and negated signals. The findpeaks function has a number of name-value pair arguments that can make this much easier.
Example
ds = gradient(signal)
[pks,pkidx] = findpeaks(ds); % Identify Peaks
[vls,vlidx] = findpeaks(-ds); % Identify Valleys