( Note: eeg-notebooks is now at version 0.2, with some major changes to the API and code base. The current up-to-date code base can be found here. The current repo is the the original repo, which has been frozen at version 0.1 and renamed. Why do this, rather than putting the legacy code on a separate branch? Because for version 0.2 we have stripped out a lot of old files (e.g. example data, which is now in a separate location), to get the repo down to a more manageable size (now ~30MB, as opposed to the present repo's 700+MB. So, please go check out the shiny new and improved library, and do get in touch (ideally in the form of an issue in the new repo) if you have any issues or questions! ).
A collection of classic EEG experiments implemented in Python and Jupyter notebooks. This repo is a work in progress with the goal of making it easy to perform classical EEG experiments and automatically analyze data.
Currently, all experiments are implemented for the Muse EEG device and based on work done by Alexandre Barachant and Hubert Banville for the muse-lsl library.
Please see the documentation for advanced installation instructions and complete info about the project.
If you are a Mac user, follow the installation instructions here
You will need a Muse 2016 and Python installed on your computer. Psychopy, the stimulus presentation library that underlies most of the experiments, officially only supports Python 2. However, some users, especially those on Linux, have been able to work entirely in Python 3 without any issues.
git clone https://github.com/neurotechx/eeg-notebooks
Install all requirements.
pip install -r requirements.txt
See here for more detailed setup instructions for windows operating systems.
Open the experiment you are interested in running in notebooks folder. Notebooks can be opened either with the Jupyter Notebook browser environment (run jupyter notebook
) or in the nteract desktop application.
All experiments should be able to performed entirely within the notebook environment. On Windows 10, you will want to skip the bluetooth connection step and start an EEG data stream through the BlueMuse GUI.
*Note: if errors are encountered during viewing of the eeg data, try starting the viewer directly from the command line (muselsl view
). Version 2 of the viewer may work better on Windows computers (muselsl view -v 2
)
The basic steps of each experiment are as follows:
- Open an LSL stream of EEG data.
- Ensure that EEG signal quality is excellent and that there is very little noise. The standard deviation of the signal (displayed next to the raw traces) should ideally be below 10 for all channels of interest.
- Define subject and session ID, as well as trial duration. Note: sessions are analyzed independently. Each session can contain multiple trials or 'run-throughs' of the experiments.
- Simultaneously run stimulus presentation and recording processes to create a data file with both EEG and event marker data.
- Repeat step 4 to collect as many trials as needed (4-6 trials of two minutes each are recommended in order to see the clearest results)
- Load experimental data into an MNE Raw object.
- Apply a band-pass filter to remove noise
- Epoch the data, removing epochs where amplitude of the signal exceeded a given threshold (removes eye blinks)
- Generate averaged waveforms from all channels for each type of stimulus presented
Notebooks in the old_notebooks
folder only contain the data analysis steps (6-9). They can be used by using the run_experiments.py
script (e.g python run_eeg_experiment.py Auditory_P300 15 1
)
Currently available experiments:
- N170 (Faces & Houses)
- SSVEP
- Visual P300
- Cueing (Kyle Mathewson)
- Baseline (Kyle, Eye's Open vs. Closed, needs notebook made)