EEG Signal Processing

Reference: Chapter 7 of Bioelectrical Signal Processing in Cardiac and Neurological Applications (Biomedical Engineering) by Leif Sörnmo and Pablo Laguna

1. Overview

The outcome of the ECG interpretable depends significantly on the quality of the measurements. Therefore, signal processing is a crucial step in the ECG analysis pipeline. The signal processing pipeline is shown in the following figure, but the actual implementation depends on the specific use case.

block diagram

The gray arrows indicate that the output of QRS detection is sometimes used to improve the preformance of noise filtering and data compression.

There is no one-size-fits-all filter

It's crucial to use filtering methods that preserve the important information you're trying to extract from the ECG. For example, a filter designed to remove electrical noise, like powerline interference, might be suitable in a system analyzing heart rate variability. However, using that same filter would be a bad idea in a system focusing on "late potentials."

So, what are late potentials? In the context of an ECG, late potentials are very low amplitude signals that occur right after the main ECG waveforms. They can be indicators of certain heart conditions, but they are often close in frequency to the electrical noise you might want to remove. Therefore, if you use a filter that's too aggressive in removing powerline interference, you might accidentally remove these important late potentials as well, missing out on crucial information.

Reviewing ECG Waveforms

ECG_waveform

ECG Component Physiological Phenomenon Typical Morphology Potential Meaning of Distortion
P Wave Atrial contraction (depolarization) Small, rounded, and upright Atrial fibrillation, atrial flutter, or other atrial issues
PR Interval Time from atrial to ventricular depolarization Flat line PR interval prolongation could indicate heart block
QRS Complex
Q Wave Initial negative deflection; part of ventricular depolarization Small downward deflection Pathologic Q waves can indicate past myocardial infarction
R Wave Main upward deflection; ventricular depolarization Tall upward spike Tall R waves may suggest ventricular hypertrophy
S Wave Downward deflection post R-wave; part of ventricular depolarization Downward deflection after R wave Deep S wave may indicate certain types of heart disease or electrical abnormalities
-
ST Segment Ventricular depolarization complete; repolarization starts Flat line Elevation may indicate myocardial infarction; depression may suggest ischemia
T Wave Ventricular repolarization (resetting) Rounded, usually upright Flattening or inversion may indicate ischemia, electrolyte imbalance
QT Interval Complete cycle of ventricular depolarization and repolarization From start of Q to end of T Long QT may indicate electrolyte imbalance, medication effects, or genetic disorders
U Wave Late ventricular repolarization (not always seen) Small, rounded, and upright Presence may indicate electrolyte imbalance or bradycardia

Remember, any distortion or abnormality in these components should be assessed in the full clinical context, often requiring additional tests or imaging studies for accurate diagnosis.

QRS and Filter Linearity

In an ECG, the QRS complex is a crucial part of the waveform that represents the electrical activity associated with the contraction of the heart's ventricles. Because it's a high-amplitude, spike-like feature, it acts like a sudden burst of energy (or "impulse") to the filter.

In Linear Time-Invariant (LTI) filters, these sudden bursts are problematic because LTI filters are sensitive to such impulses. They can produce an exaggerated or distorted output in response to these bursts, which could mislead analysis or diagnoses. In other words, the presence of the QRS complexes can throw off the filter's performance, making it less effective in preserving the integrity of other important aspects of the ECG signal.

Nonlinear filters are often more suitable for handling such scenarios. Unlike their linear counterparts, nonlinear filters can adapt more flexibly to different input conditions. For example, filters like the Median filter can be particularly effective at preserving important signal features while still removing noise. The idea here is that a nonlinear filter can differentiate better between what is considered noise and what is an essential part of the ECG waveform.

To make sure a chosen filter is doing its job without messing up the critical data, it's better to test it using simulated signals. By doing this, you can precisely quantify any distortions the filter might introduce, ensuring that it's fit for purpose.

QRS Detection Considerations: False Alarms and P Waves

Different types of errors that can occur when detecting the QRS complexes in an ECG signal. Missing a beat, or having an undetected QRS complex, is considered a more severe error than falsely detecting one that isn't actually there. Why? Well, if a beat goes undetected, correcting that mistake later in the processing chain can be challenging. On the other hand, false detections can potentially be corrected later by other algorithms that further analyze the QRS shape, essentially weeding out the mistakes.

T wave, which represents ventricular repolarization (or the 'resetting' of the ventricles), can be analyzed once the QRS is identified. This is because the T wave always follows the QRS complex, so its position is predictable.

In contrast, the P wave, which represents atrial contraction, isn't as straightforward to analyze. Atrial and ventricular rhythms can be independent, making it harder to predict the P wave based on the QRS complex. However, in most cases, these rhythms are related, so one could theoretically find the P wave by looking backward in time starting from the QRS complex. The reliability of detecting the P wave is heavily influenced by how noisy the ECG signal is. If the signal is too noisy, then reliable P wave detection, and by extension comprehensive rhythm interpretation, becomes challenging.


2. Baseline Wander Removal

Baseline wander in ECGs can distort the signal and interfere with the diagnosis of cardiac conditions like ischemia. It's especially critical when analyzing subtle changes in the ST-T segment. Baseline wander usually has a frequency below 0.5 Hz but can increase due to body movement during stress tests. Two primary methods to remove baseline wander are linear filtering and polynomial fitting.

2.1 Linear Time-Invariant Filtering

In linear, time-invariant filtering for ECG baseline wander removal, the cut-off frequency and phase response are crucial. A cut-off frequency around 0.5 Hz is generally used, especially in cases of slow heart rates like bradycardia. This ensures clinical information is preserved while baseline wander is minimized. Linear phase filtering is also favored as it maintains key ECG features such as the QRS complex and ST-T segment.

Filter design becomes a specialized narrowband filtering task, demanding careful balancing of cut-off frequency and sampling rate to prevent distortion. FIR filters are often employed because they can offer a linear phase response. However, achieving adequate stopband attenuation usually necessitates a filter with a large order, leading to computational complexity. For example, using a Hamming window, a filter with an order of around 1150 is required to get at least 20 dB stopband attenuation.

Despite the computational demand, reducing the filter order substantially compromises the filter's effectiveness. Advanced filter design techniques may shorten the filter but do not significantly reduce complexity.

Several methods exist to manage this complexity while keeping the linear phase property. These include:

  • Forward-backward IIR filtering
  • Inserting zeros into an FIR filter
  • Sampling rate iteration

Thethree techniques are described in the following subsections.

Forward-Backward Filtering

Forward-backward IIR filtering is an alternative approach to FIR filtering, addressing some of its computational challenges. IIR filters can meet the magnitude specifications with a much lower filter order, but this comes at the cost of having a nonlinear phase response. Forward-backward filtering solves this by applying the IIR filter twice—once forward and once in reverse—resulting in a zero-phase transfer function.

