You are on page 1of 12

Yang 1

Min Yang
BME 499
Prof. Wei Lin
Real time ECG signal compression method
Introduction:
Normally, a few seconds of ECG signal obtained from a patient will generate thousands
of data points. In order to transfer hours of information, a compressed data presentation will be
more favorable and it allows long-term digital storage. Even though there are a great numbers of
compression techniques available online or in the literature, the demand of searching for new
methods and algorithms to achieve higher compression ratio while preserving useful data has
been always there. The ultimate application will be focus on portable devices for 24 hour online
cardiac monitoring [2]. Currently, there are many different methods have been published by
varies research groups. They can all be grouped into two types: Lossless compression and lossy
compression. Lossless compression allows the original signal and reconstructed signal to be
identical. This method is preferred as long as the compression ratio is acceptable. In contrast,
lossy compression method allows some degrees of losing unnecessary data points in order to
achieve high compression ratio. There are also two signal domains in which ECG data
compression can be performed. The first one is compression in the time domain which consists
in approximating the signal by a sequence of straight lines and slopes [3]. The examples of this
domain are amplitude zone time epoch coding or AZTEC [6]. The second one is the frequency
domain method which involves extraction of the frequency components using a suitable

Yang 2

transform and storing the coefficients in the compressed form such as Fourier transform and
discrete cosine transform [7].
In this paper, an algorithm for ECG data lossy compression has been presented using fast
Fourier transform to achieve both high accuracy and high compression ratio. The algorithm has
been tested on a sample ECG records and the performance was evaluated by two important
parameters: compression ratio and percent root-mean-square difference (PRD) besides visual
comparison. We chose PRD measurement for its simplicity and easy to calculate, more over it is
the one of the most popular reported measure among scientific publications which makes it
easier to compare the results.
Method:
Much work has been done in ECG compression with blooming of Fast Fourier
transform(FFT) based methods [4], discrete cosine transform(DCT) and discrete sine
transform(DST) based methods [5], and wavelet based methods [1] in signal processing. For
selecting our best model, we first considered our resources, prior experience (the use of computer
application) and the degree of difficulty. Then, we evaluated some of the developed methods
based on compression ratio and percent root mean square differences (PRD). From figure 1, we
concluded that FFT is the best option because of its relative high compression ratio and low
PRD.

Yang 3
Figure 1. 4 different Transform to compress an ECG signal,DCT transform,DST transform,FFT transform and DCT2
transform.

The environment in which we performed our algorithm was Matlab. Matlab is one of
the most success programming tools in biomedical field and it integrates computation,
visualization and programming in a user friendly environment. It also provides an interactive
graphical environment and a set of useful build in functions that facilities the implementation. It
can transform signals from time domain to frequency domain by simply using command fft.
This build in function is based on a popular mehod called Cooley-Tukey FFT algorithm [8]. This
algorithm divides a discrete Fourier transform of size N into two interleaved DFTs of size N/2.
The discrete Fourier transform (DFT) is defined by the formula:

where k is an integer ranging from 0 to N1.

The algorithm first computes the DFTs of the even-indexed inputs x2m(x0,x1,
,xN-2) and odd-indexed inputs x2m+1(x1,x3,,xN-1), and combines those
two results to produce the DFT of the whole sequence. The algorithm runs at
its maximum speed when N is the power of two.
The equation becomes:

Yang 4

We can factor out he common multiplier


obtain:

k2

pii
N

out the second sum we

Yang 5

Because of the periodicity properties of the DFT, the outputs for N/2k<N
from a DFT of length N/2 are identical to the outputs for 0k<N/2. The whole
equation becomes:

This equation expresses the DFT of length N recursively in terms of two DFTs
of size N/2 which can reduce the computation time by hundreds.
After identifying and analyzing the transform method, we started to
modify a very simple FFT based code for compression which was created by
Nasri, Mehdi at Matlab center. First the data samples are read from a saved
ECG file which contains ten thousand data points and then the subroutine is
called up for performing the FFT. The output array now contains the same
number of FFT coefficients as the number of samples in the input signal. In
order to compress the signal, the higher order coefficients are set to zero and
only lower order coefficients are retained. The remaining data points were
then stored in a excel file. The figure 2 represents the sample code that
describes the function above.

Yang 6

Figure 2. compression code.

The reconstruction of the signal is obtained by using another useful build in function
called an inverse fast Fourier transform and followed by a command ifft. Before we used this
inverse transform, the same numbers of data points must be restored in order to get a full
decompressed signal. Figure 3 describes a code that generated a new set of array contains same
values when there is a match and fill with zeros otherwise. This new array is then inversely
transformed.

Figure 3. decompression code.

The performance of the proposed data compression algorithm is measured in terms of the
compression ratio and percent root-mean-square difference. The efficiency of a compression
method is related directly to the compression ratio which is given by the ratio of the amount of

Yang 7

original data to that of the compressed data [3]. To evaluate the distortion in the reconstructed
signal, PRD is used as the basis because of its simplicity and popularity. The PRD between the
reconstructed and original signals is calculated as:

where Xorg and Xrecon are the samples of the original and reconstructed signals,
respectively

