# Real-Time Computing Strategies for Automatic Detection of EEG Seizures in ICU
## 2 Materials and Methods
### Signal Preprocessing  
In our study, we employed a series of signal preprocessing techniques using the Matlab(r) v2023.b platform to enhance the quality of electroencephalogram (EEG) data collected from patients in the Intensive Care Unit (ICU). The methodology is detailed as follows: \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multicolumn{1}{c}{} & \multicolumn{6}{c}{**Demographic and Electroencephalographic Characteristics**} \\ \hline \multirow{2}{*}{**GS (rec)**} & \multirow{2}{*}{**FS (rec)**} & \multirow{2}{*}{**NCS (rec)**} & \multirow{2}{*}{**CS (rec)**} & \multirow{2}{*}{**Recording Type**} & \multirow{2}{*}{**Gender**} & \multirow{2}{*}{**N\({}^{*}\) Patients**} & **Age (Mean and Range)** & **The Suspected Cause of Epilepsy** \\ \hline
39 & 24 & 42 & 21 & S (63) N (114) & F (10) M (14) & 24 & 58.3 (28–81) & Brain Haemorrhage \\
5 & 15 & 18 & 2 & S (20) N (83) & F (7) M (11) & 18 & 55.1 (22–81) & CRA \\
16 & 5 & 11 & 10 & S (21) N (44) & F (5) M (5) & 10 & 43.7 (31–72) & Epilepsy \\
10 & 12 & 11 & 11 & S (22) N (57) & F (5) M (7) & 12 & 63.8 (45–78) & CET \\
4 & 0 & 0 & 4 & S (4) N (19) & F (3) M (2) & 5 & 65.4 (52–76) & Infection \\
1 & 3 & 1 & 3 & S (4) N (9) & F (1) M (1) & 2 & 46.5 (25–68) & Ischaemia \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Demographic characteristics of the sample size. CS = convulsive seizure, NCS = non-convulsive seizure, FS = focal seizure, GS = generalised seizure, rec = recordings, F = female, M = male, S = seizure, N = normal. Figure 1: Cohort distribution of recruited sample size. Noise Reduction Using EEGlab Toolbox: Given the prevalence of noise artefacts in the ICU environment, we utilised various methods from the EEGlab toolbox version 2023.1 (Figure 2). Specifically, we implemented the EEG processing pipeline (PREP) to address these challenges. This included the application of a 'notch' filter at 50 Hz to eliminate harmonic frequencies, coupled with a high-pass filter set at 0.5 Hz and a low-pass filter at 30 Hz. The rationale behind these filter settings was to mitigate interference from electronic ICU equipment and patient muscle activity, which can vary significantly due to the effects of sedatives. 2. Re-referencing EEG Channels: To further reduce noise, particularly artefacts unique to individual channels, we re-referenced all EEG channels to a common central channel, Cz. This step was crucial in minimising specific channel-related noise and improving the overall signal quality. 3. Signal Analysis Enhancement through ICA: For a more refined quantitative analysis of the EEG signals, we applied Independent Component Analysis (ICA). It involves the observation of random variables \(X_{1}\),..., \(X_{n}\), which are modelled as a linear combination of sources \(S_{1}\),..., \(S_{n}\) (Equation (1)). Using ICA, multivariate signals from each electrode are decomposed into independent non-Gaussian signals. This involved performing Singular Value Decomposition (SVD) on the EEG data. SVD was utilised to factorise the data matrices derived from the principal axis analysis of each EEG signal (Equation (2)). This process was conducted for each recorded channel. The aim was to simplify and distil the data from each independent channel, enhancing the clarity and usability of the EEG signals for subsequent analysis [21]. \[X_{i}=a_{i1}s_{1}+a_{i2}s_{2}+\cdots+\ a\ s_{n}\forall i=1,\ldots,n\] (1)  
Figure 2: Noise reduction in mathematical transforms. On the left, we show the graphics corresponding to the mathematical transform Fourier applied to raw data. On the right, after using a biological 1.5 transform to the signal from the upper left, the power of the spectrum from the four main frequency bands can be shown, with an evident change related to a seizure. After applying a Wavelet transform, Daubechies 4, the spectrum potency for each frequency band can be demonstrated at a moment in which a seizure is happening. Equation (1)--Basis of independent component analysis. \(a_{ij}\) = real coefficients.