The process involves three steps:

  1. Filter the input signal with the IIR filter.
  2. Reverse the output in time.
  3. Apply the IIR filter again to this reversed output and finally reverse it back.

This results in a filter with the same magnitude function but a zero-phase function, despite the original IIR filter's nonlinear phase response. The overall filter order becomes twice that of the original IIR filter.

forward_backward

In terms of computational efficiency, forward-backward IIR filtering significantly reduces the number of required multiplications compared to traditional FIR filtering. However, it's primarily suitable for off-line processing because it doesn't meet real-time causality requirements (since we need to wait until the end of the signal to reverse it). It can be adapted for "almost" real-time use with some creative workarounds, like processing in overlapping segments and carefully selecting initial conditions.

There are limitations, though:

  1. It's less stable at higher sampling rates (above 1000 Hz), as the filter's poles may approach or exceed the unit circle.
  2. It doesn't easily accommodate time-variant filtering, where the cut-off frequency varies over time.

Insertion of Zeros

Zero insertion is a method used to simplify filter complexity. The idea is to insert zeros in between every sample in an existing FIR filter designed for a lower sampling rate. Mathematically, this results in a D-fold repetition of the filter's transfer function.

zero insertion

In terms of its application, the technique not only filters out the desired baseline wander but also attenuates signal frequencies at multiples of the original lower sampling rate. These filters start to resemble comb filters as more zeros are inserted. The comb-like frequency response can be useful for removing other kinds of interference, such as powerline noise, provided the frequency of such interference fits the constraints set by the ratio of the final sampling rate to the number of inserted zeros (D).

However, there's a cautionary note: this approach can significantly distort essential diagnostic information, such as the QRS complex, due to its multiple stop-band filtering. Therefore, while it is a cost-effective method, care must be taken when employing zero insertion for medical applications like ECG.

Sampling Rate Iteration

Sampling rate iteration is another technique to simplify filter design in ECG signal processing. This method involves two key steps:

  1. Decimation: The original ECG signal is first reduced to a lower sampling rate better suited for filtering out baseline wander. Before decimation, the signal is band-limited using a linear-phase lowpass filter to avoid aliasing. Interestingly, the demands on this pre-filter are relatively relaxed, allowing for the use of low-order FIR filters.

  2. Interpolation: After filtering at the lower sampling rate, the signal is then interpolated back to its original rate. The same lowpass filter used in the decimation step can also be employed for interpolation, although an additional gain factor may be needed.

In this approach, the highpass filter traditionally used for removing baseline wander is replaced by a lowpass filter. The lowpass filter is used at the lower sampling rate to produce an estimate of the baseline wander. This estimate is then interpolated back to the original sampling rate and subtracted from the original signal, effectively highpass filtering the original ECG signal.

decimate_interpolate

From a computational standpoint, this method has advantages. The lowpass filter used for decimation only needs to produce output at specific intervals, reducing the number of required calculations. Additionally, the interpolation step is also simplified as most filtering multiplications become unnecessary due to the insertion of zeros between samples.

2.2 Adaptive Filtering for ECG Signals

Limitations of Fixed Cut-Off Frequency

Traditional methods of ECG filtering rely on a fixed cut-off frequency determined by the lowest heart rate. While effective to some extent, these filters fall short in removing baseline wander during varying conditions such as stress tests.

Adapting to Real-time Heart Rate

A more dynamic approach is to adjust the cut-off frequency based on the current heart rate, which can be assessed using the instantaneous RR interval, . The RR interval is the time between two successive heartbeats and is calculated as .

Calculating the Variable Cut-Off Frequency

The cut-off frequency is made inversely proportional to , i.e., . This allows the filter to adapt in real-time to changes in heart rate. A time-varying impulse response is derived for each cut-off frequency, and a low-pass filter is designed accordingly.

Practical Considerations

An upper limit is set for to avoid distorting the ECG signal during extremely short RR intervals. Instead of creating multiple filters for different cut-off frequencies, a prototype low-pass filter can be transformed to suit the variable frequencies.

Types of Filtering Techniques

This concept was initially designed for offline ECG processing but later adapted for real-time use. Adaptive Least Mean Squares (LMS) techniques are also employed for more advanced filtering options.

Performance Comparison

In scenarios where heart rate changes rapidly (e.g., 120 beats/minute), adaptive filtering outperforms fixed cut-off filters in removing baseline wander from ECG signals.

2.3 Baseline Correction Using Polynomial Fitting

Introduction to Polynomial Fitting

Polynomial fitting offers an alternative to linear filtering techniques for baseline wander removal in ECG signals. This method uses "knots" from the ECG, typically from the PQ interval, to fit a polynomial that estimates the baseline.

Knot Selection and Fitting

A knot is selected for each heartbeat, specifically from the "silent" isoelectric line best represented by the PQ interval. The polynomial then smoothly passes through these knots to estimate the baseline. Unlike linear filtering, this approach requires detecting QRS complexes and accurately determining the corresponding PQ intervals.

polynomial_fitting

Polynomial Orders

Using a first-order polynomial simply connects successive knots with straight lines but results in poor tracking of variations. Higher-order polynomials, particularly cubic splines, yield more accurate estimates but at the cost of computational complexity.

The Cubic Spline Technique

The cubic spline technique is popular and based on Taylor series expansion. It starts with a continuous-time framework that's easily discretized. The baseline estimate is computed within each interval and then subtracted from the ECG signal at discrete samples .

Computational Efficiency

Efficient computation of the baseline estimate is possible through recursion, significantly lowering the computational burden.

Performance Considerations

The technique is highly dependent on accurate knot determination. While straightforward in restful conditions, finding the PQ interval can be challenging in noisy conditions or during certain arrhythmias like ventricular tachycardia.

Variable Cut-off Frequency

Cubic spline fitting results in a time-variable cut-off frequency, making it effective in tracking rapid baseline wander during fast heart rates. This is because more knots become available as the heart rate increases.

Limitations

Polynomial fitting struggles when knots are far apart. Some strategies to address this include defining additional knots based on the zero-crossing pattern of the signal.


3. Addressing Powerline Interference in ECGs

Powerline interference, typically at 50/60 Hz, is a prevalent issue in ECG recordings and other bioelectrical signals. Such noise complicates the analysis of low-amplitude waveforms and may introduce spurious signals. Although certain precautionary measures can reduce this interference, signal processing techniques often remain necessary.

3.1 Basic Linear Filtering

Notch Filters

A straightforward method for mitigating powerline interference is to use a notch filter with zeros at the interfering frequency . This simple filter, however, has a significant downside: its large bandwidth attenuates frequencies close to , affecting the ECG signal.

Modified Notch Filters

