A signal conditioning module for denoising Electrocardiogram signals

: In this work, we propose to use an optimal multiband filter with least mean square algorithm to design a signal conditioning module for denoising Electrocardiogram (ECG) signals contaminated with predominant noises. The module is implemented on a Field Programmable Gate Array (FPGA) hardware. The experimental results of the proposed module are investigated and compared using an ECGID database available on Physionet. Quantitative and qualitative analysis is performed using Signal to Noise Ratio (SNR), Mean Square Error (MSE), and quality indexes to assess the effectiveness of the module. The average values of SNR are 10.90124, and MSE is 0.001761, indicating the successful elimination of noises in the filtered ECG signal using the proposed module. The signal quality indexes also demonstrate that the relevant information for diagnosing cardiac functionality is preserved. Furthermore, the performance of the designed module is tested on ECG signals obtained from electrodes placed on the human body. The Spartan 3s500efg320-5 FPGA device is employed to implement the filter design module using the partial serial architecture.


Introduction
The Electrocardiogram (ECG) signals are often contaminated with various types of noise, including noise due to body movement, skin electrode impedance, and electromagnetic interference from surrounding sources [1]. The primary noises that affect the morphological features of the ECG signal are Baseline Wandering (BW), Power Line Interference (PLI), and Electromyography (EMG). To accurately detect cardiac activities and abnormalities, efficient elimination of these noises and extraction of useful information from the ECG signal is crucial. This can be achieved through the utilization of an efficient Digital Signal Processing (DSP) module.
Several signal conditioning modules have been proposed using different DSP algorithms, and one common approach is to cascade Finite Impulse Response (FIR) and Infinite Impulse Response (IIR) filters [2,3,4]. The discrete wavelet technique (DWT) [5] and empirical mode decomposition (EMD) [6,7,8] based filter design approaches have also been proposed, but limited work has been done on the implementation of such algorithms. Advanced filter design modules using neural networks [9,10] and adaptive filtering [11,12,13] have been proposed, but the stability and filter design for such algorithms depend on the availability of training datasets. In Ref. [14] and Ref. [15], signal processing modules were proposed for the cancellation of single noise sources, specifically PLI and BW noise, respectively. In contrast, our proposed module is designed to address the cancellation of three predominant noises. However, limited research work has been done on the implementation of signal processing algorithms on hardware with less resource utilization. The signal conditioning module is preferred for implementation on a Field Programmable Gate Array (FPGA) due to its re-configurability, inbuilt DSP functional block, and low cost [16,17,18]. In Ref. [17], an FPGA implementation of a Butterworth IIR low pass filter is designed to remove only high-frequency EMG noise and implemented using Verilog. The DWT is used for denoising of ECG signals with a comparison of resource utilization on different FPGA boards [18]. In Ref. [2], a cascaded four-stage adaptive filter is designed to eliminate the predominant noises from the ECG signal sequentially. Whereas, in Ref. [19], BW and PLI noises are removed simultaneously using Discrete Fourier Transform filters. A supervised training-based neural network with deep factor analysis is used for denoising of ECG signals in Ref. [9]. However, noise models are required as a reference signal for the adaptive filter and training phase for neural network algorithms.
In this work, an optimal multiband FIR filter based on the least mean square algorithm is designed to simultaneously remove BW, PLI, and EMG noises from inherently noisy ECG signals. The proposed design is experimentally evaluated on 20 records of noisy ECG datasets from ECGID database. Additionally, the proposed filter design is also experimentally validated on the real-time ECG signals captured using skin surface electrodes. Quantitative and qualitative analysis using different parameters have been performed to demonstrate the effectiveness of the proposed module. The proposed Direct Form-I filter structure is implemented using a partial serial Hardware Description Language (HDL) architecture on the Spartan 3s500efg320-5 FPGA device with the XILINX ISE simulator platform. The main contributions of the proposed work are summarized as follows: • A less-order Direct form multiband FIR structure is designed, which effectively removes the major noises simultaneously. • The performance of the filter structure is evaluated on the records of the noisy ECG database as well as real-time ECG. • Quantitative and qualitative analysis are performed to verify the efficiency of the proposed module.
• The module was developed by implementing HDL partial serial architecture on FPGA hardware.
The remainder of this paper is organized as follows: Section 2 provides information about the materials and methodology used to develop the module. In Section 3, experimental results are discussed along with their FPGA hardware implementation. The conclusion of the proposed work is given in Section 4.

