*by Barry Van Veen*

Interest in signals that are a very small fraction of the sampling frequency is increasingly common due to the widespread availability of high speed digital-to-analog converters. For example, infra-slow oscillations (0.01 - 0.1 Hz) are sometimes of interest in electroencephalography (EEG) for understanding large-scale cortical organization. EEG signals are often sampled at 500 Hz or more. Isolating very low frequency signals requires a more sophisticated approach than directly filtering the data. The solution is to use downsampling to change the sampling rate.

## Very Low Frequency Filtering: The Problem

It is not wise to directly design an IIR low pass filter that has a passband a very small fraction, say less than 1%, of the sampling frequency. Such filters require extremely high numerical precision for both design and implementation. This is because IIR filters normally cluster poles close to the unit circle in the vicinity of frequencies corresponding to the passband. (See Frequency Response Magnitude from Poles and Zeros.) If the filter passband is a very small fraction of the sampling frequency, then the poles must be clustered very close together in the vicinity of in the -plane. The figure at left illustrates a low pass filter whose poles are about 0.001 from . Very small perturbations of the filter coefficients, such as caused by numerical rounding, can cause the poles to move slightly. The frequency response magnitude is very sensitive to the pole locations when poles are close to the unit circle, so slight movement of the poles ruins the desired frequency response.

To illustrate this problem, consider designing a first-order all pole lowpass filter. A difference equation describing this filter is

and the frequency response is

where is frequency in Hz and is the sampling frequency. Note that here we have written discrete-time frequency . Unit gain at is obtained when . Now suppose we find the pole location required to achieve a half-power cutoff frequency at Hz. A list of the values of required for decreasing values of is:

0.5441

0.9391

0.9937

0.9994

An example corresponding to the last case is Hz and Hz. Note that each factor of ten decrease in , decreases by approximately a factor of ten. The factor of 10 decrease from to corresponds to less than a one percent change in the pole location. Clearly the filter characteristics become extremely sensitive to pole locations when the poles are very close to the unit circle.

The problem illustrated above is even more severe for bandpass filters or higher order filters.

## Very Low Frequency Filtering: The Solution

Fortunately there is a simple solution to the very low frequency filtering problem. We can decrease the effective sampling rate by downsampling the signal. In its simplest implementation, downsampling involves throwing away samples. For example, in order to reduce the sampling rate by a factor of five, we only keep every fifth sample. Samples at indices which are not an integer multiple of five are discarded. This process can cause aliasing, so a discrete-time low pass filter is applied before discarding samples. This process is described in more detail in Downsampling: Reducing the Sampling Rate.

Large reductions in the sampling frequency are best accomplished in multiple stages, so that the lowpass filter applied before discarding data does not suffer from the very problem that we are trying to avoid. I usually like to limit the reduction in the sampling rate to a factor of ten in any one stage. For example, returning the the infra-slow EEG filtering problem, suppose we seek a Hz band pass filter but our data is sampled at Hz. I would successively reduce the sampling frequency by a factor of ten in each of three stages, as illustrated below. Hence the effective sampling rate at the output of the third stage is 1 Hz and the desired passband ranges from 1% to 10% of the sampling frequency. This leads to a much, much easier filtering problem.

Barry Van Veen says

The following question was posed by a member:

Analyzing slow cortical potentials of the EEG, I need to downsample from 250 Hz to 10 Hz.

(I am downsampling using decimate in Matlab without further specifications except the decimation factor)

In the blog post on “Very Low Frequency Filtering” downsampling in steps of 10 is recommended. Is a decimation factor of 25 still ok or should I downsample twice using a decimation factor of 5? (I have tried this but it resulted in an additional samplepoint in the data and I was a bit confused by this so I “decided” 25 is not that bad and focused on other things)

After seeing the blog post I am again a bit concerned… how big is the chance of getting worse data by downsampling in one step? Should I at least try both and compare results?

My response:

The potential problem with large downsampling factors (>10) is the lowpass filter used to prevent aliasing. As the downsampling factor increases, the filter passband decreases and the poles have to cluster closer together near z=1. This can result in numerical sensitivity. Is 25 too much? It is borderline in my opinion. I wouldn't do much more than 12, maybe 15. Numerical sensitivity can be difficult to exactly predict as to when it kicks in, because it is subject to numerical roundoff and finite precision arithmetic effects. For example, changing computers can change the precision of the computation. Your conclusions if you test a factor of 25 would only apply to that particular machine, and may vary for different data sets.

The other thing to keep in mind is that all filters have start up effects. Samples up to the length of the impulse response (which increases as the bandwidth decreases, BTW) are affected by the fact that the data is unknown (and usually assumed to be zero) before the record starts. MATLAB uses some tricks to try to minimize these sorts of start up transients, but it is best if you can structure your data to avoid them in the first place.

It sounds like you are downsampling individual EEG epochs, based on your comment about getting an extra data point. A much better approach, assuming you have access to the data, is to downsample before you break the data up into epochs. Then the start up effects of the lowpass filter used prior to discarding samples will not influence your data (other than possibly the first epoch).