You are on page 1of 6

ECG signal compression based on ASCII coding

using CUDA architecture


Rachid LATIF, Fatima Zahra GUERROUJ Amine SADDIK, Oussama EL B'CHARRI
Laboratory of Systems Engineering and Information Laboratory of Systems Engineering and Information
Technology LISTI Technology LISTI
National School of Applied Sciences, Ibn Zohr University National School of Applied Sciences, Ibn Zohr University
Agadir, Morocco Agadir, Morocco
r.latif@uiz.ac.ma a.saddik.ma@gmail.com
guerroujfatimazahra95@gmail.com el.bcharri@gmail.com

Abstract—Telemedicine is experiencing a great growth in recent method, it is classified into four categories: time domain
years, is a technology allowing remote health services and compression, transform domain compression, model based
exchange of medical information, among these areas we find compression, and the hybrid compression method. In the two-
telecardiology. In telecardiology the ECG requires a long dimensional (2-D) compression method, the ECG signal is
recording. For this purpose the data are high, the reason that an represented in two dimensions, then the transformation is
effective compression method is required for biomedical signals. applied to these two-dimensional (2-D) representations.
The electrocardiogram (ECG) or (EKG) is an important tool for
assessing the heart condition of a patient, and is very sensitive to ECG compression can also be classified into compression
noise. For that several methods are proposed to denoising the ECG with loss and lossless compression. Although loss compression
signal include: EMD, EEMD, DWT, and adaptive filter ADTF. has a high compression ratio (CR), it introduces distortion into
After the transfer phase it is necessary to compress the signal. the signal and may lose important data for patient diagnosis. On
Among the algorithms that can be found, low complexity the other hand, lossless compression ensures the integrity of
compression based on ASCII coding, DWT and DCT based
compression. In this work we propose an embedded system based
reconstructed data with a moderate to high compression ratio
on the CUDA architecture of the lossless ECG data compression. (CR) [8-9].
Today it becomes necessary to implement a reliable e-health
Keywords-Telemedicine; ECG; compression; ASCII coding; device that allows the diagnosis of cardiovascular disease. In
CUDA architecture recent years manufacturers began offering processors with two,
three, four, six, eight and more computing cores units instead of
I. INTRODUCTION one. And in order to speed up the processes, get better battery
Every year more people die because of cardiovascular life for devices. The heterogeneous system was developed.
disease. For that an electrocardiogram is necessary to diagnose Heterogeneous system architecture become prevalent in recent
the patient's cardiac condition. The electrocardiogram ECG or years, it allows different types of processors to work together
EKG is a test that allows to study the electrical activities of the efficiently eg: CPU-GPU, CPU-DSP, CPU-FPGA... To exploit
heart, while measuring the number of beats per second. Because this increasing hardware parallelism, new solutions like
of its low frequency band (0.5-150 Hz) it remains very sensitive OpenCL and CUDA have appeared.
to noise, among these most common noises are baselines The paper is organized as follows. The different compression
wander, Interference of a signal at 50 Hz, Interference of methods are detailed in section II, and section III presents the
electromyographic origin (EMG) [1-3]. For this purpose several
heterogeneous CPUGPU system based on CUDA. And for the
filtering methods are proposed include ADTF [3], EMD [4],
proposed architecture is detailed in section IV. To conclude,
EEMD [5-6], DWT [7] and others. The Adaptive Dual
Threshold Filter ADTF which is an adaptive filter based on two some results and discussion are given in section V.
thresholds. EMD for Empirical Mode Decomposition is an
adaptive method to unidimensional signals introduced by Huang II. COMPRESSION METHOD
et. al in 1998 which decompose the signal into IMF (Intrinsic
Mode Function). The EMD method has a problem called mode A. Time domain compression
mixing, to override this problem the Ensemble EMD appeared. First, for the discrete data compression technique. The
EEMD is a method assisted by adding a percentage of white ASCII coding method has been proposed for ECG signal
noise to the signal before decomposing it. compression [10, 11]. This method is illustrated in figure 2.The
For a better transmission it is needed to reduce the data size different steps of this scheme are detailed in the following of this
of ECG and protecting the integrity of the signal quality after the section.
filtering phase. Among the existing methods of ECG 1) Windowing
compression are two classes: one dimension (1-D) and two
dimensions (2-D). The one-dimensional (1-D) compression

978-1-7281-1232-9/19/$31.00 ©2019 IEEE


The first step of the compression is to take 8 by 8 samples
until the end of the signal and we apply all the procedures of the
compression on this array W[ ] which store 8 samples.
2) The delta function

This step serves to reduce the values of the samples in order


