Monday, 4 December 2017

Strava Data Analysis - A PC Based Visual C# Solution - V2.0.0.0 - Major Updates Dec 2017

The lastest version is here: Strava Tool Version 3.

Please download and use this version

In some previous posts I have shown the progress of my C# application to get hold of my own Strava data and do something with it.

The latest update is here: http://midlandscyclist.blogspot.co.uk/2018/04/my-windows-pc-c-strava-data-analysis.html

The last update was documented here: Strava Data Analysis - A PC Based Visual C# Solution - V1.1.0.8 - Updates Feb 1017

The current version is now at 2.0.0.0 and features a lot of updates. This is partly why the last update was over 10 months ago, and also because I'd rather be riding my bike

To find the previous posts about this software that I have written search for "Strava Data Analysis - A PC Based Visual C# Solution" in the blog

Major new features include:
  • Statistics ("simple" and "more advanced") (Visible to user)
  • Graphical display of data (Visible to user)
  • Some user interface improvements (Visible to user)
  • Quite a lot of work on the source code to make it a bit easier to support (Not visible to user)
All of these have taken me some time as its been a learning journey as well

You can download the application here: Zip File on Google Drive

Unfortunately I can't add files directly to this Blog and I don't have a hosting solution so its a bit clunky

At the moment the zip file is only the built application. There's no source code still - there are 2 reasons for this:
  • I am not sure how to split out only the files in the Visual Studio solution that are needed
  • I want to do some more work on the source code as its a bit of a mess
Assuming that you are still interested, have down loaded the zip file from the Google Drive and installed the application the remainder of this post is a bit of a user guide as to how to set up and then use the software

Firstly go to the Google Drive and find the file:



Make sure that you download Version 2.0.0.0

The Zip file contains the following files:



Double click on the "Setup" file. You will then see the following message:



Here you can choose whether or not to continue - the default option is "Don't Install" so you have to consciously select "Install".

Once installed it should appear in the Windows Start Menu:



Should you still not want to use the software you can un-install as normal from the Application menu (Its currently called "Strava Forms V2". Note that I have not yet created an an Icon for it yet)



Once it is installed start the Application. You'll see the following:



If you press the Start Button at this point you will get an error:



This is where its in-elegant. I have designed it so that you can download your private data. To do this you need the correct Strava Authentication Token. This is described here: How to get the Strava Token. This needs a lot of work. There appears to be no easy solution to doing this via a .Net application. There's certainly no specific ready to use code and I am going to have to create a second test application to look at this further.

Note that this is the weak spot of this application
 

Once you have generated a token copy and paste it into the text box marked "Strava Public Token" (note that this will be saved into an .ini file so once you have the token it will be able to be re-used (the tokens are non-expiring)

With a valid token select the relevant date range:



The Start Date of 1st January 2016 is hard coded in and the end date is today's date (by default the time of day is 00:00:00 am for the start and 23:59:59 for the end date so it will acquire any activities uploaded moments before.

Also select the units that you want to display the data in (imperial - miles, feet or metric km, m). This currently overrides the Athlete preferences read from Strava.


After a suitable pause (depending on the size of the date range, your network speed and the load on the Strava Site) you'll get results returned. (The application is currently single threaded and there's no progress indicator so please just wait).


The Application will return some Athlete Data (in the Athlete Data tab):





And in the Ride Activities tab will be all the Cycling activities within the defined date range (the number will be indicated in brackets, 342 in the example below):


If you are a Runner or do some other activity then tick Show Runs or Show Other Activities:


Show Runs will give another tab:





And Show Other Activities will show everything that's not a Cycle Ride (real, Stationary Trainer or Virtual Ride) or a Run. In my case I do swim occasionally:



However the application is Cycling focused. 

Firstly you can export the Activities list to a text file by selecting the Ride Activities tab and pressing the Export button:



Browse to a folder, give a file name and save. (Export also works for the individual Activity data).

