Periods of High Activity Detection 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 appreciated
 A: 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.
A: 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.