To overcome the bandwidth issue, the notch filter can be refined by adding complex-conjugated poles at the same angle as the zeros but at a specific radius . The bandwidth of the notch is inversely related to the proximity of to the unit circle.

As the radius gets closer to the unit circle (i.e., approaches 1), the bandwidth of the notch becomes narrower. This happens because the poles and zeros in the z-plane get closer together. When they are close, they effectively "cancel each other out" over a narrower range of frequencies, resulting in a tighter notch filter.

modified_notch_filter

Trade-offs in Filter Design

While reducing the notch bandwidth mitigates the unwanted attenuation, it increases the filter's transient response time, leading to a "ringing" artifact in the ECG. Careless use of these filters can distort the ECG signal's diagnostic value. Filters also become unstable when their poles are located outside the unit circle in the z-plane.

Advanced Linear Filtering Techniques

Higher-Order Filters

More intricate filters can be designed for better noise suppression. Increasing the filter order results in a narrower notch, allowing for more selective frequency removal.

Time-Frequency Considerations

Advanced filters can also incorporate both time and frequency properties in their design. However, there's an unavoidable trade-off: achieving higher frequency resolution results in decreased time resolution, which may introduce ringing artifacts.

3.2 Nonlinear Filtering

The key idea here is to adaptively generate a sinusoid that mimics the powerline interference in the ECG signal. This adaptive sinusoid is then subtracted from the original signal to remove the interference.

Sinusoid Generation

We use a recursive oscillator to generate a sinusoid that estimates the powerline interference. The oscillator uses complex-conjugated poles situated on the unit circle.

Adaptive Amplitude

Since the amplitude of the actual powerline interference could change over time, we adaptively update the amplitude of our generated sinusoid. This is the crucial part that makes this method resistant to sudden changes, or transients, in the ECG signal.

Error Function

To guide the amplitude update, we use an error function that measures the difference between the generated sinusoid and the ECG signal. This error function is adapted to be insensitive to DC levels.

Amplitude Update

Depending on the error, the amplitude of the generated sinusoid is either increased, decreased, or kept constant by a small fixed amount. This ensures that our estimated sinusoid closely follows any changes in the actual powerline interference.

Output Signal

The output is simply the original ECG signal minus the generated sinusoid, effectively removing the powerline interference.

Tracking Accuracy vs. Noise

A critical point is the choice of the increment for amplitude update. A small increment would make the filter slow in tracking changes, while a large increment could introduce additional noise.

Performance

This nonlinear filtering approach excels in preserving the important features of ECG, like the QRS complex, while removing the interference. The amplitude of the internal sinusoid mainly gets updated during the stable periods of the ECG signal, ensuring a good estimate.

Linear Version

If we replace the nonlinear update rule with a linear one, this filter essentially becomes a regular IIR notch filter. However, doing so would lose the transient suppression property, bringing back the ringing artifacts.

3.3 Estimation-Subtraction Method

To remove powerline interference from ECG signals, one strategy is to estimate the amplitude and phase of the interference during a quiet part of the heartbeat, known as the isoelectric segment. Then, you subtract this estimated interference from the whole heartbeat.

Identifying the Isoelectric Segment

You can pinpoint this isoelectric segment using the PQ interval on an ECG (similar to the polynomial fitting method in baseline wander removal) or other specific criteria. The method's performance drops if parts of the P or Q wave are included in this segment. In such cases, you end up overestimating the interference, which counterproductively increases the noise content at 50/60 Hz.

Subtraction Across Heartbeats

The estimated sinusoid is removed not just from the segment where it was calculated, but from the entire heartbeat. This process is repeated for each heartbeat. However, this method might cause sudden shifts in amplitude between successive heartbeats.

Mathematical Details

Mathematically, you're fitting a sinusoid to the isoelectric segment to get the best estimates for amplitude and phase . You can rewrite the equations in a linear fashion to make the problem easier to solve. Using these linear equations, you can find optimal values for and that minimally differ from the observed interference. The equations for these are represented in a matrix format, which simplifies the calculations.

Frequency Characteristics

This method can also be interpreted in terms of its frequency response, allowing for comparison with other linear filtering methods. As you increase the length of the interval where the sinusoid is fitted, the frequency response improves, but some oscillations near the stopband will remain.

Adaptations

The method can also be made adaptive by continuously updating the amplitude and phase estimates. This adaptive version uses an LMS (Least Mean Squares) algorithm and operates like a second-order IIR filter. However, it can introduce ringing artifacts after the QRS complex due to its linear nature.

adaptive_estimation_subtraction


4. Muscle Noise Filtering in ECG Signals

4.1 The Challenge of Muscle Noise

Muscle noise is a significant issue in ECG recordings, particularly during exercise. It's more challenging to filter than other types of noise, like baseline wander or 50/60 Hz interference. The spectral content of muscle noise overlaps significantly with the PQRST complex, making it tough to isolate.

ecg_artifact_spectrum

4.2 Ensemble Averaging Limitations

You can use ensemble averaging to reduce muscle noise, but it's limited to one specific QRS shape and needs multiple heartbeats. So, there's still room for better techniques.

ensemble_avg

4.3 Time-Varying Lowpass Filtering

One method employs time-varying lowpass filters. For instance, a filter with a Gaussian impulse response can be adapted from sample to sample based on a function . This function sets the width of the Gaussian and is designed to reflect local signal properties.

Adapting to the Signal

So, in smoother ECG segments, the filter applies more aggressive lowpass filtering. In the QRS interval, where the signal changes rapidly, the filter loosens up. You can make proportional to the derivative of the ECG signal to accomplish this.

The Role of

The function controls the width of the Gaussian filter at each point . If the function is proportional to the derivative of the ECG signal, then where the signal changes slowly (like in the smoother segments), would be small. A small makes the Gaussian filter wider, essentially applying stronger lowpass filtering. Conversely, where the ECG changes rapidly (like in the QRS complex), would be larger, making the Gaussian filter narrower and applying less filtering.

Steps to Implement

  1. Compute the Derivative: First, you'll need to compute the derivative of your ECG signal. You could do this using finite differences, for example.

  2. Normalize the Derivative: Optionally, normalize this derivative so that it remains within a certain range, say between 0 and 1. This makes it easier to control the filter's behavior.

  3. Compute : Now, compute based on this derivative. It could be a linear mapping, or something more complex based on your specific needs.

  4. Apply the Filter: For each point in your signal, apply the Gaussian filter whose width is controlled by . Because can change from point to point, you'll essentially be applying a different filter at each point.

  5. Overlap-Add Method: You might have to use techniques like the overlap-add method to assemble the final filtered signal, given that you're applying a different filter at each point.

Drawbacks and Artifacts

