Olimex OpenEEG: Difference between revisions
From Polyphasic Sleep Wiki
No edit summary |
No edit summary |
||
| (15 intermediate revisions by the same user not shown) | |||
| Line 8: | Line 8: | ||
Signal quality depends on several factors, including electrode placement, electrical interference, and the user's environment. While results may vary, many users have successfully used this device to monitor sleep stages. | Signal quality depends on several factors, including electrode placement, electrical interference, and the user's environment. While results may vary, many users have successfully used this device to monitor sleep stages. | ||
Generally, sleep stages follow a distinct pattern, as illustrated in the figure on the right. For more details, see section [[Olimex_OpenEEG#Sleep_Stage_Identification|Sleep | Generally, sleep stages follow a distinct pattern, as illustrated in the figure on the right. For more details, see section [[Olimex_OpenEEG#Sleep_Stage_Identification|Sleep stage identification]]. | ||
[[File:Sample Olimex data.jpg|thumb|Sleep stages in Olimex]] | [[File:Sample Olimex data.jpg|thumb|Sleep stages in Olimex]] | ||
| Line 66: | Line 66: | ||
=== Electrode placement solutions === | === Electrode placement solutions === | ||
[[File:Sleep mask.webp|thumb|Sleep mask electrode setup by a polyphasic community member]] | |||
The electrodes need to remain attached to the head during sleep to record data. There are several ways to keep them in place, some of which are described below. | The electrodes need to remain attached to the head during sleep to record data. There are several ways to keep them in place, some of which are described below. | ||
| Line 75: | Line 77: | ||
==== Ski goggles or sleep mask ==== | ==== Ski goggles or sleep mask ==== | ||
This method involves more DIY effort, but it allows electrode placement around the eyes to collect more detailed REM data. However, keeping the sleep mask or ski goggles securely in place during sleep can be challenging, especially for side sleepers, as the electrodes may shift. This should be taken into account. | |||
=== Skin preparation === | |||
With the 4 AE + 1 PE setup, little to no skin preparation is typically required, and the electrodes can usually be placed directly on the skin. However, some users may still find it helpful to clean the electrode sites beforehand. In contrast, for the 5 PE setup, proper skin preparation is essential. | |||
To prepare the skin, first remove any excess hair from the electrode sites to ensure optimal contact. Clean the area with mild soap and water or a non-alcoholic wipe, as alcohol-based wipes can dry out the skin and reduce electrical conductivity.<ref name="skinprep" /> | |||
== Software setup == | == Software setup == | ||
| Line 86: | Line 92: | ||
=== Linux === | === Linux === | ||
==== OpenViBE installation ==== | |||
Start by downloading the stable source code (version 3.6.0 was used in this guide).<ref name="openvibedownload" /> Then, follow the [https://openvibe.inria.fr/build-instructions/ build instructions]. | |||
After running <code>conda env update -f conda/env_linux.yaml</code>, '''be sure to run''' <code>conda activate openvibe</code>. This step is required to build the program within the OpenViBE environment, even though it's not explicitly mentioned in the official instructions. | |||
==== Configuring Acquisition Server ==== | |||
Run <code>sude dmesg -w</code> and plug in your device. This will help you identify the correct port (e.g. ttyUSB0). | |||
Navigate to the <code>build/</code> directory of OpenViBE, then run <code>./bin/openvibe-acquisition-server</code>. Click Driver Properties, set Number of channels to 2, and set Device to the port you identified earlier (e.g. ttyUSB0). | |||
You may also want to add your user to the <code>uucp</code> group and reboot to ensure proper permissions (<code>sudo usermod -a -G uucp <username></code>). | |||
To reduce signal noise, open the Acquisition Server's Preferences menu. Set Drift Correction to Disable and click Apply. Then, go back to Driver Properties and adjust the sampling frequency to minimize drift. | |||
To do this: | |||
* Plug in your device. | |||
* Click Connect and Play in the Acquisition Server. | |||
* Observe the drift value over time. | |||
* Try different sampling frequencies (e.g., 256, 257, etc.) to find the setting that causes the drift to change as slowly as possible. | |||
==== Configuring Designer ==== | |||
[[File:Designer.webp|thumb|Design workspace connection]] | |||
Disconnect and close the Acquisition Server window. Then run <code>./bin/openvibe-designer</code>. Go to File -> New. In the search bar, type "acquisition" and drag ''Acquisition Client'' to the design workspace (to the left side of the interface). Repeat this process for ''Signal Display'' and ''CSV File Writer (Deprecated)''. Note: the deprecated CSV File Writer is required for compatibility with other software. | |||
Next, connect all the elements in the design workspace as shown in the image. | |||
Configure the CSV File Writer by double clicking it. Use the folder button to choose where you want to save your sleep recordings. Set the filename to <code>record-[$core{date}-$core{time}].csv</code>. This will automatically include the date and time in the file name. Click Apply. Press Save, and select the name (like design_scenario). This will save the design, and it will automatically load the next time you open the Designer. Finally, close all OpenViBE windows. | |||
==== Running OpenViBE ==== | |||
To record your sleep, enter the <code>build/</code> directory of OpenViBE and run <code>./bin/openvibe-acquisition-server</code>. In the Acquisition server window, click Connect, then Play. Next, use another terminal tab to run <code>./bin/openvibe-designer</code>. In the Designer window, click the Play button to start recording. You should see the signal being captured in real time. | |||
Do not unplug the device while recording, as this may cause the program to hang. | |||
When you're finished: | |||
# Press Stop in the Designer window. | |||
# Then press Stop and Disconnect in the Acquisition Server window. | |||
After that, you can navigate to the folder you selected earlier to save your recordings. You’ll find the raw sleep data files there. | |||
==== Installing SleepEEGTools ==== | |||
Run <code>git clone https://github.com/polyphasicdev/SleepEEGTools</code> to clone the SleepEEGTools repository. Then, navigate into the project directory by running <code>cd SleepEEGTools</code>. To set up a virtual environment, run <code>python -m venv venv</code> and <code>source venv/bin/activate</code>. Next, try running the program: <code>python open.py</code>. If it fails due to missing dependencies, install them using <code>pip install <package name></code> (replace <code><package name></code> with the actual missing package listed in the error). Once everything is installed, the program should run correctly. When you're finished, deactivate the environment by running <code>deactivate</code>. | |||
==== Running SleepEEGTools to mark sleep ==== | |||
Navigate to the SleepEEGTools project directory. If you set up a virtual environment in the previous step, activate it by running <code>source venv/bin/activate</code>. Then, run <code>python open.py</code>. This will open a file browser window. Select a recording file to open the sleep marking interface. | |||
Alternatively, you can run <code>python open.py openvibe <file name></code> to open the recording directly and skip the file selection dialog. | |||
From there, you can manually analyze and mark the sleep stages. Detailed instructions for this process are provided in the [[Olimex_OpenEEG#Sleep_Stage_Identification|Sleep stage identification]] section. | |||
=== MacOS === | === MacOS === | ||
| Line 92: | Line 154: | ||
== Sleep stage identification == | == Sleep stage identification == | ||
[[File:Sample Olimex data.jpg|thumb|Sleep stages in Olimex]] | |||
Follow the instructions in the section [https://polysleep.org/wiki/Olimex_OpenEEG#Running_SleepEEGTools_to_mark_sleep|Running SleepEEGTools to mark sleep] to launch the SleepEEGTools program and select a recording. This will open the marking window. From there, you can choose a sleep stage and click on different parts of the spectrogram to mark the stages manually. Once you're finished, click Save and Quit to store your annotations. | |||
If you're unsure about how to mark sleep stages or have atypical recordings, feel free to join our [https://discord.com/invite/2kzXcg7Juf Discord server] and ask for help from experienced community members. | |||
=== Sleep stages === | |||
As shown in the image, each sleep stage has a distinct pattern. With some practice, you'll be able to recognize these patterns and mark them accurately. | |||
==== Wake/NREM1 ==== | |||
These two stages can appear quite similar. The wake state typically looks blank or appears messy with high-frequency activity. NREM1 is also mostly blank, but usually with less high-frequency noise. | |||
==== NREM2/NREM3 ==== | |||
NREM2 ([https://en.wikipedia.org/wiki/Non-rapid_eye_movement_sleep#Stages light sleep]) and NREM3 ([https://en.wikipedia.org/wiki/Slow-wave_sleep slow-wave sleep]) are part of a continuum and are primarily differentiated by the amount of delta wave activity. In NREM2, delta waves are present but not dominant. NREM3 is characterized by a significant amount of delta activity, often exceeding 20% of the total brainwave activity.<ref name="nrem" /> | |||
Both NREM2 and NREM3 (SWS) show a bold frequency band between 10 and 15 Hz. This band is typically thicker in NREM2 and thinner in SWS. Additionally, SWS tends to show more intense low-frequency activity in the 0–10 Hz range. | |||
==== REM ==== | |||
REM sleep is usually easy to identify in the spectrogram, especially within the core of a sleep cycle. REM episodes occur between NREM stages and are marked by a distinctive bow-shaped frequency band around 20–25 Hz near the end of the cycle. | |||
=== Identification in naps === | |||
[[File:Rem beta.webp|thumb|REM nap, beta waves (20–28 Hz)]] | |||
[[File:Wake.webp|thumb|Awake state, no well-defined beta waves]] | |||
[[File:Nrem1 2.webp|thumb|NREM1 and NREM2 during a nap]] | |||
Distinguishing sleep stages during a nap can be more challenging than during a full night of core sleep, but it is still possible. REM sleep is marked by beta activity, specifically in the 20–28 Hz range<ref name="remnrem" />, which helps identify REM naps. | |||
The wake state appears similar but lacks clearly defined beta waves. It typically looks disorganized, featuring high frequencies without a distinct structure. | |||
NREM naps usually begin with NREM1, which appears mostly blank, similar to wakefulness but with a clearer and more subdued pattern, as shown in the third image. The nap then progresses into NREM2. Both NREM2 and NREM3 are characterized by prominent sigma waves (12–16 Hz)<ref name="remnrem" />. Delta waves (0.3–3 Hz) are also present, being strong in NREM3 and weaker in NREM2. | |||
REM naps are most common in the morning hours (between 3–11 a.m.), while NREM naps tend to occur in the afternoon. | |||
== References == <!--T:3--> | == References == <!--T:3--> | ||
| Line 105: | Line 207: | ||
<ref name="sleepi">{{cite web |url=https://github.com/PolyphasicDevTeam/sleepi |title= SleePi |website=Github |access-date=2025-06-21}}</ref> | <ref name="sleepi">{{cite web |url=https://github.com/PolyphasicDevTeam/sleepi |title= SleePi |website=Github |access-date=2025-06-21}}</ref> | ||
<ref name="openvibe">{{cite web |url=https://openvibe.inria.fr/ |title=Software for Brain Computer Interfaces and Real Time Neurosciences |website=OpenViBE |access-date=2025-06-21}}</ref> | <ref name="openvibe">{{cite web |url=https://openvibe.inria.fr/ |title=Software for Brain Computer Interfaces and Real Time Neurosciences |website=OpenViBE |access-date=2025-06-21}}</ref> | ||
<ref name="skinprep">{{cite web |url=https://thephysiologist.org/study-materials/electrodes-and-interference/ |title=Electrodes and Skin Prep |website=The Student Physiologist |access-date=2025-06-21}}</ref> | |||
<ref name="openvibedownload">{{cite web |url=https://openvibe.inria.fr/downloads/ |title=OpenViBE Downloads |website=OpenViBE |access-date=2025-06-21}}</ref> | |||
<ref name="nrem">{{cite web |url=https://neupsykey.com/introduction-to-sleep-and-polysomnography-3/ |title= | |||
Introduction to Sleep and Polysomnography |website=Neupsy Key |access-date=2025-06-22}}</ref> | |||
<ref name="remnrem">{{cite journal |vauthors=Uchida S, Maloney T, Feinberg I |date=1994 |title=Sigma (12–16 Hz) and beta (20–28 Hz) EEG discriminate NREM and REM sleep |journal=Brain Research |volume=659 |issue=1-2 |pages=243-248}}</ref> | |||
}} | }} | ||
