# Determining how similar a signal is to a sine wave

HeartMath Institute calculates a coherence score for heart rate variability by giving a score to how sinusoidal wave-like the instantaneous heart rate signal is.

http://store.heartmath.org/s.nl/ctype.KB/it.I/id.585/KB.623/.f

What DSP techniques can be used to calculate how sinusoidal a signal is, in a manner similar to score used above?

• Since there's not much info on that site, there's no real way of telling for sure if a method you or we could come up with will be truly comaparable - you'd have to develop your algorithm, test it, and then test the Freeze Framer on the same data.
– JRE
May 26 '15 at 9:08
• Just to be clear what we are talking about, this is what I understand the FreezeFramer to be doing: Measure interval between heartbeats (end of one beat to beginning of next, rather than beginning to beginning as in a normal heart rate.) Interpolate that to deliver an interval (measure in milliSeconds) every 500 milliSeconds. Using some unspecified algorithm, calculate a value that says how close this interpolated data comes to representing a sine wave.
– JRE
May 26 '15 at 9:11

Assuming that the description I made of the FreezeFramer process is correct, then I would try determining the SINAD rating of the peak frequency in the interpolated data.

You have a sampling rate of 2Hz, giving a Nyquist of 1Hz. You will be looking for a sinusoid with a frequency well below 1Hz. The SINAD value is (basically) the amplitude of the peak frequency divided by the sum of all the other frequency amplitudes. There are better descriptions available, as well as implementations for many of the more common DSP frameworks.

• Neat! I like it.
– jojek
May 30 '15 at 21:59

Look into cross-correlation. The heartbeat signal can be one side of the correlation, and a sinusoid of interest can be another. Also auto-correlation (cross-correlation of the heartbeat signal with itself) can give you some about the periodicity of the wave form and in particular what the fundamental frequency of beating may be.

• thanks a lot. I implemented auto correlation earlier to find the fundamental frequency, and the general periodicity of the wave form. I will try a cross correlation next and see what I can get from it. May 27 '15 at 15:27
• If you found the fundamental frequency f0, to find out how similar it is to a sine wave, I would generate a pure sine wave with frequency f0 and cross-correlate your signal with the pure sine wave. Then you can come up with your own metric, maybe used a normalized-cross correlation, where you could interpret that a normalized correlation coefficient of 1.0 means the signal under test is purely sinusoidal. May 27 '15 at 16:25

I like Anthony Parks approach.

When I was facing this question what I did was I built a harmonic regression function. I found the amplitude & off-set of the function first, then found the best phase shift I could(coarse -> fine) and did a mean square error analysis on the model vs the data.

I wouldn't say this is the best solution (computation heavy), and it would not work on data too far from a sine function, but it's something.