EEG Compression Using Motion Compensated Temporal Filtering and Wavelet Based Subband Coding

Electroencephalography (EEG) signals are commonly used in medical applications for prevention, diagnosis, and detection of neurological diseases. These EEG signals have also been used in designing brain computer interfaces for assistive technologies. For densely placed electrodes and long EEG recordings, a large amount of data needs to be stored, preferably in compressed form. This EEG signal compression is particularly required in an out-of-the-lab environment so that these signals are efficiently transmitted over wired/wireless communication channels. To this end, we propose a novel compression scheme for EEG signals, which exploits the intra-channel redundancy using motion compensated temporal filtering (MCTF) and discrete wavelet transform (DWT) based sub-band coding. In the pre-processing stage, multi-frame data is constructed such that each group of picture (GOP) contains information from a single channel of EEG data. This helps in removing the intra-channel redundancy. We apply MCTF on each GOP to exploit temporal redundancy, following which the DWT is applied on temporally decomposed frames to exploit spatial redundancy. Each spatio-temporal decomposed frame is assigned a bit budget for minimum distortion. For this purpose, we assign more bit budget to temporally decomposed low pass frames as compared to high pass frames. Spatio-temporal frames are then encoded at the assigned bit rate by using set partitioning in hierarchical tree (SPIHT) algorithm to create the bit stream. Our experimental results showed 4.5% and 2.4% reduction in distortion at the same data rate for BCI-3 and BCI-4 datasets, respectively. These results improve upon the reduction in data size achieved using state-of-the-art compression methods such as SPIHT and SPIHT with independent component analysis.


I. INTRODUCTION
Electroencephalography (EEG) signal contains information which is important for diagnosis and analysis of different neurological conditions. EEG signals are used in brain computer interface (BCI) to classify different mental states. Diagnosis or classification of various mental conditions require long-term recording of EEG signals and hence a large amount of data storage and transmission bandwidth. In band limited channels, the transmission and storage of EEG data from The associate editor coordinating the review of this manuscript and approving it for publication was Ruqiang Yan. densely placed electrodes is a challenging task. This is particularly evident in ambulatory EEG and remote tele-medicine systems [1]. In various physiological signals based clinical and diagnostic applications, a dense placement of electrodes and high sampling rate has a significant role. This translates in to huge amount of data that must be stored or transmitted (in tele-health and ambulatory applications) over wired or wireless media. Moreover, in many cases the data acquisition time could go up to hours, adding more burdens on the available resources. Similarly, all clinical data is sensitive and must be secured from unwanted alterations. The security protocols also add to the amount of data that needs to be stored and transmitted. Hence, efficient compression would benefit data transmission and storage. The compression of these signals is also required for an efficient transmission of EEG data over band-limited channels and hence overcome the challenges of out-of-the-lab environment.
Data compression techniques are used to minimize the data volume while preserving significant signal features for successful reconstruction, hence reducing power consumption, transmission bandwidth, and storage space. Data compression techniques are generally categorized into lossless and lossy methods [2]. In lossless compression, there are no errors expected between the original and reconstructed and data. Hence, the content and quality of the reconstructed signal is similar to that of the original data. But such lossless compression methods cannot achieve high compression ratio or coding gain due to these requirements. On the other hand, lossy compression techniques are used for achieving high coding gain but at the cost of data quality. The compression ratio controls the amount of loss that is tolerated within such systems, where for a higher compression ratio the reconstruction loss could go higher. While losing some part of information, such schemes attempt to ensure that the overall system quality is not compromised when discarding certain parts of the signal. Hence the reconstructed data is not exactly similar to the original data (because of reconstruction loss), but high coding gain and compression ratio is achieved while ensuring reconstruction quality at acceptable level. EEG signal compression schemes are divided into single-and multi-step approaches. In the single step approach, statistical redundancy present within the EEG data is exploited by applying entropy encoding techniques (Huffman and arithmetic coding) [3]. Whereas, in multi-step approaches, pre-processing is applied on EEG data before entropy encoding, where in the pre-processing stage, EEG data is either represented in a two-or a three-dimensional volume [4]- [6]. Multiple one dimension (1D) and two dimension (2D) schemes have been proposed for an efficient coding of EEG signals [7]- [13]. The amount of EEG signals generated in clinical settings is increasing everyday and the availability of better communication technologies is shifting the focus on remote health monitoring techniques. This has created a demand for improved compression techniques, which can provide higher compression but at the same time maintain the signal quality required for clinical purposes.

