3
$\begingroup$

Has anybody been able to parse FIT files in Mathematica? The format was developed by Garmin and is used to store data from GPS devices and workout equipment. Details can be found at https://www.thisisant.com/resources/fit/

There is a Python package that can parse these (https://pypi.python.org/pypi/fitparse/1.0.0) but it hasn't been updated in years and I haven't been able to get it to work.

--

Update -- I got fitparse working.

enter image description here

$\endgroup$
  • 1
    $\begingroup$ There also seems to be an R implementation here. Since you can automatically install a copy of R from within Mathematica and call R functions, perhaps that might be useful here. Alternatively, GPSBabel seems able to convert FIT to GPX, and Mathematica can read GPX natively. $\endgroup$ – MarcoB May 12 '16 at 15:08
  • $\begingroup$ GPSBabel seems to toss everything except time stamp, coordinates, and altitude. Mathematica, in its import, then tosses the altitude. I'll try the R solution and continue to work with the Python package as time allows. $\endgroup$ – Michael Stern May 13 '16 at 19:10
  • $\begingroup$ Thanks for the checking! If you come up with a workable method, please consider posting it as a self-answer. I'm looking forward to it! $\endgroup$ – MarcoB May 13 '16 at 22:53
  • $\begingroup$ I got fitparse working in Python. The trick is not to try running Python 2.7 code in Python 3.5. I'll improve this all later, but my initial Python and Mathematica code can be found at github.com/MichaelSternNYC/fit2Mathematica $\endgroup$ – Michael Stern May 15 '16 at 19:12
  • 1
    $\begingroup$ Michael, that's great to hear! Would you post your last comment as a self-answer, so your question will show up as answered for future searchers? $\endgroup$ – MarcoB May 16 '16 at 0:57
3
$\begingroup$

After experimenting with the free multiplatform tool GPSBabel (http://www.gpsbabel.org/) and with the Python module Fitparse (https://github.com/dtcooper/python-fitparse), I can share the following:

  1. If you want latitude and longitude only, GPSBabel is fine. It converts the spatial coordinates in a Fit file into GPX format, which Mathematica can import. Unfortunately, it doesn't bring over anything except time stamp, location and elevation, and Mathematica then tosses the elevation data. This was not adequate for my purposes, but for some people it may suffice.

  2. Fitparse worked much better. It requires Python 2.7. I wrote a python script that uses Fitparse to convert a specified Fit file into a text file containing a nested list of Mathematica Associations, which can then be imported into Mathematica. Using Pythonica you might be able to do the conversion directly, without saving the converted data to disk and importing it, but the save-to-disk-and-import method is no great hassle.

FIT is a flexible format that will contain different fields depending on what is being measured and by what kind of device. My conversion preserves everything in the original file -- latitude, longitude, elevation, heart rate, cadence, temperature, whatever. My tool stores this in a nested list of Associations, where the outer Association specifies the time stamp and the type of record, while the inner list of associations specifies the data associated with that time stamp and record (heart rate, cadence, etc.), and the unit for each one.

You can see my python code for doing the conversion and sample Mathematica code that uses the output, along with a sample FIT file, at github.com/MichaelSternNYC/fit2Mathematica.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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