A Modiﬁed Run-Length Coding towards the Realization of a RRO-NRDPWT-Based ECG Data Compression System

. The wavelet-based approach that combines a reversible round-o ﬀ nonrecursive discrete periodized wavelet transform (RRO-NRDPWT) and the set partitioning in hierarchical trees (SPIHT) scheme is an e ﬃ cient ECG data compression. However, this RRO-NRDPWT-based system su ﬀ ers from the high complexity of the SPIHT scheme during realization. In this paper, a modiﬁed run-length coding (MRLC) algorithm is proposed towards the realization of a RRO-NRDPWT-based ECG data compression system. The MRLC with its regularity and low computational complexity is suitable for hardware implementation, but at a cost of compression performance. This sacriﬁce is compensated by an e ﬃ cient quantization scheme. By using the MIT-BIH arrhythmia database, the experimental results show that the proposed scheme can compete with the SPIHT scheme for a compression ratio (CR) greater than 8. Hardware simulations are taken using both the Verilog logic simulator with Cadence design platform, and a Xilinx FPGA EP2C35F672C6.


Introduction
An electrocardiogram (ECG) is a non-invasive modality that senses the electric action of heart motion from the surface of a body. Since the heart is a three-dimensional organ, heart disease diagnosis usually requires the use of several ECG signals sensed at various positions around the heart. A typical requirement for heart disease diagnosis and health care is a long-term record of 12-lead ECG signals [1]. To this end, portable ECG sensing systems associated with wireless data transmission have been developed for ambulatory monitoring and recording. ECG data compression is crucial for creating a reduction in power consumption, efficient data transmission, and storage [2,3].
In many ECG data compression methods, waveletbased approaches with high compression performance have attracted much attention from researchers [4][5][6][7]. These approaches that attempt to optimize the compromise between CR and distortion all employ the lossy compression method in which the percentage root-mean-square difference (PRD) is usually used as the distortion measure. Lossy ECG data compression can be meaningful only if clinical information and reconstruction quality can be preserved and maintained. Quality maintenance is usually time consuming due to the recursive process of compression and reconstruction error measurement. For this reason, realizing waveletbased data compression with hardware is required to create real-time recoding of multilead ECG signals. In realization, high compression performance, low complexity, and rapid convergence in reconstruction quality control are important considerations.
With low complexity, threshold-based schemes [2,[5][6][7] are one optimal option. The SPIHT scheme incorporating thresholding into tree coding provides progressive mode ECG compression [2]. In [5], thresholding was first used to maintain a fixed percentage of wavelet coefficients at zeros followed by an entropy coding. The filter bankbased method [6] uses target PRD as the criterion for threshold value determination. Recently, a method based on orthogonal wavelet filters was proposed for efficient ECG data compression [7]. This approach combines nonrecursive 1-D discrete periodized wavelet transform (1-D NRDPWT) and a reversible round-off linear transformation (RROLT) theorem in order to eliminate the word-length-growth effect. This DPWT, referred to as the 1-D RRO-NRDPWT, facilitates a real-time process and a design of linear distortion 2 EURASIP Journal on Advances in Signal Processing control. The RRO-NRDPWT-based ECG data compression also applies the SPIHT scheme for the coding of quantized wavelet coefficients.
The SPIHT scheme can be very efficient for data inherent in hierarchical self similarities. However, this scheme exploits the self similarities in terms of dynamic data structures that will impose practical limitation on hardware implementation [8][9][10][11][12], especially for large-size data sequences. In order to save the three intermediate data sets, list of insignificant sets (LIS), list of insignificant pixels (LIP), and list of significant pixels (LSP), the SPIHT encoder should reserve a buffer size of 4.5 log 2 L bits where L is the image width. This buffer size is even larger than the image itself [9]. A simulation using Xilinx Virtex 2000E FPGA [10] shows that for encoding a 16 × 16 image, SPIHT scheme needs 61531 gates. The RRO-NRDPWT-based ECG data compression system was also simulated on the Xilinx FPGA, EP2C35F672C6 [12]. The system is composed of three functional blocks RRO-NRDPWT, quantization, and the SPIHT coding in which the RRO-NRDPWT block is performed with 21-bit precision. The evaluation result shows that for 1024 ECG samples, the first two blocks require 6254 and 2383 logic elements, respectively. On the other hand, for only 32 ECG samples, the SPIHT block will need 25480 logic elements, which occupy (254180/33216) × 100 = 76.7(%) of total logic elements. Note that with the limitation of EP2C35F672C6, we cannot evaluate 64-sample case or larger.
In this paper, towards the realization of RRO-NRDPWTbased ECG data compression system, a modified run-length coding (MRLC) method is presented in place of the SPIHT scheme. The MRLC can effectively reduce computational complexity at the cost of compression performance. For compensation, a modified quantization scheme with approximate linear distortion is presented for improving compression performance. Several experiments are also taken by using the MIT-BIH arrhythmia database [13].
The rest of this paper is organized as follows. The nonlinear quantization scheme with the approximate linear distortion characteristic is developed in Section 2. The proposed ECG data compression scheme is described in Section 3. In Section 4, several experiments in ECG data compression are evaluated. The analysis and synthesis report of the proposed MRLC architecture are presented and demonstrated in Section 5. Finally, the conclusion is provided in Section 6.

A Nonlinear Quantization Scheme with Approximately Linear Distortion Characteristics
The RRO-NRDPWT is a nonrecursive 1-D DPWT that can achieve fixed-point computation in terms of error propagation resistance and a uniform distribution of subband error. The two mechanisms facilitate the significant normalization of subband data and a quantization scheme design with linear distortion characteristics.
Given a negative integer J with N = 2 −J , where N denotes the number of original sampled data of a finite 1-D signal. Let d * j for J < j ≤ 0 be a vector encompassing the reversible wavelet coefficients of the jth level. The quantization process can be defined as where tr(d * j ) denotes the truncation process that truncates each element of d * j to an integer, and b DC and c j are the terminate and jth levels' quantization scales, respectively. In the inverse quantization process, each retrieved datum will be compensated by half of the quantization scale, namely where sign( d * j ) denotes the sign vector of d * j . For the determination of quantization scales, we define c j as where SNF j = max l { 2 − j+1 k=2 − j |a kl |} is a significant normalization factor and cp[ j] are adjustable parameters and a kl is the kth row and lth column element of the inverse matrix of RRO-NRDPWT [7].
Equation (2) shows that for each segment (N = 1024 ECG samples), the reconstruction requires 11 cp[ j] including b DC . It will be efficient to generate cp[ j] with a single variable. To this end, curve fitting is one simple approach. The cp[ j] design process is described in the following.
Step 2. Introduce 11 quadratic equations for fitting the 11 cp[ j] curves with single control variable QF. The coefficients of 11 quadratic equations are found by least square error criterion.
In Step 1, an exhaustive search of cp[j] for each PRD value should be performed in an 11-D space. In so large a space, it is impossible to find a global solution. Instead, we optimize the local solution based on the quantization scheme given in [3]. For minimizing the search area, the condition cp[i] < cp[ j], for i > j is also applied. In Step 2, the seven cp[ j] values for each j will be fitted with a quadratic EURASIP Journal on Advances in Signal Processing function in which the range of PRD is fitted by 16 QF values.
One locally optimal solution is given in the following: where q = 10 · ((QF + 1)/16) 2 . In (4), QF can be an available variable for desired PRD and CR control. In order to explore the linear control performance of QF, all 48 ECG signals recorded in the MIT-BIH arrhythmia database were investigated. Each signal contains about a 15 minutes length of sampled data. The measurement results are depicted in Figure 1. Figure 1 reveals that an approximately linear relationship between PRD and QF can be obtained for all signals with different gradients. The linear distortion characteristic will facilitate a rapid reconstruction quality control.

The Proposed ECG Data Compression Scheme with the Modified Run-Length Coding
The proposed RRO-NRDPWT-based ECG data compression scheme with the modified run-length coding is shown in Figure 2. In the encoding process, the 1-D RRO-NRDPWT first produces reversible wavelet coefficients d * j . From (1), for a given QF value, we can obtain quantized data d * j . The QF and these quantized data will be losslessly encoded with a differential pulse-code modulation (DPCM) and the modified run-length method, respectively. The algorithm of modified run length coding is described in Algorithm 1.
In comparison with a specific run-length coding [14], 36 bits are required for Example 1. The proposed method needs less bits. For representation with sign bits, an example is given as follows.  Table 4, where the last three bits are used to represent the signed coefficients 3, −12, and −7, respectively. Note that the eight nmax i , i = 0, . . . , 7, represented with the same word length will be put at the beginning of output sequence, that is, a MRLC codec.
The MRLC codec can be decoded real-time block by block. The decoding process of MRLC is described in Algorithm 2.
After decoding, the reconstructed data, S J can be obtained directly from (2) where the quantization scales are generated by applying QF into (3) and (4).

Experimental Results
For hardware realization, complexity reduction usually leads to a sacrifice of compression performance. Several experiments were made in order to evaluate the compression performance of the MRLC-based approach. The original data compression scheme of [3] and the proposed scheme are referred to as NRDPWT-6r and NRDPWT-MRLC, respectively. A dataset comprising 11 ECG signals: 100, 101, 102, 103, 107, 109, 111, 115, 117, 118, and 119, recorded in the MIT-BIH arrhythmia database (360 samples/sec and 11 bit resolution) was built for the test. With 11 bit resolution, the word length of nmax i is defined as WL(nmax i ) = 4. Each signal contains about a 10-min length of sampled data. Each segment involves 1024 samples of ECG data. The experimental result is shown in Table 1 where each value denotes the average PRD for a specified CR. The value of PRD is defined by where s J [i] and s J [i] denote the reconstructed and original signals, respectively. Note that the PRD algorithm acts on a zero-mean signal. Since a baseline of 1024 is added for the storage purposed in the MIT-BIH arrhythmia database, so a level of 1024 is removed from each sample before processing. Table 1 shows the PRD-CR performances of several ECG data compression schemes including SPIHT  Table 1, also shows that for CR > 8, the NRDPWT-MRLC (k = 8) can be competitive with the SPIHT scheme [2]. For CR < 8, the average PRD difference between NRDPWT-6 R and NRDPWT-MRLC (k = 8) can be limited to within 1.5%.
For practical application, preserving clinical information is a crucial requirement for system development of ECG data compression. A quantitative relation between distortion and the degree of clinical information preservation was evaluated in [16]. The evaluation showed that reproduced ECG waveforms at specified PRDs of 7% and 9% were graded as "no diagnostic information lost" and "clinically acceptable", respectively. A reproduced waveforms at a PRD of 13% was "notably degenerated in some Q-waves and ST-segments". The experimental results show that the proposed system can be competitive with other wavelet-based approaches for CR > 8 and feasible for well preserving clinical information that includes amplitude and duration (PRD 7% for CR = 20).
Several compression results from the NRDPWT-MRLC (k = 8) scheme are demonstrated in Figure 3 in which each signal involves first 2048 samples. Figure 3(a) shows the ECG signal of record 117 with a nice waveform. For this signal, the PRD can be lower than 3% when CR reaches 22.2. The signal from record 232 with a distorted and noisy waveform is shown in Figure 3 (b) where the reconstruction error is unobservable. The ECG signal shown in Figure 3(c) is record 109 with a waveform containing a wandering baseline and slight noise coupling. This signal has poor PRD due to the smoothing effect of the quantization process. However, the Step 1: Get nmax i , i = 0, . . . , k − 1.
Step 2: Decode the elements of each blocks.
for i = 0, . . . , k − 1 if nmax i == 0 Assign all coefficients of Block i to be zeros. else {for j = 0, . . . , z i − 1 Get nmax i bits to be arg 1; if arg 1 / = 0 Decode arg 1 to be abs(coe i, j ); else {Decode arg 1 to be zero; Get Zbit bits to be arg2-1 and decode arg2 to be the number of zeros; j = j + arg 2;} end } end.
Step 3: Correct the sign of nonzero coefficients using the sign bits.      clinical information, including the amplitude and duration, can be preserved well.

Hardware Simulation
The block diagram of an MRLC encoding circuit is illustrated in Figure 4 where k = 8 is considered towing to its good compression performance. For each segment, quantized wavelet coefficients will be partitioned into 8 blocks which will be saved in mem1∼mem8, respectively. In the meantime, the nmax i for each block will be determined. It should be noted that once k is fixed, the WL(Zbit) for each block is determined due to the regularity of block length.
As shown in Figure 5, the MRLC block consists of three functional circuits, Non-zero coe i, j (NZc), zero counter (ZC), and a packer. The NZc circuit will output a sign bit and an absolute non-zero coefficient with nmax i bits. The ZC circuit driven by the data coming from memi is used to count the number (denoted by arg2) of consecutive zero coefficients. The two circuits with opposite functions are also optioned by the data coming from memi. The output of the ZC circuit involves an nmax i -bit zero and arg2-1 where arg2-1 is represented with Zbit bits. The packer is used to arrange the outputs of NZc and ZC circuits in sequence.
Because the data in different blocks (memi) will be encoded with different word lengths, the packer of Figure 4 will pack the outputs of MRLC blocks in order to generate a 32-bit bitstream. This process is performed by controlling a 32-bit barrel shifter. The MRLC encoder with k = 8 shown in Figure 4 is simulated in order to validate its functionality. The simulation was performed using a Verilog logic simulator with Cadence design platform. The synthesis result was reported by synopsys logic simulator using TSMC/Artisan 0.18 µm technology. The simulation chose tsmc18 wl10 in the slow library as the wire load model. The H/W specification is summarized in Table 2. In this simulation, mem1 ∼ mem8 was implemented with logic instead of a macro cell provided by the memory compiler of the ASIC vendor. The total gate count of the MRLC encoder is 131991 where memory and the barrel shifter occupy 125188 and 388 gates, respectively. Note that the hardware costs of the various partitions (different k) show no significant differences because the memories of different k will have the same cost. The MRLC encoder was also implemented on the Xilinx FPGA EP2C35F672C6. This design needs 15946 logic elements. In comparison with the SPIHT scheme [12], the hardware resource can be significantly reduced using the MRLC scheme.

Conclusion
Realizing ECG data compression is crucial for a realtime recording of multilead ECG signals. The waveletbased approach combining the RRO-NRDPWT and SPIHT schemes can obtain excellent compression performance, but suffers from the high complexity of the SPIHT scheme in realization. For replacing the SPIHT scheme, a new MRLC scheme has been proposed in this paper. With an efficient 8 EURASIP Journal on Advances in Signal Processing quantization scheme, the experimental results show that the new RRO-NRDPWT-based ECG data compression system can be competitive with the SPIHT scheme and can well preserve clinical information for practical application. The MRLC scheme with both regularity and very low complexity is efficient for hardware realization. The hardware simulation result shows that with the MRLC scheme, the hardware cost of realizing the RRO-NRDPWT-based ECG data compression system can be dramatically reduced.