A. RELATED WORKS
In [4], a lossless compression technique (for both 1-D and 2-D representations) was proposed, where backward difference was applied to remove the DC component. Integer lifting wavelet transform was used to de-correlate the signal and the set portioning in hierarchical trees (SPIHT) [14] algorithm was applied as a source coding scheme. The 2-D compression algorithm gave a significant reduction in distortion at low bit rates as compared to the 1-D scheme. In [5], a lossless EEG signal compression scheme was proposed where the EEG data was arranged in a matrix for processing. A two step coding scheme was used which consisted of a lossy coding layer, where SPIHT algorithm was used, and a residual coding layer (using arithmetic coding). In [15], a flexible pre-processing based EEG compression scheme using SPIHT algorithm was proposed, which was easily implementable on a Blackfin processor. In [16], JPEG2000 compression standard was used to compress EEG data and different compression parameters were tested to check their impact on the fidelity of reconstructed data. Two popular compression methods (JPEG2000 and SPIHT) were explored in [17], for compressing EEG signals. The reconstructed EEG signal was then used for seizure detection giving a comparable detection performance as compared to the raw EEG signal. In [18], EEG signal was pre-processed using principal component analysis. Independent component analysis (ICA) was then applied to the pre-processed EEG signals. The independent components and residuals were arranged in a matrix and encoded using SPIHT algorithm with different compression ratios.
In [7], a 2-D wavelet transform based method was introduced which employed a modified SPIHT algorithm. The compression was achieved by utilizing redundancy in the wavelet sub-bands. In [8], wavelet packets were used to perform EEG compression. The wavelet packets coefficients were processed such that only those coefficients were considered having an absolute value greater than a selected threshold. A run length coding scheme was used to encode the remaining coefficients. Convolutional neural networks were used for EEG and electromyography (EMG) data compression in a multi-modal approach [9], where inter-and intra-correlation among data was used to achieve compression. Two EEG compression algorithms, one for low power consumption and another for high throughput for a wireless EEG system, were presented in [10]. In [11], two EEG compression algorithms (multi-variate auto-regression and low complexity bit-variate model) were presented and compared with various other compression techniques including Huffman coding, arithmetic coding, Markov predictor, linear predictor, and context based error modelling. The impact of EEG compression was analyzed using DWT, SPIHT, and adaptive arithmetic coder on EEG based pattern recognition systems for seizure recognition and person recognition [12]. In another study, compressive sensing-based EEG compression and low-complexity feature extraction for EEG compression in wireless sensor networks were analyzed [13]. The EEG signal is known to have temporal and spatial redundancy which has not been exploited so far to the best of our knowledge.

B. OUR CONTRIBUTIONS
Most lossy EEG compression schemes reported in literature have used SPIHT algorithm on 2-D matrices generated from the 1-D signal. Temporal decomposition and wavelet based coding has not been used to the best of our knowledge for exploiting temporal and spatial redundancy. We propose a novel EEG signal compression scheme, which is VOLUME 8, 2020 based on motion compensated temporal filtering and SPIHT algorithm and are applied independently on each individual channel to remove intra channel redundancy. We perform a pre-processing step for converting one-dimensional EEG signal in to two-dimensional matrices, which are then arranged in group of pictures (GOPs). MCTF is applied on each GOP for exploiting the temporal redundancy and DWT is applied on each frame to exploit spatial redundancy. This is followed by SPIHT to generate bit-stream at the required data rate with minimum distortion. Our proposed compression algorithm gives better reconstruction quality of the original data by exploiting intra-channel redundancy of EEG signals.
The main contributions of our work are 1) EEG signal from each channel is arranged in the form 2-D matrices, which are further processed as group of pictures to exploit redundancy. 2) MCTF and DWT are applied on each GOP to remove temporal and spatial redundancy respectively and SPIHT is used to generate a scalable bitstream. 3) Better compression ratio and scalability is achieved by our proposed method when compared with other lossy EEG compression techniques. The remainder of this paper is organized as follows. The proposed compression method is presented in Section II, followed by experimental results in Section III and discussion and conclusion in Section IV.

