Link Search Menu Expand Document

Importing continuous and epoched data

Refer to the quickstart guide to load an EEG data file, and scroll data. This section of the tutorial deals with importing raw data files in different formats, some of them only available through EEGLAB plugins.

Table of contents

Four steps to easily import continuous raw data files

First, if you have a raw EEG data file, determine the file format (for files with extension .cnt might be Neuroscan or ANT raw files, which are two different formats). Then follow these four steps.

  1. Look if a menu item is available in File → Using EEGLAB functions and plugins. If it does, select the menu and import the file.

  2. Use menu item File → Using the File-IO interface. EEGLAB might install the File-IO plugin if you do not have it installed already. If the function does not return an error, your file will be imported. File-IO is a Fieldtrip module that imports a variety of data formats. Refer to the File-IO documentation for more information.

  3. Use menu item File → Using the BIOSIG interface. The Biosig toolbox (biosig.sf.net) contains links to functions to read other EEG data formats in MATLAB. EEGLAB might install the BIOSIG plugin if you do not have it installed already. If the function does not return an error, your file will be imported.

  4. Use menu item File → Manage EEGLAB extensions and search for plugins (use the magnifier on the top right corner). Use the name of the amplifier you are using, for example. Once the plugin is installed, call the newly created sub-menu item in File → Using EEGLAB functions and plugins.

In 90% of the cases, the solution above will import the EEG data file. If it does not work, then the rest of this page contains documentation on importing other file formats.

Acquiring EEG data from within EEGLAB

EEGLAB and LabStreamingLayer (LSL) are tightly tied as they both originated at the SCCN laboratory at UCSD. By installing the lsl_app_MATLABViewer extension, a menu item File → MATLAB LSL Viewer, not only allows visualizing EEG LSL streams available on the network (Mac and Windows) but also to record them as EEGLAB .set data files. Note that this extension only allows recording one stream at a time. To fuse streams, record data as XDF using the LabRecorder python application, and import the XDF file in EEGLAB using the Mobilab plugin.

List of supported Data Formats

The plugin page contains all import plugin. Search for a given file extension or amplifier name. The same list of plugins is available through the EEGLAB plugin manager by invoking the File → Manage EEGLAB extensions menu item. If you encounter any problem with a plugin, we suggest you contact the plugin authors. Plugins also often have their own documentation.

Some rare EEGLAB plugins might not be available on the EEGLAB plugin manager and might be instead distributed as zip file by amplifier manufacturers. If you do not see a plugin for your data format, ask your EEG amplifier manufacturer.

Data import plugins and custom import

Importing data using command line mexSload of BIOSIG

Note that BIOSIG has separate C functions to import data. These functions can be interfaced in MATLAB through the mexSload function. There is no graphic interface for that function. However, you may use the mexSload function to import data on the MATLAB command line, and then use the documentation in the next section to import the MATLAB array into EEGLAB.

Importing a MATLAB array

We first construct a 2-D MATLAB array ‘eegdata’ containing simulated EEG data in which rows are channels and columns are data points:

eegdata = rand(32, 256*100);
% build a matrix of random test data (32 channels, 100 seconds at 256 Hz)

To import these data, select the menu item File → Import data → from ASCII/float file or MATLAB array. Click on option MATLAB variable from the list and set the name to eegdata. Set the sampling frequency to 256 Hz, press Ok. Other dataset parameters will be automatically adjusted.

Note on importing data from other file formats: To import continuous data from a MATLAB .mat file instead of a MATLAB array, scroll the list of choices in the box above that shows MATLAB .mat file.

Note: When reading a MATLAB .mat file, EEGLAB assumes it contains only one MATLAB variable. For reading a (32-bit) binary float-format data file, two choices are available: float le (little-endian) and float be (big-endian) The correct choice here depends on the operating system. In case the bit ordering is unknown, try each of them. Note that the toolbox command line function shortread.m can also be used to read data from a (16-bit) short-integer file. The resulting MATLAB array may then be imported into EEGLAB, as shown above.

Once the data is imported, refer to the quickstart guide to scroll the data.

Importing a file containing a MATLAB structure

MATLAB files may have many different formats. They are simply containers (like Excel files may contain data organized in many different ways in different tabs). EEGLAB cannot guess the MATLAB file’s internal format, so you need to do this step yourself. MATLAB files are best imported on the MATLAB command line

mydata = load(-mat, your_file.mat)

Then see where the data is in the “mydata” structure, for example mydata.eeg might contain an array that contains raw EEG data (channels by samples). Put this data in a MATLAB variable.

myeeg = mydata.eeg; % This is an example, the name of the field "eeg" might differ for you

Then select EEGLAB the File → Import data → from ASCII/float file or MATLAB array menu item and enter “myeeg” in the first edit box (the previous section has more details on importing MATLAB arrays).

Importing sets of data averages

EEGLAB was made to process and visualize single-trial data. Despite this section in the tutorial, we strongly advise against processing and importing data averages. Instead, one should import single-trial data from which event averages may be extracted. Event-related potential (ERP) averages can also be processed and visualized, but they should not be imported directly.

However, for old data, only data averages might be available. It is possible to process the three average-ERP epochs as if they were single-trial epochs (although in this case, some EEGLAB functions may not be meaningful). To import grand-average epochs into EEGLAB, stack the different conditions in a single array as explained below.

First, the data averages for different conditions must be imported to MATLAB. For example, one may export these averages in text format and then use the standard MATLAB function

>> load -ascii filename.txt

Note that to import ASCII files to MATLAB, all column names and row names must be removed.

Then you will need to concatenate data averages. For example, from a three-condition experiment, we may derive three ERP averages with a sampling rate of 1000 Hz, covering from -100 to 600 ms with respect to stimulus onsets (Note that we always process each subject individually and then compare the results across subjects at the end of the analysis).

For instance typing » whos under MATLAB might return:

Name                       Size               Bytes                 Class
avgcond1                   31x600             14880                 double array
avgcond2                   31x600             14880                 double array
avgcond3                   31x600             14880                 double array

Grand total is 55800 elements using 446400 bytes

Note: If necessary, transpose the arrays (so rows=channels, colunmns=data samples, i.e. chan*samp) like this (not required for this example). Then concatenate the arrays.

>> allcond = [ avgcond1 avgcond2 avgcond3 ];

Finally, you will need to import concatenated data averages into EEGLAB as MATLAB arrays. Select menu item File → Importing data → From ascii/float file or MATLAB array as shown in one of the previous sections.

Other/unsuported data formats

The EEGLAB discussion list archive also contains messages from users for importing specific data formats. You may search the list archive (and the rest of the EEGLAB web site) archive using Google and adding the keyword eeglablist.

We are eager to add other data importing functions to EEGLAB, so please write a plugin and submit it on this page. We are also in contact with consultants that can create EEGLAB plugins to import unsuported data format, so feel free to contact us.