TMP19: A Novel Ternary Motif Pattern-Based ADHD Detection Model Using EEG Signals

Attention deficit hyperactivity disorder (ADHD) is a common neurodevelopmental condition worldwide. In this research, we used an ADHD electroencephalography (EEG) dataset containing more than 4000 EEG signals. Moreover, these EEGs are noisy signals. A new hand-modeled EEG classification model has been proposed to separate healthy versus ADHD individuals using the EEG signals. In this model, a new ternary motif pattern (TMP) has been incorporated. We have mimicked deep learning networks to create this hand-modeled classification method. The Tunable Q Wavelet Transform (TQWT) has been utilized to generate wavelet subbands. We applied the proposed TMP and statistics to construct informative features from both raw EEG signals and wavelet bands by generating TQWT. Herein, features have been generated by 18 subbands and the original EEG signal. Thus, this model is named TMP19. The most informative features have been chosen by deploying neighborhood component analysis (NCA), and the selected features have been classified using the k-nearest neighbor (kNN) classifier. The used ADHD EEG dataset has 14 channels. Thus, these three phases—(i) feature extraction with TQWT, TMP, and statistics; (ii) feature selection by deploying NCA; and (iii) classification with kNN—have been applied to each channel. Iterative hard majority voting (IHMV) has been applied to obtain a higher and more general classification response. Our model attained 95.57% and 77.93% classification accuracies by deploying 10-fold and leave one subject out (LOSO) cross-validations, respectively.


Introduction
Attention deficit hyperactivity disorder (ADHD) is a persistent neurodevelopmental disorder [1][2][3]. It can increase the risk of poor educational and occupational outcomes, social disability, and other psychiatric conditions [4]. ADHD is often diagnosed between the ages of 3 and 7 years, but may not be recognized until adulthood [5,6]. ADHD symptoms include inattentiveness and hyperactivity-impulsivity [7]. People with ADHD often have additional features such as impairments in their executive function and emotional regulation [8][9][10]. Systematic reviews show that ADHD affects 5% of children and adolescents and 2.5% of adults globally [11]. Boys are more likely to be diagnosed with ADHD than girls [12,13]. Early diagnosis is very important for this condition to optimize management and reduce the long-term negative sequalae in psychosocial wellbeing and integration into the community [14]. Management usually combines patient and family education and pharmacological and non-pharmacological interventions such as a range of behavioral and neurocognitive therapies [15]. The aim is to eliminate disease symptoms. Psychologists diagnose ADHD, and the professionals have responsibility for assessment and diagnosis. This assessment typically involves a combination of standardized evaluation scales plus a clinical interview, compared to the DSM-5 or ICD (International Statistical Classification of Diseases and Related Health Problems) diagnostic criteria [16]. Diagnosing ADHD can be challenging, particularly in regions with limited access to suitably trained health professionals.
There is, therefore, interest in the ability of other diagnostic tools to improve equitable access to an early diagnosis [17]. One suggested diagnostic data type is the EEG [18]. The FDA has stated that the EEG may be a helpful diagnostic tool in ADHD diagnoses [19]. An increasing number of studies on the potential diagnostic utility of EEG have now been reported in the literature. This paper proposes a new hand-modeled EEG classification for the automatic interpretation of EEG signals for diagnosing ADHD in children. The model developed in this study has high classification success and low computational complexity.
The diagnosis of ADHD using EEG signals remains a hot topic with as yet no universally agreed upon guideline for the diagnostic use and interpretation of the EEG. Moghaddari et al. [20] used the Convolutional Neural Network (CNN) for ADHD diagnosis in children. Their study utilized EEG signals from 31 ADHD and 30 healthy children, which were preprocessed and free of noise and artifacts. Thereafter, the EEG signals were converted to RGB images and provided as input to a 13-layer CNN. The developed model was evaluated with the 5-fold cross-validation technique, and an average accuracy of 99.06% was achieved. An ADHD classification method using power spectral density (PSD), spectral entropy (SE), and long short-term memory (LSTM) methods has been proposed by Tosun [21]. Their study applied an 80:20 hold-out validation strategy, and the proposed method yielded a 92.15% accuracy. Khoshnoud et al. [22] performed a nonlinear EEG analysis in children with ADHD. The largest Lyapunov exponent (LLE) and approximate entropy (ApEn) methods were used to obtain the nonlinear characteristics of the signal. These features were evaluated with a Probabilistic Neural Network (PNN), and an 87.5% classification accuracy was obtained. Chen et al. [23] proposed a deep learning framework to identify children with ADHD. In their proposed method, EEG signals are converted into image data and given as input to the CNN developed in the study. EEG signals from 50 children with ADHD and 51 healthy children were utilized. The developed model provided a 94.67% accuracy performance on the test data. Tenev et al. [24] proposed a learning approach for classifying adult ADHD individuals automatically. Their study analyzed EEG signals from 117 adults (67 ADHD and 50 controls) using a Support Vector Machine (SVM) and voting method. The proposed method achieved an 82.3% success rate in separating ADHD versus control groups. Saini et al. [25] developed an EEG signal-based machine learning model for ADHD diagnosis. The developed model uses principal component analysis (PCA) for feature selection and k-nearest neighbor (kNN) for classification. In this study, EEG signals from 77 ADHD and 80 healthy children were classified, and an accuracy of 86% was achieved. Dubreuil-Vall et al. [26] collected EEG signals from 40 subjects (20 ADHD and 20 controls) for ADHD classification. In their study, firstly, the signal was preprocessed and then the spectrogram of the signal was extracted. Thereafter, the spectrogram images of the EEG signal were fed as input to the custom designed CNN, and classification was made. The developed model reached an 88% classification accuracy. Tor et al. [27] used empirical mode decomposition (EMD) and discrete wavelet transform (DWT) decomposition methods and nonlinear features for ADHD, conduct disorder (CD), and ADHD+CD detection. They analyzed EEG data of 123 children (45 ADHD, 62 conduct disorder + ADHD, and 16 conduct disorder subjects) with a kNN classifier and obtained an accuracy of 97.88%. Loh et al. [28] reviewed the automated ADHD detection methods published in the last decade. They reviewed all the machine learning and deep learning techniques employed for the automated detection of ADHD using both physiological signals and images.
The essential motivations of the presented model are: • Presenting a new motif pattern to generate textural features; • Proposing a hand-modeled one-dimensional signal classification architecture; • Attaining robust and high classification performance with low time complexity.
Thus, this study has three main motivations. First, motifs of signals are very useful for extracting features. A new feature generation model has been proposed to use motifs as a feature vector, and this feature extraction function is named TMP. We aimed to present a highly accurate feature engineering model. Hence, we used both hand-crafted features and an architecture miming a deep learning architecture to attain high classification accuracy. Deep learning models have multiple levels/layers to generate distinctive features. Thus, we have used a multileveled feature extraction model. By using this model, an accurate EEG signal classification method has been proposed. To demonstrate its robustness, we used two validation techniques (10-fold CV and LOSO CV). These validations yielded 95.57% and 77.93% classification accuracies by deploying 10-fold CV and LOSO CV, respectively.
The novelties and contributions are: In the feature selection phase, the main feature extraction function is NCA. At the same time, we employed threshold-based elimination to obtain more distinctive features. Thus, the model is named threshold-based NCA.

