introduction
Biomedical electrical signals, such as electrocardiogram (ECG), blood pressure, and electroencephalogram (EEG), all characterize certain pathological features. Taking ECG as an example, it is usually recorded using an electrocardiogram (ECG) to record the bioelectric currents generated by the heart. Clinicians can use ECGs to assess a patient's heart condition and make further diagnoses. For some home or medical device manufacturers, it is necessary to develop specific signal processing algorithms and deploy them on embedded processors to extract medical electrical features. The development process of a complete ECG monitoring product typically consists of several parts, including ECG data acquisition, ECG signal analysis, human-machine interface, and file storage. Using the graphical system design platform provided by NI, the entire product development process, from data acquisition and signal reading to ECG analysis and report generation, can be covered, completing the entire system development and improving development efficiency. Signal analysis is often the key part of the development process and is the core software technology for various manufacturers. This article will focus on ECG acquisition and analysis, introducing how to efficiently develop ECG signal acquisition and analysis algorithms using LabVIEW.
Figure 1. Typical single-cycle electrocardiogram waveform.
ECG signal data acquisition
Generally, ECG signals are obtained by sensing bioelectric currents through several electrodes (leads) and converting the analog electrical signals generated by the leads into digital signals for computer analysis. The analog signals generated by the leads are often quite weak, with an amplitude of around mV, requiring acquisition using dynamic signal acquisition equipment or pre-amplification. Both standalone ECG leads and integrated medical ECG devices can be acquired using NI (Instrumentation Instruments) devices.
Through over 30 years of development, National Instruments (NI) has established a leading position in the test and measurement field. From portable USB devices to high-precision PXIe synchronous sampling devices, NI offers resolutions ranging from 8 to 24 bits and sampling rates from 48 kHz to 2 GHz. NI devices comprehensively consider various error values, including gain error, offset error, and uncertainty noise, to provide absolute accuracy values, ensuring the accuracy of the final measurement. Generally, ECG signals have frequencies around several hundred hertz, which can be sampled at sampling rates of approximately 1 kHz to 5 kHz. Furthermore, depending on the precision requirements of the application, 14- to 16-bit sampling precision can be selected. Essentially, any NI platform's data acquisition device can meet the sampling needs of ECG. Appropriate devices can be selected based on the application; for example, USB data acquisition is chosen for portable devices, while wireless acquisition is chosen for telemedicine applications.
Figure 2 NI Data Acquisition Solution from USB to Wireless
Regardless of the NI hardware platform used, development can be achieved through the same programming platform—NI's graphical programming software, LabVIEW. Since its inception in 1986, the LabVIEW graphical development platform has been dedicated to simplifying programming complexity, and LabVIEW graphical programming has become the standard development tool in all fields involving data acquisition and control. For medical electronic device development teams, LabVIEW provides a shortcut to integrate hardware I/O into algorithm design, seamlessly combining all aspects of the process from data acquisition, algorithm analysis, data storage, and human-computer interaction. Furthermore, different NI hardware can reuse code and be deployed to different commercial and embedded platforms, simplifying the complexity of building prototype systems.
ECG signals can be quickly acquired and displayed using LabVIEW and NI acquisition devices. Figure 1 shows a typical ECG waveform cycle. Of course, during this process, the ECG signal will be contaminated by noise and artificially introduced artifacts. These noises and artifacts are within the frequency band of interest and have similar characteristics to the ECG signal itself. To extract useful information from the noisy ECG signal, we need to process the raw ECG signal.
Functionally, ECG signal processing can be broadly divided into two stages: preprocessing and feature extraction (as shown in Figure 3). The preprocessing stage eliminates and reduces noise in the raw ECG signal, while the feature extraction stage extracts diagnostic information from the ECG signal.
Figure 3. Typical ECG signal processing flowchart
Using the signal processing capabilities in LabVIEW, users can easily create two-stage signal processing applications, including baseline drift elimination, noise removal, QRS complex detection, and fetal heart rate detection.
The following section will focus on discussing typical ECG signal processing methods using LabVIEW.
ECG signal preprocessing
ECG signal preprocessing can help users remove contaminants from ECG signals. Broadly speaking, ECG signal contamination can be categorized as follows:
• Power line interference
• Electrode separation or contact noise
Artifacts introduced during patient electrode movement
• Electromyography (EMG) noise
• Reference drift
Of these noises, power line interference and reference drift are the most significant and can strongly affect ECG signal analysis. Besides these two, other noises, which may be broadband and involve complex random processes, can also distort ECG signals. Power line interference is narrowband noise centered at 60 Hz (or 50 Hz), with a bandwidth of less than 1 Hz. Typically, power line interference can be eliminated by the ECG signal acquisition hardware or through software notch filters. However, reference drift and other broadband noises are difficult to suppress with hardware. Software design, therefore, offers a more powerful and feasible approach to ECG signal processing. Users can use the following methods to eliminate reference drift and other broadband noise.
Eliminate reference drift
Reference drift typically originates from respiration, with frequencies between 0.15 and 0.3 Hz, and can be suppressed using a high-pass digital filter. Users can also eliminate reference drift by using wavelet transform to remove trends in the ECG signal.
1. Digital Filter Method
LabVIEW's graphical and interactive approach allows for the efficient design and implementation of finite impulse response (FIR) or infinite impulse response (IIR) filters. For example, users can use the Classical Filter Design Express VI to design a Kaiser window FIR high-pass filter to eliminate reference drift. Figure 4 shows an example of using a high-pass filter to eliminate reference drift.
Figure 4. Design and use of a high-pass filter to eliminate reference drift.
2. Wavelet Transform Method
Besides digital filters, wavelet transform is also an effective method for eliminating signals within a specified frequency band. The LabVIEW Advanced Signal Processing Toolkit provides wavelet detrend functions, which can eliminate low-frequency trends in signals. Figure 5 shows a program example of using wavelets to eliminate reference drift.
Figure 5. Using WA Detrend VI to eliminate baseline drift
The example uses the Daubechies6 (db06) wavelet because this wavelet is similar to the actual electrocardiogram signal.
Figure 6 shows the original ECG signal and the ECG signals obtained after processing by digital filtering and wavelet transform. It can be seen that the processed ECG signals retain the main characteristics of the original ECG signal while containing almost no reference drift information. It can also be noted that the wavelet transform-based method is more advantageous because it does not introduce delay and has less distortion than the digital filtering method.
Figure 6. Comparison of methods based on digital filters and wavelet transform.
Eliminate broadband noise
After eliminating the reference drift, the resulting ECG signal is clearer and more stable than the original signal. However, other types of noise can still affect feature extraction from the ECG signal. These noises are often complex, broadband random processes, so traditional digital filters cannot be used; instead, the wavelet denoising function in LabVIEW can be utilized.
The electrocardiogram (ECG) signal is decomposed into individual subbands using wavelet transform, and then the wavelet coefficients are adjusted using thresholding or contraction functions. Finally, the noise-reduced signal is reconstructed. The figure below shows how broadband noise is greatly suppressed while the details of the ECG signal are preserved through unsampled wavelet transform (UWT) in LabVIEW.
Figure 7. Electrocardiogram signals before and after UWT wavelet denoising.
Feature extraction of electrocardiogram signals
For diagnosis, various features need to be extracted from the preprocessed ECG data, including QRS interval, QRS amplitude, PR interval, ST interval, and fetal heart rate. Here, we take QRS complex detection as an example.
Detecting the R-peak and QRS complex in electrocardiogram (ECG) signals can provide information about heart rate, conduction velocity, the state of various tissues within the heart, and various abnormalities. It provides a basis for the diagnosis of heart diseases, and therefore has attracted considerable attention in the field of ECG signal processing. However, noise and time-varying morphology make detection very difficult.
Because wavelets can extract and analyze key features of noisy signals by leveraging their multi-resolution advantage, many wavelet-based detection methods have been proposed in recent years. In this paper, the Multiscale Peak Detection function in the LabVIEW Advanced Signal Processing Toolkit is used to detect Q, R, and S points. Before peak/trough detection, the ECG signal is decomposed into 8-level Daubechies6 (db06) wavelets using the Multiresolution Analysis Express function, and then the signal is reconstructed using the D4 and D5 subbands. The reason for using the D4 and D5 subbands for reconstruction is that almost all QRS details are located in these two subbands, making QRS detection more accurate.
Figure 8. Implementation of multi-resolution analysis and QRS wave detection of electrocardiogram signals.
Figure 9 shows the ECG signal after wavelet multi-resolution analysis (MRA) and peak/trough detection processing, as well as the original ECG signal (from the MIT-BIH database). In this figure, it can be seen that the peaks and troughs (especially the Q and S points) become more pronounced after wavelet multi-resolution analysis.
Figure 9. Original ECG signal, ECG signal after MSA, and ECG signal after peak/trough detection.
After QRS complex detection, other methods can be used for feature analysis. For example, heart rate variability (HRV) analysis can be performed using RR interval signals to show the state of the heart and nervous system.
LabVIEW Biomedical Electron Starter Kit
The above describes how LabVIEW's powerful signal processing capabilities can be used to implement various custom ECG analysis algorithms. This article only introduces some of the more mature and effective algorithms in LabVIEW and uses them to illustrate the processing flow of ECG signals.
In addition to developing applications using LabVIEW, NI also provides the latest Biomedical Electrophysiology Starter Kit, which integrates ECG feature extraction algorithms and a user interface. See Figure 10. The kit not only supports the acquisition of clinical ECG signals through the NI data acquisition platform but also supports reading file formats from various professional databases such as MIT-BIH. Furthermore, besides its built-in wavelet analysis for QRS, P, and T wave detection, it also provides open-source algorithms that support user-defined ones. Finally, the ECG feature extraction results can be exported to TDMS files. For further signal analysis, such as heart rate variability (HRV) analysis, the biomedical electrophysiology toolkit also provides ready-made functions for direct use, as shown in Figure 11.
In addition, LabVIEW and the Biomedical Toolkit can also be used in other biomedical signal processing fields, such as electroencephalography (EEG), electromyography (EMG), and magnetic resonance imaging (MRI) 3D imaging.
Figure 10 ECG feature extraction function provided by LabVIEW Biomedical Electron Toolkit
Figure 11 Heart rate variability analysis provided by LabVIEW Biomedical Electronics Toolkit
Summarize
LabVIEW and the Biomedical Electron Toolkit provide a robust and efficient environment and tools for solving ECG signal processing problems. Users can easily and quickly develop solutions for cardiac disease diagnosis and ECG signal research, including noise reduction, analysis, and extraction of ECG signals, using readily available analysis algorithms in the toolkit or custom algorithms implemented through LabVIEW's graphical programming interface.