A bias between offline and online sessions

Known Issues and Problems with BCI2000
Locked
soncyme
Posts: 7
Joined: 03 Aug 2009, 06:28

A bias between offline and online sessions

Post by soncyme » 03 Aug 2009, 06:43

Hi, I have one question.
I am now trying to do online bci experiment using FeedbackDemo_SignalGenerator.bat, I just added gUSBampSource.exe to use the notch filter.

The algorithm I applied is CSP plus LDA. For the offline training the accuracy was around 80%, and I saved the coefficients for CSP and LDA. During the online session, each trial is band-pass filtered, then multipled by the CSP spatial filters and then multipled with LDA coefficients.

My problem is that it seems for the online session, in the MATLAB engine I checked bci_OutSignal, it could be always positive or negative, like a baseline shifting (This could happen no matter whether the subject is looking at the screen or not). However, when I tried offline classifying the recorded online data with the same coefficients of CSP and LDA, the output is not the same as bci_OutSignal as seen in the MATLAB engine. The output value is much smaller than bci_OutSignal.

Has anyone met such a problem and how can this be explained?

Thanks a lot !

gschalk
Posts: 615
Joined: 28 Jan 2003, 12:37

offline/online difference

Post by gschalk » 05 Aug 2009, 15:54

Hi,

This is a good question. The online signal processing is really quite simple. It first does spatial filtering, then the AR estimation, and then classification. One possible error is that online, the spatial filtering is done only on the signals transmitted from the Source Module, i.e., you need to make sure you are transmitted all channels (in TransmitCh), or at least all channels that you are using offline. Another possible error is that online, all values are converted into microVolts (using SourceChGain/Offset), whereas when you use load_bcidat in Matlab without any options, data are raw (i.e., not converted into microVolts).

Other ideas are to debug this would be to use a test signal (e.g., using SignalGenerator) where you modulate the signals with the mouse, then derive CSP values offline, and then test the output of each filter independently. You could do this simply visually by turning on the visualization of each filter, see how it reacts to the mouse movements, or you could disable the spatial filter and/or ar filter, so that you get raw data into the Matlab engine.


I hope this helps.

Gerv

soncyme
Posts: 7
Joined: 03 Aug 2009, 06:28

Re: offline/online difference

Post by soncyme » 05 Aug 2009, 23:56

Hi, thx for answering.
I met the same problem today.
The two main online functions I am using looks like this.
1) function bci_Initialize( in_signal_dim, out_signal_dim)
global a b
b= [ 0.0011 0 -0.0033 0 0.0033 0 -0.0011];
a=[ 1.0000 -5.5423 12.8250 -15.8631 11.0626 -4.1245 0.6423]; %[b,a]=butter(3,[1/128 10/128]);

theta =[-3.9946 ; -1.6686; 1.0409]; %for LDA
SFL = [ -0.0137 0.0093 0.0081 -0.0027 -0.0201 0.0039 0.0060 -0.0091 0.0007 0.0134 0.0172 -0.0238 0.0077 0.0035 -0.0019];
SFR =[ 0.0002 0.0078 -0.0066 0.0062 -0.0038 -0.0068 0.0027 -0.0048 -0.0093 0.0162 -0.0050 0.0156 0.0015 -0.0029 -0.0127];

2)function out_signal = bci_Process( in_signal )

global a b;

for i=1:size(in_signal,1)
tempsignal(i,:)=filter(b,a,in_signal(i,:));
end

global theta SFL SFR;

SFLL= SFL*tempsignal; %1*5 5*256= 1*256
SFRL= SFR*tempsignal;

testvector=[ 1 log(var(SFLL)) log(var(SFRL))];
out_signal= testvector*theta;

Could you tell me where it may be wrong?

Thanks a lot!
gschalk wrote:Hi,

This is a good question. The online signal processing is really quite simple. It first does spatial filtering, then the AR estimation, and then classification. One possible error is that online, the spatial filtering is done only on the signals transmitted from the Source Module, i.e., you need to make sure you are transmitted all channels (in TransmitCh), or at least all channels that you are using offline. Another possible error is that online, all values are converted into microVolts (using SourceChGain/Offset), whereas when you use load_bcidat in Matlab without any options, data are raw (i.e., not converted into microVolts).

Other ideas are to debug this would be to use a test signal (e.g., using SignalGenerator) where you modulate the signals with the mouse, then derive CSP values offline, and then test the output of each filter independently. You could do this simply visually by turning on the visualization of each filter, see how it reacts to the mouse movements, or you could disable the spatial filter and/or ar filter, so that you get raw data into the Matlab engine.


I hope this helps.

Gerv

gschalk
Posts: 615
Joined: 28 Jan 2003, 12:37

CSP

Post by gschalk » 06 Aug 2009, 07:22

Hi,

Did you check the possibilities I suggested? In particular, in BCI2000 online processing, data are converted into microVolts. See

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

Unless you perform the same conversion offline, the LDA parameters will not be correct when used online.

Gerv

soncyme
Posts: 7
Joined: 03 Aug 2009, 06:28

Re: CSP

Post by soncyme » 06 Aug 2009, 10:06

Hi, thanks for answering.
For both the offline and online settings, I set all the channels offsets 0 and gain 0.08. However, I did not convert into microvolts as the webpage suggested. Instead, I used the option '-calibrated' with the command load_bcidat, which is one of the tools contained in BCI 2000. It is said this can also help to change into microvolts...

Thx again.

gschalk wrote:Hi,

Did you check the possibilities I suggested? In particular, in BCI2000 online processing, data are converted into microVolts. See

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

Unless you perform the same conversion offline, the LDA parameters will not be correct when used online.

Gerv

soncyme
Posts: 7
Joined: 03 Aug 2009, 06:28

Re: CSP

Post by soncyme » 09 Aug 2009, 11:44

Hi, I am here to tell you the good news.
Today I trained a subject with even online accuracy 80%, and it is the second time for him to take such a BCI experiment.
I guess sometimes it does not work with some subjects...someone pattern just cannot be extracted by the method of CSP and LDA.




gschalk wrote:Hi,

Did you check the possibilities I suggested? In particular, in BCI2000 online processing, data are converted into microVolts. See

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

Unless you perform the same conversion offline, the LDA parameters will not be correct when used online.

Gerv

Locked

Who is online

Users browsing this forum: No registered users and 1 guest