•
We integrated a noisy EEG dataset containing 4173 EEG signals, each of four seconds in length. We believe this is the first proposal of a classification model for this dataset in the literature.

•
Our proposal-TMP19-was tested using two validation techniques and showed robust results. The TMP19 attained 95.57% and 77.93% classification accuracies by deploying 10-fold CV and LOSO CV, respectively.

Material
We utilized a noisy EEG dataset in this work [29,30]. The dataset contains 2330 healthy EEG signals and 1843 ADHD EEG signals. The lengths of these EEG signals are equal and four seconds in length. In this EEG dataset, there are 14 channels. The frequency sampling of these EEG signals is 128 Hz.

Method
In this paper, a new local feature extraction function has been proposed, named the ternary motif pattern. Herein, we integrated five-sized overlapping blocks to obtain motifs, and we applied the ternary function to find upper, equal, and lower values. Two feature maps have been generated using these values, and histograms of these feature maps have been utilized as feature vectors. The model overview of the presented TMP is demonstrated in Figure 1.
have been utilized as feature vectors. The model overview of the presented TMP is demonstrated in Figure 1. To better explain this model, detailed descriptions have been given below.
Step 1: Create overlapping blocks with a length of five.
= ( : is the overlapping block with a length of five, and defines the length of the signal.
where represents ternary motif values, and () defines ternary function.
Step 3: Calculate map values using ternary motif values.
The symbols 1 and 2 represent the first and second map signals, respectively.
Step 4: Extract histograms of map signals. To better explain this model, detailed descriptions have been given below.
Step 1: Create overlapping blocks with a length of five.
Herein, bl t is the overlapping block with a length of five, and len defines the length of the signal.
where val represents ternary motif values, and t f () defines ternary function.
Step 3: Calculate map values using ternary motif values. The symbols m 1 and m 2 represent the first and second map signals, respectively.
Step 4: Extract histograms of map signals.
where h 1 and h 2 are histograms of first and second maps. The length of each map signal is 243 (=3 5 ).
Step 5: Merge the generated histograms and obtain a feature vector.
The symbol f v defines the generated feature vector with a length of 486 (=243 × 2). These five steps above define the proposed TMP.
We suggested a new hand-modeled signal classification method in this paper, and our proposal is named TMP19. TMP19 contains four main phases, and these phases are: In Figure 2, a graphical overview of the proposed TMP19 is demonstrated. where ℎ 1 and ℎ 2 are histograms of first and second maps. The length of each map signal is 243 (=3 5 ).
Step 5: Merge the generated histograms and obtain a feature vector.
defines the generated feature vector with a length of 486 (=243 × 2). These five steps above define the proposed TMP. We suggested a new hand-modeled signal classification method in this paper, and our proposal is named TMP19. TMP19 contains four main phases, and these phases are: Majority voting.
In Figure 2, a graphical overview of the proposed TMP19 is demonstrated.

Feature Extraction
In the feature extraction phase, we utilized three methods: (i) TQWT [31], (ii) the proposed TMP feature extraction function, and (iii) statistical feature generator. First, we generated wavelet bands using TQWT transformation. TQWT is a parametric and third-generation wavelet transform. By using redundancy (r), oscillation (Q), and the number of level (J) parameters, a variable multileveled wavelet transform was created. The high oscillatory wavelet transform was assigned 4 and 3 for the Q and r parameters.
The system's main aim was to propose a new feature engineering model as in Dark-Net19. Thus, we generated 18 wavelet coefficient bands to use 19 inputs. These 19 signals (raw EEG signal + 18 wavelet bands) have been utilized as inputs to the feature extraction functions. The system contains two feature extraction functions: the TMP and the statistical feature generator. Both statistical parameters and motifs have been extracted using these feature extractors in the space and frequency domains. The steps of the proposed feature extraction method are given below.
Step 1: Apply TQWT to the EEG signal for generating wavelet bands.
Step 2: Generate features using TMP and statistical feature generation function.
() is concatenation function and it is feature merging function. By using Step 2, 19 feature vectors have been created and the length of each feature vector is 500 (=486 + 14).
Step 3: Concatenate the 19 generated feature vectors to create the final feature vectors.

Feature Extraction
In the feature extraction phase, we utilized three methods: (i) TQWT [31], (ii) the proposed TMP feature extraction function, and (iii) statistical feature generator. First, we generated wavelet bands using TQWT transformation. TQWT is a parametric and thirdgeneration wavelet transform. By using redundancy (r), oscillation (Q), and the number of level (J) parameters, a variable multileveled wavelet transform was created. The high oscillatory wavelet transform was assigned 4 and 3 for the Q and r parameters.
The system's main aim was to propose a new feature engineering model as in Dark-Net19. Thus, we generated 18 wavelet coefficient bands to use 19 inputs. These 19 signals (raw EEG signal + 18 wavelet bands) have been utilized as inputs to the feature extraction functions. The system contains two feature extraction functions: the TMP and the statistical feature generator. Both statistical parameters and motifs have been extracted using these feature extractors in the space and frequency domains. The steps of the proposed feature extraction method are given below.
Step 1: Apply TQWT to the EEG signal for generating wavelet bands.
where R defines TQWT bands, S is the EEG signal, 4, 3, and 18 are the Q, r, and J parameters of the TQWT function (τ()).
Step 2: Generate features using TMP and statistical feature generation function.
Step 3: Concatenate the 19 generated feature vectors to create the final feature vectors.

Feature Selection
In this research, we proposed an improved NCA-based protocol [33], with the feature selection method being named the threshold-based NCA. The selector has two layers: (i) threshold-based redundant feature elimination and (ii) NCA-based feature selection. In this phase, we selected the most informative and valuable 250 features from the generated 9500 features. The steps of this phase are: Step 4: Normalize the final feature vector by deploying a min-max normalization.
where X N defines the normalized final features, and min() and max() are the minima and maximum value finding functions, respectively.
Step 5: Eliminate the redundant features using a threshold value.
nX(:, ct) = X(:, i), i f ag d > th Herein, the summarization value of each vector (ag d ) has been calculated in Equation (14), where dim is the number of EEG signals. In Equation (15), features are eliminated, and a new final feature vector (nX) has been generated using a threshold value (th). In this research, th is selected as zero.
Step 6: Calculate qualified/sorted indexes by deploying the NCA feature selection function.
where id is a sorted index vector with a length of 9500, y defines real outputs/labels, and ξ() is the NCA feature selection function.
Step 7: Select the most meaningful 250 features from the nX.
Herein, sX is a selected feature vector with a length of 250.

Classification
To obtain classification accuracy and the predicted vector of each channel, we used a simple/shallow classifier. The kNN [34] classifier has been used, which is named the Weighted kNN. The hyperparameters of the Weighted kNN are: k:10; Distance weight: squared inverse; Distance: L1-norm (Manhattan); Validation: 10-fold CV/LOSO CV. As is evident from the above description, we used two validation techniques (10-fold CV and LOSO CV) to calculate the robust results obtained with this classifier. The classification step is given below.
Step 8: Calculate the predicted vector of each channel by applying the kNN classifier.
where p c represented predicted vectors of the cth channel, and κ() is the defined kNN classifier.
Step 9: Repeat Steps 1-8 by the number of channels. We used an ADHD dataset containing 14 channels. Thus, we repeated these steps 14 times.

Majority Voting
In the majority voting phase, the iterative hard majority voting (IHMV) algorithm was used to obtain the best classification result. IHMV was proposed by Dogan et al. [35] in 2021. We calculated 14 predicted vectors from the EEG channels individually. By incorporating the 14 predicted vectors, 12 (=14 − 2) new voted predicted vectors were created for each validation technique. The steps of this phase are listed below.
Step 10: Calculate the classification accuracy of each channel.
Step 11: Qualify/sort the predicted vectors using the predicted vectors and obtain qualified/sorted indexes.
where ix defines indexes of the sorted predicted vectors.
Step 12: Calculate voted predicted vectors by deploying the mode function.
Step 13: Calculate classification accuracies of the voted vectors.
Step 14: Choose the most accurate voted vector as the final predicted vector.
The given 14 steps above define the proposed TMP19 feature engineering model.

Results
We have proposed a new feature engineering model that uses four phases in this research. These phases use lightweight methods. Thus, the proposed TMP19 is a lightweight signal classification model, and there is no need to use expensive hardware. We implemented this model on a simply configured computer (main memory: 16 GB, processor: Intel i7-7700, operating system: Windows 11, programming environment: MATLAB 2021a). We used two validation techniques. Moreover, channel-wise voted results have been given in this section.

Performance Metrics
The used ADHD EEG dataset contains two classes, ADHD and normal. Thus, this is a binary classification problem. We built in two common classification performance measures: classification accuracy and geometric mean. To assess these metrics, the number of true positives (tp), false positives (fp), true negatives (tn), and false negatives (fn) are deployed. The mathematical notations of the accuracy (acc) and geometric mean (gm) are given below.

Channel-Wise Results
The used EEG dataset contains 14 channels. To comprehensively depict the proposed model's classification performance, we applied our proposal to each channel, and the classification performances of each channel were calculated. Furthermore, two validations were used in the classification phase. The channel-wise results are tabulated in Table 1.  Table 1 highlights the best results using a bold font face. By applying a 10-fold CV, the most accurate channel is the 13th since our TMP19 model yielded 92.16% classification accuracy and 91.91% geometric mean. According to LOSO CV results, the best classification accuracy is 74.84% on the 7th channel, and the best geometric mean attained on the 13th channel by employing LOSO CV.

Voted Results
In the last phase of the TMP19, the majority voting component is availed of. We applied the IHMV algorithm in this phase to create C-2-voted vectors. Twelve voted vectors were generated by deploying the IHMV algorithm. The results of the voted vectors are listed in Table 2. Table 2 shows that the best classification accuracies were obtained by using 11th and 1st voted vectors when deploying 10-fold CV and LOSO CV, respectively. Per Table 2, IHMV increased the classification accuracies from 92.16% and 74.84% to 95.57% and 77.93% by deploying 10-fold CV and LOSO CV, respectively. These results are the final results of the proposed TMP19.

Final Results
Our proposed TMP19-based model generates 26 (=14 results from 14 channels + 12 voted results) results, and this model selects the best results among the 26 generated results. Thus, the suggested TMP19 is a self-organized feature engineering model. Moreover, two validations were applied in the classification phase. The calculated confusion matrices of the presented TMP19 by deploying LOSO CV and 10-fold CV are given in Figure 3.
As can be seen from Figure 3, our proposed TMP19 attained 95.57% and 77.93% classification accuracies on the ADHD dataset with a 10-fold CV and LOSO CV, respectively.

Discussion
A new feature engineering model has been proposed in this research by mimicking a deep learning structure. The main motivation of the proposed TMP19 is to extract hidden motifs to obtain high classification performances. The TMP19 generates features at both high levels and low levels. High-level features have been generated using wavelet bands. Moreover, features at the frequency domain have been extracted. The threshold-based NCA method has been used to obtain distinctive features. kNN has been employed to show the classification capability of the generated features. The best classification results were generated and selected from the model by applying a majority voting technique. Then the channel-wise and voted results were given. Per the results, the most appropriate channels are the 7th and 13th for ADHD detection. Our model attained a 95.57% classification accuracy by deploying a 10-fold CV and a 77.93% classification accuracy using LOSO CV. These results showed that the presented TMP19 is a successful EEG classification model. Furthermore, we believe that we are the first team to use this dataset to develop a machine-learning model.
The results of other state-of-art classification models and our TMP19 were compared to highlight the classification ability of our model. These results are listed in Table 3. As can be seen from Table 3, our model produced better accuracy than the results of other state-of-the-art methods. Tor et al. [27] achieved better accuracy than our study. They used 3 classes with 123 subjects in the study. Classes include 45 ADHD, 62 conduct disorder + ADHD, and 16 conduct disorder subjects, and the amount of data for each class is small. In addition, two different validation techniques were used in this study. These are the 10-fold CV and the LOSO CV, respectively. Another advantage is that noisy EEG signals were used in our study. A superior side of our study to other previously presented works is to use LOSO CV. Since reliable results have been calculated using LOSO CV, we depicted our model's performances in real-world applications by helping LOSO CV. Although our proposed method exhibits a low computational complexity, it outperforms. The results obtained show the superiority of the proposed method.
The benefits of the presented TMP: • TMP19 is a parametric model. Therefore, next-generation TMP-based classification models can be proposed by using different classification methods. • TMP19 is a highly accurate model.

•
The robustness of the presented TMP19 is demonstrated by deploying a 10-fold CV and LOSO CV. Drawbacks: • Parameters should be optimized to gain higher classification performances.

•
Recently, authors in [37] have developed an automated system to detect ADHD and conduct disorder in children using empirical wavelet transform and entropy features extracted from electrocardiogram (ECG) signals. They obtained an accuracy of 88% in classifying ADHD, ADHD + CD, and CD patients for appropriate intervention using accessible ECG signals. In the future, ECG and heart rate variability (HRV) signals can be used for automated ADHD detection as they can be easily acquired using wearable devices.

•
More disorders can be used to evaluate the performance of the TMP19 model.

Conclusions
ADHD detection using EEG signals has great potential in improving the equitable early diagnosis of ADHD, maximizing appropriate treatments, and minimizing the potential longterm negative impacts of this globally common neurodevelopmental condition. However, there is a lack of consensus on the best way to utilize EEG and how machine learning may be beneficial in optimizing this as a diagnostic tool. To overcome this problem, we proposed a new feature generator called TMP. The main goal of the TMP is to extract distinctive features from EEG signals. A feature engineering model was proposed by applying the proposed feature generator-TMP. This model has 19 levels in the feature extraction phase. Hence, it is named TMP19. TMP19 was applied to a noisy EEG signal dataset for the detection of ADHD. Moreover, we used two validation techniques to show the robustness of the proposed TMP19. As can be seen from Section 5, our TMP19 reached 95.57% and 77.93% classification accuracies using 10-fold CV and LOSO CV techniques, respectively.
We plan to develop an intelligent EEG signal classification application in future work. This application will extract information from EEG signals to detect ADHD and potentially other neurodevelopmental and mental health conditions. Moreover, we plan to devise and develop an intelligent brain cap that will detect changes automatically.  Data Availability Statement: The EEG dataset database has been downloaded from [29,30].

Conflicts of Interest:
The authors declare no conflict of interest.