A01: Importing Continuous and Epoched Data

From SCCN
Jump to: navigation, search

Arrow.small.left.gif IV. Appendix
Tutorial Outline
A02: Importing Event Epoch Info Arrow.small.right.gif

Contents

Importing continuous and epoched data

Supported Data Formats

File Format File Extension File type Events Channel Labels EEGLAB Biosig File IO Support
ANT EEProbe .avr _ _ _ _ _ _ Comments
ANT EEProbe .cnt _ _ _ y y y Comments
ASCII .txt _ _ _ y y _ Comments
BCI2000 .bci2000 continuous _ _ p _ _ Comments
BCI2000 .gdf continuous _ _ p _ _ Comments
Biologic .eeg _ _ _ _ _ _ Comments
Biopac .mat/.acq _ _ _ p (see comments) _ _ Comments
Biosemi .bdf continuous Channel _ y y y Comments
Blackrock .NEV .NSx _ _ _ see comments _ _ Comments
Brain Vision Analyzer .mat continuous & segmented Embedded _ y y n Comments
Brain Vision Analyzer .vhdr _ file _ y y n Comments
BrainStorm .vsm _ _ _ _ _ _ Comments
Cogniscan _ _ _ _ p _ _ Comments
Compumedics Profusion .raw _ _ _ see comments _ _ Comments
CTF/BrainStorm .ctf _ _ _ y y y Comments
EGI/Netstation .RAW continuous & segmented Channel _ y y y Comments
Elektra (MEG) .fif _ _ _ n (see comments) y n Comments
Emotiv .edf _ _ _ y (see comments) y (see comments) y (see comments) Comments
ERPSS .raw _ _ _ y n n Comments
ERPSS .rdf _ _ _ y n n Comments
European Data Format (16-bit) .edf _ Channel _ y y n Comments
EDF+ .edf _ Channel _ y y n Comments
INSTEP .asc _ _ _ y n n Comments
Matlab Array .mat _ Channel _ y y n Comments
Micromed _ _ _ _ p _ _ Comments
Neuroimaging4D .m4d _ _ _ y n n Comments
Neuromag .fif _ _ _ see comments n see comments Comments
Neuroscan .avg _ _ _ _ _ _ Comments
Neuroscan .CNT _ Embedded (see comments) _ y y y Comments
Neuroscan .eeg continuous _ _ y y y Comments
Nihon Kodhen .eeg continuous _ _ y (see comments) Comments
Profusion .slp _ _ _ _ _ _ Comments
Snapmaster .SMA _ Channel _ y y n Comments
Spike2 .mat _ _ _ y (see comments) n n Comments
Tucker-Davis Technology .tdt _ _ _ p _ _ Comments


Please upload test files at ftp://sccn.ucsd.edu/incoming to help us fill the table.

File Format Compatibility is noted by the following:

Supported Formats y
Supported but requires MEX file y
Unverified _
Currently unsupported formats or not working n
Functionality via third-party EEGLAB Plug-Ins p


See also Electrode Data Formats and how to work with Other Formats

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. At the Data file/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.

II11pop editset.jpg


Note on importing data from other file formats: To import continuous data from a Matlab .mat file instead from 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 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.

Now is a good time to add a Description about the dataset. A window will pop up containing a text box for this purpose. Enter as much information about the dataset as possible. The information you enter will be saved with the dataset for future reference by you or by others who may load the data. You can add to or revise these comments later by selecting menu item Edit > Dataset info. It is also possible to save the newly created data into a new dataset, either retaining or overwriting (in Matlab process memory) the old dataset. To also save the new dataset (with all its accompanying information fields) to disk, enter a filename in the lower edit field. Press OK to accept.

II11pop newset.jpg


Then use menu item Plot > Channel data (scroll) to visualize the imported data.

Importing Biosemi .BDF files

Biosemi has extended the 16-bit European standard "EDF" (European Data Format) to their 24-bit data format, BDF (Biosemi Data Format). Select menu item File > Import data > From Biosemi .BDF file (calling function pop_readbdf.m). A window will pop up to ask for a file name.

Pop readbdf.gif

Press OPEN to import a file.

Then a second window pops up, press Ok.


II12pop readbdf.jpg


The third window to pop up ask for a new dataset name.


Pop readbdf2.gif


Press OK, then select menu item Plot > Channel data (scroll) to inspect the data. A sample .BDF file is available -- TEST_256.BDF (use save link as in your browser). (More sample files and reading functions are also available from the Biosemi ftp site). To extract event records from .BDF data, select menu item File > Import event info > From data channel as explained elsewhere in this tutorial.

