Jump to content

MARIO Technical Documentation

From BCI2000 Wiki
Revision as of 16:15, 7 May 2007 by Atennissen (talk | contribs)

MARIO architecture

MARIO is an off-line analysis application developed in MATLAB 7.0.2. It is now modular, object-oriented and can be easily integrated with any other software for data analysis and visualization. It can be used in Mu and P300 analyses and allows two kinds of use: users can simply fill the forms of a graphical interface making any choice with a click of its mouse, run a ready-made script or, at least, write up their own scripts according to their needs. This set of interfaces allows a wide range of possibilities for a wide range of different analyses.

Internally, the application is composed of 6 main functional modules, each one connected in cascade as in the list below:

  • Data import
  • Signal Conditioning
  • Feature Extraction
  • Spectral Extimation
  • Statistical Analysis
  • Visualization

All these modules are hidden in the graphical user interface but they can be distinguished in the batch scripts. Each one of them can be easily replaced with an improved version, a custom version or a different analysis.


Graph of modules

Here you can see a simplified version of the functions graph with their relationships (click to enlarge).



Data Import Module

Any script must have a first module to load data that theuser wants to analyze. There are 3 main types of files containing different groups of information:

  • Data files (.dat/.mat)
  • Montage files (.mmf)
  • External Parameter files (.prm) – optional

The data files contain all the data of the BCI session (Mu or P300). These data are saved in different files, one for each run, containing 29 trials. Internally any file is divided in two main parts: the first part (file header) includes all parameters set by the operator during the on-line experimentation; the second part contains the EEG signal recorded by the whole set of electrodes on the EEG cap. A special function allows at least to load data from a Matlab file (.mat).

The montage file stores information about the electrode position on the scalp. It can be drawn up writing in different sections divided by labels:

  1. a synthetic name
  2. the channel labels
  3. a valid channels list
  4. the laplacian grid
  5. the 3-dimensional spatial coordinates of all the electrodes (this section is optional)

This information is divided by labels and can be written in the Montage file without a predefined order.

At least, user can import data from an additional data file, a parameters file, that can be used if he want to replace one or more parameters from the BCI2000 ones. In this chance is enough to copy and paste in a new prm file the header string selected, changing its value.

This module is clearly the same for Mu and P300 Analysis.

Data Conditioning Module

The MARIO v.2.0 Data Conditioning module allows users to select from a wide range of spatial filters such as to include custom filter in user data analysis. So the operator can identify which channels or set of channels can give better results at the end of the statistical analysis.

For a Mu analysis, the user can select from four different spatial filter algorithms:

  • RAW
  • CAR (Common Average Reference)
  • SMALL LAP
  • LARGE LAP

The first one (RAW) does not use a filter and analyzes raw recorded data. Every other selection agrees with the choice to employ any spatial filter. An user defined analysis will be available on further versions of MARIO.

The Data Conditioning module also allows the user to compile/modify a list of valid channels on which any analysis will be conduced.

P300 Analysis can now use only two of the above spatial filters: the RAW filter and the CAR one. Any other selection will report an unhandled error.

Feature Extraction Module

Feature extraction is one of the most important stages of elaboration; it affects any further analysis.

In a Mu rhythm analysis, any feature can be obtained arranging some of the 12 BCI2000 states. User can now make a choice between two predefined analysis, a simple Mu analysis or an Extended version of the same. The first analysis considers any sample recorded between the cursor appearance on the screen and the end of the trial (when the cursor reaches the right side of the screen). The MuExteded analysis instead considers any sample recorded since the target appearance (during the first subset of data subject didn’t have any feedback) till the end of trial. In both choices, the statistical analysis will be conduced between two classes of data: the EEG activity recorded while moving up the cursor (target UP) versus the EEG activity recorded while moving down the cursor (target DOWN). Anyone of these choice will produce different R2 values between the corresponding features of the two classes

For a P300 Analysis the classes compared are only two and automatically set as frequent events and rare events.

Spectral Extimation Module (just for Mu rhythm analysis)

During this step, the program evaluates the spectrum of recorded data; any further analysis will be done on it. To do that, EEG signal is divided into equal length epoch (that can be distinct or overlapped of a percentage of overlap that user can set by Graphical User Interface or script) and a spectrum value is evaluated for anyone of these.

At the end of this process, a 3 dimensional matrix (bin × channel × epoch) joined with the one (channel × sample) compiled during a BCI2000 recording session and read by the data import module will be produced.

The algorithm employed to estimate the signal spectrum is the MEM (the same used on-line by BCI2000).

Apart from the percentage of overlap MARIO allows the user to modify the values of:

  1. Sampling frequency of recorded data;
  2. Spatial resolution (delta);
  3. Detrending order (Mean or Linear);
  4. AR model order;
  5. Low pass filter frequency;
  6. High pass filter frequency;
  7. Filter bandwidth;
  8. Epoch length;
  9. Overlap percentage.

MARIO v2.0 also computes a virtual states matrix strictly joined with signal one and derived as a arrangement of the BCI2000 states. These states label spectrum samples as valid or not and as belonging to one class or another.

Since that, every further analysis on BCI2000 data can be done.

Statistical Analysis Module

At least, a statistical analysis (at present the R2) is employed to distinguish between the class of a BCI2000 task in any trial.

MARIO uses a module that computes the R2 value between two classes that can be TargetUP and TargetDOWN for a Mu rhythm analysis, such as frequent and rare events for a P300 analysis. These data are taken from the spectra matrix (Mu analysis) or from the samples one (P300 analysis) and the regressor vector is yield from BCI2000 states.

At the end of this analysis, the real index (in a range between -1 and 1) produced is the R2 value multiplied by R2 sign. If the R2 value is near 1 it means there is an high separability between classes and high performances. If instead its value is near 0, it’s difficult to distinguish a class from another, and it means low performances.

Visualization Module

Mario offers a wide set of visualization graphs that can be combined to have a complete visualization of produced data. For a Mu rhythm analysis user can request to visualize:

  1. a trajectory plot shows the cursor position for any sample in a trial BCI2000 as user saw it on-line;
  2. a matrix (channel × bin) shows as a colour tint the R2 value of any feature. A colorbar shows the colour range between -1 and 1;
  3. Another panel shows a detail of the previous matrix. The upper topographic plot shows the R2 value for any channel in the selected bin of frequencies; the lower one is the spectrum of the selected channel for all the frequencies.

For a P300 analysis user can choose between:

  1. A R2 matrix
  2. An amplitude waveform graph
  3. A topographic plot
  4. An ERP response graph
  5. A string prediction form.

All these result visualizations can be easily included in any of user scripts for custom analysis.