## 2 Materials and Methods
### Data Analysis
#### 2.3.4 Methodology: Part B
Inputs were taken from the 19 electrodes, and the output was provided as a 5 \(\times\) 5 confusion matrix for the five EEG bands. Our objective here was to determine whether differences among the EEG bands vary with both time (baseline, stimulation or post-stimulation) and stimulation frequency. \begin{table}
\begin{tabular}{c c c} \hline \hline  & **Test-Train Data Shape** & \\ \hline
**Train Data Shape** & [10,800, 25/50, 19] & \\
**Test Data Shape** & [1200, 25/50, 19] & \\
**Train Label Shape** & [10,800, 2] & \\
**Test Label Shape** & [1200, 2] & \\ \hline \multicolumn{3}{c}{**Model Architecture**} \\ \hline
**Model: “sequential”** & & \\
**Layer (type)** & **Output Shape** & **Parameters** \\
**Conv1d\_1** & (None, 17, 32) & 2464 \\
**Dropout\_1** & (None, 17, 32) & 0 \\
**Conv1d\_2** & (None, 14, 16) & 2064 \\
**Dropout\_2** & (None, 14, 16) & 0 \\ LSTM\_1** & (None, 14, 25) & 4200 \\
**LSTM\_2** & (None, 5) & 620 \\
**Dense** & (None, 2) & 12 \\
**Total parameters:** & 9360 & \\
**Trainable parameters:** & 9360 & \\
**Non-trainable parameters:** & 0 & \\ \hline \multicolumn{3}{c}{**Model Specifications**} \\ \hline
**Conv1d** & activation: relu, padding: valid, l2 & \\  & regularization: 0.001 & \\
**LSTM** & activation: tanh, recurrent\_activation: tanh, & \\  & dropout: 0.2, recurrent\_dropout: 0.2 & \\
**Dense** & activation: sigmoid & \\
**Compiler** & number of epochs: 100, batch\_size: 32, loss: & \\  & binary\_crossentropy, optimizer: adam & \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Model summary for Phase 1, including two 1-dimensional convolutional layers and two stacked LSTM layers, two Dropout layers and a final Dense layer. Terms are explained in the online Supplementary Materials. The Output Shape defines the size of the output matrix. ‘None’ is a placeholder for the size of the dataset so that it is not fixed but can be varied; the following numbers within parentheses indicate the batch size and time steps used. The number of parameters required for each layer is also shown. Figure 5 shows the model architecture for Phase 3. Features extracted from WPD and wavelet entropy analysis were selected as inputs. 'W' and 'b' are learnable parameters; 'W' corresponds to the weights of the Neural Network, and 'b' to the bias values [51]. The data were randomly divided into training, validation and test sets using the MATLAB 'dividerand' function. The Scaled Conjugate Gradient training method was applied (using the MATLAB 'trainscg' function), and cross-entropy was used to evaluate performance. Information was also provided on algorithm performance: the number of iterations required, processing time, performance, gradient, and the maximum number of validation checks to be conducted (held at 6, the default). If the gradient was <10'5, or the number of checks reached 6, training was stopped. Methodology: Part B, Phase 4  
In our final experiment, we reverted to using the CNN-LSTM model in Keras, as in Phase 1, but this time, replacing the Dropout layers with max pooling (downsampling) layers, with three LSTM layers (as in Phase 2) and 5-fold rather than 3-fold cross-validation (see the online Supplementary Materials for an explanation of these terms). The objective  
Figure 5: Model architecture for Phase 3.