to have as many groupings as possible, which will be explained
in the following steps.
The delta D array can be generated by subtracting the sample
value from the previous sample value. The first array value of
the samples W[0] remains unchanged.
It is necessary to convert negative numbers to positive for Figure 2. Illustrative of the normalization step
ASCII coding by multiplying with (-1), and generate a bit sign
by giving "0" to positive values and "1" to negative values. 4) Data encoding
Once the delta D array is positive, it is necessary to amplify
these values by 1000 to obtain integers. In this step the notion of compression is described by the
grouping of the array values c[ ] that generate after the
3) Normalization amplification step.
We find three groupings according to the following equations:
This step occurs after the delta encoding, it is used to take
the first delta encoded value and apply the following test to 4-1) Direct grouping
eliminate cases where the first value is greater than 256 (is the
maximum number of ASCII code). Figure 3 shows the general We call that a grouping is a direct grouping only if the
algorithm of normalization. equation ((c[i]*100) +c [i+1]) <255 is satisfy.
If this condition satisfy then ((c[i]*100) +c [i+1]) replace c[i] at
the new array ECG-data.

4-2) Reverse grouping

For this group the condition is ((c [i+1]*100) +c [i]) <255,


and if this condition satisfy ((c [i+1]*100) +c [i]) replace c[i] at
the new array ECG-data.

4-3) No grouping

If the two conditions are not satisfied, then the two groups
mentioned above are impossible. So the position of c[i] and
c[i+1] is taken as it is and placed at the new array ECG-data.
The following figure shows example of Data encoding.

Figure 1. General ASCII Algorithm

Figure 3. Example of Data encoding

For the bit sign of g, g takes the value « 01 » if we have a


reverse grouping, otherwise 10 for the direct grouping, and if it
has no grouping « g » takes the value « 00 ». For the « cnv »

978-1-7281-1232-9/19/$31.00 ©2019 IEEE


takes the value 1 in the case where there is a reverse grouping memory access. To handle hundreds of threads, the
and 0 in the other cases. And the « cng » takes « 1 » only in case multiprocessor uses a new SIMT architecture "Single
there is a critical value (10, 13, 26, 255) in Ecg-data. Architecture Multiple Thread". When a multiprocessor is
offered one or more blocks of thread to execute, it divides them
The ASCII code contains critical characters that are not into warps whose execution will be planned by the SIMT unit.
marked in the text file that will generate at the end of the The warp is a set of 32 threads [14].
compression of the ECG signal, consequently the loss of data at
the reconstruction part. Among these characters we find 10 (line The CUDA program contains the host code and the device
break), 13 (return to the line), 26 (substitute), 255 (blank). code that will be executed by the GPU. The host code controls
the execution of device code as well as the communication
To avoid this problem, it is necessary to decrement the bit between host memory and device memory. The memory
sign value if it contains one of the critical values. A temporary dedicated to the CPU (host memory) and the memory dedicated
variable (rs = 1) if it detects a change in the sign bits otherwise to the GPU (memory device) are distinct. The data used on the
(rs = 0). After rs multiply by 100 and add it the value of «ii», and graphics processor must be transferred to the memory dedicated
rename it by« rsii». to GPU via PCI-express. Figure 4 show the Cuda architecture.
III. HETEROGENEOUS SYSTEM BASED CUDA
Due to the clock frequency, power consumption, and
physical limit of transistors size of single processor,
manufacturers began offering processors with multiple-core,
which enable simultaneous processing of multiple tasks.
Graphics processing units are co-processors widely used in
scientific computing, developed to accelerate graphics
applications, because of their architecture, and their high
performance.
GPU contains multiple multiprocessors and each
multiprocessor contains multiple processors. The cores of a
GPU execute instructions on different data simultaneously
SIMD "Single Instruction Multiple Data". And thus significantly
reduce graphics processing times. The data is placed in the
global GPU memory. All the cores of the multi-processors can
access this memory in parallel. The GPU architecture provides
a second memory which is the high speed L1 cache / shared
memory belonging to each multiprocessor. Thus there is also a
cache L2 has a lower bandwidth than the L1. Today GPUs are
used for general purpose parallel computing [12].
In 2007 Computed Unified Device Architecture (CUDA) Figure 4. CUDA Architecture
became the first language specifically designed by NVIDIA to
facilitate general-purpose computing on GPUs. CUDA C/C ++ IV. THE PROPOSED ARCHITECTURE
is an extension of the C/C ++ language that allows to exploit the
capabilities of graphics cards to execute highly parallel We can improve the performance of general computing on
applications. OpenCL is another programming model for GPU GPU, and exploit the parallelism between the hearts of GPU
programming, created by Khronos group is designed to support and CPU by the use of inactive hearts. In other words, when the
parallelism at the GPU level but also at the CPU. device (GPU) runs the Kernel, the processor cores are in charge
of performing some work.
Using CUDA or OpenCL makes it easier to develop and In this work we propose a heterogeneous CPU-GPU
improve the performance of parallel and intensive data architecture with CUDA to implement lossless ECG data
processing applications [13]. compression algorithm using ASCII character coding, due to
In CUDA terminology, the host is always the CPU whereas, the quality of the built signal which remains identical with a
the GPU and its memory are called the device. The host gives moderate compression ratio (CR).
the order to the GPU to execute the calculation. The code Figure 5 presents a block diagram of the architecture that has
executed by the device named kernel. The CUDA architecture been proposed.
provides grid in OpenCL NDRange, is composed of blocks
named Work groups in OpenCL which are associable, these
blocks are constituted by threads (CUDA) / Work item
(OpenCL), the thread is an instantiation of kernel. Each block
has a 1D or 2D identifier in the grid, so for the thread has a 1D-
2D-3D identifier within the block. Threads can just
communicate with threads in the same block by sharing their
data through shared memory and synchronize to coordinate their

