0% found this document useful (0 votes)
60 views5 pages

FIR Filter For ECG Signal Filtering

Uploaded by

aryankriti28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views5 pages

FIR Filter For ECG Signal Filtering

Uploaded by

aryankriti28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

FIR Filter Design for Electro Cardiogram (ECG) Signal Filtering

Milind Tirmare Ashish Rodi


Electronics and Telecommunication Electronics and Telecommunication
Vishwakarma Institute of Technology Pune, India Vishwakarma Institute of Technology Pune, India
[email protected] [email protected]

Samarth Arole Aryan Mundra


Electronics and Telecommunication Electronics and Telecommunication
Vishwakarma Institute of Technology Pune, India Vishwakarma Institute of Technology Pune, India
[email protected] [email protected]

Abstract- In this study, we present a comprehensive approach information. Common sources of noise include baseline
to generating and processing realistic electrocardiogram (ECG) wander caused by respiratory movements, muscular noise
signals while addressing common noise artifacts encountered in arising from body movements, and power line interference
clinical settings. We simulated a standard ECG waveform
from the electrical grid. These artifacts complicate the
using Gaussian pulses to accurately model the PQRST
morphology, integrating heart rate variability through
analysis and interpretation of ECG signals, necessitating the
sinusoidal modulation. To emulate real-world conditions, implementation of robust signal processing techniques to
various noise types were introduced, including baseline enhance their quality.
wander, muscle noise, power line interference, and white
measurement noise. An FIR single pass-band filter designed In this study, we propose a comprehensive framework for
using a Hanning window was employed to mitigate these simulating realistic ECG signals while incorporating
disturbances effectively, preserving the integrity of the ECG physiological variability, followed by advanced filtering and
signal. The performance of the filtering technique was smoothing techniques to improve signal fidelity. A key
evaluated using several metrics: Mean Squared Error (MSE),
component of our approach is the design of a finite impulse
Signal-to-Noise Ratio (SNR), Peak Signal-to-Noise Ratio
(PSNR), and Root Mean Square Error (RMSE). Additionally, response (FIR) filter using a Hanning window. The Hanning
the Savitzky-Golay filter was applied for further smoothing of window is particularly effective due to its ability to
the processed signal. Results demonstrate significant minimize spectral leakage, which can occur during signal
improvements in the quality of the ECG signal after filtering, processing. Unlike rectangular windows, which can
highlighting the effectiveness of the proposed methods in introduce significant side lobes in the frequency domain, the
enhancing ECG signal fidelity. The frequency response of the Hanning window provides a smoother transition at the
designed FIR filter was analyzed to ensure optimal edges, thus preserving the integrity of the signal's spectral
performance within the specified pass-band. This work content. This characteristic makes it an optimal choice for
contributes to the field of biomedical signal processing by
providing robust techniques for ECG signal enhancement,
applications where maintaining frequency information is
which are crucial for accurate diagnosis and monitoring in critical, such as in ECG analysis.
cardiac healthcare.
Keywords – multi-band FIR filter, Hanning window, signal to Moreover, we employ smoothing techniques, specifically
noise ratio, mean squared error, fast Fourier transform, the Savitzky-Golay filter, which enhances the filtered signal
frequency response by fitting successive sub-sets of adjacent data points with a
low-degree polynomial. This method not only reduces high-
I. INTRODUCTION frequency noise but also preserves important features of the
Electrocardiography (ECG) is a critical non-invasive ECG waveform, such as the P, Q, R, S, and T peaks, which
diagnostic tool that records the electrical activity of the heart are vital for clinical diagnosis. By effectively mitigating
over time. This physiological monitoring technique provides noise while retaining the original signal's morphology, the
clinicians with invaluable information regarding cardiac Savitzky-Golay filter plays a crucial role in enhancing the
health, including the heart's rhythm, rate, and electrical overall interpretability of the ECG signal.
conduction pathways. By capturing the characteristic
PQRST waveform, healthcare professionals can identify a In summary, this research highlights the significance of
range of cardiovascular conditions, from arrhythmias to accurate ECG signal processing, presenting an integrated
ischemic heart diseases. The accuracy and reliability of ECG approach that combines signal simulation, noise
interpretation are paramount, as misdiagnosis can lead to introduction, FIR filtering with a Hanning window, and
inappropriate treatment strategies and potentially polynomial-based smoothing. The findings aim to improve
detrimental patient outcomes. diagnostic capabilities in cardiovascular care by ensuring
high-quality ECG recordings that can be reliably analysed
Despite its importance, the ECG signal is often plagued by by healthcare professionals.
various types of noise and artifacts, which can significantly
degrade signal quality and obscure vital diagnostic

XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE


II. METHODOLOGY filter based on the specified cutoff frequencies and
The methodology employed in this study encompasses windowing function. This implementation not only
several stages, including ECG signal generation, design and enhanced the filter's performance but also provided a smooth
implementation of a Hanning window for FIR filtering, frequency response that is crucial for preserving the
band-pass filtering, smoothing of the signal, and evaluation morphological features of the ECG.
of the resultant signal quality using various performance
metrics. Each stage is elaborated upon below: d. Frequency Response Analysis
To evaluate the characteristics of the designed FIR filter, we
a. ECG Signal Generation performed a frequency response analysis using the freqz
To initiate our study, we first simulated a realistic ECG function in MATLAB. This analysis provides insight into
signal. The simulation was based on a time vector that how the filter responds across the frequency spectrum,
spanned 5 seconds at a sampling frequency of 250 Hz, including its gain and phase shift characteristics. By plotting
corresponding to a Nyquist frequency of 125 Hz. We the magnitude and phase response, we confirmed that the
established a baseline heart rate of 75 beats per minute, filter effectively attenuated frequencies outside the
which translates into an average RR interval of 0.8 seconds. designated pass-band while allowing the relevant ECG
To introduce physiological variability, we incorporated heart frequency components to pass through with minimal
rate variability (HRV) as a sinusoidal modulation of the RR distortion. This step was vital for ensuring the filter's
interval. The variability was represented mathematically as a efficacy in enhancing the ECG signal while mitigating the
low-frequency sinusoidal function, which enabled the effects of noise.
simulation of a more realistic cardiac rhythm. Next, we
constructed the characteristic PQRST waveform using e. Band-Pass Filtering
Gaussian functions to represent the different components of The next stage involved applying the designed FIR filter to
the ECG cycle: P-wave, Q-wave, R-wave, S-wave, and T- the noisy ECG signal. We utilized the filtfilt function in
wave. Each component was assigned specific amplitude MATLAB to perform zero-phase filtering, which eliminates
values and time delays, ensuring the overall morphology phase distortion that can arise from conventional filtering
matched that of a typical ECG. The individual waveforms methods. This technique is particularly important in ECG
were then combined to create a continuous ECG signal. This analysis, where the timing of the waveform features is
generated ECG signal served as the basis for subsequent critical. The filtered output provided a cleaner version of the
noise introduction and filtering. ECG signal, significantly reducing the amplitude of noise
components while preserving the essential characteristics of
b. Noise Introduction the ECG waveform.
To mimic the various disturbances encountered in real ECG
recordings, we deliberately introduced multiple noise types, f. Smoothing of the Signal
including baseline wander, muscle noise, power line Following the band-pass filtering, we employed a Savitzky-
interference, and measurement noise. The baseline wander Golay filter for further signal smoothing. This technique fits
was modelled as a low-frequency sinusoidal function, a polynomial to successive sub-sets of adjacent data points,
simulating the effects of respiratory movements. Muscle effectively reducing high-frequency noise while retaining
noise was represented as Gaussian random noise, which the important morphological features of the ECG signal. The
reflects the electrical activity of nearby muscle tissues. polynomial order was set to 4, and the frame length was
Power line interference was introduced at 50 Hz, a common chosen as 41 samples, which is an odd number to ensure a
frequency in many regions, and measurement noise was symmetric window. The application of this smoothing
simulated as white Gaussian noise. The resultant noisy ECG technique not only enhanced the visual clarity of the ECG
signal was a composite of the original signal and the added signal but also facilitated more accurate peak detection and
noise components, thereby creating a realistic yet feature extraction, which are crucial for clinical
challenging scenario for signal processing. interpretation.

c. Hanning Window Parameter Selection and g. Evaluation Metrics


