Home>Basic usage, Featured resources, FAQs, Support & Tips, Hyperscanning>How to convert XDF files into an Analyzer compatible format
Search our resources

Tip: Start typing in the input box for immediate search results from our Resources Knowledge Base.
For a more comprehensive search, use the site search in the main menu above.


Manuals & Operating Instructions | Contact Support

How to convert XDF files into an Analyzer compatible format

You can convert data streams that were recorded via the Lab Streaming Layer (LSL) – Lab Recorder into an XDF file to the BrainVision Data Exchange Format (BVDEF) with freely available open-source tools.

In the following, we present multiple approaches that offer either a graphical user interface for easy usability or are script based for more stability. For processing multiple files automatically, script-based workarounds may be more useful.

The first approach is based on Python, a widely known and freely available programming language. The second approach is based on the commercial software MATLAB® which requires a valid MATLAB license.

The toolboxes synchronize the data and correct for clock drifts when multiple streams are recorded into the XDF file. Note though, if you choose to export multiple streams into one BrainVision format file, offsets may be compensated with NaN values. If you export to individual files these need to be handled by the user. The Merge Channels Solution offers a dedicated functionality to account for offsets.

Python / MNELAB

  1. Download and install Python and make sure Python and Pip (included in recent Python distributions) are recognized by your system. If you are already working with Python, you can also launch your Python environment and install the packages below with the appropriate commands.
  2. For installing with Pip, launch windows command prompt by pressing Win+S then type cmd
    pip install pybv
    pip install mnelab
  3. Open MNELAB
    mnelab
  4. Open the XDF file from the MNELAB Interface with File > Open (this might take a few moments).
  5. Select all streams that you want to transfer. If you select multiple streams at once, all streams will be sampled to the same sampling frequency (option Resample to). You can choose your desired sampling frequency.

    If you choose to export streams to individual files, make sure to use the same sampling frequency if you intend to merge them later.

    Note that you have the option to change the Description of markers by adding a prefix with the stream ID.
  6. Export to BrainVision Data Exchange Format from the MNELAB Interface with File > Export data > EEG (BrainVision)…

    Note that streams imported with the Python functions above and below undergo a synchronization procedure upon loading the XDF file. Please check the quality of synchronization between multiple streams after export. Individually exported EEG streams can be checked and merged in Analyzer with the Merge Channels Solution.

    If you do not want to use the graphical user interface of MNELAB you can also write your own Python script to export to BrainVision Data files. You can make use of the open-source input/output libraries pyxdf and pybv for importing and exporting. Note that, unlike the MNELAB toolbox,  functions in these libraries do not directly support exporting multiple data streams into one BrainVision Data file. Importing, synchronization and exporting of single LSL streams is however possible.

MATLAB/EEGLAB

  1. Download and install EEGLAB. Note this tool requires a working installation and valid license for MATLAB.
  2. Install MoBILAB plugin for EEGLAB. You can download it here or install it via the EEGLAB plugin manager.

    Note that we currently recommend using the MoBILAB toolbox for easy conversion of multiple streams into one file, but the import is also possible in EEGLAB with the xdf import plugin (see below).

  3. Install bva-io plug in for EEGLAB. You can download it here or install it via the EEGlab plugin manager.
  4. Launch EEGLAB in the MATLAB desktop application.
  5. Open the XDF file via MoBILAB > Import xdf File.

  6. Select desired streams and click the button below. Tick the boxes in the Select columns to select data streams on the left and marker or event streams on the right.

  7. Export to BrainVision File Format via File > Export > Write Brain Vis. exchange format file.

Note that streams imported with the MATLAB functions above and below undergo a synchronization procedure upon loading the XDF file. Please check the quality of synchronization between multiple streams after export. Individually exported EEG streams can be merged and checked in Analyzer with the Merge Channels Solution.

If you do not want to use the graphical user interface of MoBILAB you can also use the alternative workarounds below. To make the following work, you would need to install the EEGLAB toolbox, the xdf import plugin and the bva-io plugin. Note that, unlike the MoBILAB toolbox, these plugins do not directly support exporting multiple data streams into one BrainVision Data file. Importing, synchronization and exporting of single LSL streams is however possible.

Using EEGLAB GUI

  1. File > Import Data > Using EEGLAB Function and Plugins > From .XDF or .XDFZ File.
  2. File > Export > Write Brain Vis. Exchange format file

Using EEGLAB scripts

Copy to Clipboard
Table of Contents
Go to Top