I2R001: Investigating the changes in the EEG during different mental tasks (facial expressions) and programming of data analysis
External Mentor: Dr Chin Zheng Yang
Teacher Mentor: Ms Jane Lin
Group Members: Sun Yufei, Huang Lin Wei, Fu Ziying
In this WOW! Attachment, we were assigned to the Agency for Science, Technology and Research (A*STAR), more specifically, the Institute for Infocomm Research (I²R). Our project aimed to evaluate the performance of different headbands. After the processing of the signals, some classifiers were used to classify the analysed data into two categories. The accuracy of each classifier was then calculated. The following includes three content/knowledge I have learnt, three interesting aspects of learning, and one takeaway for my life.
The Institute for Infocomm Research (I2R), established in 2002, is a branch of the Agency for Science, Technology and Research (A*STAR). It is Singapore’s largest ICT research institute. It seeks to foster world-class Infocomm and media research and develop a deep talent pool of Infocomm professionals to power a vibrant knowledge-based Singapore.
It has thus so far focused on Artificial Intelligence, Audio; Language & Speech, Data Analytics, Communications & Networks, Cybersecurity, Heterogeneous Analytics, Healthcare, Robotics & AV, Satellite, Smart Energy & Environment and Video & Image Analytics.
Adapted from: https://www.a-star.edu.sg/i2r/ABOUT-I2R/VISION-MISSION.aspx
The project aimed to evaluate the performance of various headbands that measure EEG signals. The headbands that we have tested on ourselves are the Muse headband,and OpenBCI headband. Initially, we knew nothing about EEG data and we had no idea how to utilize the headband to collect data in order to build our classifier.
Our classifier is designed using codes in MATLAB and it sorts the activities recorded into two categories: eye opening and eye closure based on the band power data from the selected electrodes.
We have to analyze the data collected from experiments using the MATLAB programme so as to conclude the performance of the headband.
Workspace with our mentor (Dr Chin) and teammates.
Data collection
During the first week of the attachment, we mainly focused on collecting using the headband. We were first introduced the names of different electrodes and their different reference points. There were 2 to 4 electrodes depending on the headband we use. To collect data, we used the software called BCIsoftware.exe to collect the raw data and label them according to the action: eye opening and eye closing. There were a total of 10 trials in the experiment, where there’s a randomized unbiased test of 5 trials for eye opening and eye closing each. There were stimcodes labeled at the end of the experiment which indicated the order of eye opening and eye closing.
Data loading
We were given a set of codes in MATLAB. We were asked to understand the logic behind the codes such that when we were writing the script for intersubject classification, we could apply the function. The main purpose of this function is to load the data collected from the software into MATLAB for further use.
Data extraction
This is also a function provided by our mentor, Dr Chin. The set of codes are titled ‘extracteegdata.m’. The purpose of this function is to extract the raw EEG data uploaded in MATLAB for further processing.
PSD graph
In order to get the power spectral density graph, we learnt to use the function getPSD that is in built in MATLAB. The following graphs are the PSD graphs generated using data from Muse headband
Temporal filtering
Initially, we were asked to understand how the bandpass works. There are different parameters to be set in the filter created. The 4 different types of parameters we vary are: passband(Wp)and stopband(Ws), ripple passband(Rp) and ripple stopband(Rs). By varying the parameters, we can select the sections we desired and eliminate the excess ones. In the later part of the project, we were introduced new functions called FilterHighPass and FilterLowPass. We were tasked to compare the results between the newly introduced and the filter we had written before within the same parameters. The filters turned out to be performing in the same way. We hence adapted the new functions afterwards.
FilterHighpass only preserves the highpass signals while FilterLowPass only preserves the lowpass signals.
Feature selection
The feature selection we have used in both our intra and inter subject classification is the Fisher Ratio. There are originally 4 features(4 channels). With the fisher ratio which distinguishes the separability of the results, we were able to select the 2 most separable features so that during the prediction in classification, the prediction between eye opening and eye closing can be more accurate.
Formula of fisher ratio
Classification
In both intra and inter subject classification, we uses the leave-one-out method for classification. What this method does is that out of 10 trials in intra subject classification, 9 trials will be used as training data to generate a model while the 1 trial remaining will be used for validation. For inter subject classification, we uploaded all three teammates' data sets (of the same headband). Two datasets will be used for training while the last set of data is used in validation.
At the end of classification, we used codes that generate a confusion matrix to reveal the result of the classification, whether the prediction class is the same as the actual class. We also computed the function to calculate the accuracy from confusion matrix.
At the end of the WOW attachment, we submitted a folder containing the following contents:
readme.txt file (instruction)
2. The submission report consists of two part. The first is the review of data collected from the four different headbands. We would need to run the codes by loading our collected data(individual) to produce a Power spectral diagram and Raw eeg data diagrams. The Power spectral diagram would be put into the report in comparison of three people's data to observe any trend while the raw EEG data will only be put in if there is any irregularity or noticeable unfamiliar patterns. Analysis is also required for the diagrams of 2 different headbands. The second part of the report is using our classifier built in MATLAB to calculate the confusion matrix and accuracy. The results should be categorized into intra subject classification and inter subject classification where intra and inter subject classifier should include the Muse and OpenBCI data.
3. Student data include all the data collected from the 2 headbands using the downloaded software BCIsoftware.exe
4. References are the reports, papers and videos we have watched in order to build up our theory and also to familiarize with new programming functions.
The results of confusion matrix and accuracy are as shown:
1. I am now exposed to more programming and I have acquired some important basic programming skills. Initially I could not even understand any codes written in the functions given by our mentor. However, after this one month attachment, I am able to write new functions and an entire script that is functional. I am very grateful for our mentor's guidance in programmming because not only did he teach us various ways of writing a function, but he also taught us methods to approach debugging. This skill can be used in real life as it is also a problem solving skills
2. Another skill that I have learnt is how to use Google in the correct way and self learn from there on. During the attachment, we often had to search for teaching lesson on Internet to understand unfamiliar stuff before our mentor could teach us further. Although this skill sounds simple, after this one month, I found that only if we search in the correct way,can we achieve what we really want. There is also no harm in searching more websites and look through to compare the differences between information.
3. I have also learnt more advanced mathematics knowledge such as the linear discriminant algorithm, gradient decent and fisher ratio. These mathematics knowledge can be further applied in the workforce. We have better equipped ourselves with more knowledge in preparation for our future.
1. During the process of programming, there were hands-on activities that excited me and triggered my interest to find out more about the project -- playing with the headbands(collection of data). I think these hands-on activities allowed us to better relate to the project instead of doing mainly in the virtual world. The analysis of the collected data is also interesting because we can now visualize the fluctuation of our brain signals. Furthermore, the different levels of fluctuations during eye opening and eye closing are also associated with levels of stress. This urged me to delve in deeper to find out more about related studies.
2. I feel that different people have different ways of writing codes, so it is just like an art which everyone has their own type of expression. Programming, although tedious, can also be viewed as a way to express our own creativity. Thus, we three teammates were able to compare and contrast between three different scripts and learn from the differences.
One takeaway for life that I have is that active and continuous learning is important in today's world. Learning does not stop after graduation or even after you have achieved your desire results. However, there are many ways of learning, and it need not always be academic learning (though academics may be the foundation of further learning). Learning can be just like we did in WOW!, which is to constantly trying and learn from our mistakes. There are still many uncertainties left for us to solve. We must be open-minded and passionate about learning new things in order to keep up with the changes of the world.