Implementation To assess the performance of our signal processing
A critical aspect of our methodology was the design of a approach, we employed several evaluation metrics to
finite impulse response (FIR) band-pass filter utilizing the compare the clean simulated ECG, the noisy ECG, the
Hanning window. The Hanning window was chosen due to filtered ECG, and the smoothed ECG. The metrics included:
its favourable characteristics in reducing spectral leakage, Mean Squared Error (MSE): This metric quantifies the
which can compromise the fidelity of the filtered signal. The average squared difference between the reference and
filter was designed with a cutoff frequency range from 0.5 processed signals, providing a measure of signal fidelity.
Hz to 17 Hz, effectively capturing the primary frequency Root Mean Square Error (RMSE): Derived from the MSE,
components of the ECG signal while attenuating noise RMSE expresses the error in the same units as the signal
outside this range. itself, offering an intuitive sense of deviation.
The FIR filter's order was set to 150 taps, ensuring a Signal-to-Noise Ratio (SNR): This metric compares the
sufficient transition bandwidth while maintaining a power of the clean signal to the power of the noise,
computationally efficient implementation. The filter indicating how much the signal has been improved after
coefficients were generated using the fir1 function in processing.
MATLAB, which computes the impulse response of the
Peak Signal-to-Noise Ratio (PSNR): PSNR provides a IV. RESULTS AND DISCUSSION
measure of the maximum possible signal power relative to
the noise power, expressed in decibels (dB), and is Simulation Results
particularly relevant for assessing signal quality in image
and audio processing, and by extension, ECG signal
processing. By analysing these metrics, we gained insights
into the effectiveness of our filtering and smoothing
techniques, thereby demonstrating the improvements
achieved through our proposed methodology.
Fig1. FFT of original signal
III. EQUATIONS

Fig 2. FFT of noisy ECG signal

Hanning Window Fig 3. FFT of single pass band Passed ECG Signal
2 πn
w[n] = 0.5 (1−cos( )) for 0≤n≤N−1
N −1
Hamming Window
2 πn
w[n] = 0.54−0.46 cos( ) for 0≤n≤N−1
N −1
Blackmann Window
2 πn 4 πn Fig 4. FFT of single pass band after smoothening
w[n] = 0.42−0.5 cos( ) + 0.08 cos( )
N −1 N −1
for 0≤n≤M−1
Kaiser Window

√ ( )
2
2n
1− −1
w[n]=I0(πβ N−1 )
I 0 ( πB)
for 0≤n≤M−1
Miscellaneous
60
RR interval =
Heart Rate
−¿¿
y(t)=A⋅ e
A is the amplitude, μ is the mean, which defines the
centre of the peak,
σ is the standard deviation, which controls the width of
the wave and t is the time variable. Fig 5. Frequency response of proposed FIR filter
P signal
SNR=10 log10( )
P noise
2
I
PSNR=10log10( max ) here Imax is max possible value
MSE
N
1
MSE = ∑
N n =1
(original−noise signal )2
RMSE = √ MSE
Fig 6. Time Domain Analysis of original ECG signal and Fig 7. Time Domain Analysis of band pass and band pass
noisy ECG signal with Savitzky-Golay smoothening (Proposed approach)

Table1. Analysis of different filters

Sr. Filter Type SNR (dB) MSE PSNR (dB) RMSE


No.
1 Rectangular Band Pass 1.08 0.04250 13.7 0.20614
2 Hanning Band Pass 2.32 0.03192 14.95 0.17866
3 Hamming Band Pass 1.15 0.04185 13.77 0.20458
4 Kaiser Band Pass 2.58 0.03066 15.12 0.17510
5 Kaiser Low Pass -0.15 0.05636 12.48 0.23740
6 Hanning Low Pass 0.12 0.05301 12.74 0.23023
7 Hanning with Savitzky- 3.48 0.02247 16.10 0.15644
Golay smoothening
(Proposed)

Table 2. Main and Side Lobe analysis


Sr. Window Function Main Lobe Width Side Lobe Attenuation
No.
1 Hanning Narrow Moderate
2 Hamming Narrow Lower than Hanning
3 Blackman Wide High
4 Kaiser Adjustable Adjustable
5 Rectangular Narrowest Poor

