Linear Matrix classifier doubts

This forum deals with BCI2000 configuration issues.
Post Reply
equicu
Posts: 3
Joined: 20 May 2016, 09:34

Linear Matrix classifier doubts

Post by equicu » 20 May 2016, 10:12

Hi,
I have some doubts regarding the matrix classifier:
For cursor task vertical one dimensional control using left hand imagery vs rest will the matrix be?

input channel input element output channel weight
C4OUT 12Hz 2 1

Naming input channel C4OUT or C4 is the same?
Is output channel=2 for vertical control and 1 for horizontal?
Is weight=1 to move the ball up with left hand imagery and down when relaxing or should the weight=-1?

For using both hands=ball up vs both feet =ball down is the matrix?:

input channel input element output channel weight
C3OUT 12Hz 2 -1
C4OUT 12Hz 2 -1
CzOUT 12Hz 2 1

Or should CzOUT weight be -1 or 0?

Your help would be much appreciated!

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Linear Matrix classifier doubts

Post by pbrunner » 20 May 2016, 10:26

Equicu,

the easiest way for you to understand is to follow the tutorial under the link below and to use the parameters that I have attached below.

Let me know if this works.

https://db.tt/w1G69hm8

Code: Select all

Source:Signal%20Properties:DataIOFilter int SampleBlockSize= 8 32 1 % // number of samples transmitted at a time
Source:Signal%20Properties:DataIOFilter int SamplingRate= 256 256Hz 1 % // sample rate
Source:Signal%20Properties:DataIOFilter floatlist SourceChGain= 8 0.019 0.019 0.019 0.019 0.019 0.019 0.019 0.019 0.003 % % // gain for each channel (A/D units -> muV)
Source:Signal%20Properties:DataIOFilter floatlist SourceChOffset= 8 0 0 0 0 0 0 0 0 0 % % // Offset for channels in A/D units
Source:Signal%20Properties:DataIOFilter int SourceCh= 8 16 1 % // number of digitized and stored channels
Source:Signal%20Properties:DataIOFilter list ChannelNames= 8 F3 F4 T7 C3 Cz C4 T8 Pz // list of channel names
Filtering:SpatialFilter int SpatialFilterType= 1 2 0 3 // spatial filter type 0: none, 1: full matrix, 2: sparse matrix, 3: common average reference (CAR) (enumeration)
Filtering:SpatialFilter:SpatialFilter matrix SpatialFilter= { C3_OUT Cz_OUT C4_OUT } { F3 F4 T7 C3 Cz C4 T8 Pz } -0.25 0.00 -0.25 1.00 -0.25 0.00 0.00 -0.25 -0.20 -0.20 0.00 -0.20 1.00 -0.20 0.00 -0.20 0.00 -0.25 0.00 0.00 -0.25 1.00 -0.25 -0.25 0 % % // columns represent input channels, rows represent output channels
Filtering:SpatialFilter:SpatialFilter intlist SpatialFilterCAROutput= 0 // when using CAR filter type: list of output channels, or empty for all channels
Filtering:SpatialFilter:SpatialFilter int SpatialFilterMissingChannels= 1 0 0 1 // how to handle missing channels 0: ignore, 1: report error (enumeration)
Filtering:Spectral%20Estimation:ARThread float FirstBinCenter= 0Hz 0Hz % % // Center of first frequency bin (in Hz)
Filtering:Spectral%20Estimation:ARThread float LastBinCenter= 30Hz 30Hz % % // Center of last frequency bin (in Hz)
Filtering:Spectral%20Estimation:ARThread float BinWidth= 6Hz 3Hz % % // Width of spectral bins (in Hz)
Filtering:Spectral%20Estimation:ARThread int OutputType= 0 0 0 2 // 0: Spectral Amplitude, 1: Spectral Power, 2: Coefficients (enumeration)
Filtering:AR%20Spectral%20Estimator:ARThread int ModelOrder= 20 16 0 % // AR model order
Filtering:AR%20Spectral%20Estimator:ARThread int EvaluationsPerBin= 15 15 1 % // Number of uniformly spaced evaluation points entering into a single bin value
Filtering:Spectral%20Estimation:SpectralEstimatorChoice int SpectralEstimator= 1 1 0 2 // Choice of spectral estimation algorithm, 0: None, 1: AR, 2: FFT (enumeration)
Filtering:Windowing:WindowingThread int WindowLength= 0.5s 0.5s % % // Length of window
Filtering:Windowing:WindowingThread int Detrend= 1 0 0 2 // Detrend data? 0: no, 1: mean, 2: linear (enumeration)
Filtering:Windowing:WindowingThread int WindowFunction= 0 0 0 3 // Window function 0: Rectangular, 1: Hamming, 2: Hann, 3: Blackman (enumeration)
Filtering:LinearClassifier matrix Classifier= 1 { input%20channel input%20element%20(bin) output%20channel weight } 2 12Hz 2 1 // Linear classification matrix in sparse representation
Filtering:LPFilter float LPTimeConstant= 1s 16s 0 % // time constant for the low pass filter
Filtering:ExpressionFilter string StartRunExpression= % // expression executed on StartRun
Filtering:ExpressionFilter string StopRunExpression= % // expression executed on StopRun
Filtering:ExpressionFilter matrix Expressions= 0 1 // expressions used to compute the output of the ExpressionFilter (rows are channels; empty matrix for none)
Filtering:Normalizer floatlist NormalizerOffsets= 2 0 10.9104 0 % % // normalizer offsets
Filtering:Normalizer floatlist NormalizerGains= 2 0 0.538485 0 % % // normalizer gain values
Filtering:Normalizer intlist Adaptation= 2 0 2 0 0 2 // 0: no adaptation, 1: zero mean, 2: zero mean, unit variance (enumeration)
Filtering:Normalizer matrix BufferConditions= 2 2 0 (Feedback)&&(TargetCode==1) 0 (Feedback)&&(TargetCode==2) // expressions corresponding to data buffers (columns correspond to output channels, multiple rows correspond to multiple buffers)
Filtering:Normalizer float BufferLength= 30s 9s % % // time window of past data per buffer that enters into statistic
Filtering:Normalizer string UpdateTrigger= (Feedback==0) // expression to trigger offset/gain update when changing from 0 (use empty string for continuous update)
Application:Sequencing:FeedbackTask float PreRunDuration= 2s 2s 0 % // duration of pause preceding first trial
Application:Sequencing:FeedbackTask float PreFeedbackDuration= 2s 2s 0 % // duration of target display prior to feedback
Application:Sequencing:FeedbackTask float FeedbackDuration= 10s 3s 0 % // duration of feedback
Application:Sequencing:FeedbackTask float PostFeedbackDuration= 1s 1s 0 % // duration of result display after feedback
Application:Sequencing:FeedbackTask float ITIDuration= 1s 1s 0 % // duration of inter-trial interval
Application:Sequencing:FeedbackTask float MinRunLength= 120s 120s 0 % // minimum duration of a run; if blank, NumberOfTrials is used
Application:Sequencing:FeedbackTask int NumberOfTrials= % 0 0 % // number of trials; if blank, MinRunLength is used
Application:Targets:FeedbackTask int NumberTargets= 2 2 0 255 // number of targets
Application:Targets:FeedbackTask intlist TargetSequence= 0 1 % % // fixed sequence in which targets should be presented (leave empty for random)
Application:Window:CursorFeedbackTask int RenderingQuality= 0 0 0 1 // rendering quality: 0: low, 1: high (enumeration)
Application:Sequencing:CursorFeedbackTask float MaxFeedbackDuration= 4s % 0 % // abort a trial after this amount of feedback time has expired
Application:3DEnvironment:CursorFeedbackTask floatlist CameraPos= 3 50 50 150 // camera position vector in percent coordinates of 3D area
Application:3DEnvironment:CursorFeedbackTask floatlist CameraAim= 3 50 50 50 // camera aim point in percent coordinates
Application:3DEnvironment:CursorFeedbackTask int CameraProjection= 0 0 0 2 // projection type: 0: flat, 1: wide angle perspective, 2: narrow angle perspective (enumeration)
Application:3DEnvironment:CursorFeedbackTask floatlist LightSourcePos= 3 50 50 150 // light source position in percent coordinates
Application:3DEnvironment:CursorFeedbackTask int LightSourceColor= 0xffffff // light source RGB color (color)
Application:3DEnvironment:CursorFeedbackTask int WorkspaceBoundaryColor= 0xffff00 0 % % // workspace boundary color (0xff000000 for invisible) (color)
Application:3DEnvironment:CursorFeedbackTask string WorkspaceBoundaryTexture= images\grid.bmp // path of workspace boundary texture (inputfile)
Application:Cursor:CursorFeedbackTask float CursorWidth= 10 10 0.0 % // feedback cursor width in percent of screen width
Application:Cursor:CursorFeedbackTask int CursorColorFront= 0xff0000 // cursor color when it is at the front of the workspace (color)
Application:Cursor:CursorFeedbackTask int CursorColorBack= 0xff0000 // cursor color when it is in the back of the workspace (color)
Application:Cursor:CursorFeedbackTask string CursorTexture= % // path of cursor texture (inputfile)
Application:Cursor:CursorFeedbackTask floatlist CursorPos= 3 50 50 50 // cursor starting position
Application:Targets:CursorFeedbackTask matrix Targets= 2 { pos%20x pos%20y pos%20z width%20x width%20y width%20z } 50 4 50 100 8 8 50 96 50 100 8 8 // target positions and widths in percentage coordinates
Application:Targets:CursorFeedbackTask int TargetColor= 0xff0000 // target color (color)
Application:Targets:CursorFeedbackTask string TargetTexture= % // path of target texture (inputfile)
Application:Targets:CursorFeedbackTask int TestAllTargets= 0 0 0 1 // test all targets for cursor collision? 0: test only the visible current target, 1: test all targets (enumeration)
Application:Human%20Interface%20Devices:KeystrokeFilter string KeystrokeStateName= % // State to be translated into keystrokes, empty for off

