Decimation Filter

Forum for discussion on different signal processing algorithms
Locked
mtmccann
Posts: 3
Joined: 13 May 2009, 17:36

Decimation Filter

Post by mtmccann » 15 May 2009, 16:31

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.

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

decimation

Post by gschalk » 16 May 2009, 13:09

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

chazzd13
Posts: 14
Joined: 12 May 2010, 03:51

Re: Decimation Filter

Post by chazzd13 » 03 Jun 2011, 04:30

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

mellinger
Posts: 1064
Joined: 12 Feb 2003, 11:06

Re: Decimation Filter

Post by mellinger » 03 Jun 2011, 10:14

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

chazzd13
Posts: 14
Joined: 12 May 2010, 03:51

Re: Decimation Filter

Post by chazzd13 » 05 Jun 2011, 20:29

Thank you so much, Juergen. I will update my code to the latest revision and try that out.

Locked

Who is online

Users browsing this forum: No registered users and 1 guest