978-1-7281-1232-9/19/$31.00 ©2019 IEEE


C. Normalization and Data encoding
These two blocks also run within device. After
normalization it is necessary to apply the grouping which is the
compression core. Figure 8 show Normalization Architecture

Figure 8. Normalization Architecture

D. The Frame
Figure 5. The Architecture proposed for ASCII algorithm Finally, the result returns to the CPU to form the frame that
contains the characters to be printed in the text file (Table I).
A. The signal windowing
In this block we have the signal acquisition and the TABLE I. THE FRAME
measurement of its size, which will be executed in the host cnv g Sign_byte cng rsii Ecg-data
(CPU) and after the window. We need to initialize our device
for the transfer the next block the eight samples will be V. RESULT AND DISCUTION
transferred to the device (GPU). Figure 6 show the windowing
Architecture. A. Result

In this part we will apply lossless compression based on


ASCII code on 8 samples of an ECG signal taken by the MIT-
BI database as shown.

-0.185 -0.185 -0.185 -0.185 -0.155 -0.055 -0.205 -0.255

So starting with the delta coding then the value of 8 samples


becomes.
Figure 6. Windowing Architecture -185 0 0 0 0,03 0,100 -0.15 -0.2

B. Delta function
In this step as mentioned above serves to differentiate the then, we will return a bit SB that will indicate if there is a
sampling and multiply the values of the samples by (-1) then negative value. In our case we have D[0], D[6] and D[7]. After
amplify them by (x1000). This step comes directly after the detecting the negative number it is necessary to multiply the
elements by (-1). After we will multiply them by 1000 to obtain
window phase, and will be executed in the device (GPU) part.
the table c[] which contains the values positive multiply by 1000.
Figure 8 shows Delta function Architecture.
Thereafter we need regrouping so in our example we have 2
No grouping, a direct grouping and a reverse grouping. As
shown in Figure 9.

Figure 7. Delta function Architecture

978-1-7281-1232-9/19/$31.00 ©2019 IEEE


Figure 11. Compressed text file

B. Performance comparaison
To test the performance of the compression algorithm. We
can measure the difference between the original signal and the
reconstructed signal, and calculate the compression ratio.
1) The compression ratio
Figure 9. Executing Model 1 The compression ratio (CR) determines the ratio between
the size of the original signal file and the compressed signal
Another bit called nbr that will count us the final size of our file. The higher the value of CR, the compression algorithm
file compress. In our case nbr contains 6 so our frame will only has the best performance as showing in the table II.
contain 6 samples instead of 8. The following figure shows our
ECG DATA signal and the compressed signal. ܱ‫݁ݖ݅ݏ݈݂݁݅ܽݐܽ݀ܩܥܧ݈ܽ݊݅݃݅ݎ‬
‫ ܴܥ‬ൌ
‘’”‡••‡†ˆ‹Ž‡•‹œ‡

2) The Percentage Root-meansquare Difference


The measurement of Percentage Root-meansquare Difference
(PRD) makes it possible to determine the distortion of the
reconstituted signal with respect to the original signal, which is
a very important measure, given by:

෌௡ୀଵሺ‘ሺሻ െ ”ሺሻሻ;
ܴܲ‫ ܦ‬ൌ ඩ ே ൈ ͳͲͲ
෌௡ୀଵሺ‘;ሺሻ
Where Xo and Xr represents the original and the reconstructed
signal sample respectively. N is the window length.

Table II: PERFORMANCE COMPARAISON OF


VARIOUS ECG

Algorithm CR PRD (%)


JPEG2000 [15] 8 0.86
Fira and Goras [16] 12.74 0.61
SangJoon Lee et al. [17] 16.5 0.61
Mukhopadhyay et al. [18] 7.18 0.023
ASCII [11] 18.84 0.0092
Figure 10. Executing Model 2

978-1-7281-1232-9/19/$31.00 ©2019 IEEE