But be cautious: these time-varying filters can introduce artificial waves in the ECG. They might smooth out the P and T waves while leaving the QRS complex mostly unaltered, causing distortions. This makes the filtered ECG unsuitable for diagnostic purposes.

4.5 The Unresolved Problem

Numerous other methods have been proposed for muscle noise reduction, but none have become a standard in clinical practice. Much like in EEG signal processing, the muscle noise issue remains largely an open problem.


5. QRS Detection

5.1 Overview

QRS detection in ECG signals is crucial for identifying each cardiac cycle's timing and thereby enabling the analysis of heart rhythms. A good QRS detector should handle various morphologies and types of rhythms, and be robust against noise and artifacts. Generally, the architecture includes a preprocessor and a decision rule.

QRS_detector_block_diagram

Preprocessor

  1. Linear Filter: The first step usually employs a bandpass filter focused on the frequency components most relevant to the QRS complex. Typically, this filter has a center frequency between 10 to 25 Hz and a bandwidth of 5 to 10 Hz. This helps preserve the QRS complex while removing other components like P and T waves.

  2. Nonlinear Transformation: After the linear filter, a nonlinear operation may be applied to further highlight the QRS complex against the background noise. This could be something as simple as squaring each sample or applying rectification. More complex transformations with memory are also possible but not always used.

ecg_artifact_spectrum

Decision Rule

The processed signal is then evaluated to identify the presence of a QRS complex. This could be as straightforward as an amplitude threshold or could involve additional tests for shape, duration, etc., to improve the detector's reliability.

Additional Considerations

  1. Noise & Artifacts: Real-world ECG signals can contain various types of noise (e.g., power line interference, muscle noise). It's essential to account for these in both the preprocessing and decision-making stages.

  2. Temporal Resolution: While the primary role of a QRS detector is to locate the QRS complex accurately, sometimes the temporal resolution needs to be improved further. Time alignment algorithms can be used for this.

  3. Adaptability: The QRS detector should be robust and adaptable to handle different QRS morphologies and should not lock onto a particular rhythm.

5.2 Signal and Noise Problems

Signal and Noise Categories

  1. Morphologic Changes: These could be either physiological (like different heartbeats patterns such as trigeminy and bigeminy) or technical (like amplitude variations due to equipment issues).

  2. Occurrence of Noise: Noise could come from:

    • Large P or T waves that might be mistaken for QRS complexes.
    • Myoelectric origins (muscle noise).
    • Transient artifacts, generally due to electrode problems.

Types of Noise in ECG

  1. P and T Waves as Noise: In QRS detection, P and T waves are treated as noise because the aim is to detect the QRS complex only. Therefore, any tall or prominent P or T waves can be problematic.

  2. Myoelectric Noise: Short bursts of noise resembling the QRS complex can be particularly challenging to differentiate.

  3. Artifacts: These are noise components that closely resemble a QRS complex in both shape and amplitude but are not; these are often due to issues like loose electrodes.

Challenges

  1. Physiological Signal Variability: The body itself can produce variations in the QRS complex, making detection challenging.

  2. Technical Noise: Problems with the recording equipment can introduce its own set of challenges.

Implications

The existence of these issues underscores the need for robust QRS detection algorithms. Such algorithms need to be adaptive and capable of differentiating between various forms of "noise" and the actual QRS complexes. They should be able to handle both physiological and technical variables that can complicate the detection process.

5.3 QRS Detection as an Estimation Problem

We will rely on machine learning estimation techniques to derive the detector structure that corresponds to the model of interest.

a. Unknown occurrence time

Signal Model Overview

Let's revisit the signal model based on Woody's method for aligning evoked responses. Imagine you have a QRS complex signal whose shape is known, but the time it occurs within an observation window of length is unknown. This signal gets corrupted by noise , which is a stationary white Gaussian noise with variance .

Mathematically, the observed signal is:

Here, is the unknown occurrence time, and is the duration of the QRS complex .

Maximum Likelihood Estimate

To find the best estimate of , the Maximum Likelihood (ML) approach is used. This involves maximizing the log-likelihood function of the observed data. The impulse response of a matched filter, designed for this purpose, turns out to be a time-reversed version of .

Noise Adaptation

The impulse response can also be adapted to deal with colored noise, not just white noise.

False Detection & Thresholding

In this model, a QRS complex is assumed to always be present, which may not be realistic. To avoid false detections, a threshold is applied to the output of the matched filter. An event is considered detected only if the amplitude exceeds this threshold.

Dynamic Thresholding & Event Sequence

After an event is detected, a "refractory period" follows where the system refrains from detecting new events for a short time. Then, the thresholding process repeats for subsequent observation windows, detecting new events as they occur. In practice, the threshold is adaptive, adjusting based on the amplitude of the most recently detected QRS complexes.

b. Unknown Amplitude and Time

Revised Signal Model

In the previous model, we assumed that the QRS complex had a fixed amplitude. Now, we're adding another layer of complexity by making both the occurrence time and amplitude unknown parameters. These are jointly estimated using Maximum Likelihood (ML). The new signal model becomes:

Objective Function for Estimation

We're still maximizing a log-likelihood function, but it's modified to account for the unknown amplitude .

Estimation Steps and Likelihood Function

For the Gaussian white noise assumption, the likelihood function can be expressed in terms of both and . The estimation is a two-step process. First, we find an estimator for through differentiation. This estimator turns out to be the energy-normalized output of the matched filter. Then, this estimate is plugged into the log-likelihood function to find an estimator for .

Dealing with Unknown Factors

The factor is usually unknown but luckily doesn't affect the estimation of .

Thresholding and Detection

Like before, a threshold test is applied to the output of the matched filter. However, the output is squared, making the test insensitive to the sign of the amplitude.

Non-Linear Transformations and Constraints

If the amplitude is constrained within a known interval, the amplitude estimates are clipped to the closest boundary value. In practice, this means applying a rectifier or squarer to the signal, depending on whether the amplitude falls outside or within the allowed interval.

Special Cases

For cases where the amplitude is known except for its polarity, similar non-linear transformations are applied, solidifying the close relationship between rectifiers and squarers with this extended signal model.

c. Unknown Time, Amplitude, and Duration

Introduction: Why Duration Matters

QRS complexes can vary significantly in duration. While normal QRS durations hover around 120 milliseconds, those originating from certain areas in the ventricles could be much wider. This calls for a model that also accounts for a scaling parameter to handle variations in duration.

Modeling Duration: Discretization and Interpolation

The scaling parameter can be discretized in multiple ways, either uniformly or through a dyadic sequence. The continuous-time waveform is rarely available, but we can work around this by using interpolation and decimation to adjust the time resolution of the known discrete-time waveform .

Estimation Procedure with Duration

