Skip to main content
Ctrl K

BikeLab FIT Analyzer

Cycling .fit activity files: a validated FIT reader, NP/VI and stability metrics with Monte Carlo bands.

1
contributor
Get started
2 commitsLast commit ≈ 3 days ago0 stars0 forks

Cite this software

Description

The engine of the BikeLab FIT Analyzer: it reads a .fit activity file in the browser and reports cadence stability, drivetrain (speed/cadence) stability, climbing stability, Variability Index (VI = NP/AP) and power:heart-rate decoupling, each with a Monte Carlo uncertainty band. The file never leaves the user's device.

fit_engine.js is the exact code that runs on the live pages: everything between BEGIN VERBATIM and END VERBATIM is copied byte for byte from them, and npm run check:page verifies it (SHA-256 per function, engine_manifest.json).

Minimal maintenance. This tool is not reviewed often. If you find a bug, a file it cannot read or a result that does not add up, write to BikeLab on WhatsApp (+51 934 391 545) and, if you can, send the .fit file.

What changed from 1.0.0

Version 1.0.0 (Zenodo record 10.5281/zenodo.20673166; its two uploads of 13 June 2026 are labelled "(no version)" and "2.0" in Zenodo, but the live page cited that code as 1.0.0) had a FIT reader that stopped at the first data message of local type 0. Garmin devices write file_id there, so it returned zero records for Garmin's own test files. Results from 1.0.0 are not comparable with 2.0.0.

1.0.02.0.0
FIT readerstopped at byte 0x00; did not skip developer fields; read field 32 (vertical speed) as speed; no compressed-timestamp rollover; one byte order for the whole filerewritten; see validation below
Off-domain behaviourresults silently altered outside bikelabstudio.comremoved
VI30 samples, zero-power samples dropped30 seconds on the 1 s series, zeros included, pauses from the FIT timer events
VI bands"stable" threshold never usedfour bands, thresholds from a published table (below)
P(stable/warning/critical)divided by 500 even when fewer iterations were validdivided by the valid iterations; they sum to 1
Climbing indexmissing initial altitude became 0 m (false climb)back-filled with the first altitude
Long ridespage frozen during the Monte Carloruns in chunks of 20 iterations; same result

FIT reader: validation

The reader is compared field by field (timestamp, altitude, heart rate, cadence, distance, speed, power) and on the timer events against:

  • Garmin's decoder (@garmin/fitsdk 21.222.0, used only as a test oracle): 47 public files and 4 synthetic files, 218,537 records, 0 differences.
  • fitdecode (Python), for the 5 files the Garmin JavaScript SDK cannot read (it rejects compressed timestamps or throws): 9,627 records, 0 differences.
  • python-fitparse's expected CSV for compressed speed/distance (record field 8, 12-bit accumulator): 754 rows, 0 differences.

The public files come from the test suites of the Garmin FIT JavaScript SDK, python-fitparse, fitdecode, fit-parser and tormoder/fit. They are downloaded at test time from pinned commits and checked by SHA-256 (test/corpus.json); they are not redistributed. They cover files written by Garmin, Wahoo, Coros, Suunto, Stryd, Sigma, Zwift, Onelap and the Strava app. Not covered: Polar, Bryton, Hammerhead.

Supported: 12/14-byte headers, little- and big-endian definitions, developer fields (skipped), compressed timestamp headers, compressed speed/distance, enhanced_speed (73) and enhanced_altitude (78) with priority over 6 and 2, invalid values per base type, chained FIT files, and truncated files (records read before the damage are kept, as the Garmin SDK does).

Metrics

MetricDefinition (as implemented)
CV_cmean coefficient of variation of cadence in 30-sample windows (step 10), cadence 30–160 rpm, speed > 1 m/s
CV_Rcoefficient of variation of 60·v/cadence (metres per crank revolution), speed 2.5–20 m/s
IESon climbs (≥ 3 % over 50 samples, ≥ 30 samples long): mean of ½·CV(speed) + ½·CV(cadence)
VINP/AP. NP: 30 s rolling mean on the 1 s series, 4th power, mean, 4th root. AP over the same seconds, zeros included. Seconds without a sample take the last recorded value (smart recording). Pauses: FIT timer stop events; files without timer events use a 30 s gap
Pw:HR(mean P/HR first half − mean P/HR second half) / first half × 100

Monte Carlo: 500 iterations; speed ± 0.3 m/s and altitude ± 2 m (uniform), cadence dropout 5–15 % per sample, power ± 2 % (uniform). Output: median, 5th–95th percentile band and the share of iterations in each band.

Thresholds

  • VI: from the TrainingPeaks Help Center reference table, article 204071734 (page dated 24 Aug 2026, read 23 Nov 2026): very steady < 1.02 (steady/endurance ceiling); steady < 1.06 on road (flat road race ceiling) and < 1.13 on MTB (floor of the MTB/cyclocross race range); critical ≥ 1.35 on road (hilly road race / flat criterium ceiling) and ≥ 1.50 on MTB. Gravel is not in that table and uses the road values.
  • CV_c, CV_R, IES, Pw:HR: BikeLab heuristics with additive corrections by discipline, suspension, drivetrain and wheel size. They have not been validated against measured data. Treat their labels as a screening aid, not a diagnosis.

Known limits and differences with the white paper

The 1.0.0 white paper describes things this engine does not do: Normal (not uniform) power noise, dropout drawn once per iteration (here per sample), linear interpolation of gaps ≤ 2 s and segmentation at gaps > 3–5 s for the variance metrics. CV_c, CV_R and IES count samples, not seconds, so smart recording changes their windows. Duration is elapsed time, pauses included.

Run the checks

npm install
npm run corpus        # downloads the public test files (pinned commits, SHA-256)
npm test              # reader vs Garmin SDK, accumulator vs fitparse, VI vs textbook, engine vs golden.json
python -m pip install fitdecode==0.10.0
python test/compare_fitdecode.py
npm run check:page    # optional: engine identical to the live pages

FIT and Garmin

FIT is a protocol of Garmin International. This repository contains no Garmin code: the reader was written from the protocol and checked against Garmin's decoder, which is installed only as a development dependency under Garmin's own licence. BikeLab Studio is not affiliated with Garmin.

License and citation

PolyForm Noncommercial 1.0.0: free for any noncommercial purpose, including research, teaching and personal use. Commercial use needs written permission from the author.

Ravello Joo, C. E. (2026). BikeLab FIT Analyzer (Version 2.0.0) [Software]. Zenodo. https://doi.org/10.5281/zenodo.24485834

All versions: DOI 10.5281/zenodo.24485833.

Keywords
Badges
verifiers
Programming languages
  • JavaScript 81%
  • Python 19%
License
</>Source code
Software Heritage
Archived | swh:1:rev:f0cf8f435ea3030afdef07709e3199f0198001df

Contributors

Related projects

BikeLab Studio: verified cycling engineering

Cycling engineering calculators with published models, golden vectors and independent verifiers.

Updated right now