Of the four lossless compression algorithms presented in [7] Jenkal W, Latif R, Toumanari A, Elouardi A, Hatim A, El Bcharri O.
Enhancement and compression of the electrocardiogram signal using the
Table II, the ASCII-based compression method provides high discrete wavelet transform. International Conference on Wireless
CR (18.84). And the PRD values are almost zero and are better Technologies, Embedded and Intelligent Systems (WITS), IEEE. 2017;
than any other method. 1-6.
[8] S. K. Mukhopadhyay, S. Mitra, and M. Mitra, “A lossless ECG data
compression technique using ASCII character encoding”, Computers and
CONCLUSION Electrical Engineering, vol. 37, 2011, pp. 486–497.
[9] S. K. Mukhopadhyay, S. Mitra, and M. Mitra, “An ECG signal
The world of high performance computing is a field known compression technique using ASCII character encoding”, Measurement,
a great growth and plays an important role in several fields. In vol. 45, 2012, pp. 1651–1660.
this work we quoted in the first part the various methods [10] S. K. Mukhopadhyay, M. Mitra, S. Mitra, “ECG signal compression using
proposed for the compression of the ECG signal. And we ASCII character encoding and transmission via SMS”, Biomedical Signal
mentioned the steps of the lossless compression algorithm based Processing and Control, vol. 8, 2013, pp. 354– 363.
on ASCII character encoding. The telemedicine domain is a very [11] O. El B’charri, R. Latif, A. Abenaou, A. Dliou, W. Jenkal, An Efficent
sensitive area, it requires efficient data processing with real time Lossless Compression Scheme for ECG Signal, (IJACSA) International
Journal of Advanced Computer Science and Applications, Vol. 7, No. 7,
transmission. Therefore in this work a heterogeneous CPU-GPU 2016.
architecture based on CUDA has been proposed to implement [12] Li H, Yu D, Kumar A, Tu YC. Performance Modeling in CUDA Streams
the ECG signal lossless compression algorithm based on ASCII - A Means for High-Throughput Data Processing, Proc IEEE Int Conf Big
coding. Because this method of compression allows a better Data. 2014 Oct;2014:301-310.
reconstruction of signal with moderate to high CR. [13] John E. Stone, David Gohara, and Guochun Shi, OpenCL: A Parallel
Programming Standard for Heterogeneous Computing Systems,2010
REFERENCES May; 12(3): 66–72.
[14] Nickolls John, Buck Ian, Garland Michael, Skadron Kevin. Scalable
parallel programming with CUDA. ACM Queue. 2008;6(2):40–53.
[1] Venes D. Taber's cyclopedic medical dictionary. FA Davis;2013. p. 1086–
7. [15] A. Bilgin, M. W. Marcellin and M. I. Altbach, “Compression of
electrocardiogram signals using JPEG2000”, IEEE Trans. Consumer
[2] Betts JG, DeSaix P, Johnson E, Johnson JE, Korol O, Kruse DH, et al.
Electronics, vol. 49, issue 4, November 2003, pp. 833–840.
Anatomy and physiology. OpenStax College; 2013.
[16] Fira CM and Goras L. “An ECG signals compression method and its
[3] Jenkal W, Latif R, Toumanari A, Dliou A, El B'charri O, Maoulainine
validation using NNs”, IEEE Trans. Biomed. Eng., vol. 55, no. 4, April
FMR. QRS detection based on an advanced multilevel algorithm. Int J
2008, pp. 1319–1326.
Adv Comput Sci Appl 2016;7 (1):253–60
[17] S. J. Lee, J. Kim, and M. Lee, “A Real-Time ECG Data Compression and
Transmission Algorithm for an e-Health Device”, IEEE Trans.
[4] kabir MA, Shahnaz C. Denoising of ECG signals based on noise reduction Biomedical Engineering, vol. 58, issue 9, September 2011, pp. 2448-
algorithms in EMD and wavelet domains. Biomedical Signal Processing 2455.
and Control. 2012; 7(5):481-89.
[18] S. K. Mukhopadhyay, S. Mitra, and M. Mitra, “An ECG signal
[5] Krgaard K, Jensen SH, Puthusserypady S. A comprehensive performance compression technique using ASCII character encoding”, Measurement,
analysis of EEMD-BLMS and DWT-NN hybrid algorithms for ECG vol. 45, 2012, pp. 1651–1660.
denoising. Biomedical Signal Processing and Control. 2016; 25:178- 187.
[6] Jenitta J, Rajeswari A. Denoising of ECG signal based on improved
adaptive _lter with EMD and EEMD. IEEE Conference on Information
Communication Technologies (ICT), IEEE. 2013; 957-962.

978-1-7281-1232-9/19/$31.00 ©2019 IEEE

You might also like