# Cognitive State Classification Using Convolutional Neural Networks on Gamma-Band EEG Signals
## 2 Methodology
### CNN Model
During training, dropout randomly sets a fraction of input units to 0 at each update, which helps prevent complex co-adaptations on the training data. It helps the model to learn more generalizable features from the EEG signals rather than memorizing specific patterns that might be unique to the training set or irrelevant to the classification task. The network concludes with an output structure designed to transform the learned features into meaningful predictions. A 1 \(\times\) 1 convolutional layer with a single filter is applied, acting as a learned linear combination of the features from the previous layer. This compact representation effectively distills the complex, multi-dimensional feature space into a single channel of information most relevant to our classification task. Following this, a sigmoid activation function is applied, which squashes the output to a range between 0 and 1. The sigmoid function, defined as [14]:  
\[\mathrm{f(x)}_{\mathrm{sigm}}=\frac{1}{1+\mathrm{e}^{-\mathrm{x}}} \tag{2}\]  
produces a probability-like score that is directly interpretable in our binary cognitive state classification task. This configuration allows the network to output continuous values that can be interpreted as the likelihood or degree of a particular cognitive state, enabling nuanced predictions beyond simple binary classification. In our EEG analysis,this output structure provides a flexible framework for quantifying the degree of cognitive engagement or attention, rather than just its presence or absence. This nuanced output can be particularly valuable in applications requiring fine-grained analysis of cognitive states or in scenarios where the intensity or certainty of a cognitive state is as important as its binary presence. This nuanced output capability, allowing for quantification of cognitive engagement intensity, enhances the model's utility in applications requiring analysis of mental states. To address the class imbalance in the EEG dataset, a weighted binary cross-entropy loss function was implemented. This imbalance stems from our data labeling approach, resulting in a minority of samples being labeled as positive (high gamma activity) and a majority as negative (baseline activity). To account for this imbalance, we employed the following loss function [31]:  
\[\mathrm{L_{wBCE}}=-\frac{1}{\mathrm{M}}\sum_{\mathrm{m=1}}^{\mathrm{M}}\left[ \mathrm{w}\times\mathrm{y_{true}}\times\log(\mathrm{y_{pred}})+(1-\mathrm{y_{ true}})\times\log(1-\mathrm{y_{pred}})\right] \tag{3}\]  
where M is the number of training examples, w is the weight (equal to 2.5 in our study), \(\mathrm{y_{true}}\) is the target label for training example m, and \(\mathrm{y_{pred}}\) is the prediction for training sample m. This 1:2.5 weighting scheme was determined empirically through iterative testing, aiming to strike an optimal balance between model sensitivity and overall performance. This approach helps mitigate the risk of the model overlooking important but infrequent neural events, which is crucial in EEG analysis where missing key cognitive state transitions could have significant implications for interpretation and subsequent applications.