User Reference:LinearClassifier: Difference between revisions
| (15 intermediate revisions by the same user not shown) | |||
| Line 4: | Line 4: | ||
has a single index (C channels x 1 element), thus the linear classifier | has a single index (C channels x 1 element), thus the linear classifier | ||
acts as a N x M x C matrix, determining the output after summation over | acts as a N x M x C matrix, determining the output after summation over | ||
channels and elements: | |||
<math>\textrm{output}_k=\sum_{i=1}^N \sum_{j=1}^M \textrm{input}_{ij} \textrm{Classifier}_{ijk}</math> | <math>\textrm{output}_k=\sum_{i=1}^N \sum_{j=1}^M \textrm{input}_{ij}\, \textrm{Classifier}_{ijk}</math> | ||
*In a BCI based on demodulation of a periodic EEG component (such as the [[ | *In a BCI based on demodulation of a periodic EEG component (such as the [[User Tutorial:Introduction to the Mu Rhythm#BCI Construction|Mu Rhythm BCI]]), the LinearClassifier's input is the time-varying amplitude or power spectrum for a number of spatially filtered EEG channels. Its output is later [[User Reference:Normalizer|normalized with respect to mean and variance]], and then used as a [[BCI2000 Glossary#Control Signal|control signal]] to determine cursor movement. | ||
input is the time-varying amplitude or power spectrum for a number of spatially filtered EEG channels. Its output is [[User Reference:Normalizer|normalized with respect to mean and variance]], and then used as a [[Glossary#Control Signal|control signal]] to determine cursor movement. | *In an ERP-based BCI (such as the [[User Tutorial:Introduction to the P300 Response#BCI Construction|P300 BCI]]), the LinearClassifier's input is a sequence of averaged EEG time courses obtained in response to a number of stimuli, and its output is considered to represent a log-likelihood ratio for each of these responses to be an ERP. | ||
*In an ERP-based BCI (such as the [[P300 BCI]]), the LinearClassifier's input is a sequence of averaged EEG time courses obtained in response to a number of stimuli, and its output is considered to represent | |||
==Parameters== | ==Parameters== | ||
| Line 29: | Line 28: | ||
==Examples== | ==Examples== | ||
=== | ===Mu Rhythm Examples=== | ||
For these examples, let us assume that you set the [[User Reference:ARFilter|ARFilter]]'s ''FirstBinCenter'' to 0, and ''BinWidth'' to 3Hz. This allows you to refer to the respective bins by their frequency, i.e. ''12Hz'' rather than ''5''. | For these examples, let us assume that you set the [[User Reference:ARFilter|ARFilter]]'s ''FirstBinCenter'' to 0, and ''BinWidth'' to 3Hz. This allows you to refer to the respective bins by their frequency, i.e. ''12Hz'' rather than ''5''. | ||
We also assume that, in the [[User Reference:SpatialFilter|SpatialFilter]], you have entered labels for output channels. This allows you to refer to channels by their names, i.e. ''CP3'' rather than ''7''. | We also assume that, in the [[User Reference:SpatialFilter|SpatialFilter]], you have entered labels for output channels. This allows you to refer to channels by their names, i.e. ''CP3'' rather than ''7''. | ||
| Line 52: | Line 51: | ||
| CP4 || 12Hz || 1 || 0.5 | | CP4 || 12Hz || 1 || 0.5 | ||
|- | |- | ||
| CP3 || 24Hz || 2 || | | CP3 || 24Hz || 2 || -0.5 | ||
|- | |- | ||
| CP4 || 24Hz || 2 || | | CP4 || 24Hz || 2 || 0.5 | ||
|} | |} | ||
Note that, in the above example, subtracting CP3 from CP4 in the classifier is not equivalent to taking the difference in the [[User Reference:SpatialFilter| | Note that, in the above example, subtracting CP3 from CP4 in the classifier is not equivalent to taking the difference in the [[User Reference:SpatialFilter|SpatialFilter]]. This is because, for a Mu Rhythm BCI, spatial filtering is followed with computing spectral amplitudes, and feature combination amounts to an addition of spectral amplitudes. Computing spectral amplitudes involves taking the absolute value (or its square), which is a nonlinear operation, with <math>|A-B| \neq |A|-|B|</math> in general. | ||
<math>|A-B| \neq |A|-|B|</math> | |||
===ERP classification=== | ===ERP classification=== | ||
Often, you will use a computer program to optimize the classifier for use with ERPs. However, for the sake of an instructive example, let us assume that you want to classify based on the temporal mean between 280 and 300ms, and the spatial mean from electrodes Cz and Pz, that your sampling rate is 250Hz. | |||
Then, there will be 6 samples in that range, starting with sample number 70: | Then, there will be 6 samples in that range, starting with sample number 70: | ||
{| border="1" style="text-align:center" | {| border="1" style="text-align:center" | ||
| Line 111: | Line 109: | ||
==See also== | ==See also== | ||
[[User Reference:Normalizer]] | [[User Reference:Normalizer]] | ||
[[Category:Filters]][[Category:Signal Processing]] | |||
Latest revision as of 13:06, 18 July 2012
Function
The LinearClassifier computes a projection of a high-dimensional signal feature space onto a low-dimensional classification space. Thus, each dimension of classification space is a linear combination of signal features. Input data has 2 indices (N channels x M elements), and output data has a single index (C channels x 1 element), thus the linear classifier acts as a N x M x C matrix, determining the output after summation over channels and elements:
- In a BCI based on demodulation of a periodic EEG component (such as the Mu Rhythm BCI), the LinearClassifier's input is the time-varying amplitude or power spectrum for a number of spatially filtered EEG channels. Its output is later normalized with respect to mean and variance, and then used as a control signal to determine cursor movement.
- In an ERP-based BCI (such as the P300 BCI), the LinearClassifier's input is a sequence of averaged EEG time courses obtained in response to a number of stimuli, and its output is considered to represent a log-likelihood ratio for each of these responses to be an ERP.
Parameters
Classifier
The Classifier parameter is a sparse matrix definition in which each row corresponds to a single matrix entry. Columns correspond to
- input channel,
- input element (bin in the spectral case, time offset in the ERP case),
- output channel,
- weight (value of the matrix entry).
Input channels may be specified by ordinal number, or by textual label if available (e.g., CP4). Input elements may be given as ordinal number, or using appropriate units (e.g., 10Hz, or 120ms).
States
None.
Examples
Mu Rhythm Examples
For these examples, let us assume that you set the ARFilter's FirstBinCenter to 0, and BinWidth to 3Hz. This allows you to refer to the respective bins by their frequency, i.e. 12Hz rather than 5. We also assume that, in the SpatialFilter, you have entered labels for output channels. This allows you to refer to channels by their names, i.e. CP3 rather than 7.
1D cursor movement
You want to give feedback from electrode CP4, using the amplitude between 10.5Hz and 13.5Hz for cursor feedback. Then, the Classifier parameter will have a single row, containing
| input channel | input element | output channel | weight |
|---|---|---|---|
| CP4 | 12Hz | 1 | 1 |
2D cursor movement
You want to use mean activity from the left and right hand areas at 12Hz to control movement in horizontal direction. Additionally, you want the difference between left and right hand areas at 24Hz to control movement in vertical direction. In the CursorTask application, the horizontal direction (X) corresponds to channel 1, and the vertical direction corresponds to channel 2. Accordingly, your Classifier parameter will have the following 4 rows:
| input channel | input element | output channel | weight |
|---|---|---|---|
| CP3 | 12Hz | 1 | 0.5 |
| CP4 | 12Hz | 1 | 0.5 |
| CP3 | 24Hz | 2 | -0.5 |
| CP4 | 24Hz | 2 | 0.5 |
Note that, in the above example, subtracting CP3 from CP4 in the classifier is not equivalent to taking the difference in the SpatialFilter. This is because, for a Mu Rhythm BCI, spatial filtering is followed with computing spectral amplitudes, and feature combination amounts to an addition of spectral amplitudes. Computing spectral amplitudes involves taking the absolute value (or its square), which is a nonlinear operation, with in general.
ERP classification
Often, you will use a computer program to optimize the classifier for use with ERPs. However, for the sake of an instructive example, let us assume that you want to classify based on the temporal mean between 280 and 300ms, and the spatial mean from electrodes Cz and Pz, that your sampling rate is 250Hz. Then, there will be 6 samples in that range, starting with sample number 70:
| input channel | input element | output channel | weight |
|---|---|---|---|
| Cz | 70 | 1 | 1 |
| Cz | 71 | 1 | 1 |
| Cz | 72 | 1 | 1 |
| Cz | 73 | 1 | 1 |
| Cz | 74 | 1 | 1 |
| Cz | 75 | 1 | 1 |
| Pz | 70 | 1 | 1 |
| Pz | 71 | 1 | 1 |
| Pz | 72 | 1 | 1 |
| Pz | 73 | 1 | 1 |
| Pz | 74 | 1 | 1 |
| Pz | 75 | 1 | 1 |
Note that, unlike in the case of spectral features, there is no difference between spatially combining channels in the LinearClassifier or in the SpatialFilter. Thus, you might as well combine Cz and Pz into a channel labeled "Cz+Pz" in the SpatialFilter, and then use this classifier configuration:
| input channel | input element | output channel | weight |
|---|---|---|---|
| Cz+Pz | 70 | 1 | 1 |
| Cz+Pz | 71 | 1 | 1 |
| Cz+Pz | 72 | 1 | 1 |
| Cz+Pz | 73 | 1 | 1 |
| Cz+Pz | 74 | 1 | 1 |
| Cz+Pz | 75 | 1 | 1 |