# Find the Period, Then the Events

Class 17, Chapter 9: Gait and Cyclic Sports. 25 slides, about 33.5 minutes.

## 1. Title

Slide up while people sit down; homework seventeen is due now. Last week we learned what a pose model gives us and how far to trust it. This week we use it on the movements that repeat: running, walking, pedaling. Today's question is the one coaches ask most about running.

## 2. It repeats, so average it  (1.5 min)

Running, walking, pedaling and swimming share one property that makes them easier to measure than a jump or a throw: they repeat. A runner at a steady pace takes the same step hundreds of times, and fifteen seconds of video holds about forty of them. One noisy step is hard to read; forty averaged are not. The price is a new first job. Before you can measure a step, you must find where each step begins and ends. A period is the time one repetition takes. Events are the instants inside it: the foot touching down. Knee angle is read at contact, contact time runs from contact to toe-off. Move the event and you move every number.

## 3. Running, seen through one keypoint  (2.5 min)

Here is our running example: a runner on a treadmill, filmed from behind at thirty frames a second, with only the two ankles kept from the pose model. The trace is clean: a person in all four hundred and sixty four frames. Image y grows downward, so the plot turns the axis over, and down on the page is down in the world. [Trace one foot with your hand.] The foot drops to the belt, stays there a moment, lifts, swings and drops again. The two feet take turns. That is the whole of running, seen through one keypoint. The dots are the contacts a program found. Our job today is to teach a program to find them.

## 4. Period first: autocorrelation  (2 min)

A tempting first program looks for every low point of the ankle and calls it a contact. On real data it fails, because a noisy trace has many small dips, and a doubled dip counts one step twice. The fix is to ask a different question first: how long is one cycle? Then you can tell the detector that two contacts of the same foot cannot be closer than about six tenths of a period. The tool is the autocorrelation: slide a copy of the trace along itself and see at which shift the two line up best. For a repeating signal, after zero, the best match is one period. Search only plausible strides, so half a stride never wins.

## 5. Listing 9.2: period, then events  (2.5 min)

This is the heart of Listing 9.2. Remove the mean, correlate the trace with itself, and take the best lag between zero point four and one point five seconds: twenty one frames, zero point seven seconds. Then, on each foot, accept low points that are in the bottom part of the range and at least six tenths of a period apart. Merge the two feet into one list of steps. Look at the output. Twenty two contacts on each foot. Then two answers for the same runner: the median step gives a hundred and sixty four steps a minute, and the count over the whole span gives a hundred and sixty nine. [Pause.] Which one would you report? Hold that thought.

## 6. Why do 164 and 169 differ?  (1.5 min)

[Thirty seconds, then hands.] The answer is A. At thirty frames a second a step can only last a whole number of frames. Ten frames is a hundred and eighty steps a minute; eleven is a hundred and sixty four. This runner's true step lies between, so the measured steps alternate between ten and eleven, and the median picks one of them. Counting forty three steps over fifteen point two three seconds uses every event, and the rounding at the two ends is spread over the whole span. Here is the rule to keep: a median of rounded intervals is still rounded. Estimate a rate from the span of many events.

## 7. One method, four sports  (1.5 min)

The rest of the chapter reuses this pattern. Walking, pedaling and swimming each need a different signal, but every detector does the same three things. Build a one-number-per-frame trace in which the event is an extreme. Learn the period, or a minimum spacing. Then accept extremes that are both large enough and far enough apart. Look at the last column: each sport also hands you a reference for free. A metronome, a taped distance, the bicycle's crank, the pool's clock and lane marks. We will use every one of them to check the video.

## 8. Five measures, four without a scale  (2.5 min)

With contacts and toe-offs found, five numbers follow. Cadence is steps per minute. Contact time is how long one foot is on the ground. Flight time is how long both are off. The duty factor is the share of the stride a foot spends on the ground; and note the denominator is the stride, two steps, not one. Step length needs a speed, and so a scale or a treadmill. The first four need none. On the right, the words. A stride is same foot to same foot; a step is one foot to the other. In running, the stance leg compresses like a spring and recoils, and between stances both feet are off the ground.

## 9. Duty factor by hand  (2 min)

[Everyone writes two numbers. Give them a minute.] Contacts three hundred and forty five thousandths of a second apart, each contact a quarter of a second, a stride zero point seven. [Click.] Cadence: sixty over zero point three four five, a hundred and seventy four steps a minute. Duty factor: zero point two five over zero point seven, thirty six percent. Who got seventy one? [Hands.] That is what you get if you divide by a step instead of a stride. It is the commonest slip with this measure, and there is a free check: running at ordinary speeds is well under fifty percent. Over fifty means the stances overlap. That is walking, or a bug.

## 10. Check it with a tape and a stopwatch  (2 min)

