This is a collaborative space. In order to contribute, send an email to maximilien.chaumon@icm-institute.org
On any page, type the letter L on your keyboard to add a "Label" to the page, which will make search easier.

Mega read

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:

Error rendering macro 'code': Invalid value specified for parameter 'lang'
>> addpath( genpath( '/usr/cenir/matlab/mega_toolbox/mega_IO' ) )

Usage

    [ header, binary, bec ] = mega_read(filename, varargin )
   ==== Input ====

First argument

  1. filename ( String ) : name of MEEG file,

       Second argument
  1. 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
  ====  Output ====
         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

   [h, b]= mega_read('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_frequency_sensor_datablock_time.lena');
    will return:
  1. Header information in h
  2. A data array in b for binary data

2. sensors selection

   [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:
  1. Header information in h
  2. A data array in b for sensors 'FP1' and 'FP2'
 

3. time selection

   [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:
  1. Header information in h
  2. A data array in b for a time window of [1, 3] in second

 

4. frequencies selection

   [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:
  1. Header information in h
  2. A data array in b for frequencies between 20 and 24

5. trials selection

   [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:
  1. Header information in h
  2. A data array in b for trials between 'trial1' and 'trial2'

6. selection in every dimension

   [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:
  1. Header information in h
  2. A data array in b
               for :
  1. trials :trial1 and trial3
  2. sensors: 'FP1 and 'FP2'
  3. a time window of [1, 3] in second

  4. frequencies between 20 and 24
 

7. read events,badChannels and ClassFile information

    [h, b,e]=mega_read('/lena13/home_users/users/datalinks/VALIDATION/example_data/lena_data/example_header_bin_event.lena','events')
             will return:
  1. Header information in h
  2. A data array in b
  3. events in e extracted from data.event
 

Back