1 Introduction

Today, by the rapid development of China’s economy, people’s work and life pressures are increasing day by day, and various health problems have arisen. Therefore, people need to recognize, and improve their physical condition. However, it requires professional, and effective guidance and consultation, so that the public can better understand their own health status, and how to obtain professional and effective health guidance is particularly important. Health and Fitness System is a health promotion application developed based on Android smartphones. Its goal is to target individuals and corporate customers, so as to grasp the current and past sports information, and enhance fitness awareness. The standard interface also transmits data about human body movement to the system background in real-time. Standardization, classification, organization, and storage are carried out in the background, and after systematic analysis, the display page or network service of mobile phone client can timely and truly understand the physical condition of user, and formulate a corresponding fitness plan accordingly [1]. However, MI training is a new type of rehabilitation training method.

This study used brain–computer interaction technology, and neurofeedback technology to explore their roles to improve MI rehabilitation training. This paper proposed the structure of brain–computer interaction system for MI rehabilitation training. This paper then conducted in-depth research on elimination, feature extraction, and classification of MI brain waves and established an Electroencephalogram (ECG) simulation system for EEG movements, as well as compared, and analyzed them. The innovation of this paper is that it used the Android system to build the platform. To determine the effectiveness of the new rehabilitation training method, a detailed analysis of the health system was conducted, and a test system was constructed or tested.

2 Related Works

MI, defined as the psychological implementation of movement without movement or muscle activation, is a rehabilitation technique. When used in conjunction with conventional physical therapy procedures, it offers a way to replace or restore lost motor function in stroke patients. Tong et al. [2] briefly reviewed the concept, and neural correlates of MI to promote better understanding, as well as enhance the clinical utility of MI-based rehabilitation programs. The advances in brain–computer interface (BCI) technology have facilitated the detection of MI from EEG, Kai and Guan [3] proposed three strategies to detect MI from EEG using BCI: operant conditioning of a fixed model was used, and machine learning of a topic-specific model computed from calibration, and an adaptive strategy of continuously computing a topic-specific model were used. In stroke rehabilitation, rehabilitation equipment can assist training. Typically, however, patients are restricted from using related rehabilitation techniques due to the inconvenient nature of traditional equipment. A new embedded rehabilitation system based on MI therapy was proposed by Kong et al. [4] to alleviate such problems. EEG was induced by grasping the motion image of the left and right hands, and then collected by the wearable device. It was transmitted to the Raspberry pie chart processing unit, and decoded into instructions via Bluetooth to control the device expansion. Neural correlates of intentionally evoked human emotions may provide alternative image strategies to control BCI applications. Bigirimana et al. [5] proposed a novel BCI control strategy, namely imagining imaginary or recalling memories of sad and happy events, and Emotion-inducing Imagery (EII). The use of two classes of EEG was compared to MI in a study involving multiple sessions. However, they were not analyzed for their MI algorithm feature extraction, so experimental calibration could not be performed.

More than twenty feature parameters are available in both the time domain and frequency domain. Since all feature parameters are used for feature extraction, a considerable amount of data must be processed. To accurately reflect the characteristics of vibration signals with fewer feature parameters, Chen et al. [6] proposed a simple, and effective vibration feature extraction method combining time-domain dimension parameters, and Mahalanobis distance. Kobayashi et al. [7] proposed a method for intelligent state diagnosis of rotating machinery using time–frequency waveform distribution, and extreme learning machine. Yan and Jia [8] introduced a new fault classification method based on multi-domain feature optimization. Although they all introduced feature parameter extraction methods in the time domain, and frequency domain, they did not apply them to sports rehabilitation training, nor did they conduct experimental analysis on their system construction.

3 Evaluation on Sports Health System and Rehabilitation Training Algorithm

3.1 Sports Health System

The fitness system consists of two parts: fitness application software, and fitness exercise background management. In addition to the Android-based Health Sports App, the system has a web application that carries the users’ entire experience. It is a Java-based network management software designed for managing activities associated with health sports. The overall architecture of healthy exercise system is shown in Fig. 1 [9, 10].

Fig. 1
figure 1

Overall architecture diagram of the healthy exercise system

Aiming at the safety and reliability issues in the healthy exercise system, a control mechanism based on user access rights is proposed. The system assigns permissions to different users, which facilitates comprehensive, and efficient management of system [11].

