trackerproject / trackeR

Infrastructure for Running, Cycling and Swimming Data from GPS-Enabled Tracking Devices
http://cran.r-project.org/package=trackeR
90 stars 7 forks source link

Cadence erroneously identified as cycling, not running #22

Closed krissen closed 4 years ago

krissen commented 4 years ago

A minor issue, but cadence seem to be identified as cadence_cycling for me, even though the tcx activity specifies <Activity Sport="Running">.

> head(run_details)
                 time latitude longitude altitude distance heart_rate speed cadence_running cadence_cycling power temperature
1 2020-04-28 05:54:59 59.37747  13.53118     2685     1.89         84  1614              NA              87    NA          NA
ikosmidis commented 4 years ago

Please share the data and a reproducible example on those, so that I can investigate. This does not happen in our test cases.

krissen commented 4 years ago

Using this .tcx and the following code:

library(tracker)

file <- "20200428-055459.tcx"
run_details <- readTCX(file, timezone = "", speedunit = "m_per_s",
        distanceunit = "m")
head(run_details, n = 1L

I get

                 time latitude longitude altitude distance heart_rate speed cadence_running cadence_cycling power temperature
1 2020-04-28 05:54:59 59.37747  13.53118     2685     1.89         84  1614              NA              87    NA          NA
krissen commented 4 years ago

I can see tcx files downloaded from Garmin connect has a <ns3:RunCadence>85</ns3:RunCadence> field under extensions whereas the tcx I provided has a <Cadence>85</Cadence> directly under Trackpoint. I generally don't use Garmin connect, but convert files from fit to tcx via a python script (cannot check at the moment, but might be FIT-to-TCX.)

Nevertheless, couldn't <Activity Sport="Running"> serve as a logic to read cadence as run cadence?

ikosmidis commented 4 years ago

Now fixed in the develop branch. It'll take a while to go to CRAN. If you want to test it do

remotes::install_github("trackeRproject/tackeR", ref = "develop")

Note that this will overwrite your current trackeR installation, but it should be safe at this stage (haven't merged some potentially breaking changes yet).

You may have seen that already, but just in case: you can directly use theread_container interface to produce a trackeRdata object if you want access to trackeR's analytic capabilities.

library(tracker)
file <- "20200428-055459.tcx"
my_run <- read_container(file, type = "tcx")
plot(my_run, what = "cadence_running")

Also, take a look at read_directory if you have many tcx's lying in a single directory.

krissen commented 4 years ago

Many thanks! Also for the additional points on usage; just getting started with analyzing runs with R. And yes, I do have quite a few files to parse through; just shy of 3000 if I remember correctly. I've tried many different libraries so far, trying to get the at the data. Initially from fit files, but so far struck out (fitdc was promising but only supported older files). Found this project when I instead attempted to use tcx files as data-sources. The fact it is being actively being developed is, of course, a major plus! 🙏

ikosmidis commented 4 years ago

Please feel free to keep filing bug reports/feedback!

krissen commented 4 years ago

Just tried the dev-version; indeed working as expected!