motor-imagery-bci-2-classifier-trainer

Working with OpenViBE signal processing scenarios and doing scenario/BCI design
Post Reply
mhadji05
Posts: 21
Joined: Tue Mar 16, 2021 9:37 am

motor-imagery-bci-2-classifier-trainer

Post by mhadji05 »

I use OpenBCI with 8 channels (O1; O2; P7; P8; C3; C4; FP1; FP2) and 2 SRB & Bias earclips on the Board.

I ran the motor-imagery-bci-1-acquisition and created the .ov file.

I try to run the motor-imagery-bci-2-classifier-trainer but I get an error

As a Reference Channel what should I put?

In the Surface Laplacian Box -> Spatial Filter coefficients there is this (4; 0; -1; 0; -1; -1; 0; 0; -1; 0; 0; 4; 0; -1; 0; 0; -1; -1; 0; -1)
What does it mean? Please explain to me ..

I have put
Number of output channels = 2
Number of output channels = 8

What do I do wrong and get errors? (see attachment image)


Thanks for any help!

Thomas
Posts: 68
Joined: Wed Mar 04, 2020 3:38 pm

Re: motor-imagery-bci-2-classifier-trainer

Post by Thomas »

Hi,

For the reference channel, you should put the name of the reference channel as it was recorded in your .ov file.
The reference channel box will then subtract the values of the samples from the reference channel from the other channels' samples.
It is basically trying to de-noise all signals.
If you are not sure what to put there, or don't have a reference channel, you can also bypass this box, and connect the identity box directly to the channel selector box. Note that this may impact the quality of the following processing.

For the Surface Laplacian box, it is actually a spatial filter. Please have a look at the documentation page for exemples of its functioning and parameters.
If you have 8 input channels, and 2 outputs, the box will expect 16 (n_intputs * n_outputs) semicolon separated values for the coefficients.

Unfortunately, I don't see the attachement you provided, but fixing the issues mentioned above might clear the errors.

Hope this helps, and let us know how you get on.

Cheers,
Thomas

mhadji05
Posts: 21
Joined: Tue Mar 16, 2021 9:37 am

Re: motor-imagery-bci-2-classifier-trainer

Post by mhadji05 »

Thanks for the reply @Thomas.

I m very new in this field. I have 8 channel eeg and i want left and right hand.
I suppose this means I have 8 input channels, and 2 outputs. Right?
the box will expect 16 (n_intputs * n_outputs) semicolon separated values for the coefficients.
Please let me know what this coefficients represent and what can I put on this input-field as coefficients to train my classifier for left right hand.
The example scenario had as default the following coefficients : (4; 0; -1; 0; -1; -1; 0; 0; -1; 0; 0; 4; 0; -1; 0; 0; -1; -1; 0; -1)
What means this? and what must I insert?

Here is the image with my errors: https://openbci.com/forum/uploads/edito ... 3yzm6u.jpg

Thanks.

Thomas
Posts: 68
Joined: Wed Mar 04, 2020 3:38 pm

Re: motor-imagery-bci-2-classifier-trainer

Post by Thomas »

Hi,

Yes you are right, you have 8 input channels and 2 outputs, one around C3 and one around C4 which correspond to the primary motor cortex area (Right and Left).


When recording EEG, signal acquired on an electrode will have received information from neighbour areas of the brain. That's how it is with non invasive EEG.
In order to get a better representation of the signal on an electrode, the laplacian filter can be used, in order to ponder the desired electrode signal with the neighbour ones. The list of coefficients, is the weight you want to give each electrode.
In you exemple, your need 16 coeffs. The first 8 coeffs to ponder your 8 channels, in the respective order they have on the channel selector, for you first output (e.g. around C3), and the second 8 coeffs to ponder the same 8 channels for your second output (e.g. around C4).
In the exemple for the first 10 coefs, coefficient 4 is used on C3, -1 for channels near C3 and 0 for channels far from C3. The second 10 coeffs do the same around C4.

That said, in your setup, the placement of your electrodes are not ideal for a laplacian as they are all quite far from C3 and C4. If you can move them to other location to be closer from C3 and C4, you could improve signal quality on C3 and C4 using the laplacian, but if you cannot, I would remove the laplacian box from the scenario.

Hope this makes sense and helps.

Cheers,
Thomas

mhadji05
Posts: 21
Joined: Tue Mar 16, 2021 9:37 am

Re: motor-imagery-bci-2-classifier-trainer

Post by mhadji05 »

Hello all,

I trained my classifier with left and right hand movement (Not fantasy but real movement) and Ι got the results below.
Can anyone explain to me what this results means? When I ran the motor-imagery-bci-3-online.xml file the accuracy was poor.

Thank you in Advance!

Results:

