Jump to content

User Reference:Normalizer

From BCI2000 Wiki
Revision as of 13:50, 11 April 2007 by Mellinger (talk | contribs)

Function

Normalizing Transform

The Normalizer applies a linear transformation to its input signal. For each channel (index denoted with i, an offset value is subtracted, and the result multiplied with a gain value:

outputi=(inputiNormalizerOffseti)×NormalizerGaini

Adaptation

From the past statistics of its input, the Normalizer estimates offset and gain values adaptively to make its output signal

  • zero mean, and
  • unit variance.

The Normalizer uses data buffers to accumulate its past input according to user-defined rules. These rules are called buffer conditions because they are given in terms of boolean expressions. Each data buffer is associated with such a boolean expression. Whenever an expression evaluates to true, the current input will be appended to the associated buffer. Whenever it comes to updating offset and gain values, the Normalizer will use the content of its buffers to estimate data mean and variance. The offset will then be set to the data mean, and the gain to the inverse square root of the data variance, i.e., the inverse of the data standard deviation.

Adaptation Rationale

It may appear crude to use the total data variance for the adaptation -- why not use linear regression on data labels (target codes) to separate into user controlled (task determined) and noise variance? User controlled variance would then correspond to target separation on the feedback screen, which is what we want to normalize in the first place.

However, a closer look reveals that the relative size of user controlled variance, and noise variance is crucial. When that "signal" variance is small compared to noise variance, we would be ill advised to use it in normalization -- this would only lead to enlarged noise, and an erratically moving cursor on the feedback screen. In this case, we rather want to normalize by noise variance, to keep the cursor well-behaved. At the same time, total variance approaches noise variance in this limit because signal variance is small.

On the other end of the spectrum, we have a signal variance that is large compared to noise variance. Here, we clearly want normalization by signal variance. However, the total variance will be dominated by signal variance. Thus, in the limit of high signal-to-noise ratio, total variance again is the entity we want to normalize by.

Thus, no matter whether signal-to-noise ratio is high or low, total data variance is a good choice for normalization.

Typical Use

Typically, the Normalizer's input is the output of a classifier, which it transforms into a zero mean/unit variance control signal which is then transmitted to an application module. Using the zero mean/unit variance property, an application module can then relate entities such as window size, screen update rate, cursor speed, and trial duration.

Parameters

For each channel of the Normalizer's input signal, adaptation is treated independently. Offsets, Gains, and Adaptation kind are represented as list parameters, with each entry in the list corresponding to a signal channel. Buffer configuration is done in matrix form, with columns corresponding to signal channels, and rows corresponding to multiple buffers.

NormalizerOffsets, NormalizerGains

Lists of offset and gain values, with entries corresponding to signal channels. These values will be updated depending on the channel's adaptation configuration in the Adaptation parameter.

Adaptation

A list of values that determines individual channels' adaptation strategy. Possible values are

  • 0 for no adaptation,
  • 1 for adjusting offsets to zero mean,
  • 2 for additionally adjusting gains to unit variance.

BufferConditions

A matrix consisting of boolean expressions. Expressions may involve States and the components of the Normalizer's input signal.

  • Each matrix entry represents a data buffer which is a ring buffer of length BufferLength. Whenever a buffer's expression evaluates to true, the current value of the input signal will be put into the buffer (overwriting past data once the buffer is filled).
  • Buffers in a certain column will buffer data from the corresponding signal channel, and will be used in adaptation of that channel only.
  • Within columns, the order of buffers does not affect computation.
  • Empty expressions do not have any effect on the computation. Thus, it is possible to have a different number of buffers for different channels.
  • A buffer to store data for the first target, and during feedback only, should have an expression such as (Feedback)&&(TargetCode==1).

BufferLength

The maximum length of each data buffer.

  • The length is specified in data blocks if given as a raw number, and in seconds if given as a number followed by the character "s".
  • All data buffers have the same capacity.
  • Once a data buffer is filled, its older entries will be replaced with new data (ring buffer).
  • In previous versions of BCI2000, buffer lengths were specified in terms of "past trials". However, this would enforce the notion of a "trial", and not generalize to continuous adaptation.

UpdateTrigger

A boolean expression that triggers adaptation when changing to true from false. Generally, continuous adaptation within trials is not desired. Rather, one wants adaptation to occur at the end of a trial. This is achieved with UpdateTrigger expressions such as Feedback!=0 or TargetCode!=0.

States

Buffer condition expressions, and the UpdateTrigger expression may involve any State present in the system. Expressions are checked for syntactical correctness and whether states are present during the Preflight Phase.

Examples

Trial-based 1D Feedback Task with 3 Targets

  • Only data from the feedback phase should enter into the adaptation.
  • To make sure that targets contribute equally to the adaptation, we use a single buffer for each target.

    We use a 3-rows-by-1-column BufferConditions matrix:

(Feedback)&&(TargetCode==1)
(Feedback)&&(TargetCode==2)
(Feedback)&&(TargetCode==3)
  • We want to use data from three previous trials of each target.
  • Feedback duration is 2 seconds.

    We set the buffer length to the equivalent of three feedback durations:

 BufferLength= 6s
  • Adaptation should happen at the end of each trial, when feedback is finished.

    We set UpdateTrigger to an expression that changes to true when feedback ends:

 UpdateTrigger= (Feedback==0)

Trial-based 2D Feedback Task with 4 Targets

  • Leaving everything else as in the previous example, we now have two dimensions corresponding to left-right (channel 1) and up-down (channel 2).
Target positions are as indicated below:
 ---------------------------
 |          ##1##          |
 |#                       #|
 |2                       3|
 |#                       #|
 |          ##4##          |
 ---------------------------
We use data from targets 1 and 4 to adjust channel 2, and targets 2 and 3 to adjust channel 1. Accordingly, the BufferConditions matrix is
(Feedback)&&(TargetCode==2) (Feedback)&&(TargetCode==1)
(Feedback)&&(TargetCode==3) (Feedback)&&(TargetCode==4)

Continuous 1D Control without pre-defined Targets

  • We know that, over a period of 10 minutes, all output values will occur with approximately equal frequency, or at least have a symmetric distribution around zero. This matches the combination of BCI2000 and Dasher or other "devices" expecting statistically balanced input.
The BufferConditions matrix will have a single entry containing a constant expression:
1
This way, data will always be buffered.
  • There are no trials. We want a continuous adaptation to the values of the last 10 minutes.
We set the BufferLength parameter to 600s, or (10*60)s.
For continuous adaptation, we enter an empty string (not a constant 0 expression) for UpdateTrigger.

See also: User Reference:Expression Syntax