0% found this document useful (0 votes)
13 views15 pages

Report Signal Petrai

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

Report Signal Petrai

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

MSc Biomedical Engineering

University of Patras
Associate Professor E. Dermatas
Student: Petrai Elissaios
[email protected]

Biomedical Signal Processing (Project)


ECG Processing

Patras 2018
Project 1: Two channels ECG - Remove artifacts and Noise
Theory
ECG Signal
Electrocardiogram (ECG) is the graphical representation of heart functionality. The ECG finds its
importance in the detection of cardiac abnormalities [1].
Electrical activity which is caused due to the muscle contraction gets reflected in the ECG signal
which is typically analyzed in the time domain. One normal sinus cycle of the ECG corresponds to
a single heartbeat. An ECG signal is typically labeled with the letters P, Q, R, S and T which
signifies its critical points as illustrated in Figure 1.
The frequency ranges from 0.67 to 120 Hz, and 0.67 Hz is the frequency (minimum) which is
observed when the pulse rate is 40 beats/min. Low frequency components consist of the P and T
waves (5–9 Hz) while the QRS complex resides at higher frequency.

Figure 1: ECG
The origins of these waves are:
1. P wave: sequential activation (depolarization) of the right and left atria
2. QRS complex: right and left ventricular depolarization
3. T wave: ventricular repolarisation
4. U wave: repolarisation of the papillary muscles, rarely seen
Noise and artifacts in ECG signals
Table 1: Types of ECG artifacts

Types of ECG artifact Cause


Baseline Wandering Baseline wander is a low-frequency component
present in the ECG system. This is due to offset
voltages in the electrodes, respiration, and body
movement. Baseline wander have frequency
greater than 1Hz.
Motion artifact Occurs when the skin is stretched, resulting in a
change to the skin voltage at the stratum
lucidum, the second layer down in the skin.
Muscle artifact (known as an Electromyography Generated by skeletal muscles. This noise occurs
(EMG) Noise) at the time of muscle activity during an ECG
recording especially in a stress test. This artifact
consist of maximum frequency of 10 Khz.
Electrostatic artifact When an electrostatically charged person moves
near the patient or ECG device, currents flow
through the high resistance of the stratum
corneum (top skin layer) and generate a voltage.
Poor contact artifact Caused by dried gel, excessive hair, poor
adhesion or when breaks in connectivity occur
anywhere between the electrode and the
monitor.
Electromagnetic Interference (EMI) Generated by items like power lines, cell phones
or radios; relatively uncommon.
Implanted stimulators Artifact is greatest in leads parallel to the
stimulus lead; pacemakers are common but other
stimulators are rare.

Biosignals are usually contaminated with artifacts from limb movements, muscular contraction or
electrical interference.
The identification of a representative ECG signal may be affected or even compromised by the
presence of noise and artifacts. Anything that doesn't belong to the electrical activity generated by
the heart is described as interfering signal.
The sources of these artifacts can be physiological, such as muscle activity or skin movements, or
non-physiological as a result of neighboring electrical devices or incorrect use of the equipment [2].
Kinds of noise which are common in ECG signal are presented in the below pictures in Figure 2.
Both Figure 2a and 1b are usually a result of movements of the subject.
Figure 2a represents motion artifact (MA), which appears to be more related with random limb
movement.
Figure 2b represents Wandering Baseline (WB) which is a systematic modulation that represents
periodic movements, such as respiratory activity.
Figure 2: Common Kinds of Noise in ECG Signal
Figure 2c represents Muscular Activation Interference (MI), that means that the ECG is
contaminated with muscular contraction artifacts.
Figure 2d represents AC Interference (ACI) and it shows the presence of the baseline noise,
possibly due to the electromagnetic noise induction of the equipment and surrounding electronic
devices [2].
Table 2: ECG Noise Frequencies

Minimizing motion artifacts:


