1
$\begingroup$

So I have some sensor data (time series) of heart rate of some users. I want to detect the times they start and finish exercising.

The data is sensor readings of heart rate every second, it's fluctuating a lot. My goal is to "locate" exercise durations and report the start and end of an exercise.

Could someone guide me to the right direction?, Should this be solved via a Fourier transformation for example ?

Any reading material or guidance would be much appreciatedData Sample

$\endgroup$

2 Answers 2

1
$\begingroup$

There are a ton of methods you could use, however you would also pick up other anomalies you would have to sift through.

You are probably better off (since exercise is most likely pretty well defined) using basic logic such as:

Any period of more than 5 minutes of average heart rate > 120 is exercise

Maybe there are nuances person to person and you want to use median heart rate to help determine that threshold but to me this seems like the most reliable solution.

Additionally, aggregating to minutes using the average per 60 seconds may help to make the exercise periods clearer and protect against a few seconds of running to catch a door or something that might spike the heart rate.

$\endgroup$
2
  • $\begingroup$ I have tried using simple logic just like the one you defined. it works well if the data is smooth enough. However, due to the nature of heartRate (fluctuates greatly in a short span of time) and some sensor issues it's giving me bad results Is there any more " automatic/scientific" ways to do that ? $\endgroup$ Commented Oct 28, 2021 at 13:35
  • $\begingroup$ Yeah, I think if you can aggregate to an avg per minute that would smoothen it out or you could look into filters like a simple moving average through the series, or as you mentioned you can filter out low frequencies from a fourier transform, or some other smoothing methods like LOESS. Here is an article on the fourier piece: fischerbach.medium.com/… $\endgroup$
    – Tylerr
    Commented Oct 28, 2021 at 14:23
1
$\begingroup$

Your data is per 1 second, but "is exercising" is not that fast of a temporal phenomenon. So first I would use a median filter, to for example 1 minute or even 5 minutes. The median filter is more robust to erroneous readings and preserves transitions better than averaging. On that data you can probably apply some simple threshold, for example say that exercising is heartrate > 120. However, when performing segmentation like this, it is wise to use some hysteresis - meaning to use a different threshold to leave the state compared to enter the state. For example only consider heartrate < 100 when in exercising state. This avoids creating many tiny state transitions when the signal is just around the threshold value.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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