In medical and health service system, the storage of user’s mobile data is very critical, so the database server should have high stability and fault tolerance. Data storage and invocation of the system, as well as incorrect inputs and operations, would require the database server to be stable and adaptable in order to ensure the system’s normal operation [12].To ensure the reliability of database, the healthy exercise system uses the method of the slave library. The health sports system sets up two servers, the master and the slave, which are respectively responsible for the user’s mobile data, while the primary server only needs to provide data write services to the primary server. The slave server, and the master server achieve high synchronization and high availability via keepalived [13, 14]. It is possible to synchronize the host library with the host station of the slave master station by setting the IP address of the host library as a high-availability virtual IP address. When both servers work together, the host library becomes the primary host. When in use, the system actively receiving virtual IP is avoided as much as possible to prevent data confusion [15].

A connection is established between the slave library, and the master library. IO thread of slave library makes a Binarylog request to the master library. After the main library receives the IO thread of slave library, it generates a logdump thread and transmits Binarylog to IO thread of the slave library. The log obtained from the library is then written to Relaylog, and the log is read from the library to implement the logic of slave library [16, 17]. Using this scheme, the master–slave library can be greatly enhanced in terms of availability, and in the event that the master–slave library becomes unavailable for some reason, it can be quickly transferred to the slave library. Thereby, the interruption of master–slave library can reduce the service quality of system, and the load of master–slave synchronization of the master–slave library on the master library is reduced. The working principle of master library and the slave library is shown in Fig. 2 [18].

Fig. 2
figure 2

The working principle of the master library and the slave library

3.2 Rehabilitation Training of Motor Imagery

The human brain can control people’s emotions, behaviors, thinking, etc. It is the psychological control center of human beings, and it is an important organ of the human body. The system is also capable of responding to anything in the outside world to achieve communication with it. The brain controls the movement of hands and feet, and even limbs, in daily life due to various reasons [19, 20].

Research showed that self-repair process of nerve cells is time-consuming, and that damaged neurons are activated, and regain their ability to regenerate during a patient’s physical activity. Some people with movement disorders often experience an inability or inability to control their extremities voluntarily during early recovery. MI is a non-motor mental level of somatic movement performed by nerve connections among the muscles of limbs, and brainstem. The advantage of MI treatment is that although the movement of limbs cannot be controlled, it can generate some imagination. Due to the nature of MI training, doctors and patients cannot see the progress of MI training on a real-time basis, as it is a recessive process, without external body movements. Consequently, doctors cannot carry out effective exercise training for the patients, making it difficult for patients to concentrate. Therefore, MI training is often difficult to achieve expected results [21].

The correct classification of motor phenomena is a key factor in the human brain–computer interface system. Among them, the correctness of motor imagination mainly depends on the characteristics of brain waves. In general, the classification accuracy of two types of motor imagery is above 90%, while the classification accuracy of multi-category motor imagery is low, which needs further research. In usual, the most common extraction method is Co-spatial Pattern (CSP). This technology is used to process brain waves, and extract spatial information. Second-class brain waves have good recognition performance, so they are widely used [22, 23]. However, CSP has its drawbacks. It is important to use multi-channel information in order to improve the effectiveness of classification. Secondly, the algorithm ignores the time–frequency characteristics of brain wave signals, and efficient features extraction techniques are needed to improve classification efficiency. On this basis, this paper combines CSP algorithm with the local eigenscale decomposition in the time–frequency domain to fully extract the information of time, frequency and space, thereby improving the recognition accuracy. The flowchart of algorithm is shown in Fig. 3.

Fig. 3
figure 3

Flowchart of feature extraction algorithm

LCD-based time–frequency domain feature extraction.

The core problem of various adaptive time–frequency analysis methods is the condition that single-component signal should satisfy. ISC is defined as:

The extreme point size of the ISC component is assumed to be Ar, and the corresponding moment is gr, r = 1,2,…,N:

$$ xX_{r + 1} + (1 - x)A_{r + 1} = 0,x \in (0,1) $$
(1)

Among them:

$$ X_{r + 1} = A_{r} + \frac{{g_{r + 1} - g_{r} }}{{g_{r + 2} - g_{r} }}(A_{r + 2} - A_{r} ) $$
(2)

Generally, x = 0.5 is taken. At this time:

$$ \frac{{X_{r + 1} }}{{A_{r + 1} }} = - 1 $$
(3)

The local feature scale decomposition process is as follows:

Based on calculated value listed, the value then brought into Formula Zr is calculated:

$$ Z_{r} = xX_{r} + (1 - x)A_{r} ,r = 2,3,...,N - 1 $$
(4)

The baseline is subtracted from the original signal to separate the baseline, namely:

$$ g_{1} (d) = a(d) - YZ_{1} (d) $$
(5)

