Olimex OpenEEG

Sleep Tracking

The Olimex EEG-SMT is a device that connects to a computer via USB. It allows you to monitor brain regions and record data during sleep. You can then visualize and mark this data to see your sleep architecture.

The accuracy or quality of readings varies greatly from user to user. This accuracy discrepancy could be attributes of computer hardware or the surroundings at the time of recording. In some cases, sources of interference affecting quality can be identified and bypassed.

Assuming clear, reliable reading setup, it is fairly easy to pinpoint what sleep stages you went through. As in this example, the user determined the portion showing sleep stages at different times The blue spectrogram would depend on the computer, environment and electrode placement along with the Olimex to record sleep.

How Olimex scores sleep stages
Olimex interface

Other Applications

According to Olimex, “many people are interested in neurofeedback or EEG biofeedback training, a generic mental training method which makes the trainee consciously aware of the general activity in the brain. This method shows great potential for improving many mental capabilities and exploring consciousness. Other people want to do experiments with brain-computer interfaces or just want to have a look at their brain at work.”

What this means is that the device is applicable to more than sleep recording. Thus, this makes it worth considering when you compare it to other sleep tracking solutions in terms of cost.

Content

  1. Data Viewing & Marking Tools
    1. SleepEEGTools
    2. Marking Guide
  2. Raw Data Plots
    1. Marking Guide
  3. General Marking Guidance
    1. Hardware
    2. Software
  4. Hardware Setup
    1. Device Setup
    2. Electrode Positioning
  5. Common Electrode Placement Solutions
    1. Elastic Headband
    2. Ski Goggles
  6. Software Setup
    1. Windows 10 Setup
    2. OpenViBE Setup
    3. SleepEEGTools Setup
    4. Reading and Marking
  7. OpenViBE Acquisition Server Additional Setup
  8. Datplot Setup & Usage

Data viewing and marking tools

SleepEEGTools (Spectrogram Analysis)

The main way to view and mark Olimex EEG sleep data is with SleepEEGTools (see the image above). This software displays Olimex EEG data as a spectrogram.

You can select the various sleep stages by clicking different parts of the spectrogram. Then, save the sleep stages you have selected and view them the next time you open that reading.

In addition, it is common practice to check their marking with others on the Polyphasic Sleeping Discord server by sharing screenshots of this program, especially among new users.

Marking Guide

See the image below for a visual reference of the guide.

Readings can start with wake, then NREM1.

  • The wake state may be blank, or in some cases, indicated by a thin bold frequency around 10 Hz (the latter is not shown).
  • NREM1 is largely blank.
  • A thick bold frequency between between 10 and 15 Hz indicates NREM2/SWS, with a varyingly thin frequency below that.
  • The NREM3 (SWS) will have a more intense frequency than the NREM2 in the 0 to 10 Hz range. This increase in intensity may be present throughout the 0 to 10 Hz range. Or it may be within a thick bold frequency range, between 5 to 10 Hz range (the latter is not shown).
  • As the upper NREM2/NREM3 frequency move up to around the 20 to 25 Hz range before coming back down at the end of a cycle in a bow shape, you can observe REM sleep.
  • For some people, the bow shape may not be present. That upper NREM2/3 frequency may disappear for the duration of the REM period. Additionally, there would commonly be a thin frequency between 0 and 10 Hz (thinner than that of NREM2/NREM3 usually).
  • REM would be easier to identify in a core due to its positioning between sleep cycles. After this, you can try to spot that visual representation in shorter naps, which have no full sleep cycles for context.

A quick word on interference:

Generally, it is unlikely to make one sleep stage look like another, outside of making readings harder to distinguish.

Sleep stages in Olimex

If your reading differs significantly from all the descriptions, it may still be possible to determine sleep stages. Please check the General Marking section.

Raw Data Plots

Viewing parts of raw data plots can sometimes be a useful way to confirm a specific sleep stage after visualizing the whole marking sleep data.

A common Windows application that can produce these plots and is Datplot. Its setup and usage with Olimex data is in the setup section.

Marking Guide

The identifiers you would be looking for might not be visible on the scale of a core sleep that lasts multiple hours. Thus, you would have to know where to expect an event and look for it on a scale where it would be visible. Examples include several minutes, or in some cases, a 20 minute nap.

