LabVIEW for ECG Signal Processing

Publish Date: Aug 16, 2012 | 82 Ratings | 3.87 out of 5 |  PDF

Overview

LabVIEW with its signal processing capabilities provides you a robust and efficient environment for resolving ECG signal processing problems. This application note demonstrates how to use LabVIEW's powerful tools in denoising, analyzing, and extracting ECG signals easily and conveniently. These tools can be also used in other biomedical signal processing applications such as Magnetic Resonance Imaging (MRI) and Electroencephalography (EEG). Now in LabVIEW Biomedical Toolkit, several VIs are provided for ECG signal analysis. Besides, it also contains an ECG Feature Extraction application to extract ECG features more conveniently.

Table of Contents

  1. Preprocessing ECG Signals
  2. Performing Feature Extraction on ECG Signals
  3. Summary
  4. Resources for Biomedical Signal Processing
  5. Related Documentation
  6. Testing Your ECG (EKG) Products to ANSI/AAMI EC13

The electrocardiogram (ECG) is a technique of recording bioelectric currents generated by the heart. Clinicians can evaluate the conditions of a patient's heart from the ECG and perform further diagnosis. ECG records are obtained by sampling the bioelectric currents sensed by several electrodes, known as leads. NI LabVIEW is an ideal tool for acquiring and processing ECG, EEG, EMG, and other biopotential signals. A typical one-cycle ECG tracing is shown in Figure 1.

figure1

Figure 1: A typical one-cycle ECG tracing

Generally, the recorded ECG signal is often contaminated by noise and artifacts that can be within the frequency band of interest and manifest with similar characteristics as the ECG signal itself. In order to extract useful information from the noisy ECG signals, you need to process the raw ECG signals.

ECG signal processing can be roughly divided into two stages by functionality: preprocessing and feature extraction.  The preprocessing stage removes or suppresses noise from the raw ECG signal and the feature extraction stage extracts diagnostic information from the ECG signal.  As an example, Figure 2 demonstrates this functionality but also demonstrates an example where ECG data may be embedded within another ECG signal, such as a Fetal ECG signal.

figure1

Figure 2: Typical ECG signal processing flowchart

With NI LabVIEW Biomedical Toolkit and other related toolkits, such as the Advanced Signal Processing Toolkit (ASPT) and the Digital Filter Design Toolkit (DFDT), you can conveniently build signal processing applications for both stages, including baseline wandering removing, noise cancellation, QRS complexes detection, fetal heart rate extraction and etc. This article discusses typical ECG signal processing methods based on LabVIEW.

1. Preprocessing ECG Signals

Preprocessing ECG signals helps you remove contaminants from the ECG signals. Broadly speaking, ECG contaminants can be classified into the following categories:

  • power line interference
  • electrode pop or contact noise
  • patient–electrode motion artifacts
  • electromyographic (EMG) noise
  • baseline wandering

Among these noises, the power line interference and the baseline wandering are the most significant and can strongly affect ECG signal analysis. Except for these two noises, other noises may be wideband and usually a complex stochastic process which also distort the ECG signal. The power line interference is narrow-band noise centered at 60 Hz (or 50 Hz) with a bandwidth of less than 1 Hz. Usually the ECG signal acquisition hardware can remove the power line interference. However the baseline wandering and other wideband noises are not easy to be suppressed by hardware equipments. Instead, the software scheme is more powerful and feasible for offline ECG signal processing. You can use the following methods to remove baseline wandering and the other wideband noise.

Removing Baseline Wandering

Baseline wandering usually comes from respiration at frequencies wandering between 0.15 and 0.3 Hz, and you can suppress it by a highpass digital filter. You also can use the wavelet transform to remove baseline wandering by eliminating the trend of the ECG signal.

1. Digital Filter Approach

LabVIEW Biomedical Toolkit provides a Biosignal Filtering VI under Biosignal Measurements->Biosignal Preprocessing palette. You can use this VI to design a Kaiser Window FIR highpass filter to remove the baseline wandering. Figure 3 shows an example of removing baseline wandering by using Biosignal Filtering VI.

 

fig3

Figure 3: Designing and using a highpass filter to remove baseline wandering

2. Wavelet Transform Approach

In addition to digital filters, the wavelet transform is also an effective way to remove signals within specific subbands. The LabVIEW ASPT provides the WA Detrend VI which can remove the low frequency trend of a signal. Figure 4 shows an example of removing baseline wandering by using the WA Detrend VI.

figure1

Figure 4: Using the WA Detrend VI to remove baseline wandering

This example uses the Daubechies6 (db06) wavelet because this wavelet is similar to the real ECG signal. In this example, the ECG signal has a sampling duration of 60 seconds, and 12000 sampling points in total, therefore the trend level is 0.5 according to the following equation:

                                                        figure1
where t is the sampling duration and N is the number of sampling points.

Figure 5 shows the original ECG signal and the resulting ECG signals processed by the digital filter-based and wavelet transform-based approaches. You can see that the resulting ECG signals contain little baseline wandering information but retain the main characteristics of the original ECG signal. You also can see that the wavelet transform-based approach is better because this approach introduces no latency and less distortion than the digital filter-based approach.

