Loading Electroencephalogram data from mobile acquisition devices: a quick training script

Adam Steiner, Minnesota State University-Mankato, Psychology
Author Profile

Summary

Keywords: EEG, Biological Signal Analysis, Excel Export

Psychology students often see electroencephalograms (EEG) as processed waveforms in a variety of textbooks. This script shows them the steps required to transform a raw data file into something normally seen in a textbook. The analysis steps are designed to guide them through the loading, brief analysis and plotting in MATLAB. However, this script assumes some knowledge of the background processes that underlie the generation of an EEG.

This MATLAB live script will guide students through the initial processing steps of a mobile electroencephalogram device. Any EEG device that exports a data file as a .WAV can be processed initially with this script.

The Backyard Brain's EEG device exports a fully compatible .WAV file and any file in a similar format can be briefly processed and exported to excel.

This link contains an easy to understand description of the basics required to operate BYB device. Additionally it provides a brief tutorial about the basics of EEG.

https://backyardbrains.com/experiments/EEG

If students do not have access to a .WAV file, the following link provides a sample .WAV file.

https://backyardbrains.com/experiments/files/EEG_Alpha_ActiveSearching_SampleData.zip

More advanced students should read through this article, though it will require login through a university portal to access.

Where does EEG come from?

Learning Goals

  • Basic knowledge of the biological foundations that contribute to the presence of electroencephalograms (EEG).
  • Basic loading of data into matlab using the Import Data option.
  • Origins of signal analysis and steps necessary to extract biologically relevant data from continuous acquisition devices - Backyard Brains Spiker Box - EEG - .WAV.
  • Basic understanding of array structure and function and how to find relevant data stored within the array for EEG frequencies of interest.
  • Basic understanding of export to excel and create table functions.

Context for Use

Our goal is to be able to generate and figure out the steps necessary to recreate average waveforms being displayed in most P300 publications, cognitive psychology, and/or cognitive neuroscience textbooks. This script will walk us through the steps required to load, process, and analyze EEG data from a .WAV as supplied by the Backyard Brains spikerbox.

Files:

Matlab script

EEG_2_Excel.mlx (MATLAB Live Script 242kB Nov7 19)

Test .WAV file

BYB_Recording_2019-07-09_10.wav ( 3MB Nov7 19)

Example Excel export

Anon-7-Nov-2019-19-54-39-EEG_data.xlsx (Excel 2007 (.xlsx) 1009kB Nov7 19)

Description and Teaching Materials

Initially students will need group instruction especially if they are not familiar with MATLAB and programming. Ideally students should be grouped with a senior lab member who will walk the students through the script step by step. Several prompts are included in the script that challenge students to think about what the EEG signal means both within the context of the biology and in terms of analysis. However, when working through this script with psychology students it is incredibly important to describe each step and process as they more than likely will have no previous basis for these functions let alone familiarity with MATLAB. This is a fairly simple script and designed to act as a brief basic EEG tutorial for much more sophisticated analyses run via other MATLAB packages such as:

https://sccn.ucsd.edu/eeglab/index.php EEGLab

http://www.fieldtriptoolbox.org/ Fieldtrip

https://neuroimage.usc.edu/brainstorm/Introduction Brainstorm

For example, we assume that students are already familiar with the hardware (EEG) and have acquired a signal file: .WAV.

1) Principle investigator trains a group of students and discusses each of the steps listed in the outline.

2) Students are tasked with modifying the variables as prompted and reporting to the PI how each variable affects the data outcome.

3) PI identifies and corrects any misconceptions and students are again asked to process their data sets.

4) Once students are comfortable with the basic processes in the live script, the more advanced students can train newer students.

5) The PI should regularly check student progress and test student's knowledge of the different variables. These might include:

- Sample Rate

- Resampling

- Smoothing

- Frequency of interest selection

- Colormap usage and scaling

Teaching Notes and Tips

It is incredibly useful to have psychology students who will be working with MATLAB complete the MATLAB onramp activity.

https://www.mathworks.com/learn/tutorials/matlab-onramp.html

For a basic application of EEG analysis, sleep is commonly described in terms of EEG waveforms.

Sleep Overview

Most psychology students will have little if any programming experience, it is incredibly important to avoid technology specific terms until students have a basic understanding. Often students report that any 'code' immediately makes them frustrated or causes them to completely lose interest. They have no familiarity with it and instead find it incredibly difficult and do not approach it with an open mind. Make sure to convey that programming is often like the scientific method, frame this script in the same context. I find it helps to have students walk you through what they think needs to be done in writing. Then, they can begin to translate that to pseudo code, and finally with help of the PI or more advanced students, into rudimentary MATLAB script.

Assessment

This script is designed to be modified and students should be encouraged to explore and attempt to change variables.

Always keep a copy of the original on hand - source control or Github repositories are an excellent way to preserve the initial file.

Ideally students should be able to explain and answer each prompt presented in the script.

There is no formal assessment for this script - instead students should be able to explain each of the methods used in each of the five goals as well as select frequencies of interest and adjust sampling rates.