Signal processing

Teaching the software to see a stroke

Segmenting a swim into individual stroke cycles sounds simple until you try it on more than one stroke. Breaststroke has an obvious glide where the velocity nearly drops to zero — easy boundaries. Freestyle and the others have continuous, overlapping propulsion and no dead spot to anchor on. Nothing I reached for worked.

FFTs and spectral analysis let me down. I started wondering if it was time for machine learning — which would mean hand-labeling a pile of data, something I really didn't want to do.

An elegant idea that didn't generalize

Then my mentor pointed me at the matrix profile, a modern approach to time-series data mining. At its core it just computes Euclidean distance between subsequences, over and over — beautifully simple. I was hopeful. But it didn't generalize: the motifs locked onto a couple of cycles and refused to recognize the rest, and adding more motifs didn't rescue it. That was a genuinely disappointing week.

Wavelets — and an accident

So I tried wavelet analysis, and it worked. It surfaces bands of concentrated frequency — exactly the structure I needed — and, to my relief, it generalized across the other strokes too. Then I noticed it was finding multiple frequency bands at once. I assumed that was an artifact, looked closer, and realized it was separating the kick from the pull as distinct rhythms in the same swim. I wasn't looking for that. It might end up being one of the most useful things the device sees.

A fair caveat: outside breaststroke, this segmentation is still early and experimental, and the app says so plainly rather than pretending otherwise. But the direction is right, and that's the part that had been missing.

← Back to the build log