Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

I need to count the number of 'patterns per second' in a signal. The problem is that the signal changes 'shape' a lot and unpredictably. It is still easy for a person to see the the pattern, but I don't know how to do this with code.

EDIT For extra clarity: say the first sample is 1 second. There are 17 copies of the pattern in this sample. So I want to compute "17 (patterns per second)". Also, it might be worth noting the samples below are from a continuous measurement, in this order.

Any ideas how to tackle this?

(It needs to count the pattern in realtime.)

Here are some samples of the signal. (Zoom level in both directions is identical for all images.)

sample 1

sample 2

sample 3

sample 4

sample 5

share|improve this question
    
it's not quite clear what you mean by pulse. Can you mark each pulses on your samples? (For example by red circle). It will be especially useful for last and first sample –  SergV Jan 14 '13 at 9:59
    
I'm sorry for not being clear. I need to count the number of 'patterns' in a certain amount of time (say 1 second). A pattern in the first sample is 3 peaks, in the last one (and all in between) it's two peaks. This inconsistency in peaks per pattern makes it hard, otherwise I could just count the peaks and divide by 2. –  Jongsma Jan 14 '13 at 10:25
add comment

2 Answers

You can trying using a musical pitch detection/estimation algorithm, which may be more robust in some cases than just a simple autocorrelation (especially in one of your examples that includes a slightly inharmonic overtone). From the frequency or period of the estimated "pitch" you can compute the number of pattern repetitions per second.

A bunch of pitch estimation methods are mentioned in my answer to this question: http://stackoverflow.com/questions/7181630/fft-on-iphone-to-ignore-background-noise-and-find-lower-pitches

share|improve this answer
add comment

Since you have a periodic signal, you can look at the autocorrelation. The lag of the peaks will tell you the periods of the components. If by "patterns" you mean the peaks within each period, you can simply do another round of peak detection.

share|improve this answer
    
Thank you for your answer! SergV pointed out that my question wasn't clear. (I think I used the word pattern incorrectly.) To be clear: I want to count the number of COPIES of the visible pattern in the samples. Would autocorrelation still be the recommended approach? –  Jongsma Jan 14 '13 at 10:36
1  
Yes, because the autocorrelation will give you the number of samples between repeats, and you know how many samples the whole things is, so divide the second by the first to get your answer. –  Emre Jan 14 '13 at 10:49
    
Autocorrelation can be only first step in your algorithm. If T is period of your signal, autocorrelation will have peaks on T, 2*T ... n*T and on T/2, T/3... T/n (harmonic of your signal). So you need to have good algorithm to find valid T. –  SergV Jan 15 '13 at 3:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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