Having got the activities you can now select which individual activity you want to view. elect the Ride Activity Data tab and double click in the first (empty) column. There will be a short pause whilst the data is retrieved from Strava. You can see which files have been selected as the "*" character is displayed in the first column and the row test colour is changed to red:



When this is complete data, in 3 more tabs is available (the Activity ID is shown in brackets as well).

Firstly the Ride Activity Data shows the 1Hz data (or whatever frequency was used):



As well as the raw measured data additional columns include calculated data such as Integral Altitude (cumulative height gain), Average Speed etc. Note that no power data is shown unless you have a power meter.

You can also Export this data as well using the Export button.

The Ride Activity Stats Tab shows some simple analysis of the activity data as well as some more advanced stats:



The Simple stats (left pane) shows the minimum, average, maximum, median and standard deviation of the raw recorded data.

The more advanced stats (right pane) is a work in progress and is based on some of the Stravistix Chrome Plugin. There's more to come here and this will be one of the sooner items in the next set of updates.


There is finally the Ride Activity Graphics tab [lots all the continuous data against either distance or time (using the radio buttons):



There is a "MouseOver" event so the actual data is displayed in the status bar at the top of the  graph pane. The Export button also exports the graphic as an image file:


Al the data for the application is stored in the default directory, currently this is as per the Installer location as is very obscure. Use the Tools Menu selection to Show Data Folder:



Here you will see the ini file (stravaforms.ini), and 2 other files: Athelete_xxxxxx.txt and Activities_xxxxxx.txt. xxxxxx is the Athlete ID:



Also for every activity selected the raw data is stored in 3 files <activity_id>_activity.txt,
<activity_id>_activity_stats.txt and <activity_id>_activity_stats_adv.txt. All these files are plain text files so can be re-used if required.

The .ini file contains some application settings (I have hidden my token):


If the .ini files exists s well as the Athlete and Activities files then the next time the application loads the data will be displayed. The start button is now an update (note that it wipes any existing data rather than appending to use accordingly).

You can quit the application in the normal manner or use the File- Quit option.

So far this is it.

What's planned for later versions (no particular order):
  • Continued code improvements
  • Use of threads to make more responsive
  • Ability to Authenticate within the application
  • Use of a database rather than files.
  • More statistical options
  • Automated Activity data retrieval 
  • More work on the Graphics pane - there is a lot of white space, its quite slow and needs more legends, axis titles etc
  • Error Trapping - currently there is almost none!
Feel free to send suggestions!

Also comment with issues/bugs/errors

Thanks

3 comments:

  1. Hello Julyan,
    How are you?

    Im trying to get informations from Club members
    We have a little competition between members and we need to compute distances and elevation gains from this members. Do you know how can I do this?
    Could you send me, please, code samples from this publication?
    Regards

    ReplyDelete
    Replies
    1. I forgot to tell you...
      Im using C#

      Delete
    2. I am using a pre-prepared set of code to access the Strava API rather than direct calls (I think I listed this in one of the earlier related posts). The Clubs data from the API only describes the type of club - it does not contain any details about individual members.
      If you want a tool to download the data for individuals and compare then this can only be done by downloading each individual members data and collating it.
      So to use my tool (and I recognise its not great) each member registers/creates an app with Strava. This allows them to get the required token that my tool needs to get their data. They each then download the data and it can be collated and analysed.
      My tool could do multiple people but it would need to run for each user and use their token, thus collecting all the data.
      However the Strava tokens are nominally private, so if you had the tokens for all your club members, in theory you could edit or delete their data.
      If they shared their public token (rather than the private token) then there would be less risk but for example here you lose data if a club member has privacy zones
      I will share the source code, but its a bit of a mess at the moment and I am not quite sure what files I need to share and what I don't. I think the best this is that I'll pull all the c# files out - both the library files (as I have made a few minor edits in some (Strava have changed the names of some data very slightly) and all the files I have created, and let people use these.
      However as I said the earliest code is a bit of a mess and as I have progressed I have improved the code style, and started to use different functions. As a result there's a mix and I want to harmonise this. If you want some code let me know

      Delete