The maximum likelihood (ML) estimation process now becomes more complex because it has to consider , , and . The procedure is somewhat similar to earlier models; you first estimate as a function of and , then maximize the likelihood with respect to both and . This can't be simplified as before because all these variables are intertwined.

Alternative Approach: Two-Part Waveforms

An easier way to model duration is by considering as composed of two identical but time-shifted and sign-inverted waveforms . This allows the use of local extreme values in the estimation procedure, simplifying the computation significantly.

Peak-and-Valley Picking Strategy

Regardless of the estimation method used, employing local extreme values as a basis for QRS detection isn't new and is sometimes called a peak-and-valley picking strategy. To qualify as a heartbeat, the distance between peaks and valleys has to be within certain limits.

Summary

Modeling the duration introduces additional complexity but is essential for more accurate QRS detection. While maximum likelihood estimators can be tailored to handle this complexity, simpler strategies involving peak-picking might be computationally more efficient.

5.4 Detector Preprocessing

a. Linear Filtering

Initial Approaches and Limitations

One of the first methods to condition the ECG signal for QRS detection involved differentiation. This emphasized rapid transitions in the signal, corresponding to the QRS complex. In discrete time, this can be represented by a filter . However, this kind of differencing filter is prone to amplify high-frequency noise, making it unsuitable in situations with low signal-to-noise ratios (SNRs).

Enhanced Techniques: Lowpass Filtering and Differentiation

A more effective strategy combines differentiation with lowpass filtering, to cut off high-frequency noise. The frequency response of such a lowpass differentiator needs to be truncated and optimized using techniques like Mean Square Error (MSE) minimization before practical use.

Customizable Filters

The paper mentions a family of filters defined by two parameters and . These are integer values that allow for flexible filter design without requiring complex operations—just addition and subtraction. Filters in this family are suitable for long-term ECG analysis. Different combinations of and have been tried and tested, yielding varying performances.

Towards Optimal Filtering

An "optimal" filter for QRS detection can be designed by optimizing parameters to achieve the best SNR. For instance, a second-order Butterworth bandpass filter with a center frequency of 17 Hz was found to produce the highest SNR in one study.

Adaptive Filtering

An alternative is to start with a fixed impulse response and then adapt it using techniques like exponential averaging as new beats are detected. While this may offer better performance on individual ECGs, the method can degrade if deviant beat morphologies are encountered.

Matching with Basis Functions

Finally, for situations where different QRS morphologies need to be considered, the Maximum Likelihood (ML) estimator can be adapted to include a bank of sub-filters, each matched to a certain basis function. This allows for a more adaptable filtering approach, although it can be computationally complex.

b. Nonlinear Transformations

Objectives and Challenges

In nonlinear transformations, the aim is to produce a single, positive-valued peak for each QRS complex. This enables simpler peak detection methods. Similar to linear filtering, the transformation should enhance QRS complexes relative to other components like P and T waves, noise, and artifacts.

Squaring and Smoothing

One common nonlinear transformation employs a squarer. However, squaring can introduce additional peaks and valleys, which may lead to false detections. To mitigate this, the squared output is smoothed through linear filtering, usually with a lowpass FIR filter.

Model-Based Approaches

Another way to design nonlinear transformations involves modeling the QRS complex with a lowpass signal modulated by a cosine function. This model can adapt to a variety of QRS morphologies by tweaking the modulation frequency and phase angle.

Extracting the Envelope

The goal here is to extract from without any prior knowledge. This involves using the Hilbert transformer to create a 90-degree phase-shifted version of . By computing the absolute value of this transformed signal, can be obtained. However, the Hilbert transformer has an infinite and non-causal impulse response, so approximations must be made.

Power-Efficient Approaches

In scenarios where power consumption is a concern, like in pacemakers, the Euclidean distance in the envelope calculation can be approximated by the "city block" distance. Further, the impulse response of the Hilbert transformer can be truncated to minimize computational load, though this introduces some ripple that must be smoothed out.

5.5 Decision Rules for QRS Detection

Adaptive Thresholding

In QRS detection, the post-processed signal needs to pass a decision rule to confirm the occurrence of a QRS complex. While a fixed threshold can work, an adaptive approach is better suited due to the quick changes in QRS amplitude and shape. Using an adaptive threshold not only minimizes false detections but also adapts to real-time changes in heart activity.

The adaptive threshold is updated each time a new QRS is detected. The threshold is usually calculated based on an exponentially updated average amplitude of previously detected QRS complexes.

Time-dependent and Interval-dependent Thresholds

This adaptive threshold can be made time-dependent to improve the rejection of large-amplitude T waves while still detecting low-amplitude ectopic beats. For example, you can define a "no-detection" interval after each detected QRS, during which no other complexes are considered. This interval is generally between 160-200 milliseconds and corresponds to the heart's refractory period, the phase when it won't respond to new electrical stimuli.

The length of this "eye-closing" period needs careful selection. Too long, and you might miss important premature beats; too short, and you risk more false positives due to T waves and other factors.

Signal Order in Detection

QRS complexes are generally detected in temporal order, even if the complete data is already available. However, some algorithms consider both past and future properties of the signal to determine QRS occurrence, allowing for a more robust detection especially if there's a sudden drop in amplitude.

Noise and Multilead Approaches

Muscle noise can degrade detection performance. Measuring noise and using that information to adjust the detection threshold can be beneficial. Moreover, a multilead approach to QRS detection is often superior because noise and artifacts are typically independent across different leads. This enhances the robustness of the detection and can be particularly useful for spotting low-amplitude ectopic beats that may be more visible in one lead compared to another.

Rhythm Information

Even though these decision rules are generally agnostic to heart rhythm, some level of rhythm information can be used to improve detection. For example, if the time between two detected beats is unusually long, it might indicate a missed low-amplitude beat. In such cases, a look-back mechanism using a lower detection threshold can be employed to catch the missed beat.

5.6 Performance Evaluation

Before deploying a QRS detector in a clinical environment, it's essential to determine and evaluate the right parameter values. Using values that worked well during development may result in poor performance on new data.

Generally, a QRS detector has multiple parameters. Conducting an exhaustive optimization can be computationally intensive. A practical approach is to focus on the parameters that have the most significant impact on performance. Others can be set based on physiological principles or ad hoc decisions.

Performance is usually measured by two probabilities: - , the chance of accurately detecting a true heartbeat - , the chance of mistakenly detecting a false heartbeat

The probability of a missed beat, , is related to as . While theoretical calculations can be made based on ECG signal models, it's more useful to evaluate these probabilities using a large and diverse ECG database. Estimates are based on the number of correct detections (), false alarms (), and missed beats ().

Manual annotation of the database is a labor-intensive task usually performed by skilled ECG readers. Each QRS complex is assigned a precise occurrence time, . A detected beat is considered accurate if the time difference between the estimated and annotated occurrence is within a defined window, . A false detection occurs when the estimated time is outside this window, and a missed beat is noted when no detection happens within the window.