Otherwise, \(g_{1} (d)\) would be used as original signal data, and the above process would be repeated, then:

$$ g_{11} (d) = g_{1} (d) - YZ_{11} (d) $$
(6)

\(ISC_{1}\) component is separated from the original data, resulting in a new signal \(v_{1} (d)\), namely:

$$ v_{1} (d) = a(d) - ISC_{1} $$
(7)

The above process is repeated to obtain the second component \(ISC_{2}\). Among them:

$$ v_{m} (d) = v_{m - 1} (d) - ISC_{m} $$
(8)

\(a(d)\) is decomposed into m ISC components, namely:

$$ a(d) = \sum\limits_{q = 1}^{m} {ISC_{q} (d) + k{}_{m}(d)} $$
(9)

Standard Deviation method (SD) is defined as:

$$ SD = \sum\limits_{d = 0}^{D} {\left[ {\frac{{\left| {g_{jr} (d) - g_{j(r - 1)} (d)} \right|^{2} }}{{g^{2}_{j(r - 1)} (d)}}} \right]} $$
(10)

In the formula, D represents the length of time. The general value is less than 0.5 to get the ideal ISC component.

Hjorth parameters are three parameters used to describe the characteristics of EEG signals. Hjorth parameters contain average power \(n_{0}\), average frequency estimate \(n_{1}\) and frequency bandwidth estimate \(n_{2}\). Therefore:

$$ n_{0} = \phi_{0}^{2} $$
(11)
$$ n_{1} = \frac{{\phi_{1} }}{{\phi_{0} }} $$
(12)
$$ n_{2} = \sqrt {\left( {\frac{{\phi_{2} }}{{\phi_{1} }}} \right)^{2} - \left( {\frac{{\phi_{1} }}{{\phi_{0} }}} \right)^{2} } $$
(13)

EEG of 22 channels is processed by LCD, and 9 ISC components are obtained. The Hjorth feature is used, and time–frequency characteristics are obtained for all 3 channels:

$$ P_{1} = \left[ {p_{11} ,p_{12} ,...,p_{1R} } \right] \in K^{1 \times RQ} $$
(14)
  1. (2)

    Spatial feature extraction based on CSP.

Assuming that \(A_{x} \in K^{M \times N}\) and \(A_{y} \in K^{M \times N}\) are the experimental data of motor imagery tasks X and Y, respectively, the covariance matrices of \(A_{X}\) and \(A_{Y}\) are found:

$$ K_{X} = \frac{{A_{X} A_{X}^{D} }}{{trace(A_{X} A_{X}^{D} )}} $$
(15)
$$ K_{Y} = \frac{{A_{Y} A_{Y}^{D} }}{{trace(A_{Y} A_{Y}^{D} )}} $$
(16)

Among them, \(trace( \bullet )\) represents the trace of matrix.

The sum of covariance \(K_{X}\) and \(K_{Y}\) matrices decomposed in the previous step is.

$$ K = K_{X} + K_{Y} = V_{0} \eta V_{0}^{D} $$
(17)

On this basis, the results of previous step are used to establish the whitening value transformation matrix Q, and format transformation, and eigenvalue decomposition are carried out.

$$ Q = \eta^{{{\raise0.7ex\hbox{$1$} \!\mathord{\left/ {\vphantom {1 2}}\right.\kern-0pt} \!\lower0.7ex\hbox{$2$}}}} V_{0}^{D} $$
(18)

The average covariance matrices \(K_{X}\) and \(K_{Y}\) can be transformed into following form:

$$ W_{X} = Q\overline{K}_{X} Q^{D} ,W_{Y} = Q\overline{K}_{Y} Q^{D} $$
(19)

\(W_{X}\) and \(W_{Y}\) are decomposed by following eigenvalues based on the formula:

$$ W_{X} = V_{X} \eta_{X} V_{X}^{D} {, }W_{Y} = V_{Y} \eta_{Y} V_{Y}^{D} $$
(20)

Among them, \(W_{X}\) and \(W_{Y}\) have the same eigenvector matrix, namely \(V_{X} = V_{Y}\), and satisfy \(\eta_{X} + \eta_{Y} = 1\). It can be seen that if the eigenvalue of \(W_{X}\) is relatively large, the corresponding eigenvalue of \(W_{Y}\) would be relatively small, and vice versa.

4 Construction and Inspection of Sports Rehabilitation System

4.1 Implementation of EEG Signal Acquisition Module

Each functional module would be programmed, and combined with each functional module, a set of brain–computer interaction system for motor imagery rehabilitation training is constructed. It has offline classification processing, and real-time classification processing, and the brain wave signal is visualized and represented as the action of virtual human body model.

The equipment of Wuhan Brainwave Technology Co., Ltd. is used to obtain the signal of brain wave. As explained in the device description, the device can not only extract brain waves from a specific part, but can also effectively suppress power frequency interference. In addition to the software of data Acquisition Service (AS), Wuhan Brainwave Technology Co., Ltd. provides the source program of signal Acquisition Client (AC), which is convenient for scientific researchers to develop on this basis. The client details are shown in Table 1. Below are some details of the AC software provided by Wuhan Brainwave Technology Co., Ltd. Researchers can transmit real-time EEG to the communication via software, or implement research by modifying the source code.

Table 1 Client software, location, and platform

4.2 Software Realization of EEG Signal Evaluation and Processing Module

  1. (1)

    Data reception

Figure 4 shows entire data transfer process from the EEG acquisition device to AC:

Fig. 4
figure 4

Data communication flow chart


First, the EEG acquisition device receives the EEG signal on the scalp, and then transmits it to AS device for data transmission via serial communication.

The computer of acquisition device is set to AS, and the port number and IP address cannot be changed. The “start” key is clicked. After the AS collects EEG data, it must transmit the data to AC in real time to facilitate the analysis and processing of the AC.

Wuhan Brainwave Technology Co., Ltd.’s AS software supports one-to-one communication, and Table 2 shows the instructions for this type of communication. This system adopts the communication software written in C# language, which can realize the display of instructions, the transmission of instructions and the real-time transmission of data. Communication is carried out according to the TCP/IP protocol.

Table 2 Command set table

The specific implementation of communication between AS and the AC is as follows: the AC transmits various communication commands. As shown in the table, after the AS receives the communication command, it transmits the corresponding packet to AC. IP address and port number of the AS have been already set. Therefore, before the communication between AC and AS, it is necessary to set the IP and port number.

  1. (2)

    Waveform display


After completing above connection operation, the data request is transmitted from AC to AS, and AS starts to transmit the data to the AC after receiving the request from the AC. After AC receives the data packets from the AS, it starts to classify the data and arranges the data in the queue in order, as well as draws the corresponding data on the interface in real time, as shown in Fig. 5.

Fig. 5
figure 5

Real-time display of EEG signal waveform

This module mainly has two modes: offline and online. A method of analyzing and processing signals offline involves manually collecting the EEGs that need to be analyzed; an online method involves collecting brain waves over a period of time and converting them into EEGs. EEG signals are transmitted to Matlab through C#, and analyzed and processed through Matlab functionsTo realize signal processing, Matlab needs to include three major functions of EEG signal artifact removal, feature extraction, and feature classification. Three sub-functions are combined into a complete function, called EEG Pattern Recognition. The input of three EEG EEG signals, C3, C4, and Cz, is represented by Chinese letters.

4.3 Software Design of Neurofeedback Module

This module converts the classification results of EEG images into control signals, and implements a virtual human body model, and an arrow representing the direction of imagination on the human–computer interaction interface. Patients’ movement imaginations can be improved and their enthusiasm for rehabilitation training can be stimulated by controlling the movement imagination. The Matlab program is suggested to identify MI-EEG. Matlab language is an efficient programming language. It contains a large number of functions that developers can implement by simply calling and debugging, and Matlab is very convenient for matrix and array operations, which is very suitable for processing movement, and brain waves. However, the design flaws of the Matlab interface are obvious. In practical applications, the user’s experience is not ideal, which affects the user’s enthusiasm to use this module. For this purpose, this paper has carried out integrated development on multiple platforms, including using the Matlab language to write high-quality signal processing functions and using C# to write good interfaces, as well as using signal processing functions in Matlab to classify exercise brain waves. The final result is delivered to the user via C# development interface, thereby enhancing the user’s enthusiasm for learning. However, in hybrid programming, C# program directly calls the Matlab engine to obtain processing. Therefore, when transmitting ECG data to the Matlab engine, the engine should be turned on first. Otherwise, once it is started, it would waste a lot of time, and it would also have a great effect on the real-time performance of signal processing.

The problem to be solved in this article is to open the main control interface and start the Matlab engine via the thread after the login is successful. This not only does not affect the host program, but also ensures real-time processing of the signal. Using the left button, the 2000 will be intercepted from the 1000 on the left and 1000 on the right when the mouse is moved to the EEG waveform display interface. Since the sampling frequency is 1000 Hz, the brainwave signal can be intercepted within 2 s, as shown in Fig. 6.

Fig. 6
figure 6

Real-time analysis of motor imagery EEG signals

