We performed an initial recording to set a membership function based on the maximum/minimum of the real inputted values. For example, a template can be composed of inputs having features of different types such as “EEG power of Oz measurement site in the wave frequency band” and “amplitude of the surface electromyography (EMG) signal of lower right limb.” Here, the BCI classifies input EEG signals into several categories linked to cognitive states. It also controls external device in real time. Consequently, the delay of recognition is suppressed to the greatest extent possible. Therefore, the consequent clause must not be a fuzzy set but a singleton, whereas the consequent clause of ordinal Mamdani’s reasoning is a fuzzy set. In conventional fuzzy reasoning, calculation of the center of gravity requires much time. Simplified fuzzy reasoning is used to avoid such related difficulties [19]. For this study, L-FTM method includes 12 inputs and 2 fuzzy labels. Therefore, the number of fuzzy rules is 2 to the power of 12, or 4096. Fast Fourier Transform (FFT) was applied to the EEG signal detected from each electrode. The summation of the value of power in the range of the selected frequency band was obtained and used as the input value for the BCI. Depending on the task, the measurement sites and the frequency bands were selected. The following two frequency bands were conceivable as subjects for recognition: α band (8–13 Hz) and β band (14–50 Hz). As described above, L-FTM is an application of learning-type-simplified-fuzzy reasoning to template matching method. Therefore, calculations are the same as those of learning-type simplified-fuzzy-reasoning. EEG power was inputted to the membership function of the defined fuzzy label of the j-th input of the i-th fuzzy rule. The multiplied outputs of all the membership functions of the i-th fuzzy rule, Gj, are obtained as the compatibility degree of the i-th fuzzy rule, µi, in Eq. (1) .
\(\mu_i=\Pi_{j=0}^nG_j\)              (1)
   Output value Z was calculated as the weighted average of the consequent values of all rules. Here, Zi is the consequent part value of i-th rule, in Eq. (2).
\(Z=\frac{\Sigma_{i=1}^n\left(\mu\cdot Z_i\right)}{\Sigma_{i=1}^n\mu_i}\)             (2)

2.2 Learning process of consequent part values

In this L-FTM, consequent values were set up by the learning process. Using the steepest descent method, Z is approximated to the target value of the teacher signal T Eq. (3). Also, Zi’ is the consequent value before updating, which differs from Zi. Here, ρ is a learning coefficient  
\(Z_i=Z'_i+\rho\cdot\mu_i\cdot\left(T-Z\right)\)             (3)
The teacher signal is allowed to be any value if the values can be linked to several distinct states. For example, 0 was a label for EEG of the resting state and 5 was a label for EEG expressed during foot movement. In the learning process, consequent values of the rules with high degree of compatibility for a certain state are modified to the teacher signal corresponding to the state, thereby producing effective rules (templates) for recognition of the specific status. In other words, recognized EEG features during a cognitive task were extracted from the rule set consisting of the combination of EEG inputs and labels. Therefore, this learning process corresponds to a searching process

2.3 Pruning

Fuzzy rule sets are EEG feature patterns routinely generated from a combination of input and fuzzy labels such as high and low. Therefore, rules with a high compatibility degree for EEG during both task and non-task status were expected to be included. Such fuzzy rules compatible to both states are expected to reduce the identification accuracy. To avoid the matter, we implemented “pruning” for the developed BCI system. The pruning process deleted inadequate fuzzy rules with a high degree of compatibility for both states and retained only rules with a high degree of compatibility for either a task state or a non-task state. The maximum value of the compatibility degree of the i-th fuzzy rule during the task situation, Ob(i), was calculated for each rule as Eq. (4).
\(Ob_{\left(i\right)}=\max\left\{\sum_{t=1}^{te}Ot_{\left(i,t\right)},\sum_{t=1}^{te}O_{n\left(i,t\right)}\right\}\)  (4)
In that equation, t represents the time of input data, te represents the last time. In addition, Ot(i;t) represents the compatibility degree of the  i-th rule at time t during the task status. Similarly, On(i;t) represents the compatibility degree of i-th rule at time t during the non-task status. Then the difference between the total value of each compatibility degree during task and non-task situations was calculated. Its absolute value is Os(i), as presented in Eq. (5).
\(Os_{\left(i\right)}=\left|\Sigma Ot_{\left(i\right)}-\Sigma On_{\left(i\right)}\right|\)         (5)
If the value of Os(i) normalized with Os(i) is smaller than the adequately set threshold, then the i-th rule was a rule with a high degree of compatibility in both states and was deleted. If the difference is large, then the i-th rule is judged as having a high compatibility degree only for task or non-task status. The rule was retained as shown in Eq. (6).
\(\Pr uning\left(R_{\left(i\right)}\right)=\left\{_{delete,\ if\left(\frac{Os_{\left(i\right)}}{Ob_{\left(i\right)}}<th\right)}^{retain,\ if\left(\frac{Os_{\left(i\right)}}{Ob_{\left(i\right)}}\ge th\right)}\ \ \ \ \right\}\)        (6)
Using only retained subsets of rules, the learning process was performed again with input values of the stored learning data. The consequent values were rearranged. Using the new template set increased the accuracy of identification of the two states.

3. Ankle rehabilitation device

3.1 Mechanisms design

For this study, an ankle joint rehabilitation device was developed as shown in Figure 2 [20] [21].