For evaluating performance, a Receiver Operating Characteristic (ROC) curve can be plotted, displaying against . This allows for selecting parameters that offer a good trade-off between accurate detection and false alarms. The choice of this trade-off will vary depending on the application. ROC analysis is also useful for comparing the robustness of different QRS detectors against noise and artifacts.

5.7 Pan-Tompkins Algorithm

The Pan-Tompkins algorithm is one of the most widely used and effective methods for QRS detection in ECG signals. Developed by Jiapu Pan and Willis J. Tompkins in 1985, this algorithm is well-regarded for its performance, even in noisy environments.

Main Components

The algorithm comprises several stages:

  1. Bandpass Filtering: The ECG signal is first filtered to focus on the frequency components that are relevant to the QRS complex. This usually involves passing the signal through a high-pass and then a low-pass filter. The idea is to eliminate noise and other ECG components like P and T waves, which are not relevant for QRS detection.

  2. Differentiation: The filtered ECG signal is then differentiated to calculate the slope information, further highlighting the high-frequency content of the QRS complex.

  3. Squaring Function: The differentiated signal is squared on a point-by-point basis. This step makes all data points positive and amplifies the high-frequency content, emphasizing the QRS complex.

  4. Integration: A moving average (or window integration) is then applied to the squared signal. This essentially integrates the signal over a predefined window, further emphasizing the area under the QRS complex.

  5. Thresholding and Decision Logic: Finally, adaptive thresholds are applied to this integrated signal to detect the QRS complex. Decision logic usually involves setting different threshold levels and looking at the recent history to reduce false positives and negatives.

Why It Works

The Pan-Tompkins algorithm is effective because it uses a sequence of transformations that each contribute to emphasizing the features of the QRS complex while de-emphasizing other signal features and noise. The algorithm is relatively simple to implement but is robust enough for use in a variety of situations, including noisy and non-stationary environments.

Limitations

While widely used and effective, it does have some limitations:

  • It might not perform as well for irregular heart rhythms or arrhythmias where the QRS morphology varies significantly.
  • Tuning may be required depending on the specifics of the ECG recording environment, like the sampling rate or the presence of specific types of noise.

6. Wave Delineation

Wave delineation is the process of defining the boundaries of individual waves in the PQRST complex of an ECG signal. This enables the calculation of wave duration and other characteristics like amplitude and shape. Delineation can also identify missing waves, a common occurrence in certain ECG leads or pathologies. While primarily used for sinus node beats, the method can be applied to any type of beat for automated classification.

Classical vs Practical Approaches

The classic way to delineate a wave is by identifying when it crosses a specific amplitude threshold. However, this is rarely practical due to issues like baseline wander in the ECG signal. A more common approach is to calculate the first derivative of the signal and identify zero crossings and extreme values, which indicate wave boundaries. This method avoids problems caused by low-frequency noise.

Delineation Procedure

In a typical procedure, the delineation starts at the steepest slope of a wave and continues until the derivative falls below a threshold. The exact moment when the threshold is crossed marks the end of that particular wave. To ensure meaningful results, the algorithm first needs to identify which waves are actually present. This is done by analyzing patterns of peak amplitudes and interpeak distances in the differentiated signal.

Thresholding Methods

The threshold can either be a fixed value representative of the boundary or can be set to a percentage of the maximum slope. The latter is more in line with how cardiologists work, as it accounts for variations in amplitude and slope between different waves.

Challenges in Noisy Environments

Noise can significantly affect wave delineation, especially when dealing with low-amplitude boundaries. Performance can be improved by coupling signal differentiation with lowpass filtering. The filter's cut-off frequency may be fixed or adapted to the specific wave under consideration.

Template Matching

An alternative to thresholding is template matching, which is less susceptible to noise. This involves correlating a template waveform with the lowpass-filtered differentiated signal.

Performance Evaluation

Once parameters are set, performance is evaluated against a manually annotated database. Metrics include the mean and standard deviation of errors between automated and expert-determined boundaries. While achieving zero deviation is unrealistic, a good algorithm will have a deviation comparable to the variations seen among experts.

Special Case: T Wave Delineation

T wave delineation is particularly challenging due to its gradual transition to the isoelectric line. Despite this, it's crucial for calculating the QT interval. Special techniques, including multiresolution signal analysis using wavelet transforms, have proven effective for T wave delineation. Wavelet-based methods have been found to produce results that better align with expert opinions compared to lowpass differentiation methods.


7. Data Compression in ECG

7.1 Overview

Introduction

Data compression is crucial in ECG applications for two main reasons: storage and transmission. As medical records and diagnostics become increasingly reliant on ECG data, the demand for storage space rises. Furthermore, the real-time transmission of ECG signals for early diagnosis or emergency situations necessitates efficient data compression methods.

Types of Compression

Compression can be either lossless, where the original and compressed signals are identical, or lossy, where some acceptable level of distortion is permitted. The aim is to achieve the best compression ratio, which is the original data size divided by the compressed size, while preserving diagnostic content.

Types of Redundancy in ECG

data_compression

  1. Intersample Redundancy: Found within single heartbeats and can be tackled by either direct or transform-based methods.

  2. Interbeat Redundancy: Occurs between similar-looking heartbeats within each lead. A QRS detector identifies these redundant beats.

  3. Interlead Redundancy: Arises from the multiple leads that observe a heartbeat. The redundancy depends on the distance between electrodes.

Key Factors in Data Compression

  1. Sampling Rate: Lower sampling rates result in less redundancy and therefore lower compression ratios.

  2. Signal Bandwidth: Signals limited to lower bandwidths often have better compression ratios.

  3. Number of Leads: More leads can mean more data but also more potential for redundancy.

  4. Noise Level: Affects the quality of compression.

Performance Evaluation

Simply relying on the compression ratio as a performance measure is insufficient, especially in lossy compression. It's also important to consider the distortion level in the reconstructed signal. Other considerations include the type of ECG data being used for evaluation, such as noise level and the presence of ectopic beats or arrhythmias.

7.2 Lossless Compression in ECG

Overview

Lossless compression is ideal when preserving diagnostic details is paramount. However, it often doesn't achieve high compression ratios. One notable method in the context of ECG is linear prediction.

Linear Prediction

Linear prediction reduces intersample redundancy by estimating the current sample as a linear combination of previous samples. The prediction error then becomes:

Because is typically much smaller than , it requires fewer bits to represent, making it suitable for compression.

Simple Predictors
  1. First-order Predictor: It predicts based on . The prediction error is then computed. The transfer function is .

  2. Second-order Predictor: It predicts by extending the line defined by and . This computes the second difference in the signal.

Both of these simple predictors have been used for ECG data compression.

