[Error] <xDAWN Spatial filter> -Bad matrix size

Working with OpenViBE signal processing scenarios and doing scenario/BCI design
Post Reply
chantrip
Posts: 42
Joined: Fri Jul 08, 2011 9:32 am

[Error] <xDAWN Spatial filter> -Bad matrix size

Post by chantrip »

Dear all

I'm a newbie to Openvibe and trying p300-speller-xDAWN. I use openvibe-0.10.0-svn2909-src with Emotiv headset. I followed the thread in viewtopic.php?f=17&t=401 and got stuck in the training phase. When I started -4-online-xml, the log file showed that xDAWN filter has encountered 'Bad matrix size - Expected 3 input channels and received 14 input channels' as shown in the attached file. I'm not sure if something is wrong during the initialization phase but so far the only change that I've made is in the setting value in line 8 of the file 'p300-speller-stimulator.cfg' from 10 to 1. So, any suggestions are welcome.

Thank you very much

-Jim
Attachments
xDAWN.JPG
xDAWN.JPG (63.23 KiB) Viewed 14677 times

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: [Error] <xDAWN Spatial filter> -Bad matrix size

Post by lbonnet »

Hi chantrip and welcome on board !
xDAWN filter has encountered 'Bad matrix size - Expected 3 input channels and received 14 input channels'
The xDAWN filter box in these scenarios is a spatial filter box. It reduces the number of input channel with linear combinations, for example from 14 input channels to 3 combinations (3 output channels).

The error you have means that the filter that you trained requires 3 input channels, and the box received 14.
so far the only change that I've made is in the setting value in line 8 of the file 'p300-speller-stimulator.cfg' from 10 to 1
So you changed the number of trials from 10 letters to 1.
Btw you just need to uncheck the tick box "override settings with configuration file" to change the settings directly in the box. Much more convenient than in the xml file ;)
Indeed this change is not what causes the error you mentioned.

Did you follow all the steps required ?
0. turn on the acquisition server, verify the connection and signal quality with the monitoring scenario
1. acquisition : acquire some data (10 letters is default behaviour)
2. train xDAWN on the file you just acquired (modify the box Generic Stream Reader to do so). This step should end with "Training finished. Eigen values are ..."
3. train the LDA classifier with the same file. This step should end with classifier performances in %.
4. online.
5. [optional] retrain xDAWN then Classifier with the last online file for better results

To make the P300 speller work with the Emotiv headset, some changes may be required.

The default scenario was tested with a 512Hz device, and a Signal Decimation box is used to lower it by factor 4. Emotiv EPOC is sampled at 128Hz, so you need to either oversample the Emotiv driver in the Acquisition Server preferences by factor 4, or remove the decimation in the scenarios.

If the xDAWN spatial filter computation seems to freeze, or ends up with "decomposition failed", it means that the algorithm thinks that a channel is already a combination of others sensors. You may have to randomly remove some channels (1-2) with a Channel Selector box just after the acquisition client. This happened to me one time.

Last advice, you should be aware that you may not reach very good performances at first try. Some tweaking in the stimulator settings may be required.

Come back to us if you experience that kind of problem, and of course if your primary problem remains (this one should definitely find a solution :) )

Hope this helps.

Laurent-
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

chantrip
Posts: 42
Joined: Fri Jul 08, 2011 9:32 am

Re: [Error] <xDAWN Spatial filter> -Bad matrix size

Post by chantrip »

Dear Laurent

Thank you very much for your helpful comments. It turns out that I've made a mistake when selecting data to train xDAWN spatial filter :(. After correcting and increasing the oversample factor from 1 to 4, I was able to get 75.27% classification rate and get very good results when trying -online- mode. :) .

I have another quick question. How to create a profile for me or others if they want to use the P300-xDAWN speller. Say, I have my own spatial filter coeffs and classifiers so I can use these parameters when I use the P300-xDAWN-speller. If I want to let my friend use it, they can simply use their own coeffs and classifiers before trying the online mode. I know that I can rename p300-spatial-filter.cfg and p300-classifier.cfg every time but is there any other way to create a user profile to make it easier?

Regards,

-Jim

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: [Error] <xDAWN Spatial filter> -Bad matrix size

Post by lbonnet »

After correcting and increasing the oversample factor from 1 to 4, I was able to get 75.27% classification rate and get very good results when trying -online- mode. :) .
Great ! How many letters do you manage to detect successfully ?
I know that I can rename p300-spatial-filter.cfg and p300-classifier.cfg every time but is there any other way to create a user profile to make it easier?
Indeed it's not very convenient. However I strongly advise you to retrain CSP and Classifier at the beginning of every session.
From one session to another, the electrodes may be in a slightly different position, thus the spatial filter need to be trained again.
Even from one day to another, your "mental state" could be different from the day you trained the system.

