Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I calculate the beats per minute (BPM) out of Kinect hand positions tracked from a conductor. I do that by finding the last and the second last minimum in my history data. I then calculate the time difference between these two minimums and extrapolate this difference to a minute to get the current BPM.

However I am struggling finding the correct mathematical equation for that. How would I start? It is basically just the following, but how would I use the $history$ instead of first and secondLow? And have a function like $bpm(x) = ?$ or similar.

$$bpm = 60 / (firstLow - secondLow)$$

To show how my data-set does look like I add a simple graphic which should give you a little more details.

History data (Y) over time

Thank you very much for your help.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Long story short, you don't want to look for peaks and the distance between them, for many reasons. First, it is heuristically difficult to do this with real data. Second, you will get all sorts of BPM variation due to small effects -- essentially small variations will corrupt your data.

What you want to do is draw a threshold at around 40% of a recent maximum, and then count all rising (or falling) crossings of that threshold. It's much easier to compute the crossing of a threshold than it is to determine a maximum/minimum in real time, and it is far less sensitive to noise.

This works because if you assume a periodic behavior, which is usually a fair assumption, then the wavelength between peaks is exactly the same as the wavelength between rising crossings of a given threshold.

In practice, to get reliable results, you might want an adaptive type estimator, because of possible variations in the baseline of the signal. This is a similar algorithm (almost exactly the same, really) to that used in detection of heart rate based on pulse oximetry data.

However, if you are comfortable with your method, then it is simple to compute BPM.

Let $\Delta t := t_{2}-t_{1}$. Then, you have $BPM = \frac{1 \mathrm{beat}}{\Delta t \mathrm{sec}} \cdot \frac{60 \mathrm{sec}}{1 \mathrm{min}}$ (in other words, your equation was correct).

share|improve this answer
    
Your objections to the method are quite interesting and I think I'll have to consider that. Thank you for your answer though. –  fdomig Aug 4 '12 at 22:43
1  
Unfortunately, I do not have the pulse-ox code that I've used handy, otherwise I could give you a more detailed answer. Nevertheless, it is a very simple change to set a threshold -- even easier than computing minima! –  Arkamis Aug 4 '12 at 22:45

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.