equicu
Posts: 3
Joined: 20 May 2016, 09:34

Re: Linear Matrix classifier doubts

Post by equicu » 23 May 2016, 08:30

Hi Peter,
Thanks for your answer.
The parameter file you attached is for left hand vs right hand or rest vs left hand?
I have reviewed your slides, the rest of forum entries and the wiki but still have doubts about the classifier matrix.
Could you please answer in more detail my previous questions?
Your help will be greatly appreciated.

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Linear Matrix classifier doubts

Post by pbrunner » 23 May 2016, 10:03

Equicu,

please see the description of the cursor task, it shows that x,y and z correspond to control signals 1, 2 and 3, respectively.

http://www.bci2000.org/wiki/index.php/U ... rol_Signal

The fragment has three spatial laplacian filters pre-programmed, centered at C3, Cz and C4. In the Offline Analysis tool you chose the frequency and location (C3, Cz or C4) that shows the largest task-related change and then select this in your classifier. The classifier weight translates the spectral power into a cursor movement, so if you have a positive weight (e.g., 1) then an increase in spectral power will make the cursor go up (for for control channel 2) or to the right (for control channel 1). The adaptation step in the filter pipeline learn the mean and std of this control signal. After some time you can turn the adaptation off (i.e., setting it to 0) and increase the gain to accelerate the control signal.

Regards, Peter

equicu
Posts: 3
Joined: 20 May 2016, 09:34

Re: Linear Matrix classifier doubts

Post by equicu » 25 May 2016, 07:55

Peter,
In the parameter file you provide the classifier matrix is:
input channel input element output channel weight
2 12Hz 2 1
Input channel 2 corresponds to Cz_OUT? (2nd output channel in the spatial filter matrix).
What task is this prm file for? Both feet vs both hands, both feet vs rest, left hand vs right hand?

Thanks for your time and patience!

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Linear Matrix classifier doubts

Post by pbrunner » 25 May 2016, 10:09

Equicu,

the parameter file is generic and can be used for any motor task. Effectively it calculates the power spectra for three spatial filters centered at C3, Cz and C4, which are labeled as C3_OUT, Cz_OUT and C4_OUT and are referenced in the first column of the classifier. All you need to do is in the classifier to select either 1, 2 or 3 for the C3, Cz or C4 centered filter and the center frequency. This decision should be based on the results of your analysis in OfflineAnalysis.

Regards, Peter

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest