# EEG Channel Selection for Stroke Patient Rehabilitation Using BAT Optimizer
## 4 Proposed Method
### Phase IV: EEG Channel Selection Using BAT Optimizer  
This phase is the main contribution, and it includes several steps to achieve the optimal subset of the EEG channels which can provide the highest accuracy rate. The following steps represent how we adapt the BAT optimizer for the EEG channel selection problem:  
* Step 1: BAT algorithm parameter initialization. In this step, the BAT parameters are initialized with initial values. These parameters are the number of microbats (solutions) (\(N\)), maximum number of iterations (\(Max_{1 tr}\)), max (\(f_{max}\)) and min (\(f_{min}\)) frequency range, velocity vector (\(v\)), loudness rate (\(A\)), pulse rate (\(r\)), initial pulse rate (\(r^{0}\)), two parameters (\(\lambda\) and \(\alpha\)) with constant values in the range [0, 1], and bandwidth range (\(\varepsilon\)) in the range [\(-\)1, 1], as shown in Table 1.  
* Step 2: BAT population memory initialization. The BAT solutions are randomly generated in this step using Equation (11), considering the BAT algorithm and particular optimization problem parameters and constraints. \[x_{i}^{j}=lb_{i}+(ub_{i}-lb_{i})\times R,\] (11) where \(\forall i=1,2,\ldots,d\), \(\forall j=1,2,\ldots,N\), and \(R\) is a random number between 0 and 1. The produced solutions together generate the population, as shown in Equation (12), and are stored in the BAT memory (BM) in ascending order on the basis of their fitness values. The best solution with the fittest values is assigned to \(x^{Gbest}\) and stored in the first position of the BM. \[BM=\ \ \begin{bmatrix}x_{1}^{1}&x_{2}^{1}&\cdots&x_{g}^{1}\\ x_{1}^{2}&x_{2}^{2}&\cdots&x_{d}^{2}\\ \vdots&\vdots&\ldots&\vdots\\ x_{1}^{N}&x_{2}^{N}&\cdots&x_{d}^{N}\end{bmatrix} ,\] (12)
* Step 3: BAT population intensification. Now, all microbats \(x\) fly and change their position considering a velocity \(v\) defined by a frequency \(f\) that is generated randomly, as shown in Equations (13) and (14). Accordingly, the bat positions are updated using Equation (15). \[f_{i}=f_{min}+(f_{min}-f_{max})\times R,\] (13) \[v_{i}^{\prime j}=v_{i}^{j}+(x_{i}^{j}-x_{i}^{G}best)\times f_{i},\] (14) \[x_{i}^{\prime j}=x_{i}^{j}+v_{i}^{\prime j},\] (15) It is notable that the microbats update their locations to be closer to the global best (\(x^{Gbest}\)). Thus, the new position of the microbats intensifies the position in a direction towards \(x^{Gbest}\). * Step 4: BAT population diversification. In this step, the microbats' positions are updated based on random parameters to attempt to find better global solutions. A new solution is selected from the BM based on a selection method and assigned to \(x^{best}\). Subsequently, the current solution is updated using \(x^{best}\), as follows: \[x_{i}^{\prime j}=x^{best}+\varepsilon\times A_{j}^{\prime},\] (16) where \(A^{\prime}\) is the loudness average. As Steps 3 and 4 are contradictory steps, the BAT algorithm chooses one of them at a time for execution. This selection is based on the following equation: \[x^{\prime j}= \begin{cases}x^{best}+\varepsilon\times A_{j}^{\prime}&\text{ if }r_{j}\leq R\\ x^{j}+v^{\prime j}&\text{ otherwise}\end{cases} ,\] (17)  
\begin{table} \begin{tabular}{c c c c} \hline \hline
**Algorithm** & **Parameters** & **Population Size** & **Runs** \\ \hline CS & \(\beta=1.5\), \(P_{a}=0.25\) & 20 & 30 \\ PSO & \(c1=c2=2\) & 20 & 30 \\ BAT & \(A=0.5\), \(r=0.5\) & 20 & 30 \\ FFA & \(\alpha=0.5\), \(\gamma=1\), \(\beta_{0}=0.2\) & 20 & 30 \\ GWO & - & 20 & 30 \\ \hline \hline \end{tabular}   
* Step 2: BAT population memory initialization. The BAT solutions are randomly generated in this step using Equation (11), considering the BAT algorithm and particular optimization problem parameters and constraints. \[x_{i}^{j}=lb_{i}+(ub_{i}-lb_{i})\times R,\] (11) where \(\forall i=1,2,\ldots,d\), \(\forall j=1,2,\ldots,N\), and \(R\) is a random number between 0 and 1.