apopt.comCBE 493R Data-Driven Athletics

Course / Tutorials / Week 9 / Q-25

Quick tutorial Q-25 · Week 9 · about 15 min · Foundation

Find foot contacts in an ankle trace

Find each foot contact in a treadmill runner's ankle trace, first the naive way, then with the running app's three guards.

  1. 1Gather
  2. 2Statistics
  3. 3Visualize (used)
  4. 4Cleanse (used)
  5. 5Features (used)
  6. 6Balance
  7. 7Scale
  8. 8Split
  9. 9Deploy
  1. Ask
  2. Collect
  3. Check (this week)
  4. Interpret (this week)
  5. Coach
  6. Reassess

Every cell runs in this page; the first run downloads Python (about 30 s). Nothing you load leaves your browser. Helpful first: Q-24 Seventeen keypoints for one frame, as a table.

The decision

Every timing measure of running, cadence, contact time and flight time, starts from a list of foot contacts. Is the list right: one contact per foot plant, none doubled, none missed?

The raw data

Try it

Chapter 9's running example is a runner on a treadmill, filmed from behind at 30 frames per second for 15.5 s. A pose model found both ankles in every frame, and the table keeps their image position and confidence. A foot on the belt is at its lowest point in the picture, which in image coordinates is its largest y. So a contact is a peak of y.

PythonOpen the ankle table and count the obvious way

Type a prediction to enable Run.

Show the expected result without running
(464, 8) 15.5 s; median ankle confidence 0.99
left ankle, every local peak: 107 'contacts'

A runner at 170 steps a minute makes 85 contacts a minute on each foot, about 22 in 15.5 s. Every local peak gives 107, five times too many: a noisy trace has small bumps, and each bump is a peak. The running app adds three guards (checked in its source, form/src/lib/metrics.ts): smooth the trace over about 0.08 s (3 frames at 30 per second); accept only peaks in the bottom 15% of the foot's range, above the 85th percentile of y; and keep peaks at least 0.2 s apart.

PythonThe app's three guards

Show the expected result without running
l: 22 contacts; same-foot interval median 0.700 s, range 0.667 to 0.733 s
r: 22 contacts; same-foot interval median 0.700 s, range 0.667 to 0.733 s
PythonThe trace with its contacts

Show the expected result without runningLeft and right ankle image height for the first four seconds, axis turned over so the belt is at the bottom, with each detected contact marked at the lowest point of each stance.

With the guards, each foot gives 22 contacts, one per stride, and the same-foot interval stays between about 0.67 and 0.73 s, 20 to 22 frames. That narrow range is the check that no contact was doubled or missed: a doubled contact would show as an interval near half a stride, a missed one as an interval near a whole extra stride. Notice that the intervals can only be whole frames, 33 ms apart; Q-26 shows what that does to a cadence.

For the athlete: a phone can find every foot contact in a steady run, as long as the whole foot stays in the frame.

With your own data

Build the same two-ankle table from your own clip (Chapter 9's first listing, or CS-10's local cells) and run this page on it. Film 15 s or more of steady running with the feet always in the frame.

Check yourself

  1. Why is a foot contact a peak of image y, not a dip?

  2. The guards keep peaks at least 0.2 s apart. At 30 frames per second, how many frames is that?

    frames

0 of 2 answered · 0 right the first time

The same method in another field

Finding events in a repeating signal with a level and a minimum spacing is how heartbeats are found in an ECG (Q-13) and how cycles are counted in a machine's vibration record.

Acknowledgements

Ankle table from Chapter 9 of Data-Driven Athletics, made with Ultralytics YOLO26 (AGPL-3.0).

References

Built 2026-11-30 with Python packages numpy 2.5.5, pandas 3.1.1, matplotlib 3.11.2, scipy 1.18.1. In the browser the same code runs on Pyodide, so the last digit can differ.