Building BCI systems that would overcome this problem is an active field of research (e.g. "subject-independent bci").

Anyway, I suggest you to try an online session using config files from an another day. Tell me if it works fine, or if you see a significant fall of performance.

If you still want to configure your openvibe for multiple-users, I suggest you take a look at this page. It describes how to set an experiment environment, so the whole scenarios are configured with only one few modification. Maybe it will give you ideas...

Hope this helps!

Laurent-
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

chantrip
Posts: 42
Joined: Fri Jul 08, 2011 9:32 am

Re: [Error] <xDAWN Spatial filter> -Bad matrix size

Post by chantrip »

Great ! How many letters do you manage to detect successfully ?
I got 10 out of 10 :).
From one session to another, the electrodes may be in a slightly different position, thus the spatial filter need to be trained again.
Even from one day to another, your "mental state" could be different from the day you trained the system.
This should be a good test. I'll try it tomorrow.

I have a couple of questions. I want to change a letter in P300 spelling into a picture similar to viewtopic.php?t=423. According to the quote
Or if you want to change the letter by a picture, you need to delete the corresponding "label" object and add an "GtkImage" object, next you need to add the path of your picture in the “pixbuf “ property.
please tell me how to do it (My picture file is in D:\Pic\snoopy.jpg). Here's a part of my P300-speller.ui code (esp the pixbuf prop) where I change a text '0' to '00'

Code: Select all

                  <object class="GtkLabel" id="label-6.6">
                    <property name="visible">True</property>
                    <property name="label" translatable="yes">00</property>
                    <property name="use_markup">True</property>
                    <property name="justify">center</property>
                  </object>
Also, please tell me how to do this from the quote
You can try to fix the size of “even box” to have a picture smaller than the "even box" and change the color of the flash, to see it better.
With this solution, you will see your picture with a border corresponding to your flash, when the line or column will be flash. But I think the flash stay discrete, that's why I'm not sure this solution give a good result.
Thank you very much for your kind supports.

-Jim

zackbam
Posts: 5
Joined: Fri Mar 09, 2012 5:54 pm
Location: Barcelona
Contact:

Re: [Error] <xDAWN Spatial filter> -Bad matrix size

Post by zackbam »

In the best case, after following the same steps as chantrip, the best estimated accuracy I can achieve is 72,5%. And then in the online scenario I get 0/10 correct instances (sometimes correct column, not not much better than random!). chantrip, did you change anything else apart from increasing the oversampling factor to 4?

When applying Nu-SVC (linear) instead of LDA, the estimated accuracy is around 83%. Then I change the first value of the file p300-classifier-processor.cfg to Support Vector Machine (SVM). When I run the online scenario I get no error or warnings, but the classifier always selects the letter 'A'.

Any hints?

fabien.lotte
Posts: 112
Joined: Sun Mar 14, 2010 12:58 pm

Re: [Error] <xDAWN Spatial filter> -Bad matrix size

Post by fabien.lotte »

The step no 5 that Laurent mentioned (retrain the spatial filter and classifier on the data acquired online) is indeed optional but if you have poor performances it is really worth trying. So if you had poor performances online, still try to focus properly on the targeted letters in the online scenario. Once the online session is complete, even if you got poor performances, retrain the xDAWN spatial filter and Classifier on the data just acquired during this online session. Sometimes it solves the problem: the poor performances might be due to a timing problem, since in the acquisition scenario there are less boxes than in the online one, which can causes different delays between acquisition and online use. But if you train your model on data acquired with the online scenario, then the delay and timing are by definition the same as in the online scenario. I hope this helps.

Best,
Fabien

zackbam
Posts: 5
Joined: Fri Mar 09, 2012 5:54 pm
Location: Barcelona
Contact:

Re: [Error] <xDAWN Spatial filter> -Bad matrix size

Post by zackbam »

Indeed fabien! This step made me write up to 8/10 correct letters and 2/10 correct columns or rows. So Emotiv is a real EEG device, quite accurate for its price! And possibly a low cost communication way of person with Locked-in. So 18/20 correctly detected P300. Using LDA, 3 output Dawn filter and estimated 10-cross validation performance 75%. When applying SVM, polynomial 2-degree, the estimated performance is 83.333% almost every time, but in the online scenario in the best case I achieve 5/10 correct letters. This might be due to a longer computation time, so the delay introduced in the stimuli might vary further more. So even if SVM gives better results, it is worst in this case, unless someone is using a high-end computer.
Thank you all for your help!

Post Reply