A. PRE-PROCESSING
In the pre-processing step, one dimensional EEG signal is converted into a sequence of frames. EEG signal is divided into non-overlapping segments consisting of N number of samples. In order to have adjacent sample correlation, odd rows are arranged directly, while even rows are arranged in reverse form. Each frame in a sequence is of size N × N as shown in Fig. 2. The resulting frames are correlated because of the slowly varying nature of EEG signals. Once the sequence of frames is constructed they are arranged in the form of group of pictures to exploit temporal redundancy which is present in adjacent frames.

B. MOTION COMPENSATED TEMPORAL FILTERING (MCTF)
The temporal correlation among the frames is removed by applying MCTF on each GOP constructed in the preprocessing step. MCTF splits frames in each GOP into even and odd frames followed by motion compensation and temporal filtering, which results in temporally decomposed low pass frames, high pass frames, and a set of motion vectors. The MCTF can successfully decompose GOPs along the trajectory of moving objects and hence achieve better results. The two adjacent frames (F n and F n+1 ) are initially filtered using temporal filtering (TF). Motion compensation (MC) takes a reference frmae (F n ) and searches for the matching block in F n+1 to obtain a motion vector (MV n+1→n ). The mapping of F n on F n+1 (M n+1→n ) is acquired by utilizing motion vectors in both horizontal and vertical directions. MC n+1 is obtained by transforming F n+1 using M n+1→n as follows, where, MV H n+1→n (x, y) represents the horizontal motion vector which is mapped from F n+1 to F n in (x, y) and MV V n+1→n (x, y) represents the vertical motion vector which is mapped from F n+1 to F n in (x, y). To decompose F n and MC n+1 , TF utilizes a lifting based scheme and decomposition is given as, where, tH (x, y) and tL(x, y) denotes the temporally decomposed high pass and low pass frames respectively. Motion estimation and compensation helped in reduction of energy in temporally decomposed high frames to achieve high coding gain.

C. DISCRETE WAVELET TRANSFORM (DWT)
We then apply discrete wavelet transform to each temporally decomposed low-and high-pass frame to remove spatial correlation as follows, where d = {H or , V er , D ia }, q 0 denotes the arbitrary initial scale, the approximation of F(i, j) is given by W φ (q 0 , m, n), and horizontal, vertical and diagonal details of F(i, j) is given by W d ψ (q, m, n). φ q 0 ,x,y and ψ d q,x,y are given as, Applying MCTF and DWT completes the spatio-temporal decomposition of each GOP. Fig. 3 shows an example of spatio-temporal decomposition of single EEG channel for two level of temporal and one level of wavelet decomposition. Initially the 1D EEG signal is decomposed into a sequence of f number of frames of size N × N i.e., (F 1 , F 2 , · · · , F f ). The g number of GOPs are then formed by dividing the sequence of frames into group of four i.e., (F 11 , F 12 , F 13 , F 14 ), (F 21 , F 22 , F 23 , F 24 ), · · · , (F g1 , F g2 , F g3 , F g4 ). Two level MCTF is applied over each GOP to obtain four frames i.e., two belonging to low pass and two belonging to high pass channel and are represented as (t − LLF 11 , t − LHF 12 , t − HF 13 , t − HF 14 ), (t − LLF 21 , t − LHF 22 , t − HF 23 , t − HF 24 ), · · · , (t − LLF g1 , t − LHF g2 , t − HF g3 , t − HF g4 ). Next one level 2D-DWT is applied to obtain approximation and detail subbands of each temporally decomposed frame represented as LL, LH , HL, and HH . VOLUME 8, 2020

