Digital signal processing (DSP) converts analog signals from the body into digital data that can be analyzed by computers. In biomedical engineering, this is how raw physiological signals like ECGs and EEGs become useful clinical information. The core concepts here are sampling, quantization, frequency domain analysis, and aliasing prevention.
Analog Signal Digitization
Sampling and Sampling Frequency
Sampling is the first step in converting a continuous analog signal into something a computer can work with. You capture the signal's amplitude at regular time intervals, and each captured value becomes one "sample." The time between samples is the sampling period, and its reciprocal is the sampling frequency (or sampling rate), measured in Hertz (Hz).
The critical rule governing sampling is the Nyquist-Shannon sampling theorem: to accurately reconstruct a continuous signal from its samples, your sampling frequency must be at least twice the highest frequency component in the signal. That minimum rate is called the Nyquist rate.
For example, if an ECG signal contains frequency components up to 150 Hz, you need a sampling rate of at least 300 Hz. In practice, you'd sample even faster (often 500 Hz or 1000 Hz for ECG) to give yourself a safety margin.
When the sampling rate falls below the Nyquist rate, you get aliasing, where high-frequency components masquerade as lower frequencies in the digital signal. More on that below.
Quantization and Digital Representation
After sampling, each sample still has a continuous amplitude value. Quantization maps those continuous values to a finite set of discrete levels, typically represented as binary numbers. This is what makes the signal truly digital.
- The number of discrete levels depends on the bit depth. An -bit system provides quantization levels. So an 8-bit system has 256 levels, while a 16-bit system has 65,536.
- The gap between the original analog value and its nearest quantization level is called quantization error (or quantization noise). More bits means smaller gaps, which means less error.
- Dynamic range describes the ratio between the largest and smallest signal levels the system can represent, often expressed in decibels (dB). For an -bit system, the theoretical dynamic range is approximately dB. A 12-bit system, for instance, gives roughly 72 dB of dynamic range.
Higher bit depths give you finer amplitude resolution and lower quantization noise, but they also require more storage and processing power per sample.
Frequency Domain Analysis of Signals
Fourier Transform and Its Variants
Time-domain signals show you amplitude over time, but many biomedical features are easier to spot in the frequency domain, where you see which frequencies are present and how strong they are.
The Fourier transform decomposes a signal into a sum of sinusoids, each with a specific frequency, amplitude, and phase. There are several variants used in practice:
- Discrete Fourier Transform (DFT): The version that works on sampled (discrete-time) signals. It takes time-domain samples and produces frequency-domain values.
- Fast Fourier Transform (FFT): Not a different transform, but an efficient algorithm for computing the DFT. It reduces computational complexity from to , which matters a lot when processing long recordings.
- Short-Time Fourier Transform (STFT): Handles signals whose frequency content changes over time (non-stationary signals). It works by dividing the signal into short, overlapping segments and computing the Fourier transform of each segment, producing a time-frequency representation.
Applications in Biomedical Signal Analysis
The power spectrum shows how signal power is distributed across frequencies. You compute it by taking the magnitude squared of the Fourier transform. This is one of the most common analysis tools in biomedical DSP.
Specific applications include:
- EEG analysis: Spectral analysis reveals brain wave bands like delta (0.5โ4 Hz), theta (4โ8 Hz), alpha (8โ13 Hz), and beta (13โ30 Hz). Changes in the relative power of these bands can indicate sleep stages, seizure activity, or cognitive states.
- ECG analysis: Frequency content helps characterize the QRS complex and detect arrhythmias. Most ECG energy falls below 40 Hz, but the QRS complex contains components up to about 150 Hz.
- Time-frequency tracking: The STFT is particularly useful for studying transient events, like how the frequency content of an EEG shifts during the onset of a seizure.
Aliasing in Digital Signal Processing
Causes and Effects of Aliasing
Aliasing happens when you sample a signal too slowly. Frequency components above the Nyquist frequency (half the sampling rate) don't just disappear. They "fold" back into the lower frequency range and appear as false low-frequency components.
Here's a concrete example: suppose you sample at 100 Hz, giving a Nyquist frequency of 50 Hz. A 70 Hz component in the original signal will appear as a 30 Hz component in the sampled data (it folds around the 50 Hz boundary: Hz). There's no way to tell it apart from a real 30 Hz signal after sampling.
Aliasing can also occur during downsampling, when you reduce the sampling rate of an already-digital signal. If you don't filter out frequencies above the new Nyquist frequency first, the same folding effect distorts your data.
Prevention and Mitigation Techniques
Preventing aliasing requires action before sampling occurs:
- Apply an anti-aliasing filter. This is a low-pass filter placed before the analog-to-digital converter. It attenuates frequency components above the Nyquist frequency so they can't fold back into the signal.
- Choose an adequate sampling rate. The rate must be at least twice the highest frequency of interest. In biomedical applications, you typically sample well above the Nyquist rate to account for filter roll-off and to preserve signal quality.
- Use decimation filters when downsampling. If you need to reduce the sampling rate of a digital signal, apply a low-pass filter to remove frequencies above the new Nyquist frequency before discarding samples.
In biomedical contexts, aliasing is especially dangerous because it can create artifacts that mimic real physiological features, potentially leading to misdiagnosis. Proper anti-aliasing is not optional.
Digital Signal Processing Implementation
Programming Languages and Software Tools
DSP algorithms are commonly implemented in:
- MATLAB: Its Signal Processing Toolbox provides functions for filtering, spectral analysis, and filter design. Widely used in research and prototyping.
- Python: The SciPy and NumPy libraries offer similar capabilities. Python is free and increasingly common in both academic and clinical settings.
- C/C++: Used when real-time performance or embedded system deployment is required, such as in portable patient monitors.
When choosing an implementation approach, consider computational efficiency, numerical stability, and whether real-time processing is needed. A bedside monitor processing ECG in real time has very different constraints than an offline research analysis of archived EEG data.
Basic DSP Algorithms and Techniques
Filtering is the most common DSP operation in biomedical applications. Filters are classified by what frequencies they pass:
- Low-pass: passes frequencies below a cutoff
- High-pass: passes frequencies above a cutoff
- Band-pass: passes a specific frequency range
- Band-stop (notch): removes a specific frequency range (commonly used to remove 50/60 Hz power line interference)
These filters are implemented as either FIR (finite impulse response) or IIR (infinite impulse response) structures. FIR filters are inherently stable and can have perfectly linear phase, but they require more computation. IIR filters are more efficient but can be unstable if not designed carefully.
Convolution is the fundamental operation for applying filters to signals in LTI (linear time-invariant) systems. For long signals, FFT-based convolution is much faster than direct computation.
Resampling techniques change the sampling rate of a digital signal. Interpolation increases the rate; decimation decreases it. Both require appropriate filtering to avoid introducing artifacts.
Spectral estimation methods estimate the power spectrum from sampled data:
- The periodogram is the simplest approach but has high variance (noisy estimates).
- Welch's method improves on this by averaging periodograms of overlapping signal segments, producing smoother spectral estimates.
Window functions (Hamming, Hanning, Blackman) are applied to signal segments before computing the FFT. Without windowing, the abrupt edges of a finite signal segment cause spectral leakage, where energy from one frequency smears into neighboring frequency bins. Different windows trade off between frequency resolution and leakage suppression.