Importing European data format .EDF files

To import data collected in the joint European 16-bit data format (EDF), select menu item File > Import data > From European data format .EDF file (calling function pop_readedf.m). A window will pop up to ask for a file name. Then select menu item Plot > EEG data (scroll) to inspect the data. A sample .EDF file is available -- TEST.EDF (use save link as in your browser). To extract event records from .EDF data, select menu item File > Import event info > From data channel as explained elsewhere in this tutorial.

Importing Netstation/EGI files

The simplest way to read EGI (Electrical Geodesics Incorporated) .RAW data files is to select menu item File > Import data > From Netstation binary simple file. Note that native EGI files in the current 2009 version of the EGI Netstation software are not EEGLAB compatible and need to be converted to Netstation binary simple. There are however two solutions to import the most recent files. One is an EEGLAB plugin and another one is through File-IO. EGI files can also be converted to EDF and imported into EEGLAB but events may be corrupted in EDF files so the "Netstation binary simple" format is to be preferred. Once the EEGLAB menu is selected, the following window will appear

Pop readegi.gif


The function pop_readegi.m should be able to read EGI Version 2 and Version 3 data files. The presence of events in the EGI format is recorded in an additional EGI data channel. Information from this channel is automatically imported into the EEGLAB event table and this channel is then removed by EEGLAB from the EEGLAB data. (If, for any reason this fails to occur, extract events using menu item File > Import event info > From data channel as explained elsewhere in this tutorial.)

Note that current Native Netstation files cannot be imported in EEGLAB/Matlab. Only "Netstation binary simple" files can be imported in EEGLAB (current Netstation files can easily be converted to Netstation binary simple from the Netstation software itself). EDF files can also be exported from Netstation and imported in EEGLAB, but the events are not stored in the last channel by Netstation. Converting data files to "Netstation binary simple" is the simpliest way to get EGI files under EEGLAB/Matlab.

When a subject is made of multiple segments (xxx001.raw; xxx002.raw; xxx003.raw etc...), select File > Import data > From multiple seg. Netstation files. A window will pop up to ask for the file name. Then select menu item Plot > EEG data (scroll) to inspect the imported data.

Finally, it is also possible to import Matlab files exported by Netstation using menu item (File > Import data > From Netstation epoch Matlab files) - the function can only import data exported using the "individual fields" option which is the default. These files contain data epochs but are missing a lot of information. It is therefore recommended to use the file "Netstation binary simple" format.

Importing Neuroscan .CNT continuous files

Note: In our experience, importing Neuroscan files is not an easy matter and no universal read function may exist. It seems that the EEGLAB function works properly in most cases, even for recent (2002) data files. For more about how to read Neuroscan files under Matlab, see a helper page(obsolete). A stand-alone Matlab function for reading this format is also available on the function index page as loadcnt.m. You may import the EEG test file TEST.CNT and use it to test the following tutorial steps.


Start by selecting the menu item File > Import data > From .CNT data file, which calls the pop_loadcnt.m function. The following window will appear:


Pop loadcnt2.gif

Select the file to input (after changing the filter to the correct directory if necessary), and press OPEN. The following window will pop up:


Pop loadcnt.gif


The first input field concerns the structure of the .CNT file. If the imported data don't look like continuous EEG, try changing this number. Most often it should be 1 or 40, but other values may work. Now press OK. A window asking for a new set name will pop up, press OK to save the new data set.


II15pop newset.jpg

Next, use menu item Plot > Channel data (scroll) to inspect the input data and menu item Edit > Event values to inspect the input event field latencies. EEGLAB (from version 4.31) automatically reads channel labels. If you call the menu Edit > Channel locations, EEGLAB will automatically find the location of most channels (based on channel labels).

We will now illustrate how to import additional epoch event information contained in an accompanying Neuroscan .DAT file into the EEGLAB dataset. Before importing the .DAT file, you must first epoch the loaded data (i.e., you must separate it into data epochs). To epoch the data, select Tools > Extract epochs


Pop epochcnt.gif


Simply press OK to epoch the data based on the events contained in the .CNT file (here using a time window extending from -1 s before to 2 s after events). The following window will appear:


II15pop newset2.jpg

Use this window to enter description and save the new dataset. For computers with limited memory (RAM), try overwriting the parent dataset (here, the continuous dataset we have just imported) by checking the Overwrite parent box in this window. One may also save the dataset to disk. Press OK when done. The following baseline removal window will pop up:


II15pop rmbase.jpg

