Introduction

Electroencephalograph (EEG) [1] is the recording of electrical activity that is used to scrutinize the neurophysiological properties of the brain [2], to diagnose brain disorders like epilepsy, sleep disorders and in various brain computer interfaces (BCI) applications like mind-controlled gaming, neuromarketing and social interaction analysis [3]. Such applications require robust portable EEG recorders like NeuroSky MindWave, Emotiv Neuroheadset and Imec EEG Headset, that record single or multichannel EEG data for an extended period (hours, days, or potentially, even months) at varying sampling frequencies and resolutions. This continuous recording of EEG can quickly generate large amounts of data, causing a serious concern in terms of power and storage requirements. To enable such portable devices to work effectively, research on compression algorithms is of prime importance.

EEG compression algorithms [4,5,6,7] exploit various spatial and transform domain properties of the signal—like context, inter/intra-channel correlation, energy compaction, residual energy and power spectrum. There exists a trade-off between attainable compression and the degree of distortion in the reconstructed signal that is explored in all lossy and near lossless compression algorithms.

Previous methodologies employed in compression include transforms like Karhunen-Loeve [8], Wavelet [9,10,11]; dimensionality reduction techniques like principal component analysis (PCA) [12], independent component analysis (ICA) [13, 14]; compressive sensing techniques [15, 16]. Compression can be further enhanced by lossless or lossy coding techniques like arithmetic coding [17], set partition in hierarchical trees (SPIHT) [18]. Near lossless compression can be realized by employing error predictors like neural network and linear sequential predictors [19, 20].

Recent works in MCEEG including tensor decomposition using parallel factor decomposition (PARAFAC), singular value decomposition (SVD) [21], wavelet image transform followed by volumetric coding [22] guarantee the maximum possible error and exploit inter/intra-channel correlation; hybrid system of PCA, FastICA with SPIHT coding [23] takes advantages of both PCA and FastICA for reducing the dimensionality and fDCT [24] exploit transform domain properties to reduce the complexity of the system. To achieve compression, most of these methods rely on computationally intensive progressive operations, limiting its use in real time scenarios. Moreover, none of these methods normalize the data, so that contribution of all samples including outliers can be considered. These outliers need not be random errors but triggered motor or imagery responses to visual, audio or other stimuli. So, there is a need to explore possible hardware-friendly schemes that operate with lower latency giving good reconstruction performance and quantifiable distortion, for normalization and compression.

In this paper, a novel and computationally simple system, SPC is proposed. The scheme demonstrates how the concept of data normalization and representation can be utilized in MCEEG compression. First, an architecture that normalizes the MCEEG data using translation logarithmic (TL) transform is proposed, followed by an integer-fractional coder (IFC) that encodes the data, resulting in data compression. Finally, the effectiveness and robustness of the scheme is validated, using distortion indicators like PRD and PSNR.

Systematization of the paper is as follows: Section 2 discusses the methodology employed in the MCEEG compression, followed by a discussion on evaluation procedures in Sect. 3. Results and discussions are elaborated in Sect. 4. Complexity analysis of the algorithm is explored in Sect. 5 and the paper is concluded in Sect. 6.

Methodology for compression

MCEEG signals are random, bipolar and skewed in nature. These signals can be acquired at varying sampling rates ranging from 250 to 2000 Hz, and digitized at 12/16/24 bit resolution. These signals are processed in IEEE single or double precision floating point format [25,26,27] by the computing systems. The proposed near lossless compression is a two-stage process where the MCEEG signal is normalized using TL block which is subsequently coded in the IFC block. The processes are detailed in the subsequent subsections and illustrated in Fig 1.

Fig. 1
figure 1

Proposed SPC system (a) encoder section (b) decoder section

Encoding process

The encoder of the SPC system is illustrated in Fig 1a. The first step in encoding is the arrangement of the MCEEG data to a 2D structure as shown in (1), where M and N correspond to the number of channels and samples per channel respectively.

$$\begin{aligned} x= \begin{bmatrix} X_{11}&X_{12}&\ldots&X_{1N} \\ X_{21}&X_{22}&\ldots&X_{2N} \\ \vdots&\vdots&\vdots&\vdots \\ X_{M1}&X_{M2}&\ldots&X_{MN} \\ \end{bmatrix} \end{aligned}$$
(1)

To exploit the contribution of all samples and make them suitable for the subsequent processing, the data is pre-processed by the TL transform, which performs two operations: translation and logarithm transformation. To ascertain that the resulting normalized samples are real and positive, the MCEEG samples are translated by a factor f, that depends on the gain of the employed MCEEG recorders.

$$\begin{aligned} g(x)= T(x+f) \end{aligned}$$
(2)

Natural logarithm is deployed in the algorithm for normalization; whilst other bases do not contribute to any significant improvement in compression and signal recovery are not discussed here.

