# A Hybrid CNN-GRU-LSTM Algorithm with SHAP-Based Interpretability for EEG-Based ADHD Diagnosis
## 3 Materials and Methods
### Feature Importance and the Selection Process  
To allow for powerful yet interpretable classification of ADHD from EEG recordings, a good preprocessing pipeline must be coupled with an effective model architecture. An awareness of this necessity guided the selection of a hybrid CNN-GRU-LSTM model that is capable of pulling out spatial and temporal features from EEG recordings. While model architecture is the cornerstone of accurate predictions, an understanding of which input features drive these predictions is equally vital, particularly in a clinical context where transparency and physiological relevance are paramount. To satisfy this need, a feature importance analysis was performed employing the XGBoostClassifier model, as shown in Figure 10. This analysis offers a numerical score that reflects the individual contributions of specific EEG channels towards the classification task. Neuroscientific consensus on the role of temporoparietal and frontal areas in attentional and executive control domains aligns with the identification of P7, F4, and Fp1 as significant factors in this case. Conversely, smaller importance values for channels, such as O2 and P8, indicate their minimal contribution in this diagnostic context, which could reflect the presence of overlapping signal features or less relevance when engaged in cognitive tasks. The application of explainable machine learning techniques in a complementary manner enhances the interpretability and trustworthiness of the overall classification system. Figure 11 provides a visual representation of the preprocessing pipeline designed to prepare EEG signals for input into the CNN-GRU-LSTM model. The process begins with raw EEG acquisition from 32 channels according to the international 10-20 system, recorded while subjects perform attention-related cognitive tasks. The following subsection outlines each stage of the pipeline and its associated mathematical representation. The first stage involves loading and organizing raw EEG signals as multichannel time series. Each recording is denoted as (1):  
\[X^{(i)}e\ R^{C*T} \tag{1}\]  
where \(X^{(i)}\) is the EEG matrix for subject \(i,C\) is the number of channels, and T is the number of time points. Subsequently, in the second stage, a band-pass filter is applied to suppress low-frequency drifts and high-frequency noise, typically within the 4-40 Hz range (2):  
\[\widetilde{X}^{(i)}=\texttt{F}_{BP}(X^{(i)}) \tag{2}\]  
where \(\texttt{F}_{BP}\) represents the filtering function applied channel-wise. Figure 10: Feature importance determined by XGBoost. At the third stage, Independent Component Analysis is utilized to separate artifacts, such as ocular and muscular noise, from neural activity. The filtered signal is decomposed into independent sources (3):  
\[\overset{\sim}{X}^{(i)}=A^{(i)}*\ S^{(i)} \tag{3}\]  
where \(S^{(i)}\)(t) is the matrix of independent components, and \(A^{(i)}\) is the mixing matrix. Components corresponding to artifacts are removed, and the signal is reconstructed. In the fourth stage, the artifact-free signal is segmented into windows of fixed duration \(L\), generating multiple time-localized segments (4):  
\[\overset{\sim}{X}_{i}^{(j)}=\overset{\sim}{X}^{(i)}\big{[};\ t_{j}:\ t_{j}+L-1 \big{]} \tag{4}\]  
where \(t_{j}\) is the starting index of window \(j\). During the fifth stage, features are extracted from each window. These include statistical and spectral features per channel, such as the mean (5):  
\[\mu_{jc}=\sum_{t=1}^{L}x_{jc}(t) \tag{5}\]  
and the power spectral density (PSD):  
\[P_{jc}=\ \mid F(x_{jc}(t)\mid^{2} \tag{6}\]  
where \(x_{jc}(t)\) is the time series in channel \(c\), window \(j\), and \(F\) denotes the Fourier transform.