In selecting the best window function for our project, we though adjustable, introduces unnecessary complexity and
found that the Hanning window offered the most balanced requires tuning to achieve similar performance. In
performance between frequency resolution and side-lobe contrast, the Hanning window offers a practical balance
attenuation. The Hanning window provides a narrow main between resolution and leakage reduction, making it the
lobe, ensuring good frequency resolution to distinguish most suitable choice for our needs.
closely spaced frequency components, while its side-lobe
attenuation of -31 dB effectively reduces spectral leakage. IV. FUTURE SCOPE
This moderate attenuation significantly improves upon the
rectangular window, which has very poor leakage In the future, the functionality of applying window
suppression (-13 dB), despite its slightly narrower main functions such as the Hanning window can be developed
lobe. Compared to the Hamming window, which offers and implemented on hardware platforms like the Spartan-
better side-lobe suppression (-41 dB), the Hanning 6 FPGA for real-time signal processing applications.
window was chosen for its consistency and simplicity, Leveraging the parallel processing capabilities and high-
performing well across a wide range of signals without speed performance of FPGAs, the windowing operation
needing adjustments. While the Blackman window can be optimized for low-latency and high-throughput
delivers excellent side-lobe attenuation (-58 dB), it comes systems. By designing efficient hardware architectures,
at the cost of a much wider main lobe, reducing its ability such as using multipliers and adders in pipeline stages, the
to resolve closely spaced frequencies. The Kaiser window, window function can be applied directly to incoming
signal data streams, allowing for real-time spectral based on a thorough understanding of the trade-offs
analysis in applications like communications, radar, and associated with each window function and how they
audio processing. Additionally, implementing the impact the overall spectral analysis.
windowing function in hardware will allow for further
optimizations, such as dynamic window selection or VI. ACKNOWLEDGMENTS
adjustable window parameters, which can be controlled We would like to thank our college, Vishwakarma
through software interfaces. This approach would Institute of Technology, Pune and Prof. Milind Tirmare
significantly enhance the system’s capability to handle for giving us the opportunity to study and design a FIR
large datasets in real-time and broaden its application in (Finite Impulse Response) filter for an ECG signal to
fields requiring high-performance DSP (Digital Signal understand the real-life application this concept. We
Processing). would also thank the Electronics department for helping
us understand each component and helping us integrate
V. CONCLUSION them into our project.
In conclusion, this project has provided a comprehensive
analysis of different window functions, evaluating their
performance in terms of spectral leakage reduction and VIII. REFERENCES
frequency resolution. We explored the characteristics of [1] Reduction of power line interference in ECG Signal
using FIR filter. International Journal of
several widely used windows, including the Rectangular, Computational Engineering Research 2014
Hanning, Hamming, Blackman, and Kaiser windows, and
compared their main lobe width and side-lobe attenuation. [2] A Survey of noise removal techniques for ECG
Through this evaluation, we determined that the Hanning signals
window offers the best balance between minimizing International Journal of Advanced Research in
Computer and Communication Engineering 2013.
spectral leakage and preserving adequate frequency
resolution, making it the most appropriate choice for our
[3] Certain Investigation on hybrid Neural network
signal processing needs. method for classification of ECG signal with FIR
By selecting the Hanning window with multi passband, filter. Scientific Filters 2024.
we achieved a solution that balances good frequency
resolution and moderate side-lobe suppression, making it [4] Interference reduction in ECG signal using Digital FIR
filters based on rectangular window. WSEAS
a practical and effective choice for most real-world signal transaction on signal processing, 2018.
processing tasks. This decision was based on a thorough
understanding of the trade-offs associated with each [5] Removal of noise from ECG using Digital FIR and IIR
window function and how they impact the overall spectral filters with Various methods IEEE Xplore 2015.
analysis. The results of this project underscore the
importance of selecting the appropriate windowing [6] The comparison features of ECG Signal with
Different sampling frequencies and filter methods for
function for specific applications and provide valuable real time measurement. Symmetry journal 2021.
insights into the impact of these choices on signal analysis
outcomes. Ultimately, this project has deepened our [7] The use of FIR filter for filtering of ECG signal and
understanding of window functions, highlighting the Comparison of some parameters. International
Journal of Engineering Science Invention 2017.
importance of a balanced approach to reducing spectral
leakage while maintaining resolution in the frequency
domain.-world signal processing tasks. This decision was

You might also like