4  Sampling and Quantization

To handle an analog signal on a computer, it must be taken at discrete points in time (sampling) and its amplitude represented in a finite number of steps (quantization). Both are operations that lose information, and what is lost cannot be recovered later.

4.1 The sampling theorem

If the highest frequency contained in a continuous signal is f_{\max}, then as long as the sampling frequency f_s satisfies

f_s > 2 f_{\max}

the original continuous signal can be perfectly reconstructed (the Nyquist–Shannon sampling theorem). f_s / 2 is called the Nyquist frequency.

4.2 Aliasing

When components above the Nyquist frequency are sampled, they appear disguised as spurious lower-frequency components. This is called aliasing. A component at frequency f is folded back to the following frequency.

f_{\mathrm{alias}} = \left| f - k f_s \right| \quad (k\ \text{is the integer such that}\ f_{\mathrm{alias}} \le f_s/2)

Gray: original continuous signal; blue: sample points; red dashed: the spurious signal seen from the sample points

TipTry it
  1. With a 9 Hz signal and 10 Hz sampling, what frequency does it appear to be?
  2. What if the signal is 50 Hz (mains noise) and sampling is 60 Hz? The mains noise appears as a spurious 10 Hz component in the same band as the QRS
  3. What happens if the signal and sampling frequencies are the same?

4.2.1 Anti-aliasing filter

Once aliasing has occurred, spurious and genuine components cannot be distinguished. Therefore, components above the Nyquist frequency must be removed by an analog low-pass filter before A/D conversion. This is called an anti-aliasing filter.

ImportantKey points
  • Aliasing cannot be removed by a digital filter after sampling
  • Real filters cannot cut off sharply, so the sampling frequency is set not just barely at twice the highest signal frequency but high with a margin (several to about 10 times)
  • Many modern A/D converters use an oversampling scheme (such as ΔΣ), sampling at a very high frequency, band-limiting digitally, and then decimating

4.3 Typical sampling frequencies for biosignals

Signal Main frequency content Typical sampling frequency
ECG (diagnostic) 0.05–150 Hz 500 Hz or higher
ECG (HRV analysis) R-wave timing accuracy is important 250–500 Hz or higher (interpolate the peak if lower)
ECG (heart-rate monitor) 0.5–40 Hz 125–250 Hz
PPG (heart rate) about 0.5–5 Hz 25–100 Hz
PPG (PRV analysis) Beat timing accuracy is important 100–500 Hz or higher
Electromyogram (surface) 20–500 Hz 1000–2000 Hz
Electroencephalogram 0.5–100 Hz 250–1000 Hz
Note“Frequency content” and “timing accuracy” are different matters

A high sampling frequency is needed for HRV analysis not because the R wave has high frequency content, but because we want to determine beat timing (the position of the R-wave peak) to the ms. With a sampling period of 4 ms (250 Hz), the timing error is up to about ±2 ms. Interpolating around the peak with a parabola lets you estimate the timing with finer precision than the sampling period.

4.4 Quantization

An A/D converter divides the input voltage range (full scale) into 2^N steps (N: number of bits) and converts it into a number. The width of one step is called the LSB (least significant bit).

\mathrm{LSB} = \frac{\text{full scale}}{2^N}

The quantization error is at most ±0.5 LSB, and the signal-to-quantization-noise ratio of an ideal A/D converter for a full-scale sine wave is:

\mathrm{SNR} \approx 6.02 N + 1.76\ [\mathrm{dB}]

TipTry it
  • With an input range of ±5 mV, how many bits are needed to see the shape of the P and T waves?
  • With an input range of ±300 mV (a design that measures including the electrode DC offset), how many bits are needed for the same appearance? Think about why recent ECG ICs use 24-bit ΔΣ A/D converters and adopt designs that measure including DC

4.5 Summary

  • Sampling theorem: f_s > 2 f_{\max}. Components above the Nyquist frequency become spurious low-frequency components through aliasing
  • Aliasing cannot be removed afterwards → anti-aliasing filter before A/D conversion
  • In HRV analysis, the sampling frequency is determined not only by frequency content but also by beat timing accuracy
  • The fineness of quantization is input range / 2^N. Designs with a wide input range need more bits