# Finding peaks of periodic data set

I have a data set that is roughly periodic. It is the distance between feet as a person walks. A portion of this data can be seen below. The y axis is the absolute distance between feet, and the x axis is time. Three distinct peaks can be seen in this image. I am interested in the x and y values of these peaks (this is when the legs are the furthest apart during the walk).

I thought since the data is vaguely sinusoidal, that I could take the root mean square, then multiply by $\sqrt2$ to obtain the amplitude. Performing this on the data shown below yields an amplitude of 56.9, which seems accurate. But it still doesn't determine when the peaks occur.

What is a good way to find each of these peaks computationally?

• Two questions: 1) Is the noise level in your example "typical"? (it is rather smooth). 2) Are you using a particular software framework? (eg. Matlab) Oct 14, 2016 at 14:40
• It's not shown in the picture, but there are some peaks that are clearly noise in the dataset. I am using Matlab Oct 14, 2016 at 14:42

## 1 Answer

As posed, this question does not actually seem to depend on the periodic nature of the data?

If you want to find the actual peaks in your data, typically you would literally just scan the data to find local maxima. (For regularly gridded data in Matlab this can be done with imregionalmax.)

A secondary issue related to "finding peaks" is precision. In some cases it may be desirable to refine the discrete local maximum at a sub-grid scale. This can be done by fitting a quadratic to the discrete peak and its neighbors, and computing the peak of the quadratic (assuming it is positive definite). There are some details related to ensuring a consistent sub-grid peak is identified, which are described in many places (e.g. papers on SIFT).

However, the primary issue is dealing with noise. There are various ways to do this. The simplest is perhaps to smooth the data. This can be done with a Gaussian blur in some cases, but this will tend to change the peak position. Alternative smoothing approaches would be an edge preserving filter (e.g. median filter, medfilt2() in Matlab), or a Savitzky-Golay filter (e.g. a quadratic filter, to combine smoothing & sub-grid refinement in one step). Another simple method is to ignore local maxima below a given relief threshold (e.g. imextendedmax() in Matlab).

Aside from using parametric models (e.g. Fourier analysis), you could apply other constraints based on the quasi-periodic nature of the time series. For example if you apply one of the techniques above to detect local maxima, and similarly for local minima, then you would want to ensure that the subset of these you call "peaks" and "troughs" form an alternating sequence (i.e. one of each per period).