Respiration: is used to characterized by low frequency 0.4-2Hz.
Patient Movement: 1-3 Hz
Transport: Medium frequency 3-15 Hz

Minimizing muscle artifact


Muscle tension: high frequency 20-150 Hz (Reducing the upper cutoff frequency filter from 150 to
40 Hz reduces muscle artifact)

Muscle Tremor: High frequency (20-150 Hz) and/or medium frequency (3-5 Hz)

Minimizing electromagnetic interference


Power line: usually 50-60 Hz
Cell Phone or Other Equipment: High frequency
Denoising Techniques
There are many techniques to remove ECG signal noise and artifacts. In the below scheme are
displayed

Figure 3: Denoising Techniques


We will present mainely wavelet transform and filters, as was our choice to solve the “Project 1”.

Wavelet Transform:
The time-frequency representation of DWT is performed by repeated filtering of the input signal
with a pair of filters namely, low pass filter (LPF) and high pass filter (HPF), and its cutoff
frequency is the middle of input signal frequency. The coefficient corresponding to the low pass
filter is called as Approximation Coefficients and similarly, high pass filtered coefficients are called
as Detailed Coefficients. The approximation coefficient is consequently divided into new
approximation and detailed coefficients. This decomposition process is carried out until the required
frequency response is achieved from the given input signal. This multi-resolution analysis enables
us to analyze the signal in different frequency bands; therefore, we could observe any transient in
time domain as well as in frequency domain. The choice of mother wavelet can be selected based
on correlation between the signal of interest and the wavelet-denoised signal. Discrete Wavelet
(DWT) based wavelet denoising have incorporated using Transform different thresholding
techniques to remove power line interference from ECG signal. Thresholding methods are used to
denoise the ECG signals. For example, a wavelet decomposition until level 3, is represented in
Figure 4.

Figure 4: Wavelet Decomposition of Level 3


Thresholding algorithms. The algorithms proposed by Donoho and Johnston can reduce the noise
by shrinking or scaling the detail coefficients smaller than threshold.
Two kind of threshold are used
1. Hard threshold