Optimal MSE Predictor

An optimal predictor can be determined by minimizing the Mean Squared Error (MSE). This involves solving a set of linear equations derived from the autocorrelation function of the data.

Performance

Higher-order predictors offer only minor improvements in performance when the sampling rate is 200 Hz. The optimal predictors are better at capturing QRS complexes than simple structured predictors.

Inverse Filtering

For reconstruction, the original signal can be obtained through inverse filtering using . The filter is stable if the zeros of are inside the unit circle.

Caveats

Even though it's a lossless technique, rounding off to a finite number of bits can make the compression lossy, especially for MSE predictors whose coefficients may not be integers.

7.3 Lossy Compression Methods: Direct Approaches

Overview

Direct methods for lossy compression work in the time domain. They select a subset of "significant" samples from the original signal for compression, discarding the rest. To reconstruct the omitted samples, these methods typically use interpolation techniques.

Selecting Significant Samples

In this process, the first and last samples in the subset are fixed. Interpolation is often achieved through simple polynomial functions. Although more complex functions can be used, this increases the overhead due to additional parameters.

The criteria for selecting significant samples often depend on ensuring a tolerable reconstruction error. This selection can be done in a sequential manner or by processing a larger block of samples. The block-based approach usually performs better but is less suited for real-time applications.

Impact of Noise

The effectiveness of direct methods is affected by noise. Higher noise levels require more significant samples, thus reducing compression ratios. Direct methods are generally better suited for noise-free environments.

Case Studies: AZTEC and SAPA

AZTEC Method

AZTEC is one of the oldest methods and is computationally lightweight. It represents the signal using plateaus and slopes. However, its results are not always suitable for diagnostic interpretation.

SAPA Method

SAPA, or Scan-Along Polygonal Approximation, is another popular method. Unlike AZTEC, SAPA represents the signal using a sequence of straight lines, which can offer a more accurate approximation.

Other Methods and Improvements

Several modifications to these base methods aim to improve signal reconstruction. For example, varying the error tolerance dynamically can produce better results. Some approaches even combine different methods for various segments of the signal.

Fan Method and Block-Based Optimization

The Fan method is similar to SAPA but has been around for longer. Another variation involves using block-based optimization to minimize the reconstruction error, albeit at the cost of increased processing time.

7.4 Lossy Compression: Transform-based Methods

Transform-based compression works on the idea that you can represent a signal in a more compact form by using only a subset of its basis functions. This isn't a new concept; we saw it used in Section 4.5 for analyzing event-related potentials (EPs). Essentially, you approximate the signal by keeping only the most important terms (K out of N) in its series expansion. These selected terms are then stored or transmitted, while the less important ones are discarded. To find these terms, you take the inner product of the signal with each basis function.

Now, when it comes to compressing data like ECG signals, you first divide the signal into blocks, each generally containing one heartbeat. This means you have to identify the QRS complex in each block before you can proceed with the compression. The length of these blocks can vary because heart rates change. If your compression method expects blocks of a fixed length, you'll have to either pad shorter blocks or trim longer ones.

This method isn't foolproof. For irregular rhythms like ventricular fibrillation, where you can't find a QRS complex, the block division approach fails.

When deciding how many basis functions (K) to use, it's a balancing act between compression efficiency and how accurately you can reconstruct the signal. You can adapt the value of K for each block depending on the error you're willing to tolerate. This gives you more control over the quality of the reconstructed signal, but also means you'll need to store additional information to keep track of the varying K values for each block.

In cases where you don't know the basis functions in advance, you'll also need to store them as additional data. An example shows that using different numbers of basis functions based on an RMS quality measure meets the specified error tolerance for different heartbeats.

Karhunen-Loève Transform for Data Compression

Choosing the right set of basis functions is crucial for effective data compression. The Karhunen-Loève Transform (KLT) is often considered a go-to choice because it minimizes the mean squared error (MSE) in approximating the original signal. Here, the aim isn't to separate signal and noise, but to find basis functions that make the compressed version look as much like the original signal as possible.

In KLT, the basis functions are obtained as eigenvectors of the signal's correlation matrix . The transformed domain is then defined by a coefficient vector , which is calculated using these eigenvectors. Performance of the KLT can be assessed through an index that gives an average sense of how well the basis functions approximate the original signal. However, this doesn't speak to the quality of individual blocks, so additional criteria might be necessary for choosing the number of basis functions ().

Regarding the data used for , basis functions can be either "universal" (based on many patients) or "subject-specific" (from a single recording). Subject-specific functions usually give better results because they're tailored to the individual data. However, they also have to be stored or transmitted as additional information. It's important to align the beats properly in time before estimating to avoid efficiency loss.

An interesting bonus of using KLT is that it can reduce noise in the reconstructed signal. This happens because the most significant basis functions capture most of the signal's energy, leaving noise in the truncated, less important functions.

However, KLT has its limitations. For example, it struggles with ECG data where heart rates change a lot, like during a stress test. Since KLT basis functions assume a fixed distance between the QRS complex and the T wave, they become inefficient for representing signals where this distance varies. In such cases, more basis functions may be needed, reducing the overall compression efficiency.

Wavelets and Wavelet Packets for Data Compression

Wavelets provide an alternative to the KLT, with advantages in speed and flexibility. The Discrete Wavelet Transform (DWT) has proven effective for compressing ECG signals. Just like in KLT, larger magnitude coefficients are kept first since they contain most of the signal energy. Wavelet coefficients often have a temporal relationship across scales, which can help in selecting which coefficients to keep for compression.

The Discrete Wavelet Packet Transform (DWPT) takes the DWT a step further. While DWT only decomposes scaling coefficients, DWPT decomposes both scaling and wavelet coefficients. This makes DWPT more flexible but also more complex. You end up with a binary tree structure, unlike DWT’s dyadic tree. This allows for a highly adaptable representation of signals. Coefficient selection in DWPT is often driven by metrics like entropy, aiming to concentrate as much information as possible in fewer coefficients. This could also be guided by setting an error tolerance for distortion.

Interestingly, DWPT approximates KLT quite well but doesn't have KLT’s limitation of being signal-dependent. DWPT only requires coding the binary tree structure, not the total basis functions like KLT.

Other Transforms for ECG Data Compression

There are other, signal-independent transforms like Discrete Fourier Transform (DFT), Walsh Transform, Discrete Cosine Transform (DCT), Discrete Legendre Transform, Hermite Transform, and Optimally Warped Transform. While they generally underperform compared to KLT and DWPT, they often have the advantage of quick computation. For instance, DFT can be efficiently calculated using the Fast Fourier Transform (FFT).

