Data relationships in a single activity

Here we’ll explore different ways to look at two different attribute together in connectstats.

Let’s say we want to look at how the speed and heart rate relate to each other. The first approach is simply to plot the two series together on the same graph as below.

2fieldsplots 12

The arrows 1 and 2 shows that on the two short interval when the running speed increased, the heart rate increased as well.

One approach to relate the information a bit better is to use a color overlay to show the one information on the a single plot

2fieldsasline

The arrow 1, shows where the line becomes darker and red as the heart rate increased with the speed, the arrow 2 shows the heart rate slowing down as the color goes back to the green

The last and, in my opinion, most interesting way to relate the two series of data is the scatter plot.

Scatterplot 17

Here you can see the points (arrow 1) where the speed/heart rate increased together. Array 2 is the beginning of the run with lower heart rate until it stabilised in the region of arrow 3 for most of the run. The regression line shows how the main relationship between the 2 data goes, here slightly to the downward slopping as expected.

It is also interesting in the lap view to see where in the larger scatter plot a given lap appear as below

Scatterlap 9

The green points show for this mile lap that the beginning was quite fast/high heart rate (arrow 1) and then slow down of both speed and heart rate (arrow 2), and clearly at the lower end of the overall speed of the run.

Data and smoothing used in connectstats

ConnectStats let us apply basics statistics technics to analyse our fitness data. We use these techniques to answer questions about the activities. How well did I do on this run? Is my stamina improving? Did I push myself more today that last week?

Raw Data

Before doing any analyses, let’s review the raw data we have access to. ConnectStats relies on the collection of the data is done with a garmin device and a collection of sensors.

The raw data varies by activity type and device.
For outdoor activities, the raw data will be gps coordinates, a timestamp, speed and values from different sensors: Heart Rate beat per minutes, cadence (legs or pedal), Power delivered on the bike, and sometimes more advance running dynamics like Vertical Oscillation, ground contact time. For swimming the data collected will be the time for each length and the number of stroke.

Here is an example of what the raw data looks like Blog txt

Depending on the activity or the device the raw data will be collected at fixed intervals or at different intervals trying to reduce the amount of data saved. If you move in a straight line for 5s at constant speed, it isn’t necessary to collect the points every seconds as they can easily be interpolated.

From this raw data, there are two main directions for the analysis we can do. The first is analysing a single activities and the second is analysing summary of each activities over time.

Focus on a single activity

The summary statistics are quite simple. Mostly we will want to look at the average of the different measure, maximum and minimum. Where it gets more interesting is to look at the series of data. As for most statistics analysis a first phase will be cleaning the data.

Data Cleaning

Let’s look at the graph of the data collected by the gps. You can see it is quite noisy, there is also large part of the data that is not really interesting to look at to. Some is gps noise, area with bad reception, pause due to stop lights,

Rawdatabad

To clean the data, we can first use assumption on expected constraints on the data. For example, define a minimum speed considered valid running speed, or a minimum valid heart rate to remove unreasonable spikes. Another technique used by connectstats is to filter points that have unrealistics acceleration.

FilterBadValues

The last smoothing technic we can apply is a moving average of a few points. Usually the app will use 5 points moving average for data, but it can be controlled in the sliding left settings window.

Filterbadnormalsmoothing

In the case below the graph start to be more readable now, especially with the 2 minutes moving average overlay, which shows the two short faster run intervals around 30min and 40min.

Historical Scatter Plots I like to use

One of my initial motivation to write the app was to look at my activities using scatter plots. I was especially interested in looking at the relationship of heart rate and speed.

Here you can find information how to access them.

scatter-hr-pace

The first thing I look is where is my last activity in my overall history. Here you can see that I was in the middle of the pack, a bit on the high heart rate side.

Screen_Shot_2014-01-18_at_17_44_54-6

 

It’s also interesting to check the pattern overtime. You can see here that the more recent colors are on the higher HR, slower pace area. Not good, I need to improve.

Screenshot_19_01_2014_22_25

Sometimes it can also be useful to check only the recent history, using this button to rotate between all, 1m, 3m, 1y

Screenshot_19_01_2014_22_31-4

Other times, I also want to have a more sophisticated filter for the graph, in that case I can use the search feature. If I define a search in the activity list I can then get the scatter plot only for those activities. The statistic tab will have an extra button beside running, cycling swimming and all: Search.

Screenshot_19_01_2014_22_34-2 Screenshot_19_01_2014_22_35-2 Screenshot_19_01_2014_22_36

Some other interesting historical relationship to look at for bikers: Power and Cadence or Power and Heart Rate

Screen Shot 2014-01-18 at 22.57.28 Screen Shot 2014-01-18 at 22.57.46

 

Best Rolling Plots

Critical Power Plots

I discovered recently the concept of Critical Power Plot, after a user left a comment on the site. Critical Power is the maximum power you can maintain for a given period of time. The concept seems mostly used by cyclists. But it felt to me it could be extended to other data: What is the best pace I maintained for any given period of time? What is the maximum heart rate I maintained for a given period of time?

So I decided to give it a go and implement it in ConnectStats. All I had to do was maintain a rolling average every X seconds and keep track of its maximum. It’s quite an expensive computation: for N points, I need to do NxN computations, and the devices processing power is a bit low, so I chose 5 seconds for X, which seems to work well in practice even on my old iPhone 4.

Of course, the original data in the file produce by the watch isn’t nicely produced every 5 seconds and for the algorithm to work efficiently, I have to resample the original data at the average on that exact interval, which can result in a bit of loss from the original file. But in practice it didn’t appear too bad on most of the ride I looked at.

I end up with a new time serie evenly spaced every 5 seconds: the maximum average heart rate over 5 seconds, over 10 seconds, over 15 seconds, etc, etc.

Just had to come up with a name, cyclist refer to it for the power field as Critical Power, but “Critical Power” or “Critical Pace” felt a bit confusing to me, so I named it “Best Rolling Heart Rate” or “Best Rolling Pace”

Here is the example from my best 10k race for the heart rate.

doc-detail-bestrolling-hrplot

 

This is quite nice and works also for power or pace.

Best Rolling Laps

Of course the plots are nice, but the next thing I wanted to know was for that best HR what were my others statistics for each of that given period of time where I reached that maximum?

So I enhanced the auto lap feature to show the best rolling lap corresponding to a few arbitrary periods of the plot. Below you can see the details for the Best Rolling Power or Critical Power of a friend, along with the distance, speed, HR for each of the correspond section of the ride.

doc-detail-bestrolling-lapsdoc-detail-bestrolling-lapchoices

 

 

 

The last missing piece was to plot on the map and highlight on the plot of another statistic where that best average was reached as below

doc-detail-bestrolling-lapdetail