A REM movement can indicate the initiation of REM sleep and can last for 1-3 seconds. These movements can appear in clusters separated by a few seconds. See the image below. 

Detection of a REM movement

K-complexes, pulses lasting around 900 ms, appear at most 1-3 times a minute. These can indicate NREM2/SWS. Unlike REM movements, K-complexes should be visible in channels that are further away from the eyes. They may look roughly as follows:

How Olimex represents K-complexes
K-complexes

Note: Spindles can follow K-complexes (or a set of several pulses in a lower frequency than the k-complex pulse), though they haven’t been spotted in Olimex readings.

These events generally do not max out the frequency range. Otherwise, they are most likely noise.

Notably, the images above are general examples of what the events might look like. Their appearance would vary depending on what timescale you are looking at. Therefore, pay close attention if matching visual events line up with the time scale that these events would usually take place in.

General Marking Guidance

To identify sleep stages based on EEG data from scratch (or to get additional confirmation of marking) with the visualization methods above, it is a good idea to read up on the sleep mechanics. This would give you a better understanding of what to expect from a reading.

It might also be a good idea to start with a core sleep recording, if possible. This way you can get an initial visual representation of every sleep stage from the beginning.

Additionally, the community of sleep trackers on the Polyphasic Sleeping Discord server will likely be able to help you with marking if you ask nicely. Experience in marking different EEG readings (and sleep patterns in general) can facilitate marking readings whether your reading looks the same as most or not.

Components

Hardware

EEG

You will need the main EEG-SMT device and 5 electrodes.

According to the manual, “You can either choose to use 5 passive electrodes or 4 active electrodes + 1 passive electrode (necessary for electrical feedback). However, when you use active electrodes instead, no skin preparation is a requirement and you can achieve better performance under imperfect conditions.”

The above instructions are available on the Olimex website. Additionally, you also need a USB cable with a type B connector to use the device. A 1.5 meter length is usually recommended.

Accessories

You will need some ways to hold the electrodes on your head while you sleep. The electrode positioning description in the Hardware Setup section showcases different methods to achieve this.

Software

  • First, find a way to record the sleep sessions with the Olimex. The most common way to do this is with OpenViBE. Though, theoretically you should be able to use any software that supports “OpenEEG Modular EEG P2” devices. There is also a open source project called SleePi on GitHub for this purpose.
  • Next, you need a way to look over the whole reading to be able to view mark it. SleepEEGTools is a common spectrogram tool for this purpose.
  • Third, you need a way to plot the reading in its raw form for viewing of some markers which benefit from this type of view. A common Windows tool for this purpose is DatPlot.

The data viewing and marking tools section covers the use of some of the common software.

For Windows 10 users, there is a guide on how to install everything you need for recording and marking (mainly with the most commonly used software).

Olimex also has a manual for setting up the device, which may be worth looking at.

Hardware Setup

Initial Device Setup

Note: There is no need to remove the electrodes once they are plugged into the main device. Doing so has caused the electrode jacks to break for some users. Hence, it is better to make sure they are properly plugged in from the start.

To get the EEG-SMT ready (with the above in mind):

  • Identify the one passive electrode (if you have one passive and four active electrodes).
  • Plug it into the DRL jack. Compared to the active electrodes, it should not have black parts on the cable side.
  • Plug the rest in the remaining sockets.
Hardware setup

Electrode Positioning

The DLR electrode (for feedback or noise cancellation) can go on the ear (from the Olimex manual) or in the middle of the forehead. Therefore, there have been good results with both for sleep tracking purposes. The rest of the electrodes change positions based on what you want to track.

There are a couple of basic concerns about sleep tracking with the Olimex:

  • There are two electrode pairs (or channels)
  • Data relevant to sleep is generally recorded on/around the forehead and/or the eyes.

The most basic electrode layout would be to ignore the distinction between the two channels and position the electrodes in a line on the forehead randomly (with the DLR in the middle). This can work well enough.

Taking the channels individually, you can get a more diverse and complete dataset by focusing on a specific area with each channel.

  • One channel could be on the forehead as mentioned previously.
  • The other could be closer to or around the eyes for more REM data detail in that channel.
  • Both channels could also be around each eye.

Positioning around the eyes can be better for sleep tracking. Some layouts (of electrode pairs) with ocular setup include:

  • Placing one electrode above and one below the eye.
  • One electrode next to the eye (on the outer side of the face) and one above.
  • Placing all electrodes on the forehead (with one channel over the eyes and the other higher up).

