Design and Implementation of digital FIR band stop filter for removal artifact from noisy ECG signal

In Digital signal processing, FIR Band stop Filter used to remove an unknown noise component in ECG signal lying within a 60 Hz frequency range. This paper gives the design appropriate signal processing algorithms for the refinement of ECG signals so that their characteristics may be extracted: this involves the design of a digital filter for the elimination of the power line interference and determines the waveform characteristics (PR, QRS and ST intervals and PR and ST segments) of the available ECG recording. Comparison of these characteristics with those of normal ECG recordings provides a way of identifying problems with the human cardiovascular system


INTRODUCTION
Electrocardiogram (ECG) signal is some index of the functionality of the heart.For example, a physician can detect arrhythmia by studying abnormalities in the ECG signal.Since very fine features present in an ECG signal may convey important information, it is important to have the signal as clean as possible [1].Figure 1 shows a clean ECG signal.Power line interference is easily recognizable by interfering voltage in the ECG may have frequency 50/60 Hz [2].
The interference may be due to stray effect of the alternating current fields due to loops in the patient's cables.Other causes are loose contacts on the patient's cable as well as dirty electrodes.When the machine or the patient is not properly grounded, power line interference may occur.Figure 2 shows such a polluted ECG signal.In this paper, the processed ECG waveforms were taken from the MIT-BIH Arrhythmias Database and Mat lab help from the math work to design and write code for design IIR notch filter and FIR Band stop filter to remove power line noise from ECG.
The ECG signal we used is real clinical data and has been sampled at fs = 360Hz for a period of just over 10 seconds.The ECG signal we began with is plotted in the time domain with correct time axis along with the signal's FFT with correct axis as well [12].The results are seen in Figure 3.The average power spectrum of the ECG was computed as well and plotted on the same axis as the FFT of the ECG in Figure as well.This gives a very clear picture of the nature of our interference; that of a simple 60Hz sinusoid [3].
This design project is to leverage our knowledge of digital signal processing to remove an unknown noise component in a medical Electrocardiogram (ECG) signal.We begin by finding the Fast Fourier Transform (FFT) of our ECG signal.From the information gained by plotting the FFT of the ECG signal in the frequencydomain we proceed to design two types of digital filters to remove this interference.The first filter design is an infinite impulse response (IIR) notch filter.We examine the filter's amplitude and phase response which is followed by a discussion of the filter's effectiveness and practical consideration.We then examine the ECG signal both in the time and frequency domain after the notch filter is applied.Three Type 1 finite impulse response (FIR) filters of varying order are designed as well [11].As with the IIR notch filter the FIR filters effectiveness and practical considerations are discussed and the filtered data is examined in both the time and frequency domain.A comparison of the FIR filter results with those of the IIR filter logically follows.
Upon having a clean ECG signal the quantative properties of the data are determined from the IIR filtered ECG signal.This includes the PR, QRS and ST intervals along with the PR and ST segments.Lastly we discuss a method for automating extraction of the aforementioned intervals.

DESIGN AND IMPLIMENTATION OF DIGITAL FILTER
Four filters were designed all together, three FIR filters and an IIR.This was done for multiple reasons, including a realistic performance comparison and for a learning experience.

FIR BANDSTOP FILTER DESIGN
Three FIR filter designs were also implemented due to FIR filters' linear phase characteristics.The linear phase properties help preserve the important timing information as mentioned above.However, we must sacrifice a low order filter for this linear phase characteristic.This increase in filter order affects computational time and filter response time.To further illustrate the compromise between filter orders, computational time and filter response time FIR, filters of varying order were designed and implemented.FIR Type 1 filters of order m 0 = 50, m 1 = 100 and at the extreme of m 2 = 200 were designed.For all FIR designs the stop-band begins at F 0 = 58Hz and pass band begins at F 1 = 62Hz as to be symmetric around 60Hz.Equation 5shows the transfer function that was used for the FIR band-stop filter.

