# DenseNet-Based Classification of EEG Abnormalities Using Spectrograms
## 5 Discussion
For the signal images, we constrained the signal amplitude to a fixed range (\(-0.0003\) uV to \(0.0003\) uV) to suppress extreme outliers and stabilize the visual representation. For spectrograms, we limited the frequency range to 0.1-100 Hz to focus on clinically relevant EEG activity and exclude high-frequency noise. Similarly, for scalograms, we selected wavelet scales corresponding to the same 0.1-100 Hz frequency band, which helps reduce the impact of irrelevant or noisy components outside this range. Moreover, we used the entire TUAB EEG recordings in the development of our method. Each EEG recording used in this study lasts approximately 20 min (see Table 4). We split the EEG into 5 min segments, generating around three to five images per file. Not all 5 min segments in the EEGs labelled as abnormal will contain abnormal events. Similarly, some segments from normal EEGs may contain artifacts. To address this, we averaged predictions from multiple image outputs to obtain the final prediction for each file, thereby reducing the misclassification rate. Table 6 shows that this approach improves overall accuracy by averaging prediction probabilities across all images from each EEG file. Figure 6 presents the confusion matrix for the test set, where spectrograms are used as the input. To enhance the interpretability of our model, we employed LIME and Grad-CAM techniques. Figures 7-10 present the spectrogram (A), LIME highlights (B), and the heatmap (C) generated by LIME. The spectrogram shows the frequency content of the EEG signal over time, while LIME highlights specific sections of the spectrogram that significantly affect the model's predictions, aiding in the understanding of classification decisions. The heatmap, generated by LIME, uses color gradients to indicate the importance of different spectrogram regions in the model's decision-making. Warmer colors (red) represent a positive impact, while cooler colors (blue) indicate a negative impact. Grad-CAM heatmaps (D) are also shown in Figures 7-10. Warmer colors, like red and yellow, highlight regions most influential in the model's decision, while cooler colors, like blue, represent less significant areas. In the superimposed images, the red and yellow regions align with EEG areas of higher power, frequency, and amplitude, providing deeper insight into the model's decision-making process in image classification. Figures 7-10 illustrates true positive, true negative, false positive, and false negative events, along with their corresponding LIME (B and C) and Grad-CAM visualizations (D and E), highlighting the specific areas of the spectrogram that the model focused on during classification. In Figure 7, an example of a true positive event is shown. The LIME heatmap (Figure 7C) and Grad-CAM overlay (Figure 7E) clearly highlight the high-power signal with an elevated frequency on channel O1. This signal is marked in blue within the red block on the LIME heatmap, and as the yellow epoch within the red block on the Grad-CAM overlay. The original spectrogram in red indicates higher power at this point. These visualizations demonstrate that this high-power signal plays a crucial role in the model's prediction of abnormal EEG. The increased power corresponds to the classification of abnormal EEG, as higher power is considered a positive indicator of abnormalities. In contrast, Figure 8 presents a true negative event, where the lower-frequency power signal on channel O1 (within the red block in the Spectrogram, Figure 8A) is crucial for classifying the spectrogram as normal EEG. This comparison highlights that abnormal EEG often shows higher-frequency characteristics compared to normal EEG. In Figure 9, a false positive event is shown, where elevated power in channels T5 and O1 led to the misclassification of a normal EEG as abnormal. This is highlighted in blue on the LIME heatmap (Figure 9C) and yellow on the Grad-CAM overlay (within the red block, Figure 9E). The misclassification can likely be attributed to artifacts in the spectrogram that misled the model.