0
$\begingroup$

I want to detect 6 peaks in a signal. I am open to any suggestions. There is one problem where my signal sometimes jumps high and stays higher than the rest of the signal. I don't know why this happens but would like a solution to lower the signal back to the points where the rest of the signal was lower, which might help detect all 6 peaks. I attached a picture.

enter image description here

$\endgroup$
  • $\begingroup$ If you know that the jump is greater, or much greater than the peaks, themselves, and if you know an estimate of the value of the jump, then you can simply detect first when it occurs (as per the pic, say val=80), and when that happens subtract its value (the pic shows ~160), then, when the jump drops below 80, you know it has past and the trick is no longer needed, until the next jump. In the meantime, perform detection of the peaks as you wish. Two ifs, though. $\endgroup$ – a concerned citizen Mar 22 at 6:59
0
$\begingroup$

I think the easiest option is to detect the massive sudden increase/decrease. Try calculating the difference between samples. If this difference is too big (positive or negative), we substract this difference on all future measured samples.

Create a variable for this offset. start with an offset of 0, when de absolute value of the difference between samples is too big, add this (non absolute) difference to the offset, then all next samples are $x_{new}=x-offset$.

$\endgroup$
  • $\begingroup$ How do you define "to big" ... what determines if it is too big ... 2 standard deviations, greater than the mean, what metric could I use ... $\endgroup$ – wwjdm Mar 22 at 15:19
  • $\begingroup$ Try to calculate the difference in the samples. for sample $i$ calculate the difference between sample $i$ with sample $i-1$. The threshold to detect if the difference is too big should obviously be less than the smallest signal jump you've encountered, but not small that you detect a false signal jump. In the example you've provided, I would go for a threshold value like 75. $\endgroup$ – ehagenaars Mar 22 at 16:02
0
$\begingroup$

Try calculating a moving-window fit of a well-chosen test function to your data. This would also remove the necessity of removing your signal jumps. Your peaks don't really look like a peak to me, but more like a smeared-out box-car function. You could choose the analysis window in such a way that it is approximately equal to the width of the peak and use something like $a(x-w_\textrm{center})^4 + c$ as a fit function ($w_\textrm{center}$ is a shift of the window center so that your parameter $a$ yields a maximum in the middle of your peaks). You will then have to set an appropriate threshold on the resulting series of $a$-parameters, which should have a much clearer peak-like structure. You can also concentrate only on the negative values of $a$ to identify only the peaks and not the dips between the peaks.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.