# DenseNet-Based Classification of EEG Abnormalities Using Spectrograms
## 3 Methodology
### Model Development  
DenseNet121 is a convolutional neural network architecture that utilizes dense connections between layers, where each layer is connected to all subsequent layers in a feed-forward manner [35]. This structure helps mitigate the vanishing gradient problem, resulting in several benefits: it reduces the training complexity of deep learning models, enables the reuse of features, and decreases the number of parameters compared to other architectures [36]. DenseNet121 is widely used for image classification tasks, particularly in medical image analysis, as it can achieve high accuracy with fewer parameters, making it suitable for solving complex medical classification challenges [37].  
In this study, signal images, spectrogram and scalogram serve as inputs separately. We utilize the DenseNet121 architecture pre-trained on ImageNet as a feature extractor for EEG-based classification tasks. We exclude the top fully connected layers of the DenseNet121 model, allowing fine-tuning of the model for normal and abnormal classification. Table 2 shows the input and outputs of our study.  
To improve the model's adaptability to the task, we unfreeze the last 10 layers of DenseNet121, making them trainable while keeping the earlier layers frozen to retain pre-learned ImageNet features, followed by three fully connected layers with 128, 64, and 32 units, respectively, each using ReLU activation and L2 regularization (0.005) to prevent overfitting. The final output layer consists of a single neuron with a sigmoid activation function for normal and abnormal classification.  
The model is compiled with the Adam optimizer with a learning rate of 0.01, and the loss function is binary cross-entropy, which is appropriate for the binary classification task. The performance is evaluated using accuracy, recall, and precision. To prevent overfitting and ensure optimal model performance, early stopping (patience = 20) is implemented, monitoring validation loss, while a model checkpoint is used to save the best-performing model based on validation accuracy. The model is trained for up to 100 epochs using the training and validation datasets. Table 3 shows the hyperparameters used for model training and validation.  
\begin{table}
\begin{tabular}{p{113.8 pt} p{113.8 pt} p{113.8 pt} p{113.8 pt}} \hline \hline
**Feature Type** & **Description** & **Data Format** & **Purpose** \\ \hline \multirow{2}{*}{Signal Images} & Raw EEG signal converted to & \multirow{2}{*}{2D images} & \multirow{2}{*}{Capture temporal EEG patterns} \\  & time-domain images & & \\ \hline \multirow{2}{*}{Spectrograms} & Time-frequency representation of & \multirow{2}{*}{2D images} & \multirow{2}{*}{Capture frequency changes over time} \\  & EEG signals & & \\ \hline \multirow{2}{*}{Scalograms} & Time-frequency representation using wavelets & \multirow{2}{*}{2D images} & \multirow{2}{*}{Capture localized time-frequency features} \\ \hline \multirow{2}{*}{Output} & EEG classification label & \multirow{2}{*}{Binary label (Normal/ Abnormal)} & \multirow{2}{*}{Identify EEG abnormality status} \\  & & & \\ \hline \hline \end{tabular}
\end{table}
Table 2: Input and output features used in the model.