Jump to content

MARIO Technical Documentation: Difference between revisions

From BCI2000 Wiki
Atennissen (talk | contribs)
No edit summary
Mellinger (talk | contribs)
No edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==MARIO architecture==
==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.
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.
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.
This set of interfaces allows a wide range of possibilities for a wide range of different analyses.


Line 27: Line 27:
==Data Import Module==
==Data Import Module==


Any script must have a first module to load data that theuser wants to analyze.
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:
There are 3 main types of files containing different groups of information:


Line 37: Line 37:
These data are saved in different files, one for each run, containing 29 trials.
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.
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).
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 can be
The montage file stores information about the electrode position on the scalp. It consists
drawn up writing in different sections divided by labels:
of different sections divided by labels:


#a synthetic name
#a synthetic name
Line 48: Line 48:
#the 3-dimensional spatial coordinates of all the electrodes (this section is optional)
#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.
These labelled sections  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.
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.
This module is clearly the same for Mu and P300 Analysis.
Line 56: Line 56:
==Data Conditioning Module==
==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.
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:
For a Mu analysis, the user can select from four different spatial filter algorithms:
Line 65: Line 65:
*LARGE 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 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 user to compile/modify a list of valid channels on which any analysis will be conduced.
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.
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.
Line 75: Line 75:
Feature extraction is one of the most important stages of elaboration; it affects any further analysis.
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.
In a Mu rhythm analysis, any feature can be obtained by 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 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 subject didn’t have any feedback) till the end of trial.
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).
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 R<sup>2</sup> values between the corresponding features of the two classes
Either of these choices will produce different R<sup>2</sup> 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.
For a P300 Analysis only two classes are compared and automatically set as frequent events and rare events.


==Spectral Extimation Module ''(just for Mu rhythm analysis)''==
==Spectral Extimation Module ''(for Mu rhythm analysis)''==


During this step, the program evaluates the spectrum of recorded data; any further analysis will be done on it.
During this step, the program evaluates and analyzes the spectrum of recorded data.  
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.
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.
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.
Line 92: Line 92:
The algorithm employed to estimate the signal spectrum is the MEM (the same used on-line by BCI2000).
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:
Apart from the percentage of overlap, MARIO allows the user to modify the values of:


#Sampling frequency of recorded data;
#Sampling frequency of recorded data
#Spatial resolution (delta);
#Spatial resolution (delta)
#Detrending order (Mean or Linear);
#Detrending order (Mean or Linear)
#AR model order;
#AR model order
#Low pass filter frequency;
#Low pass filter frequency
#High pass filter frequency;
#High pass filter frequency
#Filter bandwidth;
#Filter bandwidth
#Epoch length;
#Epoch length
#Overlap percentage.
#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.
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.
 
Since that, every further analysis on BCI2000 data can be done.


==Statistical Analysis Module==
==Statistical Analysis Module==


At least, a statistical analysis (at present the R<sup>2</sup>)  is employed to distinguish between the class of a BCI2000 task in any trial.
A statistical analysis (presently, R<sup>2</sup>)  is employed to distinguish between the classes of a BCI2000 task in any trial.


MARIO uses a module that computes the R<sup>2</sup> 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.
MARIO uses a module that computes the R<sup>2</sup> 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 (in a range between -1 and 1) produced is the R<sup>2</sup> value multiplied by R<sup>2</sup> sign. If the R<sup>2</sup> 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.
At the end of this analysis, the real index produced (in a range between -1 and 1) is the R<sup>2</sup> value multiplied by R<sup>2</sup> sign. If the R<sup>2</sup> 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==
==Visualization Module==


Mario offers a wide set of visualization graphs that can be combined to have a complete visualization of produced data.
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:
For a Mu rhythm analysis the user can request to visualize:


#a trajectory plot shows the cursor position for any sample in a  trial BCI2000 as user saw it on-line;
#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) shows as a colour tint the R<sup>2</sup> value of any feature. A colorbar shows the colour range between -1 and 1;
#a matrix (channel × bin) where the R<sup>2</sup> value of any feature is shown in a color tint. A colorbar shows the color range between -1 and 1
#Another panel shows a detail of the previous matrix. The upper topographic plot shows the R<sup>2</sup> value for any channel in the selected bin of frequencies; the lower one is the spectrum of the selected channel for all the frequencies.
#Another panel showing a detail of the previous matrix. The upper topographic plot shows the R<sup>2</sup> 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:
For a P300 analysis the user can choose from:


#A R<sup>2</sup> matrix
#An R<sup>2</sup> matrix
#An amplitude waveform graph
#An amplitude waveform graph
#A topographic plot
#A topographic plot
Line 133: Line 131:
#A string prediction form.
#A string prediction form.


All these result visualizations can be easily included in any of user scripts for custom analysis.
All these result visualizations can be easily included in any of the user scripts for custom analysis.
<!--
[[Category:MARIO]]
[[Category:Matlab]]
[[Category:Data Analysis Tools]]
-->

Latest revision as of 15:43, 14 May 2011

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.


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 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:

  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)

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:

  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 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:

  1. a trajectory plot showing the cursor position for any sample in a trial BCI2000 as the user saw it on-line
  2. 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
  3. 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:

  1. An 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 the user scripts for custom analysis.