Scale changes after reading .dat using EEGLAB Import

Forum for software developers to discuss BCI2000 software development
Post Reply
Ryan
Posts: 29
Joined: 27 Aug 2010, 15:03

Scale changes after reading .dat using EEGLAB Import

Post by Ryan » 21 Mar 2015, 15:02

Hi All,

I observed an interesting phenomenon, that when using EEGLABImport to import .dat from into Matlab, the data is rescaled, usually much larger than what you can observe with BCI2000 viewer.
I did some testing and found that the scale difference is exactly 1/SourceChannelGain.
I wonder if EEGImport forgets to take SourceChannelGain into account.

Well, another thing I noticed is about Source filter. I configured the Source filter with 0.3~70Hz bandpass and 60 Hz notch filter. Later on I loaded the data with EEGLABImport into EEGLab, and took a look at the power spectrum, and found that notch filter was clearly there, however 70 Hz lowpass was not obvious. Can someone let me know if it's because the lowpass in source filter is very mild? or bandpass is applied after saving the data? According to the manual, it seems source filters work similar as hardware filter, which should have been applied before storing data.

Thanks,
Ran

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: Scale changes after reading .dat using EEGLAB Import

Post by boulay » 21 Mar 2015, 16:50

Hi, did you use EEGLAB import from the BCI2000 distribution or from the EEGLAB plugins installation utility?

Ryan
Posts: 29
Joined: 27 Aug 2010, 15:03

Re: Scale changes after reading .dat using EEGLAB Import

Post by Ryan » 22 Mar 2015, 18:14

Hi Boulay,

I used the one from BCI2000 distribution, by copying it into EEGLAB plugins folder.

Ran

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: Scale changes after reading .dat using EEGLAB Import

Post by boulay » 22 Mar 2015, 18:55

I maintain the one used in EEGLAB's plugin manager. Please use that instead and try again. The one from BCI2000 should work if you downloaded the trunk source within the last 2 years. However, if you are using a BCI2000 'release' version then the load_bcidat command does not use -calibrated, and no gains are applied.

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

Re: Scale changes after reading .dat using EEGLAB Import

Post by pbrunner » 23 Mar 2015, 10:53

Ryan,

For you first question: As Chad already hinted the observed behavior is because in load_bcidat, by default, signal data will be in raw A/D units. To obtain signal data calibrated into physical units (microvolts), specify '-calibrated' as an option anywhere in the argument list [1].

For your second question: This depends on which source module you are using. Please note that the signals will always be stored just as they came from the amplifier system. Thus, if the filtering happens on the acquisition hardware (i.e., the amplifier system) then the stored signals should be filtered. This for example is the case with g.tec hardware. If the filtering is happening in a signal processing filter within BCI2000 then the data will be stored unfiltered just like it came from the amplifier.

Regards, Peter

[1] http://www.bci2000.org/wiki/index.php/U ... oad_bcidat

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: Scale changes after reading .dat using EEGLAB Import

Post by boulay » 23 Mar 2015, 11:46

Peter, my impression is that he is using the SourceFilter[1] as part of the SignalSource module, not in the SignalProcessing chain. This registers in position 1.01 by default. Hardware registers in position 1.0, so I assume that the SourceFilter happens immediately after hardware acquisition but before writing to disk. Is that incorrect?

[1] http://www.bci2000.org/tracproj/browser ... Filter.cpp

Ryan
Posts: 29
Joined: 27 Aug 2010, 15:03

Re: Scale changes after reading .dat using EEGLAB Import

Post by Ryan » 23 Mar 2015, 12:11

Hi Chad and Peter,

Thank you for the informative replies. That totally solved my problem regarding the first question. Really appreciate it.

For the second question, I have the same question as Chad.

I am using EGI's GES300 amplifier to stream EEG data to BCI2000.
I have configured the "SourceFilter" in the "Source" tab, rather than "Signal Processing" module.
It says in the Wiki that "the SourceFilter filter will be applied immediately after data acquisition, and it will modify the data which will be saved to disk, i.e., it will behave just as if it were a hardware filter built into the amplifier" [1].
I'd like to double check that this is the case.

Thanks,
Ran


1. "http://www.bci2000.org/wiki/index.php/U ... r#Function"

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

Re: Scale changes after reading .dat using EEGLAB Import

Post by pbrunner » 23 Mar 2015, 14:08

Ryan,

Chad's statement is absolutely correct. If you are using the SourceFilter then the "filtered" data should be stored. That being said, the filter order of the Butterworth filter is 2, which given the 1/f characteristics of the EEG signal may not be extremely visually apparent [1]. If this is necessary for your application, you could modify the filter order in the SourceFilter.cpp, however I would rather recommend to store the data "unfiltered" and use the filter settings in the visualization. You can also if needed for your processing use the IIRFilter in the SignalProcessing pipeline with higher filter orders. Both alternatives will preserve the original signal for post-hoc analysis.

Regards, Peter

[1] http://www.electronics-tutorials.ws/filter/fil57.gif
[2] http://www.bci2000.org/wiki/index.php/P ... Base_Class

Ryan
Posts: 29
Joined: 27 Aug 2010, 15:03

Re: Scale changes after reading .dat using EEGLAB Import

Post by Ryan » 23 Mar 2015, 14:53

Thank you Peter.
That's very well explained.
Just one more question related to the filter, the source filter is applied to EEG in sample-block basis, is that right?

Thanks,
Ran

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: Scale changes after reading .dat using EEGLAB Import

Post by boulay » 23 Mar 2015, 15:29

The signal gets passed to the filter one block at a time, but the filter implementation processes one sample at a time. See from line 130 at ref [1]. It's an IIRFilter. It is not necessary to retain a buffer of past data; the filter state is updated on each sample. Whether you run 1000 samples through the filter and end up in a given state, or if you initialize a filter with 0 samples and set it to that specific state, the result is identical.

[1] http://www.bci2000.org/tracproj/browser ... IRFilter.h

Ryan
Posts: 29
Joined: 27 Aug 2010, 15:03

Re: Scale changes after reading .dat using EEGLAB Import

Post by Ryan » 23 Mar 2015, 15:34

Thank you, Chad!
Ran

sarwanov
Posts: 1
Joined: 03 May 2015, 04:34

Re: Scale changes after reading .dat using EEGLAB Import

Post by sarwanov » 03 May 2015, 04:37

That's good post you have shared.Great Job

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest