INFORMATICS SYSTEM FOR CONCENTRATION STATE ANALYSIS ON THE BASIS OF A DEVICE OPERATING IN THE BRAIN – COMPUTER INTERFACE TECHNOLOGY

. The informatics system designed for the needs of the workgroup working at the Faculty of Automatic Control and Computer Sciences of Opole University of Technology consisting of two applications, of which one is currently the most popular operating system in smart phones was described in the article. The objective of operation of the mobile application is connection of functionality of a device for electroencephalographic measurements with a daily used mobile phone. Thanks to applied connection in the form of an application it is possible to verify the concentration state of the particular person during execution of the particular action with the special consideration to the tasks, which require high concentration. Thanks to the elaborated mobile application we are able to determine the most effective daytime for learning and to draw the characteristics of the concentration loss time. The second application in the system is used as the synchronization server.


Introduction
The issue of lack of concentration, which appears during the daily activity of a human brain is commonly known. In times of computerization of life and access to more and more innovative tools and interfaces it is possible to aid operation of a human body by relevant monitoring of its life functions. Monitoring of a human brain operation by acquisition and analysis of an electroencephalographic signal is feasible, among other things. For this purpose, for needs of the workgroup at the Faculty of Automatic Control and Computer Sciences a device NeuroSky MindWave Mobile [5] was used. The designed mobile application task is to collect and analyse the data gathered with its use. Additionally, as a tool supporting operation of the above mentioned application a service was elaborated for synchronization and aggregation of the stored data from some mobile devices in the form of an application -a synchronization server correlated with a mobile application. Currently, in the software market there is a little number of mobile applications devised, among other things, for the most effective determining of the daytime for studying during a day for the particular human being, correlated with the equipment of NeuroSky company. Also the spectrum of use of the created application due to its functionality and the module of generating of the statistics is broad.

Brain-computer interface technology
Realization of the subject IT system for demands of the concentration state analysis of its user was conducted on the basis of the current hardware accomplishments in the brain-computer interface technology [4]. Currently this segment of communication devicesinterfaces features high growth dynamics taking the number of various solutions into consideration. The most powerful in the world manufacturers of this equipment are Emotiv Inc. company and NeuroSky Inc. company. Due to lower costs of purchase of a NeuroSky device, it was used in realization and system tests. In the past it was also supported by easier commercialisation of the applications on equipment products, available virtually for every user of a smart phone. The brain-computer interface technology allows for direct control of a device, mobile robot or application using brain and in fact relevantly processed and classified electroencephalographic signals [6]. Within the brain-computer interface technology there are invasive and noninvasive measurement methods. The commercial devices available in the market are based on non-invasive methods. Thus using of such a device is related only, however not in all the cases, with moisturising of felt pads located on electrodes with conducting liquid or special gel (Emotiv EPOC NeuroHeadset device). In case of applying during studies of a device NeuroSky MindWave Mobile ( Fig. 1) neither gels nor conducting liquids are required. The first electrode is located under a plastic cover in an arc surrounding user's head, the second one is a reference electrode and is in the form of an ear ring clip. The sampling frequency of the device is 512 Hz, the signal is filtered by the device in the range from 3 to 100 Hz. Devices operating on the basis of the BCI technology (Brain Computer Interfaces) are based on five basic operations such as: reading of the EEG signal, recording of brain activity in the form of an input signal, extraction of features from the signal using among others: frequency analysis, spatial filtering, etc. [3], classification of the features by adjusting to the masters defined beforehand and then transfer of control commands to the device or application.
At present the brain-computer interface technology is applied in practice helping the disabled people. Very often it is the only method of communication with the world outside, thanks to which a human being is able to executed basic activities by himself in the room where he is, such as switching on/off light or opening the window blinds. Thanks to the brain-computer interface technology it is not necessary to use muscles, which is especially important for people suffering from ALS (Amyotrophic Lateral Sclerosis) or Guillain's-Barre's syndrome. Moreover, thanks to the BCI technology it is also possible to control a wheel chair.

Applied programming technologies
Due to high popularity of the Android operating system, it was decided to select this platform for the mobile devices. The most popular programming language for the Android operating system is the JAVA language, therefore it was selected from among: C, C++, C#, Go etc. to write in it the mobile application. It is worth mentioning that using other languages than JAVA would require using of the NDK library (Native Development Kit), which implies the necessity of creating applications on low abstraction level and requiring time consuming optimisation. Moreover, the NeuroSky Company renders the ThinkGear SDK library available for Android used for communication with the device, on the basis of which the application design was made. The library allows for on-line monitoring of the data being acquired, including the signals responsible for concentration, meditation, eye ball movement, etc. with use of the MindWave Mobile device. During realization of the application the following libraries were used: Android SDK Tools, Apache Commons IO 1.3.2, Butter Knife 7.0.1, GreenDAO 1.3.7, Jackson-Databind 2.3.2, Joda-Time 2.8.1, Spring for Android 1.0.1. Within works on the application the ADB component was used (Android Debug Bridge), which enables debugging in real time of real mobile devices equipped with the Android system. GreenDAO is the ORM class tool (Object Relational Mapping), with which mapping of the objects was realized into the data base tables. It features a small size of the library, low utilization of resources of the operating system and fast operation. The next implemented library is Spring, thanks to which it is possible, for example, to manage transactions in the database, support web applications, insert of dependencies, which is reflected in larger freedom of dependencies between different components. In order to establish a connection between the client part of the application and a server, a tool is necessary, which is able to convert POJO objects (Plain Old Java Objects) into JSON objects (JavaScript Object Notation) and JSON into POJO. Due to the fact that the application created for needs of the data analysis was made in the Java language, the Jackson library of the FasterXML Company was used, featuring very fast and reliable operation. During realization of the application a problem was encountered with flexible operation od dates in the JAVA language, which resulted from low speed of the library operation and also obstructed management of the time zones. It is worth mentioning that this situation changes completely for 8.0 version of the JAVA language, unfortunately, due to supporting the Android platform at the moment of creating the application by the JAVA language in 7.0 version its application was impossible.
Apart from the client application, the web application on the Android system was also made, playing the main function in the designed system. To make it the Spring Framework library and the Spring Boot module were used, which decidedly accelerated works on the project. It is also worth noting the fact that thanks to using Spring Boot, the application does not require external servlet motors and an http server. The application is used in this IT system as a synchronization server. In future it may be extended into the application, on which it would be possible to browse the user's statistics from the web browser level. At the current moment of system realization it was not necessary though.

Software realization
During the designing phase of the IT system a class diagram was made, in which each class should have precisely one responsibility. Within the works on the class diagram, special attention was drawn to the fact that the classes located higher on the abstraction hierarchy were dependent from the classes located lower. One of the objectives within the framework of realized system was its execution on the basis of the due architecture, thanks to which the modules would be easily expandable and the unit tests would allow for providing application stability.
The fundamental module used in operation of the designed IT system is the mobile application module depending on connection with the NeuroSky MindWave Mobile device, which is used for data acquisition. It is entirely independent from the remaining system components, which is targeted to provide the possibility of its later separation as a library and the possibility of applying in any other application operating in the Android system. The main point od the designed application is the ConnectionManager class, which plays the role of an interface between the device and the software part. This class has two descendant classes: MindWaveConnectionManager, thanks to which communication with any physical device based on the ThinkGear technology is possible and the MindWaveDevice class, which is directly responsible for connection with the ThinkGear device and allows obtaining information about the connection state and change of its status. The session creation module was separated as a separate Service component, which is one of the basic components in the Android system and allows executing of long lasting activities in the background of the mobile application. Within the works on the application the main class was also created, recorded in the data base, connecting all the component responsible for the data interpretation. The most important object in the application is used for storage of all the measurements realized during one session, including calculated exhaustion values, user average concentration, etc. The value of the average concentration is stored for optimizing purposes. The main class of applications correlates also with the class targeted to calculate user exhaustion on the basis of concentration measurements. Thanks to the GreenDAO library, the classes being entities in the data base were generated automatically. In the application designed for needs of the subject of analysis two classes being the entities were defined. The first one presents one measuring session. In order to be able to use the application on many devices a field was added to the above mentioned class, which is allocated by the synchronization server, thanks to which we have the guaranteed possibility of identification of the definite sessions among the ones created by all the devices synchronization at the particular time with the server. Within the class also a field was created destined to store for recording the length of session duration, thanks to which it is possible to obtain information concerning the best concentration relation to the session length. In the entity also the calculations are recorded that are conducted during its lasting and the list of measurement values performed during the session. The next class in the application allows for correct identification of each measurement within the span of all the measurements sent to the synchronization server. Additionally the date and time of taking the measurement is also recorded, which allows for precise reconstruction of the progress of each session and performing of many statistics and diagrams. IAPGOŚ 2/2016 p-ISSN 2083-0157, e-ISSN 2391-6761 Each system module is responsible for synchronization of user measurement sessions with the server. Within the works on the module, two classes were implemented used to import and export the data in the form of the system user measurement sessions to the synchronization server. The class objects are sent to the server and received in the JSON form. For the needs of the class object mapping to the DTO objects (Data Transfer Object) playing the role of the data containers converters were created.