D. SPIHT
For bitstream generation, spatio-temporal coefficients of each frame are encoded by using SPIHT algorithm [15], [18], [19], which is a widely used algorithm for coding of EEG signals and is based on three steps i.e., partial ordering of magnitude with set partitioning algorithm, ordering of the transmission bit plane, and exploitation of the self similarity among wavelet coefficients of different scales. The reconstructed quality of EEG signal highly depends on the amount of bit budget assigned to each spatio-temporal frame. As most of the energy lies in temporally decomposed low pass frames as compared to high pass frames. Therefore more bit budget is assigned to low pass frames than high pass frames at each temporal level. For t levels of temporal decomposition, the number of frames in GOP must be equal to 2 t . After first level of temporal decomposition, the number of low pass frames and high pass frames are 2 t−1 . Temporal decomposition is applied further in low pass frames resulting in 2 t−2 low pass and high pass frames at temporal level 2. This temporal decomposition process continues until there is a single low pass and high pass frame at temporal decomposition level t. Let R gf be the bit budget assigned to each frame in the GOP. Let R Hi be the bit budget selected in the proposed scheme for each high pass frame at temporal level i, which is computed as, where i = 1, 2, · · · , t. The bit budget saved from temporally decomposed high pass frames at each level is then assigned to low pass frame at level t and is computed as, The bitstream is generated in such a manner to minimize the distortion at particular rate of temporally decomposed low pass and high pass frames.

