# How to find peaks and periods?

I am looking at data like this:

Source data: http://pastebin.com/raw.php?i=L6cd8d5K

The data is quasi-periodic, there is a distinct cycle but it is not an exact repeat, and the period changes considerably. I would like to find accurate peak positions, and period durations, for each cycle. Ideally the peak positions would match the intuitive notion of where the exact peak is.

What makes this hard:

• noise: although it may not be entirely noise! the variation is much greater when the values are high, and so the highest spikes tend to occur near where the "real" peak is.

• the waveform is not symmetrical: neither left-to-right nor up-down. doing something like a highpass filter will move peaks up and down by an amount that depends on their duration and the shape in between.

What is unlikely to work well:

• bandpass filter combined with conventional peak picking: the position of the peaks will shift since values from the (asymmetrical) up and down slopes is added to where the peak is. The really high values will not have a high weight in the result since the lowpass part of the bandpass filter will spread their energy to adjacent values.

• autocorrelation: the shape of successive cycles is too different.

• period durations measured from the leading (or trailing) edge of one cycle to the next: again shapes are too different.

• Do you want to find the peaks of the underlying low frequency signal or of the high frequency noise? or both? – Aaron Apr 25 '14 at 16:23
• @Aaron: the two are not necessarily separate :) there are bursts of stronger high frequency "noise" or spikes near the low frequency peaks. I want to find something similar to what a human might label the peaks as, which in many cases is the highest spike on top of the low frequency peak. – Alex I Apr 25 '14 at 17:18
• I think you need to be more specific in your definition of peak. There are lots of different ways a human could label them. Can there be two on the same underlying low frequency cycle? – Aaron Apr 25 '14 at 19:01
• Try findpeaks which has some really nice parameters you can use to pick the peaks. – user16765 Jul 25 '15 at 14:20
• i wouldn't write off auto-correlation so summarily. also try a DC-blocking filter (subtract a well-aligned moving-average DC) to see what your data would look like. – robert bristow-johnson Jul 25 '15 at 17:12