After testing our algorithms basic performance, we started to improve


this algorithm toward a real time based application. Because in a real clinical
test, the ECG signal is obtained continuously. For the base algorithm, the
compression cannot be performed until the full data point is obtained and
the processing time will be longer. So, the improved algorithm will obtain
sub-arrays and each sub-array will perform individual transform and inverse
transform. The new sub-arrays will then be grouped together at the end of
the algorithm.
Even though the improved algorithm seems to be more applicable for a
real time ECG compression, there are still some obstacles we needed to
remove such as signal leakage and signal aliasing. In order to solve the
discontinuity generated when putting sub-arrays back into one complete
array, the improved algorithm equals the end value of previous sub-array to
the beginning value of following array as shown below.

Yang 8

In order to reduce the high frequency component of the compressed


signals, a Matlab build in function fir1 is used. The Finite impulse
response (FIR) design for our case uses the hamming window method.

Result:

Figure 4. top represents original and bottom represents compressed signal for base algorithm.

Yang 9

Figure 5. Improved algorithm with each sub-arrays original data and compressed data.

Figure 6. combined signal from each compressed sub signals.

Figure 7. left picture shows discontinuity, and right picture shows connection between each sub-arrays.

Yang 10

Figure 8. picture after filtering.

Column1
CR
PRD

Base
Improved
algorithm
algorithm
After filtering
89.57
88.42
1.1661
5.6897
13.277

Table 1. different compression ratio and percent root-mean-square differences.


From figure 1, we obtained that compressed signal contains certain high frequency noise
component. From figure 5 and 6, the high frequency components were also found in compressed
signal from sub-arrays. Figure 7 shows a result of removing signal leakage.
Discussion:
The high frequency components appeared in every compressed signal, this is because of
inverse FFT generated random high frequency signals. It is acceptable as long as the root-meansquare difference is low. Figure 7 shows the result of our algorithm for solving discontinuity

Yang 11

when signals combined from each compressed sub signals. From figure 7, we found that
separating original signal into several sub-signal arrays increases the PRD value; this is because
larger sample size contains more information and generates lower random errors. In fact, for any
experiments, as the sample size goes to infinity, the random errors will go to zero. We also found
that our filtering method increase the PRD and did not significantly reduce the high frequency
component as shown in figure 8. It can be solved by using new filtering method or completely
remove filtering function. Even though we did not test the time spend for compression, we would
predict a much short time spent by improve algorithm than the base algorithm.
Conclusion:
Data compression of ECG signals allows long-term digital storage and archiving of ECG
recordings [2]. A lossy compression algorithm for ECG signals based on Fast Fourier transform
is experimented. The performance parameters of the compression technique shows a
compression ratio can be as high as 89% with a PRD of 1.17 for base algorithm and 5.69 for
improved algorithm. This represents a substantial reduction in ECG signal and an increased
storage capacity of the digital recorder. By comparing the results with other published literature
[1] [2] [3] [4], we found that our compression ratio was much higher than others; however, our
PRD value is also significantly higher than others.
In conclusion, this algorithm has its clinical potential, but need to be further improved in
order to reduce PRD value and achieve better performance. The developed algorithm can then be
transfer into physical channels to perform real ECG compression.

Yang 12

Reference:
1. Hilton, M.L., 1997. Wavelet and Wavelet Packet Compression of Electrocardiograms.
IEEE Trans. on Biomedical Engg., 44(5): 394-402.
2. Hossain, Md. Sharafat, and Nowshad Amin. "ECG Compression Using Subband
Thresholding Of The Wavelet Coefficients." Australian Journal Of Basic &
Applied Sciences 5.5 (2011): 739-749. Academic Search Complete. Web. 6 May
2012.
3. Kulkarni, P K, V Kumar, and H K Verma. "Diagnostic Acceptability Of FFT-Based ECG
Data

Compression." Journal Of Medical Engineering & Technology 21.5

(1997): 185-189.
MEDLINE with Full Text. Web. 6 May 2012.
4. Wei, Yang, Zhao Zhiqin, and Nie Zaiping. "Fast Fourier Transform Multilevel Fast
Multipole

Algorithm In Rough Ocean Surface Scattering." Electromagnetics

29.7 (2009): 541-552.


Academic Search Complete. Web. 6 May 2012.
5. Zigel, Y., A. Cohen and A. Katz, 2000. The weighted diagnostic distortion (WDD)
measure for

ECG signal compression. IEEE Trans.on Biomedical Engg.,

47(11): 1422-1430.
6. Cox, J. R., NOLLE,F . M., FOZZARD, H. A. and OLIVERG,. C. (1968) AZTEC a
preprocessing program for real-time ECG rhythm analysis. IEEX Transactions on
Biomedical Engmeering.
7. Reddy, B . R. S. and MURTHY, 1. S. N. (1986) ECG data compression using Fourier
descriptors. IEEX Transactions on Biomedical Engmeering. 33, 428 - 433.
8. Lexing, Ying, and SERGEY FOMEL. "Fast Computation Of Partial Fourier Transforms."
Multiscale Modeling & Simulation 8.1 (2009): 110-124. Academic Search
Complete.

Web. 6 May 2012.

You might also like