4.4 Experimental Design

  1. (1)

    Experimental design


Experiment preparation: the preparation work before the experiment is the same as the offline signal acquisition content. After the connection is completed, operation steps are followed to open the software developed in this paper.

Experiment content: the subjects were selected, and divided into two groups. P1, P2, and P3 are numbered as G1. During the experiment, man–machine interface is used to feedback information in real time; P4, P5, and P6 are numbered as G2, and there is no feedback in the trial. The situation is the same for other two groups. In one group, feedback information is provided while the other group performs virtual human actions; in one group, feedback information is not provided, and one group has to delete information from the screen during the experiment. Other prompts are the same as other group's feedback. Group G1 performs three groups of experiments in each mode. Each set is 100 reps. The number and mode of experiments in Group G2 are consistent with the experimental results in Groups P1, P2, and P3 in group G1, as shown in Table 3.

Table 3 Experiment information sheet
  1. (2)

    Analysis of experimental results


The motor image direction control was group A, the arm training mode was group B, and the leg training mode was group C. After the subjects were guided to carry out above experiments, the test conditions of each subject were counted, as shown in Fig. 7. The number of successful P1, P2, and P3 in Group A Experiment 1 was 53, 54, and 51, respectively. Experiment 2 was 57, 56, and 54. Experiment 3 was 60, 62, and 60. The Group B and C were significantly higher than the Group A.

Fig. 7
figure 7

Online experiment of brain–computer interaction system for motor imagery rehabilitation training

The average success rate of each subject was calculated from Table 3, as shown in Fig. 8.

Fig. 8
figure 8

Plot of the average success rate for each subject

The results in Fig. 8 show that the success rates of three persons in the G1 group were 59.88%, 58.89% and 59.22%, respectively, and the success rates of motor imagery direction control in the G2 group were 64.22%, 63.33% and 64.11%, respectively. Based on the results of different experimental methods, the motor imagination success rate of the G2 group with feedback information is significantly higher than the G1 group without it. Therefore, the introduction of feedback information into motor fantasy rehabilitation training can effectively improve the effect of motor fantasy.

  1. (3)

    Analysis of the operability of system


The transformation of the success rate of subjects in each experiment obtained from Table 3 is shown in Fig. 9.

Fig. 9
figure 9

Success rate of each mode. a The success rate of the subjects. b The success rate of each subject in the G2 group

As can be seen in Fig. 9a, the success rate of the third experiment is significantly higher than the previous two, but the group with feedback information has significantly increased. Through rehabilitation training of motor fantasy, users can be more familiar using the system, and at the same time, the learning efficiency of students can be improved. As shown in Fig. 9b, in group G2, the control success rate of virtual human body model is higher than the control of motor imagination direction, so the way of using the virtual human body model’s action as feedback information is better than one-way feedback.

It can be seen from above results that the group with feedback is better than the group without feedback. After two trainings, the accuracy is improved, and the accuracy rate reached 74.33%. According to the results, the virtual human body model effectively reflects the physiological state of the subjects and improves the test success rate by comparing the arrow’s feedback with that of the virtual human body. The brain–computer interaction system developed in this paper for the purpose of motor fantasy rehabilitation can give optimal feedback based on the content of action imagination, so that it has better operability and achieves the desired effect.

The acquisition module of EEG signal is integrated by the software and hardware of company A, and its main function is to transmit EEG signal to a signal processing device called the client; the EEG signal analysis and processing module is mainly responsible for the analysis, and sorting of MI-EEG signals. The pattern recognition and classification of EEG are carried out via Matlab, and the results are finally sent to the neurofeedback module. Neurofeedback completes the recognition of MI-EEG by converting the recognition into a control signal, and controlling the interface to complete the recognition. This chapter provides a detailed description of its work. Simulation experiments show that the system can help rehabilitation training well, and can improve self-control to a certain extent.

5 Conclusion

The research contents of this paper are summarized as follows: the software converted the processing results into the actions of arrows, and mannequins in the human–computer interaction interface, and completed feedback to the user. The components were integrated together, and the construction of the whole system was realized, as well as the experiment was carried out. EEG diagnostic accuracy of the system was very high, and the results showed that the method had a good effect. The average accuracy of method reached more than half, indicating that the application of system in MI rehabilitation training was effective. It was possible to visualize the results of the online analysis and processing of EEG in the form of an arrow so that the user could understand the current EEG state in a more intuitive way, and also for the research developer to understand the current market conditions. It not only facilitated the development and improvement of the system, but also promoted the enthusiasm of users, and had broad prospects and great promotion significance.