Methods and Materials
In this work, a signal conditioning module is designed to remove unwanted signals from real-time ECG signals using an FPGA hardware device. Figure 1 illustrates the methodology employed for implementing the signal conditioning module for ECG signals on an FPGA platform. The proposed methodology improves the quality of acquired ECG signals, which is helpful in extracting useful information required for the diagnosis of cardiac activity.

Database
In this work, Physionet ECGID database [20] is used as a test signal to validate the filter design performance. Twenty distinct noisy ECG records are considered for experimental purposes. The sampling frequency of the records is 500 Hz, and duration of 10 seconds is considered. Each record of the ECGID database is provided with two categories of ECG signals, namely signal 0 and signal 1. Signal 0 refers to the noisy ECG signal, while signal 1 is the filtered version of signal 0 and is considered a benchmark clean ECG signal for qualitative analysis. Moreover, the final design is also tested on a real-time ECG dataset obtained using adhesive disposable surface electrodes.

Filter algorithm for signal conditioning module
In the noisy ECG signal, different types of noise are present in different frequency regions. To remove such noises simultaneously from the ECG signal, cascading of low pass, band pass, and high pass filters is required. Instead of using a cascade design, a single linear-phase FIR multiband filter [21] is designed, which is easier to implement on a hardware platform. Here, a linear-phase FIR filter is designed for stability, ease of implementation, and retention of useful information. The windowing method and frequency sampling method are easy to design. However, both methods do not allow precise control of the critical frequencies in the transition band and can result in the ringing effect. Therefore, an optimal method for FIR filter design is adopted. The frequency response of the N-length FIR multiband filter is given as [22] H where h n are impulse response coefficients. While designing of multiband filter, h n are obtained using least square error optimization function defined as where h dn are M samples of the desired impulse response. The selection of M samples such that M ≫ N. Here, an ideal desired impulse response is formulated as the sum of simple ideal low pass filters with transition band [23]. The number of B(b) transition bands is taken based on the desired specifications needed for elimination of noises. Finally, the desired response of multiband filter is formulated as The specification for the designed multiband filter is given in Table 1.

Parameters for analysis
The designed signal conditioning module is validated through quantitative analysis using the ECGID database. Two performance metrics, namely SNR and MSE, are considered for evaluation. SNR F is the standard metric used to quantify the presence of noise in the filtered ECG signal from an energy perspective and is calculated as follows SNR F = 10 log 10 1 where ECG Clean is the clean available as signal 1 in the ECGID database while ECG Filtered is the filtered ECG output. The MSE is the mean of the squared error difference between the filtered and clean ECG signals and is given by It is important to verify the ability of the filter algorithm to attenuate artifacts while maintaining the useful information of the ECG signal for clinical inspection. The necessary information that it needs to be preserved during the processing of ECG signals is mentioned in Ref. [24]. Here, the filter signal quality indexes are proposed in Ref. [1] to validate the performance of the filter design. Two signal quality indices are investigated for the filtered signal with respect to the noisy signal by measuring the power present in particular frequency bands.
The baseline signal quality index (SQI BL ) is derived from the ratio of the baseline power to the interested ECG signal power, as given in Ref. [24] and Ref. [25]. The baseline power is mainly present in the ECG signal due to breathing and lies between the frequency ranges of 0-2 Hz [24]. The range of frequency for the interested ECG signal is approximately from 0-40 Hz [24,25]. The SQI BL is defined as where p( f ) refers to power of ECG signal. The range of SQI BL is between zero to one. A value of SQI BL near one indicates that the ECG signal contains useful signal power, while a value near zero indicates that the ECG signal contains noisy or corrupted data. The value of SQI BL implies the ability to remove unwanted BW noises while maintaining important information present in the ECG signal. The QRS complex wave is an important aspect of the ECG signal in terms of maintaining morphological information for clinical inspection. While processing the ECG signal, one should be concerned about retaining the information present in the QRS wave. The QRS wave signal strength occurs approximately between the frequency range of 5 to 15 Hz [25]. The signal quality index for QRS signal (SQI QRS ) is defined as The value of SQI QRS for filtered ECG signal nearer or higher than the value of SQI QRS for noisy signal indicates that QRS complex is retained in the ECG signal without loss of information.

