Read Garmin .fit file function

61 views (last 30 days)
Gabri
Gabri on 2 May 2024
Commented: Star Strider on 2 May 2024
I already saw a question related on this topic of 2018 but I was wondering if in the meantime someone wrote a function to read directly on Matlab .fit files from Garmin.
I cannot use the gpx file because it only exports GPS informations, while fit file has everything of an activity inside of it and I want to do some post processing on these info.
For the moment a workaround I found is to use the external software Golden Cheetah that already does post processing. It's a complete software but quite heavy. I use it only to convert fit into csv and read them on matlab.
An internal function would it great. Fit files are not text file like gpx, but are encrypted. I guess it is possible to decrypt it (found a Garmin java script, but it has some problems in the conversion) because I don't think the format is protected by copyright.

Accepted Answer

Star Strider
Star Strider on 2 May 2024
@Gabri — According to the information in the Programming Languages section of the links you provided (thank you), the SDK supports Python. Since MATLAB also does (see: Python with MATLAB) I suggest that as the way to go with this project. Those files are binary files, and the format is not going to be easy to work with, since that would involve writing your own MATLAB code to read them, especially since the necessary information (precision, machine format and such) does not appear to be provided in the Garmin documentation.
This is going to be a challenge. When you get your code working, please contribute it to the File Exchange.
  2 Comments
Gabri
Gabri on 2 May 2024
Thank you for the info. I didn't know Matlab could use Python.
I actually found a python tool (python-fitparse Documention — python-fitparse 0.0.1-dev documentation (pythonhosted.org)) of few years ago that I could try to run in Matlab.
Thank you
Star Strider
Star Strider on 2 May 2024
As always, my pleasure!
I have not had any reason to use Python so far, however there have been several Answers posts about it, so I explored it. Apparently, some things are easier to do in Python than MATLAB, and like Garmin, there appear to be other SDKs using Python that involve instrumentation interfacing and similar capabilities.

Sign in to comment.

More Answers (1)

Sachin Lodhi
Sachin Lodhi on 2 May 2024
Edited: Sachin Lodhi on 2 May 2024
Hello Gabri,
I understand that you want to read a Flexible Image Transport System (FITS) file in Matlab. For this, you can use the 'fitsread' function. The 'fitsread' function reads the primary data of the FITS file and returns it as an adjusted array. The function replaces undefined data values with 'NaN' and scales numeric data by the slope and intercept values, always returning double precision values.
The 'fitsread' function facilitates the retrieval of raw data from FITS files, enables the extraction of subsamples of data, and permits the reading of data from designated columns within a FITS file, among other functionalities.
Here is a sample code snippet that uses 'fitsread' function to read data from 'filename.fits' file.
data = fitsread('filename.fits');
I recommend you to please go through the following documentation for more information on 'fitsread' function -
  1 Comment
Gabri
Gabri on 2 May 2024
No, not the FITS format, but the Garmin FIT format (Flexible and Interoperable Data Transfer)
Which is not a text file like the GPX format, but an encoded file that if you try to open it with notepad or similar, you don't see anything.
I'm attaching an example of activity from Garmin website.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!