Filtering time series data


I am currently using Butterworth filters (notch - 60Hz, band-pass 1-200Hz, 4th order). My questions are:

  1. Can the filters be used in succession? I will perform the notch filtering first followed by band-pass.
  2. If I would like to remove harmonics of 60Hz, should I design multiple filters targeting specific harmonics? Can all these filters be used in succession?
  3. If I design a filter using dfilt.df2t for the notch, harmonics and band-pass, I can then cascade them using dfilt.cascade. However, the output of dfilt.cascade can only be used with filter. So should I perform filter in the forward direction, then reverse it and filter in the reverse direction on the raw signal - to mimic filtfilt function?
  4. If I am applying the filters to the raw signal should I still be concerned with tapering my data? I epoch the raw data after filtering and I have at least 1-2 seconds of edge data that does not get epoched.
    Thank you for taking the time to read my query.
  • Priya

Hi Priya. Is there any reason not to use an FIR filter? It might give better results than an IIR filter.

  1. Yes, particularly for a wide-band filter, re-filtering the data using different filter kernels might be a good idea. You might consider, for example, applying a high-pass filter at 1 Hz, then a low-pass filter at 200 Hz, and then the notch filters. It would be good to look at the impulse response function of your filter kernel to make sure it looks good. For an FIR filter, you simply plot the power spectrum of the filter kernel. For an IIR filter, you would create an impulse (all zeros and a 1 in the middle), filter that, and then look at the power spectrum of the filtered signal.

  2. Yes, but you can look at the power spectrum of the data first. If there aren’t strong harmonics, then there’s no need to notch them out.

  3. Definitely you’ll want to do zero-phase shift filtering. Either with filtfilt or by reversing it yourself.

  4. Nope, you should be fine with the continuous data.

Hope that helps!

Dear Mike,

Thank you so much for your response.

I had inherited the steps for EEG processing from my predecessor and did not make changes to them. He had used an IIR and I stayed with it. I am questioning these choices after spending some time with my data and your books. I am also creating a pipeline to compute cortico-muscular coherence so I am hyper aware of adding artifacts by choosing incorrect steps.

What are the benefits of an FIR over IIR? Isn’t IIR processing faster?

With regards,

Briefly: IIR filters are faster, but they are less stable and can induce phase perturbations. FIR filters are a bit slower but are more stable and more accurate. The thing is that 30 years ago, this was a real limitation, but on modern computers – and particularly for offline analyses – FIR filters are the way to go. In the best-case scenario, IIR and FIR will give equally good results, but IIR filters will never be better than FIR.