[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> Received train stimulation. Data dim is [2040x2]
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> For information, we have 1020 feature vector(s) for input 1
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> For information, we have 1020 feature vector(s) for input 2
[ INF | At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> k-fold test could take quite a long time, be patient
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> Finished with partition 1 / 7 (performance : 78.694158)
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> Finished with partition 2 / 7 (performance : 35.051546)
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> Finished with partition 3 / 7 (performance : 47.602740)
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> Finished with partition 4 / 7 (performance : 51.890034)
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> Finished with partition 5 / 7 (performance : 37.671233)
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> Finished with partition 6 / 7 (performance : 17.525773)
[ INF ] At time 362.242 sec <Box algorithm:(0x02e67945, Ox5ea8d309) aka Classifier trainer> Finished with partition 7 / 7 (performance : 45.890411)

[ INF ] At time 362.242 sec <Box algorithm:: (0x02e67945, Ox5ea8d309) aka Classifier trainer> Cross-validation test accuracy is 44.903699$ (sigma = 17.3113783)
[ INF ] At time 362.242 sec <Box algorithm:: (0x02e67945, Ox5ea8d309) aka Classifier trainer> Cls vs cls 1 2
[ INF ] At time 362.242 sec <Box algorithm:: (0x02e67945, Ox5ea8d309) aka Classifier trainer> Target 1: 43.9 56.1% , 1020 examples
[ INF ] At time 362.242 sec <Box algorithm:: (0x02e67945, Ox5ea8d309) aka Classifier trainer> Target 2: 54.1 45.9% , 1020 examples
[ INF ] At time 362.242 sec <Box algorithm:: (0x02e67945, Ox5ea8d309) aka Classifier trainer Training set accuracy is 51.960784% (optimistic)
[ INF ] At time 362.242 sec <Box algorithm:: (0x02e67945, Ox5ea8d309) aka Classifier trainer> Cls vs cls 1 2
[ INF ] At time 362.242 sec <Box algorithm:: (0x02e67945, Ox5ea8d309) aka Classifier trainer> Target 1: 66.0 34.0 %, 1020 examples
[ INF ] At time 362.242 sec <Box algorithm:: (0x02e67945, Ox5ea8d309) aka Classifier trainer> Target 2: 62.1 37.9 %, 1020 examples

Thomas
Posts: 68
Joined: Wed Mar 04, 2020 3:38 pm

Re: motor-imagery-bci-2-classifier-trainer

Post by Thomas »

Hi,

The partitions performances displayed are the result of the k-fold test. To learn more about this test, please visit the box documenation page, in the cross-validation section.

But basically the performance value is a percentage and the higher it is the better.

Then the two blocks at the bottom are the cross-validation and test confusion matrices. They are also commented in the box documentation in the Confusion Matrices section.

Here, the results are not great.
Target 1: 43.9 56.1% -> means that 43.9% of feature vector for Target 1 were actually predicted as target 1.
Target 2: 54.1 45.9% -> means that 45.9% of feature vector for Target 2 were actually predicted as target 2.

With this kind of training results, it makes sense that the online results were poor too.

It is difficult to say why this is happening. I would look at the quality of the EEG data (quality of signal, noise...).

Hope this helps you seeing clearer.

Cheers
Thomas

mhadji05
Posts: 21
Joined: Tue Mar 16, 2021 9:37 am

Re: motor-imagery-bci-2-classifier-trainer

Post by mhadji05 »

Thomas thanks for your response.

You mention this:
Here, the results are not great.
Target 1: 43.9 56.1% -> means that 43.9% of feature vector for Target 1 were actually predicted as target 1.
Target 2: 54.1 45.9% -> means that 45.9% of feature vector for Target 2 were actually predicted as target 2.



Are you sure Target 2: 54.1 45.9% -> means that 45.9% of feature vector for Target 2 were actually predicted as target 2.

I think means that 54.1% of feature vector for Target 2 were actually predicted as target 2.

Please let me know

Thomas
Posts: 68
Joined: Wed Mar 04, 2020 3:38 pm

Re: motor-imagery-bci-2-classifier-trainer

Post by Thomas »

Hi,

Yes, unfortunately, I confirm that I meant it the way I wrote it.

Confusion matrices are displayed this way. Please have a look at this wiki page for more details.

Cheers,
Thomas

mhadji05
Posts: 21
Joined: Tue Mar 16, 2021 9:37 am

Re: motor-imagery-bci-2-classifier-trainer

Post by mhadji05 »

I'm trying to train the classifier for MI but the accuracy results I get are very bad.

I'm using Channel Selector Box with channels: (C3; C4; P3; P4; T3; T4; F3; F4) and
Surface Laplacian Box with coefficients: (4; 0; -1; 0; -1; 0; -1; 0; 0; 4; 0; -1; 0; -1; 0; -1), 8 inputs and 2 outputs,
Temporal filter box with: (low 8Hz & high 24Hz)
I tried both 7 and 5 partitions for k-fold cross-validation.

Unfortunately my results are very BAD (Cross Validation test accuracy: -> Left 44.9 and Right 41.1)

If you can please suggest me what I could do to improve accuracy I would appreciate it very much!

Thanks in advance.

Thomas
Posts: 68
Joined: Wed Mar 04, 2020 3:38 pm

Re: motor-imagery-bci-2-classifier-trainer

Post by Thomas »

Hi,

Have you tried the scenario with different people ? There are people for whom BCIs do not work so well, so it is worth trying with someone else, to see if you get better results.

Another point, on the laplacian, is the set of electrodes used. They are not very close to each other, so this filtering might not give the best results. Maybe a higher density headset would be better (I know it's easier said than done).

Last thing and I may state the obvious, but checking the electrodes are well positioned and making sure the mapping in OpenViBE is correct.

Hope this helps.

Cheers,
Thomas

mhadji05
Posts: 21
Joined: Tue Mar 16, 2021 9:37 am

Re: motor-imagery-bci-2-classifier-trainer

Post by mhadji05 »

Thanks for the answer.
Last thing and I may state the obvious, but checking the electrodes are well positioned and making sure the mapping in OpenViBE is correct.
Do you mean if the electrodes are in the right position on the scalp?
Also you mean OpenViBE Acquisition Sever / (OpenBCI) Driver Properties / Change Channel names / index Names --> must be in the same order with the connected pins on EEG-board?

The answer is YES I did it if this is what you mean.

Thomas
Posts: 68
Joined: Wed Mar 04, 2020 3:38 pm

Re: motor-imagery-bci-2-classifier-trainer

Post by Thomas »

Ok great, that's what I meant indeed. :D

Post Reply