Simply press OK and continue.

Importing Neuroscan .EEG data epoch files

Select File > Import data > From .EEG data file, calling function pop_loadeeg.m. A first window will pop up to ask for the file name and a second window (below) will query for data format (16 or 32 bits) and for data range. See the pop_loadeeg.m function for more details (a 16-bit sample file is available here for testing). Data epochs have now been extracted from the EEG data. See also the section below about importing DAT file containing epoch information.


Pop loadeeg.gif


Then select menu item Plot > EEG data (scroll) to inspect the imported data. In this case, epoch events have also been imported from the file and can be visualized using menu item Edit > Event values.

Importing Snapmaster .SMA files

Select menu item File > Import data > From Snapmaster .SMA file (calling function pop_snapread.m). A window will pop up to ask for a file name. The following window will pop up to ask for relative gain, leave it on 400 and press Ok.


II16pop snapread.jpg


A window will pop up to ask for a file name. Then select menu item Plot > Channel data (scroll) to inspect the data and item Edit > Event values to inspect event latencies and types. A sample .SMA data file is available -- TEST.SMA (use save link as in your browser).

Importing ERPSS .RAW or .RDF data files

To read ERPSS files (Event-Related Potential Software System, JS Hansen, Event-Related Potential Laboratory, University of California San Diego, La Jolla, CA, 1993), select menu item File > Import data > From ERPSS .RAW or .RDF file (calling function pop_read_erpss.m). A window will pop up to ask for a file name. Then select menu item Plot > Channel data (scroll) to inspect the data and item Edit > Event values to inspect event latencies and types. A sample .RDF data file is available -- TEST.RDF (use Save link as in your browser). A header file for the ERPSS format is also available here.>

Importing Brain Vision Analyser Matlab files

To read Brain Vision Analyser (BVA) Matlab files, first export Matlab files from the BVA software. Then use menu item File > Import data > From Brain Vis. Anal. Matlab file (calling function pop_loadbva.m). A window will pop up asking for a file name. After reading the data file, select menu item Plot > Channel data (scroll) to inspect the data and item Edit > Event values to inspect event latencies and types. Channel locations will also be imported and can be visualized using menu item Plot > Channel locations > By name. A sample BVA Matlab data file is available -- TESTBVA.MAT (use Save link as in your browser). Note that you need a macro (and Matlab installed) to be able to export Matlab files from Brain Vision Analyser.

Importing sets of data averages into EEGLAB

EEGLAB was made to process and visualize single-trial data. Event-related potential (ERP) averages can also be processed and visualized, but they should not be imported directly. Note that in our current practice, we perform averaging over trials after applying ICA and not before (see Makeig et al. Science, 2002).

However, an increasing number of ERP researchers find it of interest to apply ICA to related sets of ERP grand averages (see Makeig et al, J. Neuroscience, 1999 and Makeig et al., Royal Society, 1999). To import data 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. For Neuroscan user, we have also programmed the function loadavg.m which can read most binary .AVG Neuroscan files.

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 necessary for this example)

>> avgcond1 = avgcond1';

Then concatenate the arrays

>> allcond = [ avgcond1 avgcond2 avgcond3 ];

Finaly, you will need to import concatenated data averages into EEGLAB. First start EEGLAB:

>> eeglab


Select menu item File > Importing data > From ascii/float file or Matlab array


Importing data averages


Enter the information as indicated above. The following window pops up and allows you to add comments and/or save the new dataset immediately. Press OK to create a new dataset.


Pop newset.jpg


Select Plot > Channel ERPs> in rect. array and set the last option, 'Plot single trials', to YES to visualize the three condition ERPs.


II43pop plotdata.jpg


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). See the Single subject data analysis tutorial for more information.

Importing data in other data formats

The Biosig toolbox (biosig.sf.net) contains links to functions to read other EEG data formats in Matlab. You may download the Biosig plugin for EEGLAB (see the EEGLAB plugin page).

For other non-suported data format, the home page of Alois Schlolg contains links to other Matlab reading functions. We are also willing to add other data importing functions to EEGLAB, so please send us a sample raw data file together with a Matlab function to read it and a README file describing the origin of the data and its format. We will attempt to include such functions in future releases of EEGLAB. Contributing authors will retain all rights to the functions they submit, and the authors' name(s) will be displayed in the function header. See our page on how to contribute to EEGLAB.

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 from the bottom of the main EEGLAB web page.


Arrow.small.left.gif IV. Appendix
Tutorial Outline
A02: Importing Event Epoch Info Arrow.small.right.gif