$$\begin{aligned} h(x)= \ln g(x) \end{aligned}$$
(3)

The normalized data h(x) is split into integer \(I_{r} (x)\) and fractional \(I_{f}(x)\) parts using (4) and (5).

$$\begin{aligned} I_{r}(x)=\lfloor h(x)\rfloor \end{aligned}$$
(4)
$$\begin{aligned} I_{f}(x)=h(x)-I_{r}(x) \end{aligned}$$
(5)

\(I_r(x)\) and \(I_f(x)\) are encoded separately using the IFC. \(I_r(x)\) can be encoded using any spatial coding schemes that exploit the redundancies introduced by the TL transform. In the current architecture, run length encoding (RLE) [28] is employed because of its simplicity in implementation. The encoded data are represented as \({(D_1,C_1) (D_2,C_2)\ldots (D_i,C_i)\ldots (D_n,C_n)}\), where \(D_i\) and \(C_i\) are the ith distinct integer and their occurrence (count) respectively. As arithmetic coders and Huffman coders introduce complexity in the system with only a marginal improvement in compression, they are not considered suitable in the proposed architecture.

Subsequently, \(I_f(x)\) can be encoded to an equivalent representation with error deviation depending on the bit depth d of the base converter. First, the converter converts \(I_f(x)\) to its equivalent binary stream b using (6), which is the generalized relation for converting fractions to or from any base.

$$\begin{aligned} b= a_0 m^{-1}+ a_1 m^{-2}+a_2 m^{-3}+\cdots +a_{k+1} m^{-k} \end{aligned}$$
(6)

where m is the base, k is the resolution and a takes values \({0,1,\cdots ,m-1}\). For example, for converting the fraction to binary, m is 2, and a takes values 0 or 1.

Data representations for faster encoding and decoding [29] include methods like variable byte, byte-oriented encoding, binary packing, binary packing with variable-length blocks and patched coding. Such representations are also useful in size reduction and faster access. A similar packing strategy of the binary stream has been employed in this architecture.

For data representation in the proposed algorithm, the binary stream b from base converter is reshaped and packed into groups of eight bits to form an integer equivalent representation of the fractional data called PI. This representation supplemented with spatial coding technique, helps the algorithm to achieve compression. The coded MCEEG is stored as frames as depicted in Fig 2, having three fields MCEEG header, integer data and fraction data. Figure 3 illustrates the encoding of four samples of 2D MCEEG signals being encoded and represented by distinct integer, integer occurrence and pseudo integers.

Fig. 2
figure 2

Framing process in MCEEG compression

Fig. 3
figure 3

Sample MCEEG encoding process

Decoding process

