Effective but reliable peak counting algorithm

I have a system that regularly collect a time domain signal and I have to count the number peaks. The difficult part is that for some reason some noise may come up as spikes that make conventional counting algorithm such as local maxima or turning point do not work perfectly. Expert here please suggest method for counting the number of peak. I am attaching a sample diagram showing 32 peaks that is typical. Million thanks!
Have you tried running a smoothing algorithm over the data before your conventional counting?
If the spikes are single point, then a simple 3-point median smooth is quite effective. Sometimes a combination of median then binomial or S-G smoothing may help. You need to try with your data to see what works.

Hope this helps,
Kurt
Thank you for your recommendation. I tried some sort of low pass filter but it is not that effective if the spike is really strong. I will try your approach. Thanks!
Do your peaks always show up as a pair? If so, can you use that to find peaks of interest?

Does the example shown in your original post include problematic noise spikes? If not, it would be helpful to see the problem.
jtigor wrote:
Do your peaks always show up as a pair? If so, can you use that to find peaks of interest?

Does the example shown in your original post include problematic noise spikes? If not, it would be helpful to see the problem.



Those peaks essentially no need to exist as pairs but most of the time they do.

The sample plot doesn't show those spikes. I will try to upload some noise data in addition. Thanks.
By eye it looks as though your peaks are ~100 data points wide, whereas the noise is not what I had thought in that it is not the odd narrow spike.

I think that a wide binomial or S-G smooth should deal with this - try with a width of 21 (say) or even ~double that.

Good luck,
Kurt
Are your peaks always above a certain height relative to the baseline and your spikes always lower than a certain value relative to the baseline? If so, you might combine a peak detection (slope change or derivative method) with a height restriction criteria. IOW, detect all the peaks, then eliminate everything below a certain threshold in height (or select only those above a certain threshold in height).

The underlying frequency of your peaks and spikes seems comparable, so I suspect that low pass filters or smoothing might still not clear all issues consistently, though it could also offer a cleaner starting point for further processing.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
jjweimer wrote:
Are your peaks always above a certain height relative to the baseline and your spikes always lower than a certain value relative to the baseline? If so, you might combine a peak detection (slope change or derivative method) with a height restriction criteria. IOW, detect all the peaks, then eliminate everything below a certain threshold in height (or select only those above a certain threshold in height).

The underlying frequency of your peaks and spikes seems comparable, so I suspect that low pass filters or smoothing might still not clear all issues consistently, though it could also offer a cleaner starting point for further processing.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville


The peaks do have a minimum value but the spikes do not. Long time ago we use the threshold method but it is not that accurate just because of that. Here is a close snapshot of the data from the peak 4th peak and you can see those noise more closely between the 6th and 7th peak. You can see there are four groups of resonant peaks between the 6th and 7th peaks.
eesyliu wrote:
Here is the one with a lot of noise between the 6th and 7th peak from the left.

If this is electrophysiology recordings, the noise looks like the system pickup signal of a mobile phone to me. What I find is that if somebody carries a mobile around your rig and the place doesn't have robust signal strength, this often occurs, especially somebody is texting. I find that in a hard way
Is your expected signal to be in a given frequency range? Have you tried doing a band pass filter (hardware) of the signal before it is collected?
wwzhang2 wrote:
eesyliu wrote:
Here is the one with a lot of noise between the 6th and 7th peak from the left.

If this is electrophysiology recordings, the noise looks like the system pickup signal of a mobile phone to me. What I find is that if somebody carries a mobile around your rig and the place doesn't have robust signal strength, this often occurs, especially somebody is texting. I find that in a hard way



No. It is a kind of strain measurement result of a moving wheel. It is mechanical system actually.
proland wrote:
Is your expected signal to be in a given frequency range? Have you tried doing a band pass filter (hardware) of the signal before it is collected?



It is because we are also interested to see the high frequency band of the signal and therefore we can just stop the high frequency band by adding a filter. In fact this is a mechanical system and we can't add a filter to it.