1. Introduction
The diagnostic content of an electrocardiogram lies in a few brief waveforms per heartbeat: the P wave, the QRS complex and the T wave. In a recording from a wearable device these sit among disturbances that overlap them in both time and frequency. Muscle noise is broadband. Electrode motion produces slow excursions and abrupt steps, and respiration and posture move the baseline. Linear filters with fixed passbands remove what lies outside the cardiac band and can do nothing about what lies inside it.
Wavelet shrinkage acts differently. The signal is expanded in a wavelet basis, small coefficients are suppressed and the remainder is transformed back. Because a QRS complex is represented by a few large coefficients while noise spreads thinly over all of them, thresholding can separate the two even where their spectra overlap. Donoho and Johnstone (1994) proved that a single threshold proportional to the noise standard deviation and to the square root of twice the logarithm of the sample count comes within a logarithmic factor of ideal performance, and Donoho (1995) analysed the soft-thresholding form. The result assumes white Gaussian noise of known level. Wearable recordings violate that assumption, and this note describes a rule adapted to them.
2. Why the Universal Threshold Falls Short
Three properties of ambulatory noise defeat the textbook rule. The noise is coloured: motion artefact concentrates at low frequencies and muscle noise at high ones, so its variance differs from one decomposition level to the next and a threshold fixed from the finest level is too small for the coarse levels. It is also non-stationary, rising when the wearer moves and falling at rest. And the universal threshold is conservative by design, which with soft thresholding shrinks every retained coefficient by the full threshold and so lowers the amplitude of the R wave. Since clinical measurements and beat detectors both depend on QRS amplitude and slope, that bias matters more here than in generic denoising.
The statistical literature supplies the remedies. Donoho and Johnstone (1995) showed that thresholds chosen level by level adapt to unknown smoothness, and the practice of estimating the noise scale from the median absolute deviation of the coefficients, divided by 0.6745, makes the estimate insensitive to the few large coefficients that carry signal (Donoho and Johnstone, 1994). Gao (1998) proposed the non-negative garrote as a shrinkage function that is continuous like soft thresholding yet approaches the identity for large coefficients like hard thresholding. The rule below assembles these with one element specific to the electrocardiogram.
3. The Proposed Rule
The rule has four parts and a closing step for the baseline, summarised in Table 1. Figure 1 shows how the treatment differs across the sub-bands of the decomposition.
| Part | What is done | Purpose | Cost |
|---|---|---|---|
| Transform | Decimated wavelet transform by integer lifting steps | Multiresolution analysis without floating point | A few additions and shifts |
| Noise scale | Median absolute deviation per level, per block | Follow coloured, time-varying noise | One small sort per level |
| Threshold | Level-wise universal threshold, relaxed around R peaks | Protect QRS amplitude and slope | One comparison |
| Shrinkage | Non-negative garrote function | Continuity with little bias on large coefficients | One division |
| Approximation | Attenuate the final approximation band | Remove baseline drift | One multiplication |

3.1. Transform
The discrete wavelet transform is computed by the pyramid algorithm of Mallat (1989), whose cost is proportional to the number of samples. On a microcontroller it is best realised by lifting. Daubechies and Sweldens (1998) showed that any finite wavelet filter pair factors into a sequence of simple prediction and update steps performed in place, and Calderbank et al. (1998) showed that rounding inside those steps yields transforms that map integers to integers and remain exactly invertible. A short biorthogonal wavelet with a smooth, symmetric analysis function is recommended, since symmetry avoids phase distortion of the waveform. The depth is chosen from the sampling rate so that the final approximation band lies below the lowest frequencies of clinical interest.
3.2. Noise scale and threshold
The recording is processed in blocks of a few seconds. Within each block and at each level j, the noise scale σj is the median absolute deviation of the detail coefficients divided by 0.6745, and the base threshold is σj multiplied by the square root of 2 ln nj, where nj is the number of coefficients at that level in the block. Estimating the scale afresh for each block lets the threshold rise during movement and fall at rest.
The element specific to the electrocardiogram is a relaxation of the threshold where the QRS complex is expected. Most QRS energy lies between roughly 5 and 15 Hz, the band on which the detector of Pan and Tompkins (1985) is built. A simple detector of that kind, run on the detail levels covering this band, marks the R peaks. In a short window around each mark, and only at the QRS-band levels, the threshold is multiplied by a factor below one. Elsewhere the full threshold applies. The coarser detail levels, where P and T waves reside, receive a lighter threshold throughout because those waves are low in amplitude and easily erased. The relaxation factor and window length are the two free parameters of the rule.
3.3. Shrinkage and baseline
Each detail coefficient d with threshold t is replaced by zero if its magnitude is below t and by d - t2/d otherwise, which is the garrote function of Gao (1998). The subtracted term decays as the coefficient grows, so the tall R-wave coefficients pass almost unaltered while coefficients near the threshold are shrunk smoothly, without the discontinuity that makes hard thresholding produce spurious oscillations. Baseline drift is handled at no extra cost by attenuating the final approximation coefficients before reconstruction, the wavelet equivalent of a high-pass filter.
4. Why the Rule Is Cheap
Efficiency follows from the structure and can be stated without measurement. The lifting transform and its inverse need a fixed, small number of integer additions and shifts per sample. Thresholding adds one comparison and, for retained coefficients only, one division. The median is the single operation that is not linear in block length when done by sorting, and it is needed once per level per block on arrays that halve in size at each level; a selection algorithm or a running histogram of the integer coefficients brings it to linear time as well. Memory is one block of samples, since lifting works in place. The decimated transform is not translation invariant, and the cycle-spinning remedy of Coifman and Donoho (1995) would multiply the cost by the number of shifts averaged. The rule leaves it out and relies on the garrote function to limit the artefacts that cycle spinning was designed to remove.
5. How the Rule Could Be Assessed
No recordings were processed for this note, and the rule should be regarded as untested. A fair assessment is nonetheless easy to specify, because the field has shared materials. The MIT-BIH Arrhythmia Database provides annotated two-channel recordings (Moody and Mark, 2001), and the noise stress test of Moody et al. (1984) supplies separate records of baseline wander, muscle artefact and electrode motion artefact that can be added to clean segments at chosen signal-to-noise ratios. With a known clean reference, the improvement in signal-to-noise ratio can be computed directly.
Waveform fidelity is not the only criterion. What the user of a wearable needs is that beats are still detected and that intervals and amplitudes are still measured correctly. An assessment should therefore also report the sensitivity and positive predictivity of a standard QRS detector before and after denoising, and the shift in wave boundaries found by a delineator such as that of Martínez et al. (2004). The rule should be compared with the universal soft threshold, with a level-dependent threshold lacking the R-peak relaxation, and with a conventional band-pass filter, so that the contribution of each part can be seen. Records added from noise databases remain an approximation to the artefacts of a specific device, and final judgement needs recordings from that device.
6. Conclusion
A thresholding rule suited to wearable electrocardiography can be put together from components that are individually well understood: integer lifting, level-wise robust noise estimation, a threshold relaxed around the R peak and garrote shrinkage. The combination respects the coloured, changing noise of ambulatory recording, guards the QRS complex against the amplitude loss of the universal rule and stays within the arithmetic budget of a small processor. Its two free parameters and its dependence on a preliminary R-peak detector are the points at which it may fail, and they are the first things an experimental study should examine.
Conflict of interest
To be declared by the author(s) before publication.
Funding
To be declared by the author(s) before publication.