Here is a check that needs no camera at all. Tape two lines twenty metres apart, with room to reach pace before the first. A runner crosses in six point six seconds and a partner counts eighteen steps. Speed three point zero three, step length one point one one, cadence a hundred and sixty three point six. The step-length formula must agree, and it does, because all three come from the same count and time. That is the point. If the app's step length for the same run is one point three while its cadence matches, the app's error is in its speed, which means in its scale. You will do exactly this in the field exercise this week.

## 11. How the running app finds a contact  (1.5 min)

The running app works on foot height: the heel if the model has one, otherwise the ankle, since the seventeen-keypoint models have no heel. It takes a contact candidate at any low point in the bottom fifteen percent of the foot's range, at least a fifth of a second after the last one. Then it grows each candidate while the foot stays in the bottom thirty percent. Percentiles rather than pixels make the rule work at any camera distance. Run the simplified version on our example and you get a contact of six frames, a duty factor of twenty nine percent. One frame more or less is almost five points. Treat it as a number to check, not a finding.

## 12. The shape measures a coach asks about  (2 min)

Coaches talk about shape more than timing: overstriding, sitting back, landing on a straight knee, bouncing, dropping a hip. Each is a real mechanical property, and each is partly visible to one camera. Overstride is the horizontal distance from the hip to the foot at contact. The app gives it in centimetres and as a percent of leg length; the percent divides out the scale, so track that one. Trunk lean is measured from image vertical, which is world vertical only if the camera is level. Knee angle at contact. Vertical oscillation of the hips, which needs the scale. And hip drop, from behind. Now the important question: what does each one matter for?

## 13. How strong is the evidence?  (3 min)

Read the last column first. Cadence is the best studied form variable you can change: raising step rate five to ten percent reliably lowers knee loading in the lab. Evidence that it changes injury is one case series of twelve runners, with no control group. Overstride, the measure coaches ask about most, has the least direct evidence. Hip drop separated injured from healthy runners, but in a comparison at one time, which cannot tell cause from consequence. The strongest trial retrained runners to land softly, measured with instruments, not video: sixteen percent injured against thirty eight. Even a real group difference does not predict one runner. These numbers are training information, not a diagnosis.

## 14. Back to the question: the runner or the camera?  (2 min)

So, back to today's question. Is the runner overstriding, or is the camera making it look that way? Overstride is a horizontal distance between two dots, measured in the picture. If the camera is not square, horizontal distances along the line of sight shrink. If the runner moves toward or away from the camera, the scale changes during the clip. Filmed from in front and to one side, a foot can look far ahead of the hip when it is not, or the reverse. The checks are simple: film square, from far back, use the percent of leg length, and film again on another day. If the number moves more between days than it differs from the target, you cannot answer the question with this setup.

## 15. Sprinting is a different movement  (1.5 min)

A sprinter is not a distance runner going faster. In a study of thirty three runners with top speeds from six to eleven metres a second, the faster ones did not reposition their legs faster. The swing took about the same time for all of them. They went faster by pushing harder on the ground in a shorter contact. So a distance band applied to a sprinter marks good sprinting as a fault. The running app has a separate sprint mode, which you choose; it does not detect sprinting by itself. And note the frame budget: at thirty frames a second, a hundred-millisecond contact is three frames. Sprint contact times need slow motion and the right rate setting.

## 16. Walking has double support, not flight  (2 min)

Walking is not slow running. Each foot is down for about sixty percent of the cycle, so twice a cycle both feet are down: double support. There is no flight. That breaks the running detector, so the walking app turns the order around: it tracks how far each ankle is ahead of the hip, which peaks once a cycle, near heel strike, and sets stance bounds as a share of the cycle the walker actually produced. Two formulas. Double support: the two stances add up to more than a stride by exactly the time both feet are down. And speed. Walking speed is a well-studied health marker in older adults, with a stopwatch and a tape. A video estimate has to earn that.

## 17. Cycling: crank phase without seeing the crank  (2 min)

Cycling turns the problem inside out. The foot never leaves the pedal, and the crank is often hidden. So the app gets the crank's phase from the rider. Take the distance from the hip to the ankle. The hip barely moves on the saddle; the ankle goes round with the pedal. The law of cosines gives this curve: exactly one maximum and one minimum per revolution, whatever the rider or the camera, and a swing of about thirty five centimetres, large compared with keypoint noise. Count frames between maxima and you have cadence: forty frames at sixty is ninety revolutions a minute. And the bicycle is a ruler: raise the saddle a measured amount and predict the knee change.

## 18. Before Class 18  (1.5 min)

Homework eighteen is due at the start of Thursday's class. Tape twenty metres with run-ins at each end, put the phone square to the middle, and run once at your own easy pace. Then set a metronome to your natural cadence, five percent above and ten percent above, in random order, at the same pace. For each run, count the steps, time the twenty metres, and read the app's cadence, contact time and overstride. Then the question: what changed, and was the change bigger than the run-to-run spread? Easy pace only, and skip it if you are injured; there is a case-file path. Read the rest of Chapter 9 for Thursday.
