## 3 Methods  
### EEG-Based Concentration Level Detection  
For preprocessing, EEG data collected via Muse headbands (4 channels: AF7, AF8, TP9, TP10, sampled at 256 Hz) underwent Discrete Wavelet Transform (DWT) using the Daubechies-4 (db4) wavelet basis. A 5-level decomposition was applied to isolate five canonical EEG bands: \(\delta\), \(\theta\), \(\alpha\), \(\beta\), and \(\gamma\). Each band was processed separately, resulting in five distinct matrices. The frequency bands corresponded to cognitive states, where \(\alpha\) related to relaxation, \(\beta\) to active thinking, \(\theta\) to drowsiness, \(\gamma\) to cognitive load, and \(\delta\) to deep sleep. Feature extraction followed a sliding-window approach (1 s windows with 0.5 s overlap). Within each window, we extracted the following features:  
* Mean, skewness, and kurtosis;
* Minimum and maximum values;
* Variance and covariance matrix;
* Eigenvalues and matrix logarithms of the covariance matrix;
* FFT magnitude and top 10 most energetic frequencies. From each window, a total of 989 features were computed. To reduce dimensionality and improve generalization, we applied Information Gain for feature selection, retaining the top 256 features per wave type. Each resulting feature matrix was reshaped into a 16 \(\times\) 16 grayscale image. For classification, a multi-CNN architecture was utilized, employing a 5\(\rightarrow\)1 CNN fusion model (CNN(5\(\rightarrow\)1)) [18], where five parallel CNNs were trained (one per wave type) and their features were concatenated in the flattened layer. The CNN architecture (per branch) consisted of the following:  
* Conv2D (32 filters, 3 \(\times\) 3, ReLU);
* Conv2D (64 filters, 3 \(\times\) 3, ReLU);
* MaxPooling2D (2 \(\times\) 2);
* Dropout (0.25);
* Flatten;
* Dense (512 units, ReLU);
* Dropout (0.5);
* Output: Dense (3 classes, Softmax). The concatenated output (shape: 11520) was passed through a final dense layer (512 ReLU) and a softmax layer for classification into three mental states: relaxed, neutral, and concentrated. The final model (CNN(5\(\rightarrow\)1)) was trained for 400 epochs. Algorithm 1 presents the steps for EEG classification. Due to the limited availability of large-scale child EEG datasets, the initial EEG model was pre-trained using adult data and calibrated to each child through a 20 s personalized adaptation phase. This brief calibration allowed real-time mapping of dominant EEG patterns without needing long training sessions, which are difficult to conduct with children. ```
1:Input: Raw EEG signals \(S\) from channels \(\{TP9,TP10,AF7,AF8\}\)
2:Output: Concentration level \(C=\{\)concentrated, neutral, relaxed\(\}\)
3:Step 1: Apply Discrete Wavelet Transform (DWT)
4: Decompose \(S\) into five frequency bands: \(\alpha,\beta,\theta,\gamma,\delta\)
5: Using DWT Type II:
6:\(X_{j,k}=\sum_{n}x[n]g_{jk}[n]\)
7:\(Y_{j,k}=\sum_{n}x[n]h_{j,k}[n]\)
8: where \(X_{j,k}\) and \(Y_{j,k}\) are the approximation and detail coefficients at scale \(j\), and \(g_{j,k}[n]\) and \(h_{j,k}[n]\) are the wavelet and scaling functions, respectively. 9:Step 2: Compute Statistical Features
10: Mean: \(\hat{y}_{k}=\frac{1}{N}\sum_{i=1}^{N}y_{ji}\)
11: Skewness: \(g_{1,k}=\frac{\sum_{i=1}^{N}(y_{ji}-\hat{y}_{k})^{3}}{N_{k}^{2}}\)
12: Kurtosis: \(g_{2,k}=\frac{\sum_{i=1}^{N}(y_{ji}-\hat{y}_{k})^{4}}{N_{k}^{2}}-3\)
13:Step 3: Compute Covariance-Based Features
14: Covariance matrix: \(s_{k\ell}=\frac{1}{N-1}\sum_{i=1}^{N}(y_{ki}-\hat{y}_{k})(y_{\ell i}-\hat{y}_{ \ell})\)
15: Eigenvalues: \(\det(\mathbf{S}-\lambda\mathbf{I}_{K})=0\)
16: Logarithm of the covariance matrix:
17:\(e^{\mathbf{B}}=\mathbf{I}_{K}+\sum_{i=1}^{\infty}\frac{\mathbf{S}^{x}}{n!