## 2 Materials and Methods
### Data Analysis
#### 2.3.3 Methodology: Part A  
Fast Fourier transform (FFT) is traditionally used to convert a time-domain signal (time series)\(-\)such as EEG\(-\)into a frequency domain signal. However, as is well known, FFT is not suitable for the analysis of non-stationary, non-Gaussian and nonlinear signals such as EEG. WPD, although less frequently used in ML EEG studies, is one of several methods that are more appropriate for such data [35], and is capable of dealing with both low- and high-frequency signal components (unlike the wavelet transform itself, which has good temporal resolution but poor frequency resolution at high frequencies, and good frequency but poor time resolution at low frequencies [36]). Using WPD, the EEG signal is decomposed into a pre-selected number of frequency bands using multiple mirror filters in a binary tree structure. Different algorithms are possible when implementing WPD. In all four phases of our analysis, we chose to use a cost function based on 'energy entropy' to quantify the error between predicted values and expected values in the algorithm.  
Wavelet packet transform was applied for each group of data, adopting a MATLAB (Matrix Laboratory) multisignal WPD feature extraction code developed by [PERSON] et al. [37; 38; 39]. Since the acquired EEG signals were sampled at 500 Hz, the number of samples selected per window to extract features was 500, and the spacing of the windows (the increments between them) was chosen to be 25. The decomposition level used was 7 [40]. For a full tree topology at this level, for each of the 19 EEG electrodes, 255 features were extracted in total using a high-low bandpass filter bank [41], resulting in a WPT feature matrix (n, (255 \(\times\) 19)). Wavelet entropies were then evaluated from the WPT feature matrix to reduce the size of the data and obtain a strong biomarker for classification. At this stage, the feature matrix was separated into fractions, with 255 samples for each of the 19 electrodes. The size of each of the 19 resulting submatrices was thus [n,255]. The parameter-free wavelet entropy code used here is based on that developed by [PERSON] et al. [42]. The wavelet filter selected was 'Coiflet-4', and the decomposition level was 7, based on results from our previous study on discrete wavelet transform (DWT), in which we found that Coiflet performance was better when compared to that of other wavelet families [43]. When the wavelet entropy algorithm was applied to these matrices, (255*19)-sized feature matrices, containing the entropy values, were acquired for every two classes. Finally, these feature matrices were fed into a 1D CNN-LSTM hybrid classifier to generate the classification model (Phases 1, 2 and 4).  
In our EEG study, four different frequencies of peripheral electrical stimulation were used: a'sham' at 160 Hz but a very low amplitude ('0'), and 2.5 Hz, 10 Hz and 80 Hz at above the sensory threshold. For the wavelet packet decomposition of signals for the four types of stimulation frequency (SF), 100 non-overlapping samples were extracted from the EEG data for each type of SF, with each sample containing 5000 data points (recordings for each class were cropped and data sizes balanced). One sample for each type of SF was processed with WPD, using the Daubechies 2 (DB2) wavelet basis function [44]. Each sample was decomposed into eight frequency bands (FB), from FB1 to FB8. Finally, these feature matrices were fed into a Multilayer Perceptron Neural Network (MLP-NN) classifier to generate the classification model in Phase 3.