In summary, while KLT may offer optimal performance in terms of MSE, it's computationally demanding and signal-dependent. Wavelet-based methods like DWT and DWPT provide a good trade-off between compression performance and computational efficiency. They also allow for more flexibility in adapting to the specifics of the signal being compressed. Other transforms exist but usually at the cost of reduced performance.

7.5 Interbeat Redundancy

Let's address interbeat redundancy in ECG signals, which is a form of redundancy not captured by traditional compression techniques that focus on intersample redundancy. One simple approach is to use the previous heart beat to predict the next one, which effectively reduces the data needed to represent the ECG signal. This is known as the residual ECG.

However, this straightforward "previous-beat" prediction method has limitations. One key issue is its sensitivity to noise. An improvement on this is to use an "average beat subtraction" method, which takes the average of the J most recent beats for prediction. This helps to reduce noise and improve prediction accuracy.

Time alignment is crucial when using these prediction techniques. A misaligned prediction can introduce large errors, requiring more bits for representation. The sampling rate is also an important consideration, as a low rate can lead to large prediction errors.

Further sophistication can be introduced by using predictors that also account for intersample correlation. These "long-term predictors" use autoregressive (AR) models to capture both intersample and interbeat correlations. The parameters for these models can be derived by minimizing prediction error.

Additionally, it's crucial to categorize beats according to their morphology. For example, if a beat's prediction error energy exceeds a certain threshold, a new average beat is initialized, unless the beat can be matched with an existing category.

Finally, these time-domain techniques for reducing interbeat redundancies can also be applied in the transform domain, giving you another set of tools for ECG data compression.

In summary, dealing with interbeat redundancy requires a more nuanced approach than handling intersample redundancy. It involves making predictions based on previous or averaged beats, categorizing beats, and optimizing time alignment. These complexities all aim to improve compression rates while maintaining the integrity of the ECG signal.

7.6 Interlead Redundancy

Interlead Redundancy in ECG Data Compression

Interlead redundancy arises when you're working with multilead ECGs, as different leads tend to be correlated. The challenge is how to incorporate this interlead redundancy into the compression scheme. Applying single-lead compression techniques to each lead separately won't fully exploit this redundancy.

Two-Step Transform-based Methods

One strategy is to use a two-step process:

  1. Transformation Step: A transform like the Karhunen-Loeve Transform (KLT) is used to concentrate the signal energy spread across multiple leads into fewer leads.
  2. Compression Step: Once the energy is concentrated, single-lead compression methods are applied to each transformed lead.

The KLT is particularly useful here because it can be adapted to suit interlead correlations. Basically, you estimate a correlation matrix between leads and use its eigenvectors to define a transformation. This effectively redistributes the energy so that only a few leads contain significant information while others mostly account for noise.

Energy-based Selection

Post-transformation, you can choose to compress only those leads where the energy exceeds a certain threshold. This is an efficient but less accurate way of reconstructing the original ECG.

Unified Approach

A more comprehensive approach involves treating both intersample and interlead redundancy simultaneously. All segmented leads are "piled" into a single vector and subjected to compression. Although computationally more expensive, this "piled vector approach" usually offers more efficient signal representation.

Incorporating Long-term Predictors

Lastly, long-term predictors, which were originally designed to capture interbeat correlations, can be adapted to also incorporate interlead information. This involves tweaking the predictor equation to account for both types of correlation.

transform_based_data_compression

In summary, interlead redundancy offers another layer of complexity when it comes to ECG data compression. Depending on the computational resources and the level of accuracy needed, different approaches can be employed to make the most out of this redundancy.

7.7 Quantization and Coding

When you're dealing with ECG data compression, you can't just stop at redundancy reduction. You also need to figure out how to quantize and code the resulting data. This is important for accurately reconstructing the original signal.

Scalar Quantization

In scalar quantization, each coefficient is quantized individually, which can be done using either a uniform or non-uniform grid.

  • Uniform Quantization: This is straightforward and generally effective when the data follows a uniform probability distribution function (PDF). You just need to determine the step size and the number of quantization levels.

  • Non-uniform Quantization: If the PDF is not uniform, the optimal quantizer will have non-uniform steps. This typically results in lower distortion, but it does require more side information for coding. If you need to frequently update the quantizer because the ECG data has nonstationary characteristics, the added complexity can be a drawback.

Vector Quantization

Vector quantization quantizes multiple samples at a time and has been shown to produce better compression performance compared to scalar methods. However, this advantage diminishes if the coefficients are uncorrelated. For instance, if you're using the Karhunen-Loeve Transform (KLT), the coefficients are uncorrelated, so vector quantization doesn't offer much benefit here.

Bit Allocation

You have to make decisions on bit allocation, especially when dealing with transformed data. Generally, more bits are allocated to coefficients with higher magnitude because they are crucial for accurate reconstruction. The fewer bits allocated to smaller magnitude coefficients, the more you can compress the data at the cost of some level of distortion.

7.8 Performance Evaluation

Evaluating the performance of ECG data compression techniques requires more than just eyeballing the compressed and original signals. There are established metrics to guide you.

Key Metrics
  • Compression Ratio (P_CR): This measures how much the data has been compressed. It's calculated by dividing the number of bits needed to represent the original signal by those needed for the compressed signal.

  • Bit Rate (P_BR): This is the average number of bits per second required to represent the ECG. Unlike P_CR, it's not affected by sampling rate or word length.

  • Percentage Root Mean-Square Difference (P_PRD): This measures the distortion between the original and compressed signals. It's simple to compute but has limitations, such as being less useful for signals with different amplitude characteristics.

Distortion Measures and Their Flaws
  • P_PRD: While easy to compute, this metric has some flaws. For example, it can misleadingly show less distortion if there is baseline wander in the ECG or if the ECG has large-amplitude QRS complexes.

  • P_RMS: This is an alternative to P_PRD, and it describes error in absolute terms rather than percentages. This can be more meaningful in a clinical context where diagnoses often rely on fixed criteria.

  • Weighted Diagnostic Distortion (WDD): This advanced measure considers the clinical significance of various ECG parameters, such as wave amplitudes and durations. It addresses the limitations of simple distortion measures by using a weighted approach.

Rate Distortion Curve

You often see performance as a rate distortion curve, which plots signal distortion against the bit rate. This helps identify the "sweet spot" for acceptable distortion and bit rate.

Diagnostic Information

A big caution here: even a low distortion rate doesn't guarantee that the diagnostic information is preserved. For example, losing a tiny Q wave could be critical for diagnosing myocardial infarction, but it might not impact P_PRD or P_RMS much.

Summary

To really evaluate the effectiveness of ECG data compression, you need to consider multiple metrics that account not just for compression efficiency but also for the quality and clinical usefulness of the reconstructed signal. Advanced metrics like WDD provide a more nuanced evaluation but require complex algorithms to compute. Therefore, it's essential to consider the trade-offs depending on the application's needs.