Figure 5: Comparing the digital filter-based and wavelet transform-based approaches

Removing Wideband Noise

After you remove baseline wandering, the resulting ECG signal is more stationary and explicit than the original signal. However, some other types of noise might still affect feature extraction of the ECG signal. The noise may be complex stochastic processes within a wideband, so you cannot remove them by using traditional digital filters. To remove the wideband noises, you can use the Wavelet Denoise Express VI.

This LabVIEW based higher-level Express VI first decomposes the ECG signal into several subbands by applying the wavelet transform, and then modifies each wavelet coefficient by applying a threshold or shrinkage function, and finally reconstructs the denoised signal. The following figure shows an example of applying the undecimated wavelet transform (UWT) to the ECG signal.

figure1

Figure 6: Removing wideband noises from an ECG signal by applying the UWT

The UWT has a better balance between smoothness and accuracy than the discrete wavelet transform (DWT). By comparing the denoised ECG signal with the non-denoised ECG signal, as shown in Figure 7, you can find that the wideband noises are strongly suppressed while almost all the details of the ECG signal are kept invariant.

Figure 7: ECG signals before and after UWT denoising

Back to Top

2. Performing Feature Extraction on ECG Signals

For the purpose of diagnosis, you often need to extract various features from the preprocessed ECG data, including QRS intervals, QRS amplitudes, PR intervals, QT intervals, etc. These features provide information about the heart rate, the conduction velocity, the condition of tissues within the heart as well as various abnormalities. It supplies evidence for the diagnoses of cardiac diseases. For this reason, it has drawn considerable attention in the ECG signal processing field. This section mainly discusses how to perform ECG feature extraction.

LabVIEW Biomedical Toolkit provides an ECG Feature Extractor VI, and also an ECG Feature Extractor application for users to extract ECG features conveniently (Add link for “How to use ECG Feature Extractor” here). You can select whether to detect QRS only or to detect all supported ECG features, including R position, R amplitude, iso level, QRS onset, QRS offset, P onset, P offset, T onset and T offset.

Figure 8: ECG multiresolution analysis and implementation of QRS detection

The ECG Feature Extractor firstly detects all beats (R waves) in the signal, and then extracts other features for every beat. Thus the accuracy of detecting R waves is very important. For normal ECG signals, they can be easily detected, as shown in Figure 8. While abnormal morphology makes the detection difficult for ECG from patients with some specific heart diseases. Thus sometimes you need to perform some signal enhancement (preprocessing) before feature extraction. The preprocessed ECG signal is used to detect position of R waves. After that, all other features will be extracted using original signal, because the signal enhancement may change these features.

Signal enhancement usually contains two steps: filtering and rectification. R waves of human ECG usually have a frequency between 10-25Hz. Thus R waves can be more obvious and easily for detection after filtering using a bandpass filter. Rectification sometimes can further enhance the R waves to make them easier to detect. Absolute and square are two common used rectification methods. Figure 9 shows the processing result of an ECG signal with some negative R waves and very large T waves. It can be seen that, after enhancement, all beats can be easily detected. Biosignal Filtering VI is used to filter the signal. In ECG Feature Extractor application, a preprocessing settings window is provided for users to perform the signal enhancement interactively.

Figure 9: Original ECG, ECG after MRA and ECG after peak/valley detection

 

After extracting the features, you can perform heart rate variability (HRV) analysis on the R-R interval signal to demonstrate the state of the heart and nerve system. In HRV Analyzer of LabVIEW Biomedical Toolkit, you can directly synchronize the RR intervals from ECG Feature Extractor.

Back to Top

3. Summary

LabVIEW and the signal processing-related toolkits can provide you a robust and efficient environment and tools for resolving ECG signal processing problem. This application note has demonstrated how to use these powerful tools in denoising, analyzing, and extracting ECG signals easily and conveniently not only in heart illness diagnosis but also in ECG signal processing research. Moreover, these tools can be also used in other biomedical signal processing applications such as Magnetic Resonance Imaging (MRI) and Electroencephalography (EEG).

 

Back to Top

4. Resources for Biomedical Signal Processing

» LabVIEW Biomedical Toolkit - Collection of example programs and LabVIEW VI's for biomedical signal processing and file I/O.

» Biomedical User Group Forum - On-line user community with discussion forum and resources for LabVIEW users in the biosciences.

 

Back to Top

5. Related Documentation

Refer to the following documents to learn more about ECG measurements and the application of Graphical System Design using the NI sbRIO with the TI MDXMDKEK1258 Electrocardiogram (ECG) Analog Front End (AFE) module:

Back to Top

6. Testing Your ECG (EKG) Products to ANSI/AAMI EC13

Learn how to test and validate any Electrocardiography (ECG) (EKG)  based medical device to ANSI/AAMI EC13.  

In this document, you will learn how to automate and reduce time required to test and validate any ECG based device using NI PXI modular instruments and NI software.

Back to Top

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit