Importing data from EEG devices#
MNE includes various functions and utilities for reading EEG data and electrode locations.
BrainVision (.vhdr, .vmrk, .eeg)#
The BrainVision file format consists of three separate files:
A text header file (
.vhdr) containing meta data.
A text marker file (
.vmrk) containing information about events in the data.
A binary data file (
.eeg) containing the voltage values of the EEG.
Both text files are based on the INI format consisting of
sections marked as
comments marked as
and key-value pairs marked as
Brain Products provides documentation for their core BrainVision file format. The format specification is hosted on the Brain Products website.
BrainVision EEG files can be read using
.vhdr header file as the argument.
Renaming BrainVision files can be problematic due to their multi-file structure. See this example for instructions.
For writing BrainVision files, you can use the Python package pybv.
European data format (.edf)#
EDF+ files may contain annotation channels which can be used to store trigger
and event information. These annotations are available in
BioSemi data format (.bdf)#
BioSemi amplifiers do not perform “common mode noise rejection” automatically. The signals in the EEG file are the voltages between each electrode and the CMS active electrode, which still contain some CM noise (50 Hz, ADC reference noise, etc.). The BioSemi FAQ provides more details on this topic. Therefore, it is advisable to choose a reference (e.g., a single channel like Cz, average of linked mastoids, average of all electrodes, etc.) after importing BioSemi data to avoid losing signal information. The data can be re-referenced later after cleaning if desired.
Data samples in a BDF file are represented in a 3-byte (24-bit) format. Since 3-byte raw data buffers are not presently supported in the FIF format, these data will be changed to 4-byte integers in the conversion.
General data format (.gdf)#
GDF files can be read using
GDF (General Data Format) is a flexible format for biomedical signals that overcomes some of the limitations of the EDF format. The original specification (GDF v1) includes a binary header and uses an event table. An updated specification (GDF v2) was released in 2011 and adds fields for additional subject-specific information (gender, age, etc.) and allows storing several physical units and other properties. Both specifications are supported by MNE.
Neuroscan CNT (.cnt)#
CNT files can be read using
Channel locations can be read from a montage or the file header. If read
from the header, the data channels (channels that are not assigned to EOG, ECG,
EMG or MISC) are fit to a sphere and assigned a z-value accordingly. If a
non-data channel does not fit to the sphere, it is assigned a z-value of 0.
Reading channel locations from the file header may be dangerous, as the x_coord and y_coord in the ELECTLOC section of the header do not necessarily translate to absolute locations. Furthermore, EEG electrode locations that do not fit to a sphere will distort the layout when computing the z-values. If you are not sure about the channel locations in the header, using a montage is encouraged.
EGI simple binary (.egi)#
EGI simple binary files can be read using
EGI raw files are simple binary files with a header and can be exported by the
EGI Netstation acquisition software.
EGI MFF (.mff)#
EGI MFF files can be read with
EEGLAB files (.set, .fdt)#
These files can be read with
eXimia EEG data (.nxe)#
EEG data from the Nexstim eXimia system can be read with
Persyst EEG data (.lay, .dat)#
EEG data from the Persyst system can be read with
Note that subject metadata may not be properly imported because Persyst sometimes changes its specification from version to version. Please let us know if you encounter a problem.
Nihon Kohden EEG data (.eeg, .21e, .pnt, .log)#
EEG data from the Nihon Kohden (NK) system can be read using the
Files with the following extensions will be read:
.eegfile contains the actual raw EEG data.
.pntfile contains metadata related to the recording such as the measurement date.
.logfile contains annotations for the recording.
.21efile contains channel and electrode information.
.edf files is currently not
Note that not all subject metadata may be properly read because NK changes the specification sometimes from version to version. Please let us know if you encounter a problem.
XDF data (.xdf, .xdfz)#
MNE-Python does not support loading XDF files out of the box, because the inherent flexibility of the XDF format makes it difficult to provide a one-size-fits-all function. For example, XDF supports signals from various modalities recorded with different sampling rates. However, it is relatively straightforward to import only a specific stream (such as EEG signals) using the pyxdf package. See Reading XDF EEG data for a simple example.
A more sophisticated version, which supports selection of specific streams as well as converting marker streams into annotations, is available in MNELAB. If you want to use this functionality in a script, MNELAB records its history (View - History), which contains all commands required to load an XDF file after successfully loading that file with the graphical user interface.
Setting EEG references#
The preferred method for applying an EEG reference in MNE is
mne.set_eeg_reference(), or equivalent instance methods like
raw.set_eeg_reference(). By default,
the data are assumed to already be properly referenced. See
Setting the EEG reference for more information.
Reading electrode locations and head shapes for EEG recordings#
Some EEG formats (e.g., EGI, EDF/EDF+, BDF) contain neither electrode locations
nor head shape digitization information. Therefore, this information has to be
provided separately. For that purpose, all raw instances have a
mne.io.Raw.set_montage() method to set electrode locations.
When using locations of fiducial points, the digitization data are converted to the MEG head coordinate system employed in the MNE software, see MEG/EEG and MRI coordinate systems.
Estimated memory usage: 9 MB