Omar Chenine
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

  1. Crop to the plotting area.
  2. Estimate the grid spacing in pixels.
  3. Extract the darkest trace per column.
  4. Smooth and detect R peaks.
  5. Convert pixel distances to time and voltage using the stated calibration.
  6. Estimate rhythm, axis, PR, and QRS.
  7. 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.