… (5)
Where h(i) is given by Equation 6and h(p) is given by Equation 7.
.. .( 6) … (7) Where T is the sampling period and is given by Equation 8.The magnitude and phase plot for all three FIR filters is shown in Figure 4.The FIR magnitude plots show that with increasing filter order, the sharper the transition bands of the filters are in addition to differing linear phase shifts.It is also noted that with increasing filter order the pass-band ripple decreases and attenuation at the center frequency increases.Focusing our attention now on the FIR filtered ECG signals in the time and frequency domain in Figure 5.We see that the varying filter orders affect the filtered signal in similar ways.It's clear from looking at the both the time domain and frequency domain plots for the FIR band-stop filter of order m 0 = 50 cannot adequately filter the noise out.referring back to Figure 5.We see that when m 0 = 100 the attenuation is Δ0.10.This appears to just not be enough attenuation for the noise which is present.This conclusion is further supported when the data is shown in the frequency domain.It's clear that the noise has a large amount of the signal strength.Moving on the filter of order m 1 = 200 we see much improved results.

… (8)
In the time domain the appears to be clear of almost all noise except for some pretty sever oscillations occurring for nearly the first two seconds of the signal.Shifting our attention to the frequency domain of this filter we see that the noise has dropped well below the level of the other frequencies present in the filtered signal.
The frequency domain plot also supports this stance in addition to further attenuation of adjacent frequencies.The attenuation of adjacent frequencies again relates to filter order.It's important to remember that filter order affects transition band "steepness".This is nicely portrayed by these plots because it immediately shows that, while in all cases some attenuation begins around our frequencies F 0 and F 1 , it is the most severe with the highest order filter because the attenuation even at the limits of the cutoff frequencies is very high.

RESULTS
After closely examining three Type 1 FIR band-stop filters of varying order, we found that FIR filter perform best overall due to the FIR filter's phase response is linear.This implies finite computational resources and keeping costs down.The FIR band-stop filter of order m 1 = 100 is shown in Figure 6.anything the notch filtered ECG data should have extra noise because looking at its FFT the 60Hz interference is not as attenuated as that of the FIR filtered ECG.Despite this due to the oscillations uniform distribution throughout the FIR filtered time domain signal, we believe it to be noise and not important to the signal.
A comparison of the noise extracted after subtracting the filtered signal from the original input in the time domain is also shown in Figure 7.

CONCLUSION
This paper proposed analysis of the noise polluted signal in both the time and frequency domains we came to understand the nature of the noise.From this understanding we designed and implemented three FIR band-stop filters.We compared the filtered signals produced by FIR filter and other filter's results and concluded that the IIR notch would be the best filter choice given the application and the likely DSP platform for actual implementation.In the end it gives better performance instead of one things delay time which should have been less but there's always ways to improve things.

Figure 2 :
Figure 2: ECG Signal polluted by power line noise.

Figure 3 :
Figure 3: ECG signal in time domain and frequencydomain.

Figure 4 :
Figure 4: FIR band-stop filter magnitude and phase plots.

Figure 5 :
Figure 5: FIR band-stop filtered ECG signal in time and frequency domain.

Figure 6 :
Figure 6: FIR band-stop of order m 1 = 100 filtered ECG compared to IIR notch filtered ECG.It is important to note though that upon closer inspection of the two signals in the time domain it appears that they do differ relatively significantly.The biggest difference is the shift in time.Specifically the Q peak of the FIR filter with order m 1 = 100 at ~ 2.15 seconds.Also there appears that the FIR filtered signal has some extra oscillations in it.It would seem like if

Figure 7 :
Figure 7: FIR band-stop computed interferences.for the notch filter and only the FIR band-stop filter of order m 1 = 100.These two signals look drastically different.The reason for this would seem to be the highly selective nature of the notch filter versus the band-stop's fidelity to our original specification that is our specifications called a band stop filter with a stop band of four Hertz.Its result indicates clearly that this paper give very satisfactory result for removal of power line noise in dynamic ECG signal.