Difference between revisions of "User Tutorial:Analyzing the Initial Mu Rhythm Session"

From BCI2000 Wiki
Jump to: navigation, search
(Generating a Feature Plot)
 
(15 intermediate revisions by 5 users not shown)
Line 2: Line 2:
  
 
==Generating a Feature Plot==
 
==Generating a Feature Plot==
The first step in these analyses is to separate data into amplitudes at individual '''frequencies''' and '''locations.''' These amplitudes are called ''features,'' and their correspondence with the subject's imagination will be plotted as a so-called ''feature map.'' From a feature map, it is possible to determine those frequencies and locations whose amplitude is maximally correlated with the subject's task, i.e., those features that are most different between two conditions. These features will subsequently be used to provide feedback in a BCI experiment.
+
The first step in these analyses is to separate data into amplitudes at individual '''frequencies''' and '''locations.''' These amplitudes are called ''features,'' and their correspondence with the subject's movements will be plotted as a so-called ''feature map.'' From a feature map, it is possible to determine those frequencies and locations whose amplitude is maximally correlated with the subject's task, i.e., those features that are most different between two conditions. These features will subsequently be used to provide feedback in a BCI experiment.
 +
 
 +
[[Image:OfflineANA.PNG|right|700px]]
  
 
To generate a feature plot from the initial session's data, perform the following steps:
 
To generate a feature plot from the initial session's data, perform the following steps:
 
*Start the [[User Reference:BCI2000 Offline Analysis|BCI2000 Offline Analysis]] tool:
 
*Start the [[User Reference:BCI2000 Offline Analysis|BCI2000 Offline Analysis]] tool:
 
**If you have a version of Matlab installed, run <tt>tools/OfflineAnalysis/OfflineAnalysis.bat</tt>.
 