~ D
{
Dj= j
0,
if |D j|> λ
if |D j|≤λ

2. Soft threshold

~
Dj=
{
sign(D j )( D j −λ) if |D j|> λ
0, if |D j|≤λ

where D j =σ √2 log‖d j‖ and σ =median d /0.6745

Wavelet Implementation Combining IIR Filter


The first approach was with wavelet technique. We read many algorithms such as [3], [4], [5],
however the main idea is almost the same. Combining Table 1 and Table 2 we will use the below
algorithm in order to remove same noises and artifacts in our ECG.

Algorithm Implemented
1. In time domain, an IIR notch filter is used in order to remove powerline noise (result is
displayed in Figure 5).
2. Decomposing of the noisy signal using wavelet transform. Using the discrete wavelet
transform by selecting mother wavelet (sym5 or sym8, db4, db6 etc), the noisy signal is
decomposed, at the decomposition level of 10. As a result approximate coefficients and
detail coefficients are obtained.
Table 3: 10 level Coefficients for Fs=360Hz

Coefficients Fs=360Hz
cD1 180-360
cD2 90-180
cD3 45-90
cD4 22.5-45
cD5 11.25-22.5
cD6 5.6-11.25
cD7 2.8-5.6
cD8 1.4-2.8
cD9 0.7-1.4
cD10 0.35-0.7
cA10 0.17-0.35
3. Removing Basline Wander. Baseline wander is a low frequency component, so is removed
by setting to zero cD10 and cA10 coefficients (results are displayed in Figure 6).
4. Reduction of EMG noise. Cumulative density function is calculated in order to apply a
thresholding window for the cD3 and cD4 coefficient. ( results are displayed in Figure 7)
5. Apply soft thresholing to the coefficients cD8 and cD9 in order to reduce motion artifacts.
The result is displayed in the final signal.
6. Removing high frequencies. Frequencies higher than 100Hz in a ECG has no useful
information. So coefficients cD1 and cD2 are set to zero. The result here again is displayed
in the final signal.
7. Reconstruct the wavelet using modified coefficients and same mother wavelet and same
level. Final results of all the above steps are shown in final signal displayed in Figure 8.
The results received from this implementation are appeared following.
Figure 1 displays the signal of channel 1 before and after the IIR Notch filter. The IIR Notch filter
was applied in both channels, however for comfortable reasons of view only the channel 1 is
displayed, in a random period of time.

Figure 5: Signal of Channel 1 before and after IIR Notch Filter


Figure 6: Baseline Wander Removal

Channel cD3 cD4


1

Figure 7: Cumulative Density Functions with the Respective Thresholding Windows.


Figure 8: Final Filtered Signal after IIR Notch Filter and Wavelet Transform
As shown in Figure 8, for a random sample of values (1:2000) has been zoom in. Comparing to the
initial signal, the final signal is seems to be much more clean and denoised for both channel 1 and 2.
The analytical implementation can be found on the code progr_1.m.
Project 2: Two channels ECG - Eliminate noise and Estimate
mean heard rate (every 0.5 secs)
In “project 2” almost the same technique with “project 1” was used. The only new is the function
that was written for R peaks location and for the calculation of mean heart rate per 30seconds.
Running the code (progr_2.m) with the new signal imported, we plot the same things like in
“project 1”. However on report here, we plot only the initial and final filtered signal as shown in
Figure 9.

Figure 9: Initial and Final Filtered Signal For the New ECG Signal
As in “project 1”, we have again same satisfactory results. However it is observed that channel 2
probably has negative polarity. At step of heart peak and mean heart beat calculation, only the one
channel is used. For this reason, we avoided to inverse the second channel.
Before running the new function, an average filter was used to the final signal in order to remove
glitches and to increase in this way the performance of peak detection.
Algorithm for R peak detection and mean heart rate calculation
This algorithm is implemented in the function Rpeakfinder. It takes three parameters, one the signal,
one the minimum distance between R peaks and finally the minimun height is excpected the R peak
to be.
1. This function stores R peaks locations and time that were occurred.
2. The algorithm works inspecting every value of signal to be higher than the previous and the
next one.
3. Next, from the previous values that it found, it compares which values are higher than the
threshold (minpeakh→ minimum peak height).
4. Finally, the values that were smaller than threshold (minpeakh→ minimum peak height) are
removed.
5. From values that remained from the previous step, the differentiation between every value
which it’s next was extracted. If this value satisfies minimum peak distance then it consider
to be an R peak.
6. Finally the matrix with locations of R peaks and the amplitude of signal for that location (i.e.
R peak), are returned.
The mean heart rate per minute results from the formula:
60
RR internal( seconds)
In our task is requires mean heart rate for half minute, the above formula implies to be:
30∗fs∗Total Number of Peaks
Total Number of Samples
The final results from algorithm implemented is displayed in following figure

Figure 10: R Peaks Locations


Zooming in randomly in Figure 10, R peaks are shown in a better way.
Figure 11: R Peaks in a Random Part of ECG Signal

The mean heart rate was found to be 30.42 beats per 30 seconds, otherwise almost 61 beats per
minute. This number is normal rate for a normal person.

Figure 12: Mean Heart Rate per 30 Seconds


Project 3: One channel ECG - Eliminate artificial noise
In this project we tried lot of approaches as we have a very noisy signal:
1. The first approach was to resample the signal with a sampling frequency of 250Hz, using the
command in matlab:
[p,q] = rat(250/44100);
resampled_signal = resample(Original_signal, p, q);
After resampling the signal, the next step was to design a notch filter removing powerline
frequency. Finally designing filters for removing low and high frequencies. However the result was
not so satisfactory.

2. The second approach was to remove the DC in time domain. After that to find the FFT of
the new signal. So in the frequency domain to cut-off low frequencies and high frequencies.
Finilly calculating the IFFT and ploting the final signal. Or we could do the same in time
domain designing some low pass and high pass filters. In both cases however, again the
result was not so satisfactory.

3. However, we preferred this approach just for the simplicity of implementation and the
almost clear result. The approach here was to remove first the DC component and after that
designing an IIR notch filter for removing power line in time domain (we preferred
removing 30Hz instead of 50Hz). In the final step we used the MATLAB built-in wavelet
automatic 1-D denoising function:
xd = wden(ecg_notch,'sqtwolog','s','mln',100,'sym5');
In this way with an extremely short code implementation we had better results than the other
two approaches.
Instead of sym5, we had good results with other wavelet families as ‘sym8’, ‘db4’, ‘db6’,
but we preferred (almost randomly ‘sym5’) and “100” for level decomposition after some
experiments trying different levels. Following, we display the initial signal and the final
filtered signal Figure 12.
The result it is like we have an contaminated PRQRST with an other (second) ECG signal
(see the zoom in part at samples 570000 to 650000. It sensible the information to be on the
second signal. So possibly, it would be a good approach in some way to remove big PQRST
which is beyond 1 x 106 and 1.3 x 106
Figure 13: Initial Signal and Signal after IIR Notch filter

Figure 14: Final Filtered Signal


References
[1] Mr. Hrishikesh Limaye 1 , Mrs. V.V. Deshmukh 2, “ECG Noise Sources and Various Noise
Removal Techniques: A Survey”, ISSN 2319 - 4847
[2] J. Rodrigues, D. Belo, and H. Gamboa, “Noise detection on ECG based on agglomerative
clustering of morphological features,” Computers in Biology and Medicine, vol. 87, pp. 322–334,
Aug. 2017.
[3] N. Rashmi, G. Begum, and V. Singh, “ECG denoising using wavelet transform and filters,” in
2017 International Conference on Wireless Communications, Signal Processing and Networking
(WiSPNET), Chennai, 2017, pp. 2395–2400.
[4] S. Thalkar and D. Upasani, “Various Techniques for Removal of Power Line Interference From
ECG Signal,” vol. 4, no. 12, p. 12, 2013.
[5] School of Mechatronics Engg Universiti Malaysia Perlis, Malaysia, P. Karthikeyan, M.
Murugappan, School of Mechatronics Engg Universiti Malaysia Perlis, Malaysia, S. Yaacob, and
School of Mechatronics Engg Universiti Malaysia Perlis, Malaysia, “ECG Signal Denoising Using
Wavelet Thresholding Techniques in Human Stress Assessment,” International Journal on
Electrical Engineering and Informatics, vol. 4, no. 2, pp. 306–319, Jun. 2012.
[6] S. Abbaspour, M. Linden, and H. Gholamhosseini, “ECG Artifact Removal from Surface EMG
Signal Using an Automated Method Based on Wavelet-ICA,” p. 6.
[7] S. Ardhapurkar, R. Manthalkar, and S. Gajre, “ECG Denoising by Modeling Wavelet Sub-Band
Coefficients using Kernel Density Estimation,” Journal of Information Processing Systems, vol. 8,
no. 4, pp. 669–684, Dec. 2012, doi: 10.3745/JIPS.2012.8.4.669.
[8] S. Jani, “ECG Signal Processing using MATLAB For Heart Rate Analysis,” p. 22.
[9] M. K. Islam, A. N. M. M. Haque, G. Tangim, T. Ahammad, and M. R. H. Khondokar, “Study and
Analysis of ECG Signal Using MATLAB &LABVIEW as Effective Tools,” IJCEE, pp. 404–408,
2012, doi: 10.7763/IJCEE.2012.V4.522.
[10] J. Joy, “Wavelet Based EMG Artifact Removal From ECG Signal,” Journal of Engineering,
vol. 2, no. 2319, p. 4, 2013.

You might also like