# EEG Channel Selection for Stroke Patient Rehabilitation Using BAT Optimizer
## 4 Proposed Method
### Phase IV: EEG Channel Selection Using BAT Optimizer
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. 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} ,\] (18)
* Step 3: BAT population intensification. Now, all microbats \  
* Step 5: BM update. The position of the microbats in the BM will be updated in this step if the new location is fitter than the old one and \(R\leq A_{j}\). Moreover, \(X^{Ghest}\) will be updated if the new BM contains a solution with a better fitness value. Subsequently, \(r_{j}\) and \(A_{j}\) values will be updated in accordance with Equations (18) and (19). \[r_{j}=r_{j}^{0}(1-e^{(-\gamma\times itr)},\] (18) \[A_{j}=\alpha\times A_{j},\] (19) where \(itr\) denotes the current iteration number. * Step 6: stop criterion. Steps 3, 4, and 5 will be repeated until the algorithm reach the stop criterion.