User Reference:ExpressionFilter

From BCI2000 Wiki
Jump to navigation Jump to search

Function

The ExpressionFilter uses Arithmetic Expressions to determine its output. As arithmetic expressions may contain state variables and the filter's input signal, this provides a way to

  • modify data processing according to BCI2000 system state,
  • to introduce state variable information into additional signal channels,
  • to replace processing results with system state information.

Parameters

Expressions

A matrix of strings which represent arithmetic expressions. These expressions determine the filter's output signal.

Output signal dimensions are derived from matrix dimensions:

  • matrix rows correspond to signal channels, and
  • matrix columns correspond to signal elements (samples).

For each signal block, each of the expressions is evaluated, and the result is entered into the corresponding element in the output signal. Expressions may contain references to the filter's input signal, and to state variables (see examples).

When the Expressions parameter is an empty matrix (a matrix with a row count of zero), the ExpressionFilter will copy its input into its output unchanged.

States

Any available state may enter into one of the expressions.

Examples

The following 2-by-2 matrix will replace a 2-by-2 input signal with its square. Additionally, when the ResultCode state variable is nonzero, the output will be zero.

Signal(1,1)^2*(ResultCode==0)   Signal(1,2)^2*(ResultCode==0)
Signal(2,1)^2*(ResultCode==0)   Signal(2,2)^2*(ResultCode==0)

When the JoystickFilter is used to track a joystick position, the JoystickXpos and JoystickYpos state variables represent joystick position. When the ExpressionFilter is present in the signal processing module, placed between LinearClassifier and Normalizer, it may be configured to control the cursor directly by joystick position, using this 2-by-1 matrix:

JoystickXpos
JoystickYpos

In the same configuration, to re-enable cursor movement by the output of signal processing without removing the ExpressionFilter from the signal processing module, either set the Expressions parameter to an empty matrix, or use this matrix:

Signal(1,1)
Signal(2,1)

See also

User Reference:Expression Syntax