III. EXPERIMENTAL RESULTS
To evaluate the performance of the proposed EEG compression scheme, we used two datasets provided by the Berlin brain computer interface group (BCI-3 [20] and BCI-4 [21]). BCI-3 data was recorded using a 64-channel system from five healthy subjects, while performing a motor imagery task. This dataset was sampled at a frequency of 1000 Hz and digitized at 16-bit resolution. The final data obtained was downsampled at 100 Hz. BCI-4 data were recorded using a 59-channel system, while performing cue imagery task. This dataset was sampled at a frequency of 1000 Hz and digitized at 16-bit resolution. We used following parameters i.e., percent-root-mean square difference (PRD), compression ratio (CR), mean square error (MSE), peak signal to noise ratio (PSNR), signal to noise ratio (SNR), quality score (QS), and computational complexity to demonstrate the compression performance of the proposed EEG signal compression scheme. PRD between the original and reconstructed EEG signal was calculated as, where X ori and X rec represents the original and reconstructed EEG signal respectively, and M represents the total number of samples. Compression ratio is defined as, where, B ori denotes total number of bits used to represent the original data and B cmp represents the number of bits used to represent the compressed data. MSE between the original and reconstructed EEG signal was calculated as, PSNR between the original and reconstructed EEG signal was calculated as, SNR between the original and reconstructed EEG signal was calculated as, SNR = 10 × log 10 X ori X ori − X rec .
The tradeoff between reconstruction quality and compression ratio is measured in terms of quality score, which is calculated as, The computational complexity of the algorithm is presented in terms of average encoding time to encode the entire data of single subject in the dataset. Moreover, percentage increase or decrease in encoding time of the proposed scheme compared with some reference scheme is calculated as, where T Pr and T Ref represents the average encoding time of the proposed and reference scheme respectively. The positive value of T indicates the percentage increase in the encoding time of the proposed scheme as compared to reference scheme. In our proposed scheme, MCTF was applied to remove temporal redundancy. Temporally decomposed low pass and high pass frames were generated at each temporal level by using the CDF 9/7 biorthogonal filters [22]. For motion estimation and compensation a macroblock (size: 16 × 16) and windowing (size: 32) was used. To further remove the spatial redundancy from each temporally decomposed frame,  Different values of N were used in our proposed scheme to select an appropriate frame size. EEG signals were compressed at different compression ratios (4 to 32) and PRD of reconstructed signal at each compression ratio was calculated. Fig. 4 shows the compression result of the proposed scheme using different frame sizes and compression ratios in terms of average PRD of all subjects for BCI-3 ( Fig. 4(a)) and BCI-4 ( Fig. 4 (b)) datasets. For all frame sizes, the average PRD value increases as we increase the value of CR. Moreover, the average PRD value decreases as we increase the frame size from 32 × 32 to 128 × 128. The average PRD value increases as we further increase the frame size from 128 × 128. While we have set the parameter by varying the value of N (from lower to higher) and observing that the same value (N = 128) gives the optimal results for both datasets. Therefore, we argue that this should be the frame size and hence used N = 128 for the rest of the experiments. Although, for other datasets the value can vary and could be determined empirically. The impact of GOP size on compression of EEG signal was also evaluated (Fig. 5) for different GOP sizes i.e., 2, 4, 8, and 16. The number of temporal decomposition levels for GOP size 2, 4, 8, and 16 is 1, 2, 3, and 4 respectively. For all compression ratios, the average PRD value decreases as we increase the number of frames in each GOP. The lowest average PRD value for all compression ratio is achieved at GOP size of 16, which is used for the rest of results in the paper. It is clear from Fig. 5 that by increasing the number of frames in each GOP, performance of the proposed scheme is improved irrespective of the compression ratio used. As EEG signal is quasi-static, sample correlation information is utilized at large GOP size to remove the temporal redundancy. Therefore, our proposed method achieves a high value of CR at low PRD with larger GOP size.
Our proposed methodology is compared with two state-ofthe-art lossy EEG compression techniques i.e., SPIHT [15]  and ICA+SPIHT [18] in terms of PRD, mean square error (MSE), signal to noise ratio (SNR), peak signal to noise ratio (PSNR), quality score (QS), and computational complexity. For SPIHT based method, seven level CDF 9/7 DWT decomposition was performed. The DWT coefficients were quantized using a standard integer quantization and passed to the SPIHT encoder for generation of bitstream. For ICA+SPIHT based method, the data was divided into 4096 epochs. EEG from each channel of each epoch was arranged in a matrix form of size 64 × 64. Three principal components were retained having three biggest eigenvalues on the PCA preprocessing stage. Three levels of DWT was applied and SPIHT was used for bitstream generation. Fig. 6 shows the performance comparison of the proposed MCTF based EEG compression scheme with stateof-the-art EEG compression scheme using SPIHT [15] and ICA+SPIHT [18] for BCI-3 and BCI-4 datasets in terms of PRD. It is evident that our proposed scheme outperforms both EEG compression schemes for all compression ratios. A maximum of 5.97% and 3.71% reduction in PRD was achieved for BCI-3 dataset in comparison to SPIHT and ICA+SPIHT respectively at high compression ratio. Furthermore, a maximum of 4.16% and 2.26% reduction in PRD was achieved for BCI-4 dataset in comparison to SPIHT and ICA+SPIHT   respectively at high compression ratio. Similarly, a minimum of 4.55% and 1.86% reduction in PRD is observed on BCI-3 dataset in comparison to SPIHT and ICA+SPIHT respectively at low compression ratio. A minimum of 2.76% and 1.18% reduction in PRD is observed on BCI-4 dataset in comparison to SPIHT and ICA+SPIHT respectively at low compression ratio. On average 4.50% and 2.19% reduction in PRD is obtained by our proposed scheme in comparison to SPIHT and ICA+SPIHT based EEG compression schemes respectively. Fig. 7 show the performance comparison of the proposed MCTF based EEG compression scheme with SPIHT [15] and ICA+SPIHT [18] for BCI-3 and BCI-4 datasets in terms of mean squared error (MSE). It can be observed that the proposed technique outperforms other EEG compression schemes. A maximum of 53.88% and 30.06% reduction in MSE was achieved for BCI-3 dataset in comparison to SPIHT and SPIHT+ICA respectively. Furthermore, a maximum of 77.14% and 65.36% reduction in MSE was achieved for BCI-4 dataset in comparison to SPIHT and ICA+SPIHT respectively. Similarly, a minimum of 14.46% and 3.57% reduction in MSE is observed on BCI-3 dataset in comparison to SPIHT and ICA+SPIHT respectively at low compression ratio. A minimum of 27.65% and 12.53% reduction in MSE is observed on BCI-4 dataset in comparison to SPIHT and ICA+SPIHT respectively. On average 33.67% and 20.17% reduction in MSE is obtained by our proposed scheme in comparison to SPIHT and ICA+SPIHT based EEG compression schemes respectively.
The performance comparison of the proposed scheme with SPIHT [15] and ICA+SPIHT [18] in terms of PSNR are shown in Fig. 8 for BCI-3 and BCI-4 datasets. It is  evident that the proposed scheme performs better in comparison to other EEG compression schemes. A maximum of 8.85% and 6.47% increase in PSNR was achieved for BCI-3 dataset in comparison to SPIHT and SPIHT+ICA respectively. Furthermore, a maximum of 3.2% and 1.46% increase in PSNR was achieved for BCI-4 dataset in comparison to SPIHT and ICA+SPIHT respectively. Similarly, a minimum of 1.13% and 0.16% increase in PSNR is observed on BCI-3 dataset in comparison to SPIHT and SPIHT+ICA respectively. A minimum of 1.68% and 0.4% increase in PSNR is observed on BCI-4 dataset in comparison to SPIHT and SPIHT+ICA respectively. On average 3.73% and 1.69% increase in PSNR is obtained by our proposed scheme in comparison to SPIHT and SPIHT+ICA based EEG compression schemes respectively.
The performance comparison of the proposed scheme with SPIHT [15] and ICA+SPIHT [18] in terms of SNR are shown in Fig. 9 for BCI-3 and BCI-4 datasets. It is evident that the proposed scheme performs better in comparison to other EEG compression schemes. A maximum of 6.42% and 2.42% increase in SNR was achieved for BCI-3 dataset in comparison to SPIHT and SPIHT+ICA respectively. Furthermore, a maximum of 5.80% and 3.17% increase in SNR was achieved for BCI-4 dataset in comparison to SPIHT and ICA+SPIHT respectively. Similarly, a minimum of 2.97% and 0.30% increase in SNR is observed on BCI-3 dataset in comparison to SPIHT and ICA+SPIHT respectively. A minimum of 2.85% and 0.41% increase in SNR is observed on BCI-4 dataset in comparison to SPIHT and ICA+SPIHT respectively. On average 4.21% and 1.92% increase in SNR is obtained by our proposed scheme in comparison to SPIHT and ICA+SPIHT based EEG compression schemes respectively. The overall comparison of the proposed MCTF based EEG compression scheme in terms of PRD, MSE, SNR, PSNR, and QS is shown in TABLE 1. It is evident that the proposed scheme performs better than other schemes in terms of all the parameters. Fig. 10 shows the comparison of the proposed compression technique with SPIHT and ICA+SPIHT compression techniques in terms of average encoding time. The encoding VOLUME 8, 2020 time is measured on a computer system with Intel core i7, 4GHz processor and 16 GB RAM. It can be observed that that the average encoding time of the proposed technique increases by 9.07% and 7.12% in comparison to SPIHT and SPIHT+ICA respectively on the BCI-3 dataset, whereas on the BCI-4 dataset the average encoding time of the proposed technique increases by 3.86% and 1.97% in comparison to SPIHT and SPIHT+ICA respectively. On average 3.73% and 1.69% increase in PSNR is obtained by our proposed scheme in comparison to SPIHT and SPIHT+ICA based EEG compression schemes respectively.

