Skip to content

[Class] Time Domain Filter

João Saraiva edited this page May 27, 2022 · 1 revision

This class allows you to design time domain filters! Conventional time filters apply a convolution operation to a window sliding through the samples.

How to instantiate a Filter

Give the following design properties:

  • 📶 operation: The convolution operation to apply to each segment. Choose one from ConvolutionOperation:

    • MEDIAN - Median of the window' samples
    • HAMMING - Hamming window
    • HANN - Hann window
    • PARZEN - Parzen window
    • KAISER - Kaiser window
    • GAUSSIAN - Gaussian or Normal window
  • ↔️ window_length: The length of the window (in timedelta).

  • overlap_length: The overlap between adjecent windows when sliding (in timdelta).

  • **options: Other parameters to be passed to scipy filtering function -- optional.

Example of a Median filter of length 2s and 0.5s of overlap

filter = TimeDomainFilter(ConvolutionOperation.MEDIAN, timedelta(seconds=2), timedelta(seconds=0.5))

Example of 2s filter with the Hamming window

filter = TimeDomainFilter(ConvolutionOperation.HAMMING, timedelta(seconds=2))

Getters and Setters

You can get and reset any of the properties given at instantiation.

Apply Filter

It's so easy, let's do it 👩🏽‍💻! To apply a Filter you have designed (e.g. f1) to a Biosignal, just call filter from that Biosignal and give f1:

biosignal.filter(f1)

The filter will be applied to every channel of biosignal and return 0 in case of success.