# Connexions

You are here: Home » Content » Filter Selection and Construction

### Recently Viewed

This feature requires Javascript to be enabled.

# Filter Selection and Construction

## Filter Form Selection

### Open Ephys Requirements

The vast majority of neural signals require some form of bandpass filtering to be useful. In general, the DC offset must be removed from signals, along with the high-frequency noise, leaving the actual neural data of interest. The Open Ephys GUI employs a simple 4-pole Butterworth bandpass filter for its filtering. An IIR filter is used because the group delay in the pass-band is lower than that of a FIR filter. For garnering a fast response time, keeping the group delay at a minimum is important. While it is impossible for IIR filters to have a linear phase response, the pass-band response has a relatively linear phase. Creating and optimizing a digital IIR Butterworth bandpass filter that operates on a large number of channels will provide the Open Ephys project with a fast filtering solution for the GUI.

### Filter Setup

Reasonable digital low-pass and high-pass IIR filters can be designed using only two zeros and two poles. This is commonly known as the digital biquad filter. The difference equation for a digital biquad filter is given below:

y [ n ] = b 2 x [ n ] + b 1 x [ n - 1 ] + b 2 x [ n - 2 ] - a 2 y [ n - 2 ] - a 1 y [ n - 1 ] y [ n ] = b 2 x [ n ] + b 1 x [ n - 1 ] + b 2 x [ n - 2 ] - a 2 y [ n - 2 ] - a 1 y [ n - 1 ]
(1)

And corresponding transfer function:

H ( z ) = b 0 + b 1 z - 1 + b 2 z - 2 1 + a 1 z - 1 + a 2 z - 2 H ( z ) = b 0 + b 1 z - 1 + b 2 z - 2 1 + a 1 z - 1 + a 2 z - 2
(2)

To create a bandpass filter with tunable low and high cutoff frequencies, we can simply cascade a low-pass and a high-pass filter. Cascading the filters is equivalent to multiplying the frequency responses of the two digital biquads, which creates a transfer function with 4 poles and 4 zeros:

H ( z ) = b 0 + b 1 z - 1 + b 2 z - 2 + b 3 z - 3 + b 4 z - 4 1 + a 1 z - 1 + a 2 z - 2 + b 3 z - 3 + b 4 z - 4 H ( z ) = b 0 + b 1 z - 1 + b 2 z - 2 + b 3 z - 3 + b 4 z - 4 1 + a 1 z - 1 + a 2 z - 2 + b 3 z - 3 + b 4 z - 4
(3)

To generate the filter coefficients for a typical bandpass filter for neuroscience experiments, we used MATLAB's Butterworth filter generator with a passband frequency range from 0.1 to 300 Hz and an order of 4:

[b,a] = butter(2,[0.1 300]/25000)


## Direct Form II Transposed Filter

### Implementing the Filter

Transpose-form filters are derived as a result of the flow-graph reversal theorem. The filter assumes 0 for all initial conditions. The figure below shows the block diagram for a digital biquad filter. For the bandpass filter that we are building, we need to add two additional transposed stages to account for the second biquad. The final transposed filter structure is shown in Figure 1 below.

We defined the transposed filter mathematically by a series of equations. Intermediate variables were assigned to the central stages.

y [ n ] = b 0 x [ n ] + w 1 [ n - 1 ] y [ n ] = b 0 x [ n ] + w 1 [ n - 1 ]
(4)
w 1 [ n ] = b 1 x [ n ] - a 1 y [ n ] + w 2 [ n - 1 ] w 1 [ n ] = b 1 x [ n ] - a 1 y [ n ] + w 2 [ n - 1 ]
(5)
w 2 [ n ] = b 2 x [ n ] - a 2 y [ n ] + w 3 [ n - 1 ] w 2 [ n ] = b 2 x [ n ] - a 2 y [ n ] + w 3 [ n - 1 ]
(6)
w 3 [ n ] = b 3 x [ n ] - a 3 y [ n ] + w 4 [ n - 1 ] w 3 [ n ] = b 3 x [ n ] - a 3 y [ n ] + w 4 [ n - 1 ]
(7)
w 4 [ n ] = b 4 x [ n ] - a 4 y [ n ] w 4 [ n ] = b 4 x [ n ] - a 4 y [ n ]
(8)

This system of difference equations appears to be very different from the difference equation we require, but quick substitution of the intermediate ww functions shows that the difference equation is no different from a cascade of digital biquad filters.

### Motivation for Use

The Direct Form II Transposed filter is fundamentally the same as other filter configurations. However, it differs because it requires fewer delay units and therefore fewer memory accesses. We can henceforth expect that this filter transposition applies to this implementation as it achieves high function throughput without added register pipelining. Utilizing a Direct Form I filter implementation would require us to constantly keep track of 4 previous inputs and 4 previous outputs. This form allows us to keep track of only 4 intermediate values, and use the current inputs and outputs for calculations.

## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks