All writing
ECGSignalsHealthcare
ECG digitization: the grid is not the signal
2 min read
The problem
An ECG image contains a waveform, a grid, labels, and often a lot of white space. The waveform is the signal. The grid is the ruler. If you do not calibrate the ruler, the axis and intervals are guesses.
The pipeline
- Crop to the plotting area.
- Estimate the grid spacing in pixels.
- Extract the darkest trace per column.
- Smooth and detect R peaks.
- Convert pixel distances to time and voltage using the stated calibration.
- Estimate rhythm, axis, PR, and QRS.
- Flag low quality traces for review.
The failure
The first version treated every image as if it had the same scale. It produced beautiful reports with wrong intervals. The fix was to surface the calibration assumption in the UI and refuse to print a number when the grid could not be found.
What the review flag is for
The flag is not a disclaimer at the bottom of the page. It is a branch in the product. A low confidence trace goes to a person, not to a confident report.
Lesson
In signal work, the scale is part of the model. Document it, display it, and test it.