Concentration state analysis
In order to perform the concentration state analysis it is necessary for the user to initiate the measurement session. Having selected the Tracking option in the Main menu the system shows the measurement session window. Then the user selects the Start Session option. In case of of switching off of the Bluetooth module the system switches it on automatically. Then, after an attempt of setting the connection with the MindWave Mobile device a session is created, the time counter is initiated and the measurement is taken. After elapsing of one second the system refreshes the screen and draws the diagram of the user's concentration. After 60 seconds the system calculates the user's level of exhaustion, thus updating the diagram of his exhaustion progress. On this basis it is possible to calculate the total exhaustion of the system user [1]. Upon exceeding by the user of the maximum exhaustion level the message is displayed suggesting the necessity of taking a brake at work. Then, after selection by the user of the Stop Session option, the system closes the connection with the device, records the session in the data base and sets the screen to the initial state. In order to display by the user of the measurement session statistics the My Sessions option must be selected. At that time the system shows the user the list of all the measurement sessions from the newest to the oldest one. The system automatically calculates the statistics and shows the user the date and time of the session duration. It also shows the progress of concentration and exhaustion of the user during the session.  Fig. 2 and 3 presents the main window of the designed mobile application and the screen tracking used for monitoring of the concentration and exhaustion states of the user. In this window one can read the current time of the session lasting and the state of connection of the application with the device. Moreover, a diagram is drawn where one can read the progress of concentration value acquisition process and calculated exhaustion value of the user [2].  Fig. 4 the values of concentration and exhaustion are shown on the presented diagram. The line demonstrating measurements of concentration was presented in blue, exhaustion measurement in red. Sending of the session to the server takes place when the user brakes the measurement, then the application closes and records the session and brakes the connection with the MindWave Mobile device. Upon finishing of the session the screen returns to its initial state. It is possible for the user to return to measurements of one of the sessions that had been realized earlier.
The next application module is the question of verification of the recorded data using the implemented statistics. For this purpose the option Statistics is available in the mobile application, which is presented on Fig. 5. In this window one can see the number of all sessions of the user, bar graph showing the average concentration of the user during the particular day hours (horizontal axis presents the hours from 0-23). It is possible to infer from the diagram in which hours the person is the most concentrated. It allows to draw the conclusions concerning the time of the top concentration, which is necessary for execution of duties that require high attention. The next diagram presented on Fig. 5 presents the average attention of the user depending on the session length. The horizontal axis presents the session length and the vertical one presents the average concentration. The applied algorithm operates in the way that the concentration from all of the sessions, which lasted for the same time is summed up and divided by their number, thus presenting the average concentration of the user for the particular session length. It is also possible to read from the Statistics module the information concerning the average concentration of the user from all the sessions and their average length.

Summary
The mobile application written for the needs of the conducted studies of the concentration state analysis using the BCI technology is supported from the SDK 15 version, i.e. from level 4.0.3. of the Android system. During designing of the application the problem of the ORM application was encountered. The originally selected Sugar ORM 1.3 library, despite of its many advantages still featured low functionality, especially in respect of performing operations on entities. Additionally it slowed down system operation substantially. Therefore finally the subject system was elaborated on the basis of the GreenDAO library. The designed mobile application allows generating of the characteristics, on the basis of which it is possible to determine the best periods of time and daytime for studying or other tasks that require high concentration and attention. In future the works are planned targeted to expand the statistics module with new functionalities. Moreover, in order to obtain larger number of the data, it is possible to consider in future application of a measuring device with larger number of channels. This can be e.g. EPOC+ NeuroHeadset made by Emotiv Company.