Page 1 of 1
Decimation Filter
Posted: 15 May 2009, 16:31
by mtmccann
I'm interested in creating a decimation filter to go in the middle of the BCI2000 filter chain, such that early filters can operate at one sampling rate and later filters can operate at another.
Is this possible? My understanding is that filters need to create an output sample for each input sample, which a decimation filter would not do.
decimation
Posted: 16 May 2009, 13:09
by gschalk
Hi,
Each filter in the filter chain takes an input signal and transforms it into an output signal. The output signal can have a different dimensionality (i.e., # channels or samples) than the input signal. Signal properties are defined in the Preflight() function using the SignalProperties operator. See
http://www.bci2000.org/wiki/index.php/P ... ion_Module
for an example.
Gerv
Re: Decimation Filter
Posted: 03 Jun 2011, 04:30
by chazzd13
Greetings.
I am also trying to implement a decimation filter for the mu rhythm BCI. However, it seems that later filters (e.g. ARFilter and LinearClassifier) query the initial SamplingRate and SampleBlockSize. Are there other dependencies or possible hurdles I should be aware of? Any help you can provide in getting this to work would be greatly appreciated.
Sincerely,
Charles
Re: Decimation Filter
Posted: 03 Jun 2011, 10:14
by mellinger
Hi,
since a few source code revisions back, filters do no longer query the original sampling rate. Rather, sampling rate is now a read-only property of the SignalProperties class (
http://www.bci2000.org/wiki/index.php/P ... ties_Class), and may be manipulated from the GenericFilter::Preflight() and GenericFilter::Initialize() member functions of your filter.
To indicate that decimation by a factor
decimationFactor has happened, use the following code in your decimation filter's Preflight() function:
Code: Select all
Output = Input;
Output.SetElements( Input.Elements() / decimationFactor );
Output.ElementUnit().SetGain( Input.ElementUnit().Gain() * decimationFactor );
You also need to take care that the decimation factor evenly divides the input's number of elements, e.g. by using an appropriate PreflightCondition() statement.
As you know, you will need to low-pass filter your data before decimating it in order to avoid subsampling artifacts. BCI2000 contains an IIRFilter base class, and a FilterDesign class that makes it easy to implement such a filter. For an example, see
src/shared/modules/signalsource/SourceFilter.
Best regards,
Juergen
Re: Decimation Filter
Posted: 05 Jun 2011, 20:29
by chazzd13
Thank you so much, Juergen. I will update my code to the latest revision and try that out.