The decoder of the SPC system is illustrated in Fig 1b. For decoding the compressed MCEEG consisting of the RLE encoded data and PI, is first processed in the integer fractional decoder (IFD). The RLE data is unpacked by interpolating the coded integer \(D_i\) by the parameter \(C_i\) to obtain \(I_r(x')\). Subsequently, the PI are binarized and reshaped according to the bit depth value used for encoding, which is retrieved from MCEEG Header. The reshaped data is converted to fractional base using (6) to obtain \(I_f(x')\). Both processes can be performed in parallel hence, reducing the decoding time. \(I_f(x')\) is added with \(I_r(x')\) resulting in the reconstructed normalized signal \(I(x')\).

$$\begin{aligned} I(x')=I_r(x')+I_f(x') \end{aligned}$$
(7)

Inverse transformation of \(I(x')\) is performed in the ILT block where an exponential operation defined by (8) is performed initially.

$$\begin{aligned} h(x')=exp I(x') \end{aligned}$$
(8)

Subsequently the reconstructed MCEEG signal \(x'\) is obtained by translating \(h(x')\), given by (9), where factor f, is the same as that used in the encoder.

$$\begin{aligned} x'=T(h(x')-f) \end{aligned}$$
(9)

Performance validations

To evaluate the efficacy of the proposed scheme, few data sets have been chosen, labelled as data set 1–8, from each of these standard databases illustrated in Table 1. The databases used are from Berlin BCI Competitions (II–IV) [30,31,32], Swartz Center for Computational Neuroscience (SCCN) [33] and PhysioNet [34]. The database is made up of MCEEG recording of different subjects performing various motor or imagery tasks, subjected to various constraints and stimuli. Data sets 1, 4 and 5 are processed in IEEE double precision floating point format whereas data sets 2, 3, 6 and 7 in IEEE single precision floating point.

Table 1 MCEEG data sets used for testing

Performance measures

The efficacy of the proposed method is validated based on various quality indicators [35], like compression ratio (CR), maximum absolute error (MAE), percentage root mean square difference (PRD), root mean square error (RMSE) and peak signal to noise ratio (PSNR). As PRD alone does not convey the distortion in the reconstructed signal, other measures like PSNR, MAE, PAE and RMSE and their relations are also investigated.

Results and discussion

The proposed architecture of MCEEG compression algorithm shown in Fig.1 was evaluated using the data set discussed in Sect. 3. All channels of the EEG data sets were taken for simulation, though increasing or reducing the number of channels or samples per channel did not have any significant impact on the degree of compression. A visual illustration of the original, reconstructed and error signal at a bit depth of 5, is illustrated in Fig.4. The bit depth of five can be considered as an optimal choice as it gave almost similar and relatively good CR and distortion measures for all the data sets.

Fig. 4
figure 4

Superimposed original, reconstructed and residual error signals at an optimal bit depth of five

The logarithmic transformation normalized the data, and the process is fully reversible. The reconstructed signal quality was visually validated and quantified numerically using the least absolute error (LAE) distortion parameter. The maximum error in the reconstructed signal was in the order of \(10^{-7}\)\(10^{-9}\). The CR and distortion performance for different bases of the logarithmic transform showed no significant variation hence, are not discussed further.

Observation of the proposed algorithm

The performance of the proposed algorithm for different data sets are illustrated in Figs. 5, 6, 7. The bit depth d of base converter contributes largely to the compression as well as distortion in the recovered signal, as illustrated by Fig. 5a–c. The lower value of bit depth results in higher compression, with larger distortion in the recovered signal and vice versa. Hence, choice of optimal value of bit depth depends on the acceptable amount of distortion in the reconstructed signal. This value was found out with visual scoring along with numerical values of the distortion metrics PRD, RMSE, PAE, MAE and PSNR as elaborated in the subsequent paragraphs.

It was observed that at higher bit depths distortion is negligible and CR is comparatively less. For e.g., from Figs. 5f, 6a, d, CR at a bit depth of eight is nearly two, with PRD value very close to zero and PSNR above 44 db. The performance of the algorithm at different sampling frequencies (100, 1000 Hz) is almost the same as exemplified by distortion indicators corresponding to data sets 4 and 5 in the performance plots. Another observation is that the resolution of the original data does play a significant role in achievable CR. It can be concluded that higher CR can be achieved at higher resolutions of the ADCs and vice versa. This is a significant observation as currently available ADCs are operating at higher resolutions than those employed in this study.

Fig. 5
figure 5

Performance illustration of proposed scheme of different MCEEG data sets for varying bit depth

Fig. 6
figure 6

Performance illustration of proposed scheme of different MCEEG data sets for varying CR

Fig. 7
figure 7

Performance illustration of proposed scheme for different MCEEG data sets

Distortion performance indicators vary among the data sets at the same bit depth. PAE value indicates the largest difference between the original and reconstructed signal. MAE, on the other hand, indicates the mean error in the reconstructed signal. RMSE value, apart from being an error measure also serves as a performance indicator of the outliers. There was a four-fold increase in the RMSE value and a two-fold increase in the PAE and MAE values for a successive reduction in bit depth.

For a bit depth of five, the acceptable average CR of 3.16 occurs at average MAE value of 3.88. Moreover, from Fig. 7b, at the average value of MAE, the maximum variation of PAE ranges from 10 to 15. This provides an upper limit to the sample error at the current CR. Furthermore, average PSNR of 37.69 db and PRD of 2.72 are observed at the specified CR. Hence, based on the visual scoring and critical inference from Figs. 5, 6, 7, it can be concluded that the optimal bit depth across different data sets can be taken as five, though in some data sets much lower bit depths can also be considered with similar distortion parameters.

Table 2 illustrates the encoding and decoding time of the proposed algorithm for different number of channels and samples per channel. Computations were performed on a PC with Intel Core2Duo processor operating at 1.8 GHz with 2 GB RAM. From the table, the average encoding and decoding times per sample can be computed, which are 0.3 and 0.04 ms respectively. This is a clear indicator that the algorithm is computationally simple and fast when compared to other progressive computation algorithms.

Table 2 Computation time of the proposed scheme, for different sample sizes

Use of public and common data sets are required for relative performance analysis of novel compression algorithms. In the proposed work, data sets 4, 7 and 8 were used for performance comparison as they were the ones used in recent compression algorithms [22, 24, 36]. A comparison is illustrated in Table 3, taking PRD and PSNR as reference quality indicators and the best CR measure is indicated in bold. The comparative results signify that the performance of the proposed method in terms of compression and distortion is comparable with recent work but with a much lower time complexity. The main highlight of the proposed algorithm is its simplicity in compressing and decompressing the MCEEG data [24] claims to be computationally light, but it is not superior to the proposed algorithm, as observed from the table, in terms of compression and distortion parameters of the reconstructed signal. The performance of the proposed algorithm is compared with a very recent paper [36], which employs DPCM and clustering methodology to achieve compression and from the table it can be seen that the proposed algorithm outperforms both in CR and signal quality.

Table 3 Relative performance comparison of the compression algorithm

Complexity analysis

In this section, the computational efficiency of the proposed scheme is analysed in terms of memory requirement and time complexity.

Memory requirement analysis

Consider n distinct 24 bit samples given by \(\left( {\begin{array}{c}2^{24}\\ n\end{array}}\right)\) and by information theoretical argument, the number of bits to represent the data is given by \(log{2^{24} \atopwithdelims ()n}\), which can be approximated using the property in combination as \(log{2^{24} \atopwithdelims ()n} \ge (n*log\frac{2^{24}}{n})\), the size of n elements or samples. It can be proved that the proposed method can compress the data reasonably well. For n samples, the integer and fractional parts are processed separately.

Integer part

To take advantage of the redundancies introduced by the TL transform, RLE is performed where the encoder returns two values: one is the distinct integer and the second is its occurrence count. Consider that there are c distinct integers in the set of n integers, such that c satisfies the condition, \(1\le c\le n\). The number of bits required to represent c integers is given by

$$\begin{aligned} ln{2^{8} \atopwithdelims ()c} \ge c*ln\left(\frac{2^{8}}{c}\right) \end{aligned}$$
(10)

Memory requirement for occurrence or count of c integers is the same as (10). The overall memory requirement of RLE scheme is given by

$$\begin{aligned} 2*ln{2^{8} \atopwithdelims ()c} \ge 2*c*ln\left(\frac{2^{8}}{c}\right) \end{aligned}$$
(11)

Fraction part

The data is binarized using d bits defined by bit depth. The number of samples n is taken such that product of \(d*n\) is divisible by eight (size of the integer). Following the similar procedures, the number of bits required for representing the fraction is given by \(2*log{2^{8} \atopwithdelims ()k}\), where \(k=\frac{d*n}{8}\). To illustrate the effect of bit depth on memory requirements, consider 3 cases d takes values 16, 8, 1, the memory requirement is \(log{2^{8} \atopwithdelims ()\ 2n}\), \(log{2^{8} \atopwithdelims ()\ n}\) and \(log{2^{8} \atopwithdelims ()\frac{n}{8}}\) respectively. It has been observed from the illustration that bit requirement reduces as the value of d decreases.

Total memory requirement of the proposed scheme is the sum of memory required for bit depth (d), translation factor (f), encoding of the integer and fractional part as shown in (12). The requirement of the scheme is much smaller than the actual requirement in storing single precision samples.

$$\begin{aligned} 8+8+2*c*ln \left(\frac{2^8}{c}\right)+\frac{d*n}{8}ln\left(\frac{2^8}{\dfrac{d*n}{8}}\right) \end{aligned}$$
(12)

Variation in (12) occurs when

  • Number of samples n, becomes very large leading to larger occurrence or count values;

  • Translation factor f can take on larger values depending on the gain of MCEEG recorders.

An upper bound can be set to handle larger f and occurrence or count of distinct integers c in \(I_r(x)\). Even with this upper bound, the increase in space requirement is not significant since

  • The number of distinct integers c resulting from the TL transform is very small when compared to the total number of samples n.

  • Increase in the number of bits for representing larger translation factor f does not create a significant change in overall requirement, as a larger sample space is considered.

Time complexity

Time complexity is another quality measure signifying the computational performance of any algorithm. Most EEG compression algorithms available in the literature do not comment on their complexity measure, making a comparative study difficult. As most of these algorithms employ methodologies like PCA, ICA, Compressive Sensing or decomposition techniques like SVD, according to known literature, the lowest complexity attainable is \(O(n^{2})\).

The upper bound for the complexity of the proposed algorithm is given by O(nmd), where n is the samples, m is the number of channels and d is the precision or bit depth. As m and d are fixed, they do not contribute to complexity. Thus, the algorithm has a linear dependence with the number of samples taken over a period, given by O(n).

Conclusion

The significance of this study is that it provides a computationally simple model for compressing MCEEG signals. In the proposed SPC system, the signal is normalized using the TL transform and the resulting coefficients are coded using IFC, ensuing in data compression. The proposed scheme achieved an average CR of 3.16 with a computational complexity of only O(n) and average encoding and decoding times per sample of 0.3 and 0.04 ms respectively. This is reasonably better than the other methods which rely on computationally intensive operations, to achieve similar CR. Moreover, the distortion level indicators such as PRD, MAE, PAE, RMSE and PSNR showed promising results to substantiate that the algorithm is suitable for MCEEG compression. As a future scope, the inter and intra-channel redundancies can be exploited to increase CR further and adaptively choose optimal bit depth to attain higher CR across different data sets, without compromising on the existing complexity.