IV. CONCLUSION
In this paper, we have proposed a new MCTF and DWT based sub-band coding scheme for EEG signal compression. The EEG signal from each channel was converted in to two dimensional representation, which are further divided into GOPs. MCTF was applied on each GOP to exploit temporal redundancy followed by DWT to remove spatial redundancy. In order to achieve better decoding quality, more bit budget was assigned to temporally decomposed low pass frames as compared to temporally decomposed high pass frames. Our experimental results have shown that the proposed scheme performs better than state-of-the-art EEG compression schemes in terms of PRD, MSE, PSNR, SNR, and QS with marginal increase in encoding time. In future, we intend to exploit inter-channel redundancy by using MCTF, DWT and sub-band coding. in electrical engineering from NUST, Pakistan, in 2019. He is currently an Associate Professor with the Department of Electrical Engineering, Bahria University. His research interests include image quality assessment and machine learning. He is currently an Assistant Professor with the the Department of Nuclear Engineering, King Abdulaziz University. His research interests include bridge-the-gap between real and computer generated imagery, medical imaging, tracking and radiotherapy to investigate new methods for tracking, and modeling and understanding of the effect of inter-and intra-fraction motion during radiotherapy and applications, include 4D treatment method, tracking internal body motion, radiotherapy dose escalation, and segmentation and respiratory motion compensation. VOLUME 8, 2020