Hardware description
For hardware implementation of digital filters, we used the Spartan 3s500efg320-5 FPGA board, which is a versatile and powerful platform for developing and testing FPGA designs and is suitable for digital signal processing applications. The Spartan 3s500efg320-5 FPGA belongs to the Spartan-3 family of FPGAs developed by Xilinx. It consists of 4656 logic cells and 9312 flip-flops, providing significant programmable logic resources for implementing complex digital circuits. Additionally, it features 20 multipliers and 1164 Configurable Logic Blocks (CLBs), which offers flexibility in designing and implementing custom logic functions. The code of the multiband filter design is simulated, synthesized, and implemented using the Integrated Synthesis Environment (ISE) tool.

MATLAB Simulation
The proposed multiband filter was designed using MATLAB software for signal conditioning of ECG signals. The performance of the design was evaluated using records from the Physionet ECGID database as well as on the real-time ECG signal captured using skin surface electrodes. The optimal least mean square-based method was used to obtain the coefficients of the multiband FIR filter, and the filter order was selected to achieve the required attenuation in the stop bands. The magnitude versus frequency plot of the designed filter is shown in Figure 2, which demonstrates significant attenuation in the low and high-frequency stop bands with fewer passband ripples.
We evaluated the performance of the designed filter by utilizing various records of noisy ECG signals as inputs from the ECGID database, and subsequently analyzed the results through qualitative analysis. The time domain response of the noisy real-time ECG signal taken from the ECGID database for sample number 1 is shown in Figure 3(a) and the filtered ECG signal from the proposed multiband filter is shown in Figure 3(b). Additionally, the experimental investigation is also performed on real-time ECG signals  captured using skin surface electrodes with a sampling frequency of 500 Hz. The electrodes were interfaced with a computing system using an Arduino board and taken as an input to the designed multiband filter in MATLAB software. The time domain response of the noisy real-time ECG signal and filtered ECG signal are shown in Figure 4(a) and (b), respectively. The smoothness of the obtained filtered ECG signal indicates that high-frequency noises were successfully eliminated. The visual inspection of Figure 4 shows that the proposed multiband filter design retained the morphological characteristics of the processed ECG signal along with clinical information. The shift in the baseline of the filtered ECG signal indicates that bias due to low-frequency noises was eliminated. To further ensure the elimination of BW, PLI, and EMG noises, frequency domain analysis was performed on real-time ECG signal. The frequency domain analysis of the real-time ECG signal before and after filtering is shown in Figure 5 and Figure 6, respectively. The frequency domain analysis of the filtered ECG signal in Figure 6 shows that noises were attenuated from the noisy ECG signal.

Quantitative and Qualitative analysis
In this subsection, we conduct quantitative and qualitative analyses on the filtered signal using metrics such as Signal-to-Noise Ratio (SNR), Mean Squared Error (MSE), and two signal quality indices. The quantitative analysis is performed using the equations (4) and (5) on 20 samples of the ECGID database, and its SNR output along with MSE is given in Table 2. The average SNR out value obtained for the filtered signal for the 20 sets of records is 10.90124, with an average SNR input of -1.969682. The average SNR improvement over the 20 records is 12.87092. The MSE of the filtered signal obtained by taking the average  of 20 records is 0.001761, with an average input error of 0.06579335. The signal quality indexes, described in section 2, are experimentally investigated to find the effectiveness of the proposed filter algorithm on 20 records of noisy ECG signals taken from the ECGID database. The SQI BL and SQI QRS are calculated using equations (6) and (7) for noisy 'signal 0' and filtered 'signal 1' ECG signals given in the database, as well as for the filtered ECG using the proposed filter design. The obtained results are given in Table 2 for comparison with benchmark dataset and analysis. The wide range for SQI BL values of noisy ECG records from 0.1394 to 0.8274 shows that records of both low and highly corrupted ECG with BW noise are considered. The closeness of SQI BL values nearer to zero indicates the high presence of BW noises. The average SQI BL value obtained for proposed filter is 0.901325, compared to filtered ECG given in Ref. [20], which is 0.796355. The closeness of SQI BL value nearer to one shows that the proposed filter design is able to remove BW noise efficiently. The average value of SQI QRS for the noisy ECG record is 0.57476, for the proposed filter is 0.592325, and for the filtered ECG given in Ref. [20] is 0.608455. The closest value of the proposed filter with the noisy ECG record indicates that the energy of QRS complexes is retained.