**If you have a version of Matlab installed, run <tt>tools/OfflineAnalysis/OfflineAnalysis.bat</tt>.
**Otherwise, follow the instructions provided [[User_Reference:BCI2000_Offline_Analysis#Systems_that_do_not_have_MATLAB_installed_or_with_versions_that_predate_MATLAB_v7.0|here]].
+
**Otherwise, follow the instructions provided [[User_Reference:BCI2000_Offline_Analysis#Systems_that_do_not_have_MATLAB_installed_or_with_versions_that_predate_MATLAB_v7.0|elsewhere]].
 
*In the '''Analysis Domain''' field, choose ''Frequency''.
 
*In the '''Analysis Domain''' field, choose ''Frequency''.
 
*In the '''Acquisition Type''' field, choose "EEG".
 
*In the '''Acquisition Type''' field, choose "EEG".
 
*As a '''Spatial Filter''', choose "Common Average Reference (CAR)".
 
*As a '''Spatial Filter''', choose "Common Average Reference (CAR)".
*Enter <tt>states.StimulusBegin == 1</tt> into the '''Trial Change Condition''' field.
+
*Enter <tt>auto</tt> into the '''Trial Change Condition''' field.
 
*Into the field labeled '''Target Condition 1''', enter <tt>states.StimulusCode == 0</tt>.
 
*Into the field labeled '''Target Condition 1''', enter <tt>states.StimulusCode == 0</tt>.
 
*Enter the word "Rest" into the field labeled '''Target Condition Label 1'''.
 
*Enter the word "Rest" into the field labeled '''Target Condition Label 1'''.
*Similarly, enter <tt>states.StimulusCode == 2</tt> into the '''Target Condition 1''' field, and "Right Hand" into '''Target Condition Label 2'''.
+
*Similarly, enter <tt>states.StimulusCode == 2</tt> into the '''Target Condition 2''' field, and "Right Hand" into '''Target Condition Label 2'''.
*Click the "Add" button located besides the '''Data Files''' field. A file chooser dialog will appear; navigate to <tt>data/<Subject>001</tt>, and select all <tt>.dat</tt> files available there (use your keyboard's ''ctrl'' button to click-select multiple files), then click the dialog's "Open" button.
+
*Click the "Add" button located besides the '''Data Files''' field. A file chooser dialog will appear; navigate to <tt>data/mu/<Subject>001</tt>, and select all <tt>.dat</tt> files available there (use your keyboard's ''ctrl'' button to click-select multiple files), then click the dialog's "Open" button.
 
*Click "Generate Plots", and wait for the feature plot to appear.
 
*Click "Generate Plots", and wait for the feature plot to appear.
  
Once the computation is complete, you will see a feature plot similar to the one below. In that plot, the horizontal axis corresponds to frequencies, and the vertical axis corresponds to individual channels. Color codes represent [[Glossary#r-squared|r-squared]] values; these are numbers between 0 and 1, providing a measure for the amount to which signal amplitude is determined by the subject's imagination.
+
Once the computation is complete, you will see a feature plot similar to the one below. In that plot, the horizontal axis corresponds to frequencies, and the vertical axis corresponds to individual channels. Color codes represent [[Glossary#r-squared|r-squared]] values, which are numbers between 0 and 1. R-squared values provide a measure for the amount to which a particular EEG feature (i.e., amplitude at a particular frequency and location) is influenced by the subject's task (e.g., hand vs. foot movements).
  
 
[[Image:eeg1FeaturePlt.png|600px]]
 
[[Image:eeg1FeaturePlt.png|600px]]
  
Typically, there will be clusters of large r-squared values in the feature plot. In principle, picking the largest r-squared value from the map, and using its frequency and channel to configure the online system, would be sufficient. Still, it is important to check whether the signal in question is consistent with the [[User_Tutorial:Introduction_to_the_Mu_Rhythm#Physical_Properties|mu rhythm's known properties]]. This way, it is possible to avoid misconfiguration due to [[User_Tutorial:EEG_Measurement_Setup#EEG_Artifacts|EEG artifacts]], other noise, or random effects.
+
Typically, there will be clusters of large r-squared values in the feature plot. The initial step to configure the online system is to determine which brain signal feature differed the most between two particular tasks.  This is accomplished by picking the largest r-squared value from the map and by noting its corresponding frequency and location. However, it is important to verify whether the feature in question is consistent with the [[User_Tutorial:Introduction_to_the_Mu_Rhythm#Physical_Properties|mu rhythm's known properties]]. This verification is necessary to avoid misconfiguration due to [[User_Tutorial:EEG_Measurement_Setup#EEG_Artifacts|EEG artifacts]], other noise, or random effects.
  
 
==Generating Spectra and Topography Plots==
 
==Generating Spectra and Topography Plots==
 
*Pick the four largest r-squared values from the feature map between 9 and 36Hz, and read off their frequencies and channels. The plot's "Data Cursor" tool (''Data Cursor'' from the ''Tools'' menu) may be helpful for this.
 
*Pick the four largest r-squared values from the feature map between 9 and 36Hz, and read off their frequencies and channels. The plot's "Data Cursor" tool (''Data Cursor'' from the ''Tools'' menu) may be helpful for this.
*In the analysis program's '''Spectra Channels''' field, enter the channel numbers you read off the feature map.
+
*In the analysis program's '''Spectra Channels''' field, enter the channels you read off the feature map.
*Click the '''Generate Spectra''' button. ''(Available in future versions of the Offline Analysis tool.)''
 
 
*In the '''Topo Frequencies''' field, enter the frequencies you read off the feature map.
 
*In the '''Topo Frequencies''' field, enter the frequencies you read off the feature map.
*Click the '''Generate Topos''' button. ''(Available in future versions of the Offline Analysis tool. In the current version, click "Generate Plots".)''
+
*Click the '''Generate Plots''' button.
  
 
[[Image:MuRhythmModulation.PNG|600px]]
 
[[Image:MuRhythmModulation.PNG|600px]]
  
The generated '''topography plots''' display the spatial distribution of r-squared values. For right-hand movement imagination, there should be a clear maximum of r-squared values over the ''left'' motor cortex, as displayed in subfigure (A) and (B) above.  
+
The generated '''topography plots''' display the spatial distribution of r-squared values. In this comparison of EEG activity for right-hand movements and rest, there should be a clear maximum of r-squared values over the ''left'' motor cortex as shown in subfigure (A) and (B) above.  
 
The generated '''spectra plots''' display amplitude distributions, and r-squared measure, over frequencies. Ideally, they should appear similar to the  (C) and (D) subfigures above.
 
The generated '''spectra plots''' display amplitude distributions, and r-squared measure, over frequencies. Ideally, they should appear similar to the  (C) and (D) subfigures above.
  
 
==Analyzing Remaining Conditions==
 
==Analyzing Remaining Conditions==
Up to now, you performed an analysis of how imagined movement of the '''Right Hand''' is correlated with brain activity. In order to choose the most useful channel and frequency for online feedback, perform similar analyses for the remaining conditions:
+
Up to now, you performed an analysis of how brain activity is related to imagined movements of the '''Right Hand.''' In order to choose the most useful channel and frequency for online feedback, perform similar analyses for the remaining conditions:
 
*In the analysis program's '''Target Condition 2''' field, enter <tt>states.StimulusCode == 1</tt>, and ''Left Hand'' into '''Target Condition Label 2'''.
 
*In the analysis program's '''Target Condition 2''' field, enter <tt>states.StimulusCode == 1</tt>, and ''Left Hand'' into '''Target Condition Label 2'''.
 
*Make sure the '''Overwrite existing plots''' check box is unchecked.
 
*Make sure the '''Overwrite existing plots''' check box is unchecked.
 
*Click ''Generate Plots'' to create a feature plot for imagined movement of the left hand.
 
*Click ''Generate Plots'' to create a feature plot for imagined movement of the left hand.
 
*As previously, pick the four largest r-squared values, and compute spectra and topographies for their channels and frequencies.
 
*As previously, pick the four largest r-squared values, and compute spectra and topographies for their channels and frequencies.
*Results should be similar to right hand results, except that modulated activity should originate from the right rather than the left motor cortex.
+
*Results should somewhat resemble that derived for the right hand, except that the colored activity changes should appear over the right and not the left motor cortex.
 
*Repeat the analysis for conditions <tt>states.StimulusCode == 3</tt>: ''Both Hands'', and <tt>states.StimulusCode == 4</tt>: ''Both Feet''.
 
*Repeat the analysis for conditions <tt>states.StimulusCode == 3</tt>: ''Both Hands'', and <tt>states.StimulusCode == 4</tt>: ''Both Feet''.
 
**For the ''both hands'' condition, the result should resemble a combination of ''left hand'' and ''right hand'' results.
 
**For the ''both hands'' condition, the result should resemble a combination of ''left hand'' and ''right hand'' results.
**For ''both feet'', modulated activity should be centered around electrode Cz.
+
**For ''both feet,'' modulated activity should be centered around electrode Cz.
  
 
==Picking Optimal Features==
 
==Picking Optimal Features==
By now, you should have identified a number of maximum r-squared values for each condition, and you should have some impression how plausible corresponding channels and frequencies are.
+
 
*Remove all implausible maxima from your list.
+
Here we are looking for the frequency with the highest r-squared value between 9Hz and 36Hz. Further, acceptable readings are centered on the proper electrode for the predicted stimulus; C3 for readings from the right hand, C4 for the left hand, both C3 and C4 for both hands, and Cz for both feet.
*From the remaining entries, pick the one with the largest r-squared value. Note this entry's frequency and electrode name, and the subject instruction (condition) that is associated with it. These are the parameters that you will use to configure the online system.
+
 
 +
Equipped with the frequency and electrode that provides the reading with the highest r-squared value, we can begin configuring the setup for proper use.
  
 
==Next Step==
 
==Next Step==

Latest revision as of 15:11, 25 July 2019

This tutorial step assumes that you have performed an initial mu rhythm session. In order to identify the parameters (i.e., frequency and location) of a subject's mu rhythm, we will determine how different the EEG signal amplitude is for different types of imaginations that the subject performed during the recording. You will use the BCI2000 Offline Analysis tool for this purpose.

Generating a Feature Plot

The first step in these analyses is to separate data into amplitudes at individual frequencies and locations. These amplitudes are called features, and their correspondence with the subject's movements will be plotted as a so-called feature map. From a feature map, it is possible to determine those frequencies and locations whose amplitude is maximally correlated with the subject's task, i.e., those features that are most different between two conditions. These features will subsequently be used to provide feedback in a BCI experiment.

OfflineANA.PNG

To generate a feature plot from the initial session's data, perform the following steps:

  • Start the BCI2000 Offline Analysis tool:
    • If you have a version of Matlab installed, run tools/OfflineAnalysis/OfflineAnalysis.bat.
    • Otherwise, follow the instructions provided elsewhere.
  • In the Analysis Domain field, choose Frequency.
  • In the Acquisition Type field, choose "EEG".
  • As a Spatial Filter, choose "Common Average Reference (CAR)".
  • Enter auto into the Trial Change Condition field.
  • Into the field labeled Target Condition 1, enter states.StimulusCode == 0.
  • Enter the word "Rest" into the field labeled Target Condition Label 1.
  • Similarly, enter states.StimulusCode == 2 into the Target Condition 2 field, and "Right Hand" into Target Condition Label 2.
  • Click the "Add" button located besides the Data Files field. A file chooser dialog will appear; navigate to data/mu/<Subject>001, and select all .dat files available there (use your keyboard's ctrl button to click-select multiple files), then click the dialog's "Open" button.
  • Click "Generate Plots", and wait for the feature plot to appear.

Once the computation is complete, you will see a feature plot similar to the one below. In that plot, the horizontal axis corresponds to frequencies, and the vertical axis corresponds to individual channels. Color codes represent r-squared values, which are numbers between 0 and 1. R-squared values provide a measure for the amount to which a particular EEG feature (i.e., amplitude at a particular frequency and location) is influenced by the subject's task (e.g., hand vs. foot movements).

Eeg1FeaturePlt.png

Typically, there will be clusters of large r-squared values in the feature plot. The initial step to configure the online system is to determine which brain signal feature differed the most between two particular tasks. This is accomplished by picking the largest r-squared value from the map and by noting its corresponding frequency and location. However, it is important to verify whether the feature in question is consistent with the mu rhythm's known properties. This verification is necessary to avoid misconfiguration due to EEG artifacts, other noise, or random effects.

Generating Spectra and Topography Plots

  • Pick the four largest r-squared values from the feature map between 9 and 36Hz, and read off their frequencies and channels. The plot's "Data Cursor" tool (Data Cursor from the Tools menu) may be helpful for this.
  • In the analysis program's Spectra Channels field, enter the channels you read off the feature map.
  • In the Topo Frequencies field, enter the frequencies you read off the feature map.
  • Click the Generate Plots button.

MuRhythmModulation.PNG

The generated topography plots display the spatial distribution of r-squared values. In this comparison of EEG activity for right-hand movements and rest, there should be a clear maximum of r-squared values over the left motor cortex as shown in subfigure (A) and (B) above. The generated spectra plots display amplitude distributions, and r-squared measure, over frequencies. Ideally, they should appear similar to the (C) and (D) subfigures above.

Analyzing Remaining Conditions

Up to now, you performed an analysis of how brain activity is related to imagined movements of the Right Hand. In order to choose the most useful channel and frequency for online feedback, perform similar analyses for the remaining conditions:

  • In the analysis program's Target Condition 2 field, enter states.StimulusCode == 1, and Left Hand into Target Condition Label 2.
  • Make sure the Overwrite existing plots check box is unchecked.
  • Click Generate Plots to create a feature plot for imagined movement of the left hand.
  • As previously, pick the four largest r-squared values, and compute spectra and topographies for their channels and frequencies.
  • Results should somewhat resemble that derived for the right hand, except that the colored activity changes should appear over the right and not the left motor cortex.
  • Repeat the analysis for conditions states.StimulusCode == 3: Both Hands, and states.StimulusCode == 4: Both Feet.
    • For the both hands condition, the result should resemble a combination of left hand and right hand results.
    • For both feet, modulated activity should be centered around electrode Cz.

Picking Optimal Features

Here we are looking for the frequency with the highest r-squared value between 9Hz and 36Hz. Further, acceptable readings are centered on the proper electrode for the predicted stimulus; C3 for readings from the right hand, C4 for the left hand, both C3 and C4 for both hands, and Cz for both feet.

Equipped with the frequency and electrode that provides the reading with the highest r-squared value, we can begin configuring the setup for proper use.

Next Step

Configuring Online Feedback shows you how to configure the BCI system using the parameters obtained in the analysis.

See also

User Tutorial:Mu Rhythm BCI Tutorial