My MSc thesis on "Classifying brain activity using electroencephalography and automated time tracking of computer use".
Progress was tracked using GitHub issues and the GitHub Projects board.
We investigate the ability of EEG to distinguish between different activities users engage in on their devices, building on previous research which showed a considerable difference in brain activity between code- and prose-comprehension, as well as differences during code- and prose-synthesis. We perform a replication study and improve upon past results using state-of-the-art machine learning classifiers based on Riemannian geometry.
Furthermore, we extend the scope of previous work by introducing the automated time tracking application ActivityWatch, to track the device activities that the user is engaging in. This lets us label EEG data with naturalistic device activity, which we then use to train classifiers to discern activities such as code writing vs prose writing, or work vs media consumption. Our results indicate that a consumer-grade EEG device can discern between different activities that a user performs at the computer. Among other results, we show that not only can code and prose comprehension be distinguished, but also code and prose writing.
The latest version of the writing can be downloaded at:
- Thesis report: erik.bjareholt.com/thesis/thesis.pdf
- Goal document: erik.bjareholt.com/thesis/goaldoc.pdf
- Presentation: erik.bjareholt.com/thesis/presentation.pdf
- Popular scientific article (Swedish): erik.bjareholt.com/thesis/popsci.pdf
Setting it up:
- Ensure you have Python 3.7+ and
poetry
installed - Install dependencies with
poetry install
Collecting data:
- Run
eegwatch --help
for instructions on how to collect EEG data - Run ActivityWatch to collect device activity data
- Run the codeprose task in eeg-notebooks to collect data for the code vs prose task
- Install eeg-notebooks with
pip install git+
- Run the codeprose task with
eegnb runexp -ex visual-codeprose -subject X
- Install eeg-notebooks with
Running classifier:
- Run
./scripts/query_aw.py
to collect labels from the running ActivityWatch instance- You probably want to adjust the categorization rules embedded in the file
- (TODO) Run
eegclassify --help
for instructions on how to train and run the classifier
I've worked with multiple devices, but the experiments were performed using the Muse S, which is therefore the best-supported device.
- Muse S
- PPG support (experimental)
- Neurosity Notion 1 & 2
- Thanks to @andrewjaykeller at @neurosity for sending me a refurbished Notion 1 to test with!
- Neurosity Crown
- OpenBCI Cyton
- In theory: any device supported by Brainflow or muse-lsl
Code notebooks are built in CI and available at:
- Main - primary notebook for the thesis, where we train a classifier for the code vs prose comprehension task.
- Signal - for signal filtering and quality checking.
- Activity - for classification of device activities.
- PPG - for a basic PPG analysis.
See the Acknowledgements section in the thesis.