FPGA Implementation
For FPGA hardware implementation, the obtained filter coefficients of the multiband filter from MATLAB software are quantized to 16 bits, and the input ECG record is quantized to 12 bits. The hardware signal processing module is designed using the Very High-Speed Integrated Circuit (VHSIC) Hardware Description Language (VHDL) using XILINX ISE software. The VHDL codes for multiband FIR filter module are synthesized using various HDL architectures, including parallel, serial, and partial serial implementations. A partial serial architecture is a type of digital circuit design that uses both serial and parallel processing to optimize for area and performance. In a partial serial architecture, the data is processed in parallel up to a certain point, and then the remaining processing is done serially. This can help to reduce the number of resources needed to implement the circuit, while still maintaining high performance. To optimize for area depending upon the available resources in an FPGA, the partial serial architecture can be tailored to use the available resources in the FPGA as efficiently as possible. In the proposed work, partial serial architecture is used with 2 multipliers for the optimization of the area and speed of the module. The FPGA resource utilization summary is given in Table 3.
After generating codes of filter design using VHDL, the Register Transfer Level (RTL) design is synthesized which is a netlist of logic gates and flip-flops that can be implemented in hardware. The behavioral simulation waveform of the proposed signal condition module is shown in Figure 7. The synthesized RTL design is then implemented on a Spartan 3s500fga320-5 device. After simulating, synthesizing, and implementing the VHDL code of the multiband filter design, a bit file is generated. The bit file contains the instructions for programming the Spartan 3E device. The bit file is then targeted to the Spartan 3E device via a Joint Test Action Group (JTAG) cable.
The designed multiband filter is capable of eliminating all predominant noises from the ECG signal, in contrast to other design methods proposed by Ref. [12,13,15,17,19], which focus on removing one or two types of noise at a time. The cascade approach used by Ref. [2] eliminates all predominant noises sequentially, which increases the design complexity and cost for hardware implementation. Similarly, the methodology adopted by Ref. [2,9] improves the quality of the filtered ECG, but researchers have not extended their work to hardware requirements and implementation. In contrast, the multiband filter designed in this work provides an efficient and effective solution for eliminating noise from the ECG signal, with a lower implementation cost and complexity. By targeting multiple frequencies simultaneously, the  Table 3. FPGA Resource Utilization.

Discussion
The proposed signal conditioning module achieved the average SNR improvement of 12.87 for records of 20 samples as compared to Ref. [26], where they achieved an SNR improvement of 5.5 for the same dataset with 10 records. However, most research works are carried out on the MIT-BIH dataset, which provides arrhythmia data by considering added noises. In Ref. [8] and Ref. [14], they achieved an average SNR of 21.78 and 25.2, respectively, but they are considering a module to remove one noise at a time, while we have proposed a module to remove three predominant noises. The separately added EMG and PLI noise on the MIT-BIH dataset is considered by Ref. [12], which achieved SNRs of 15.8 and 25, respectively, for only 8 samples. In Ref. [15], an SNR of 20 is achieved, but they have considered only BW noise for 8 samples. However, we have considered 20 different samples that have inherent noises and achieved good quantitative results. Furthermore, we have extended our work with qualitative analysis and capturing real-time ECG signals. The above-discussed research work is limited to simulation results only, while the proposed module is implemented on the FPGA hardware platform.

Conclusion
A signal conditioning module was proposed for denoising ECG using a multiband filter design, which was implemented on FPGA hardware. The multiband filter can simultaneously eliminate three predominant noises present in different frequency bands from ECG signals. Validation of the filter design is carried out using performance parameters such as SNR, MSE, and quality index. Statistical improvement in SNR and MSE indicates that the proposed module can efficiently remove noise. The obtained results of quality indexes show that morphological characteristics and useful information are preserved in the filtered ECG signal. The multiband filter design module is implemented on the FPGA hardware with less implementation cost using partial serial architecture, which reduces resource utilization compared to cascade filter designs. The efficiency of the proposed filter design is experimentally verified using real-time ECG signals. The proposed signal conditioning module is implemented on the Spartan 3s500efg320-5 device, utilizing 55% Flip flops, 34% LUTs, 20% Bonded IOBs, and 10% MULT18X18SIOs. Furthermore, future research can extend the signal conditioning module to incorporate a classification module for the diagnosis of cardiac abnormalities.