mega_read
mega_read is a Matlab function that reads MEG/EEG data from MEG-EEG files (.lena, .ds .fiff). It returns a header structure, binary data as well as events bad channels and class files information.
It uses C++ libraries (Cmex) compiled for Matlab2009 and further versions of Matlab. Therefore, mega_read is compatible with Matlab2009, not with previous versions of Matlab.
Recent addition (May 2012): you can now read data over selected ranges of channels, frequencies, and time windows. This may allow loading huge files that could not be read at once due to memory limitations.
Before using mega_read, please add '/usr/cenir/matlab/mega_toolbox/mega_IO' to your Matlab Path:
Code Block |
---|
|
>> addpath( genpath( '/usr/cenir/matlab/mega_toolbox/mega_IO' ) )
|
Usage
Code Block |
---|
[ header, binary, bec ] = mega_read(filename, varargin )
|
Code Block |
---|
==== Input ====
|
First argument
- filename ( String ) : name of MEEG file,
Code Block |
---|
Second argument
|
- varargin (list of string) : is used if we don't need to read the whole data in the file. see below how it is used
Code Block |
---|
==== Output ====
|
Code Block |
---|
header ( structure ) : a structure containing the header information that can be manipulated by the user
binary ( double ) : data array of the binary values
bec (structure) : a structure containing events, badChannels and classFile information if specified in varagin
|
Examples
1. read it all
Code Block |
---|
[h, b]= mega_read('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_frequency_sensor_datablock_time.lena');
will return:
|
- Header information in h
- A data array in b for binary data
Code Block |
---|
[h, b]= mega_read('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_frequency_sensor_datablock_time.lena', 'sensor' , 'FP1' ,'FP2' );
will return:
|
- Header information in h
- A data array in b for sensors 'FP1' and 'FP2'
3. time selection
Code Block |
---|
[h, b]= mega_read('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_frequency_sensor_datablock_time.lena','time' , '1' , '3' );
will return:
|
- Header information in h
Wiki Markup |
---|
A data array in b for a time window of \[1, 3] in second |
4. frequencies selection
Code Block |
---|
[h, b]= mega_read('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_frequency_sensor_datablock_time.lena', 'frequency' , '20' ,'24' );
will return:
|
- Header information in h
- A data array in b for frequencies between 20 and 24
5. trials selection
Code Block |
---|
[h, b]= mega_read('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_frequency_sensor_datablock_time.lena','trial' , 'trial1' , 'trial3' );
will return:
|
- Header information in h
- A data array in b for trials between 'trial1' and 'trial2'
6. selection in every dimension
Code Block |
---|
[h, b]= mega_read(('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_frequency_sensor_datablock_time.lena','trial' , 'trial1' , 'trial3' , 'sensor' , 'FP1' ,'FP2' ,'time' , '1' , '3', 'frequency' , '20' ,'24');
will return:
|
- Header information in h
- A data array in b
- trials :trial1 and trial3
- sensors: 'FP1 and 'FP2'
Wiki Markup |
---|
a time window of \[1, 3] in second |
- frequencies between 20 and 24
Code Block |
---|
[h, b,e]=mega_read('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_header_bin_event.lena','events')
will return:
|
- Header information in h
- A data array in b
- events in e extracted from data.event
Back