It is worth trying out different layouts to get the best readings.

Common Electrode Placement Solutions

This section covers common ways to hold the electrodes on the head for sleep tracking.

Elastic Headband

One of the most simple ways to apply a headband is to put the electrode wires through the headband at the back of your head (going up) over the top of your head towards the front. This is where you can hold the end of the electrodes anywhere the band goes.

This is a decent way to get the electrodes in place without much initial preparation. However, you will have to adjust the position of the electrodes each time, rather than just placing an assembled placement solution on the head. As an addition, this method is fairly limited to the forehead area, realistically speaking.

To make the headband easier to use day-to-day, you can sew the electrodes in place. This would remove the short prep time you would otherwise have to go through every time you use it.

Additionally, you could combine multiple headbands in a DIY solution to more rigidly position electrodes in specific places.

Ski Goggles

The shape of ski goggles allow the positioning of electrodes around the eyes. This can be a good general base for attaching the electrodes in general. The cover of the glasses can be removed to make them more practical indoors.

This solution may be slightly more involved than a simple headband, with some DIY effort required, but the eye-based recording can yield better results.

Note: The ski goggles need to be fixed in place to ensure that the electrodes do not move during sleep.

Software Setup

Windows 10 Software Setup for Sleep Reading and Marking

For your computer to recognize the device, get the “setup executable‘ in the  ‘Windows*” row here. Install and restart your PC.

  • Afterwards, (if you plugged the EEG device in), your mouse may start going crazy.
  • You can unplug the EEG for now.
  • To stop the mouse glitch, you can go into the registry (Start > Run/Search > “regedit” > Enter).
  • Edit the ‘Start’ to 4 value in the following entry: “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\sermouse”. It should be 3 by default.
  • Then, plug in the EEG again and the mouse should not move on its own anymore.

OpenViBE Setup

Download and run the stable windows installer for the OpenViBE software from this page. This is what you will need to record the sleep blocks with the device, so run through the installer.

Once you have installed OpenViBE to do the recording, you will need to run ‘OpenViBE acquisition server’ and ‘OpenViBE designer’ each time. They should be in the Start menu.

To set up the acquisition server, you will need to know the COM port of the EEG device.

  • You can get this by right clicking on the Windows icon and on selecting Device Manager.
  • From the top menu in device manager, in view, click “Show hidden devices” if it is unticked.
  • Then, look in the “Ports (COM & LPT)” section. If there is only one item, that COM port will be the EEG.
  • If there is more than one, you can right click and check properties for each until you find one that has the ‘Manufacturer’ listed as ‘FTDI’.
  • Note the COM port number.

Now, plug in the EEG and run the acquisition server.

  • In the window that appears, from the “Driver” dropdown select “OpenEEG Modular EEG P2”.
  • Then, click the “Driver Properties” button.
  • In the window that pops up: change the ‘Number of channels’ to 2 and set the “Device” to the COM port you previously identified.
  • Click Apply on the “Device configuration” window and click Connect and Play. You should then see “Receiving…” and “0 clients connected”. In this state, when you set up the other part of OpenViBE, you will be able to connect to the device and record sleeps.
  • When you confirm this state, click Disconnect, and close the Acquisition Server windows for now.
  • Closing them properly like this will make it remember the configuration when you run it next time.
  • Unplugging the EEG while the acquisition server is running can cause it to crash, in which case the settings will not be saved (unless they were already saved previously).

Next, run the “OpenViBE designer”. Create a new design from the new option from the “File” menu at the top.

  • In the search box (to the right of the interface): type “acquisition“.
  • Drag-and-drop Acquisition client to the design workspace (to the left in the interface).
  • Then, in the search box: type “display“.
  • Drag-and-drop the Signal Display box to the design workspace.
  • Finally, in the search box: type “writer” and drag-and-drop the “CSV File Writer (Deprecated)” box to the design workspace. The deprecated version specifically is necessary for the other software to work, so make sure you have the right one.

Afterwards, connect the three elements as shown in the image below.

OpenViBE designer setup
  • To set up the CSV File Writer, double click on it.
  • In the new window, next to the filename, click on the button to browse a location you want to save your readings.
  • While browsing, set the name to “record-[$core{date}-$core{time}].csv” or something similar.
  • This will put the date and time of the recording in the name when saving to facilitate identifying specific readings.
  • When you are done browsing, click Apply.
  • Now, save this design setup with the ‘Save’ option in the File menu at the top. The design you save should automatically load the next time you run the Designer.

At this point, you are ready to record sleeps. If the acquisition server is running in the previously described state, you can press the play button to start recording and see a live preview of the signal. Right now, you can close the OpenViBE windows.

SleepEEGTools Setup

Next is the setup of the SleepEEG tools for sleep viewing and marking. To run the SleepEEGTools, you’ will need Python 3. It is available here. Use the big button that says  “Download Python 3…” Then, run the installer that you just downloaded. On the first screen, make sure to tick the option “Add Python … to PATH”.

  • Click Install Now. You can close it when it is done.
  • Next, you will need to go here and look for the “Tools for Visual Studio…”
  • From that section, you can download the “Build Tools for Visual Studio”.
  • Run the installer.
  • When you see the “Workloads” options, check ‘Visual C++ build tools” and click install. Once complete, close the installer and restart.

Now, find the “Visual Studio …” folder in your start menu and run the “x86_x64 Cross Tools Command Prompt …”

  • In a popup window, type: “pip install numpy spectrum “matplotlib” “
  • Press enter.
  • Finally, visit https://github.com/PolyphasicDevTeam/SleepEEGTools and click on “Clone or download”.  
  • Select ‘Download ZIP’.
  • Extract what you download and place it somewhere easy to find.
  • When installation is complete, you should be good to go for sleep marking.

At this point, the basic setup is complete.

Reading and Opening Readings for Marking

To record, make sure the EEG is plugged in with the red light on first.

  • Run “OpenViBE acquisition server”.
  • Click Connect and Play.
  • Then, run “OpenViBE designer”.
  • Click the Play button at the top to start recording, then the stop button to stop recording.

To mark sleep with this setup:

  • Go into your SleepEEGTools folder and right click while holding shift.
  • Click “Open PowerShell window here”.
  • Once the PowerShell window opens, run the marking tools by entering “python open.py” which opens a browsing window.
  • Here, you would locate a reading, which would then open up the marking window.

For a readout marking guide, see the SleepEEGTools section under “Olimex EEG data viewing and marking tools”.

“OpenViBE acquisition server” Additional Setup

To potentially make the signal from your EEG less noisy:

  • Go in the OpenViBE acquisition server Preferences menu. Make sure “Drift Correction” is set to “Disable” and click “Apply”.
  • Then, try to tweak the sampling frequency in the “Driver Properties” menu such that drift builds as slowly as possible. In other words, try to ‘connect’ and ‘play’ when your device is plugged in and see how much the drift value (given in ms) moves up or down over time.
  • Afterwards, try different sampling frequency values to see which is closest to a consistent amount of drift.

Datplot Setup and Usage

You can download Datplot here. Installation should be straightforward. If Windows produces some errors, restart and try again.

To use it for displaying Olimex data:

  • Select “Load New Data Source…” in the file menu at the top and find a reading.
  • In the popup import window, set “Get column (parameter) names from line” to 1, set the “Column delimiter” to semicolon and click “Import Data”.
  • Then, in the top right “X-Axis parameter”, dropdown select “Time (s)’”  Right click on the empty graph and select “Add” in the “Graph Pane” menu.
  • In the top chart, right click > “Data Curve” > “Add” and select “Channel 1” from the ‘Parameter Name to Plot’ dropdown. Then click ‘Plot  Curve’ and close.
  • Repeat step 3 with the bottom chart and select “Channel 2” instead of “Channel 1” where applicable.
  • For each of the charts, right click the plotted data line > “Data Curve” > “Format”. In the popup menu, click “Hide Symbol > “Apply” > “Close”.
  • Use the scroll wheel on the mouse for zooming/panning.

The right click options for charts allow you to scale charts to fit data in many ways, which can be useful.

Note: The program will work more slowly or faster depending on how fast your hardware is. Faster CPU and/or more RAM means better performance. Most importantly, the sleep duration that you are loading. 

If you are having trouble reading the data due to performance issues, edit the recording file and cut away anything you do not want to look at specifically. You can identify a portion of the sleep session to read in SleepEEGTools as a guide for what to remove and what to keep.

Main author: Litchnom

Page last updated: 2 April 2021