MARIO Technical Documentation
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 three 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, 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.

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 in which to load data that the user 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 data to be loaded from a Matlab file (.mat).
The montage file stores information about the electrode position on the scalp. It consists of different sections divided by labels:
- a synthetic name
- the channel labels
- a valid channels list
- the laplacian grid
- the 3-dimensional spatial coordinates of all the electrodes (this section is optional)
These labelled sections can be written in the Montage file without a predefined order.
The user can import data from an additional data file, (a parameters file), that can be used if he wants to replace one or more parameters from the BCI2000 ones. For this, it is enough to copy and paste the selected header string in a new prm file, and change 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 so as to include a custom filter in the user data analysis. The operator can identify which channels or set of channels will 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. A user defined analysis will be available on further versions of MARIO.
The Data Conditioning module also allows the the user to compile/modify a list of valid channels on which to conduct any analysis.
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 by arranging some of the 12 BCI2000 states. The user can now make a choice between two predefined analyses, 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, the subject does not have any feedback) until 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). Either of these choices will produce different R2 values between the corresponding features of the two classes
For a P300 Analysis only two classes are compared and automatically set as frequent events and rare events.
Spectral Extimation Module (for Mu rhythm analysis)
During this step, the program evaluates and analyzes the spectrum of recorded data. To do that, the EEG signal is divided into equal length epochs (These epochs can be distinct or overlapped as a percentage of overlap, which the user can set by using the Graphical User Interface or script.) A spectrum value is evaluated for anyone of these epochs.
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:
- Sampling frequency of recorded data
- Spatial resolution (delta)
- Detrending order (Mean or Linear)
- AR model order
- Low pass filter frequency
- High pass filter frequency
- Filter bandwidth
- Epoch length
- Overlap percentage
MARIO v2.0 also computes a virtual states matrix strictly joined with signal one and derived as an arrangement of the BCI2000 states. These states label spectrum samples as valid or not valid and as belonging to one class or another.
Statistical Analysis Module
A statistical analysis (presently, R2) is employed to distinguish between the classes of a BCI2000 task in any trial.
MARIO uses a module that computes the R2 value between two classes; these can be TargetUP and TargetDOWN for a Mu rhythm analysis, or frequent events 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 produced (in a range between -1 and 1) is the R2 value multiplied by R2 sign. If the R2 value is near 1, there is an high separability between classes and high performance. If, instead, its value is near 0, it is difficult to distinguish one class from another, and it means low performance.
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 the user can request to visualize:
- a trajectory plot showing the cursor position for any sample in a trial BCI2000 as the user saw it on-line
- a matrix (channel × bin) where the R2 value of any feature is shown in a color tint. A colorbar shows the color range between -1 and 1
- Another panel showing 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 the user can choose from:
- An R2 matrix
- An amplitude waveform graph
- A topographic plot
- An ERP response graph
- A string prediction form.
All these result visualizations can be easily included in any of the user scripts for custom analysis.
