aspen.processings.filter_signal

Filter a signal

Functions

filter_signal(x, btype, filter_freq[, …])

Filter a signal.

Classes

FilterSignal(filter_signal_btype, …[, …])

Filter a signal.

class aspen.processings.filter_signal.FilterSignal(filter_signal_btype, filter_signal_filter_freq, filter_signal_impulse_response='fir', filter_signal_filter_order=None, filter_signal_firwindow='hann', samp_freq=16000)[source]

Bases: aspen.interfaces.abs_common_interface.AbsCommonInterface, aspen.interfaces.abs_processing_interface.AbsProcessingInterface

Filter a signal.

Parameters
  • filter_signal_btype (str) – The type of filter.

  • filter_signal_filter_freq (Union[str, float, ndarray]) – Cutoff frequency. In the case of bandpass or bandstop, specify the lower/upper freqencies splitted by the underscore symbol (e.g. 800_1200).

  • filter_signal_impulse_response (str) – Type of impulse response of filter. Defaults to “fir”.

  • filter_signal_filter_order (Optional[int]) – Number of the filter order. Defaults to “None”. This means that the filter order set 512 for fir and 2 for iir, respectively.

  • filter_signal_firwindow (str) – Type of FIR window for filtering noise. Window function is listed in Scipy doc. (https://docs.scipy.org/doc/scipy/reference/signal.windows.html) Use only when impulse-response=fir”. Defaults to “hann”.

  • samp_freq (int) – Sampling frequency. Defaults to 16000.

__call__(x)[source]

Apply signal filtering

Parameters

x (ndarray) – Input signal

Return type

ndarray

Returns

Output signal

static add_arguments(parser)[source]

add arguments

classmethod load_class_kwargs(args)

Return the kwargs dict for class __init__ from parsed arguments

Parameters

args (Namespace) – (config)argparse arguments

Return type

dict

Returns

kwargs for class __init__

aspen.processings.filter_signal.filter_signal(x, btype, filter_freq, impulse_response='fir', filter_order=None, firwindow='hann', samp_freq=16000)[source]

Filter a signal.

Parameters
  • x (ndarray) – Input signal

  • btype (str) – The type of filter.

  • filter_freq (Union[str, float, ndarray]) – Cutoff frequency. In the case of bandpass or bandstop, specify the lower/upper freqencies splitted by the underscore symbol (e.g. 800_1200).

  • impulse_response (str) – Type of impulse response of filter. Defaults to “fir”.

  • filter_order (Optional[int]) – Number of the filter order. Defaults to “None”. This means that the filter order set 512 for fir and 2 for iir, respectively.

  • firwindow (str) – Type of FIR window for filtering noise. Window function is listed in Scipy doc. (https://docs.scipy.org/doc/scipy/reference/signal.windows.html) Use only when impulse-response=fir”. Defaults to “hann”.

  • samp_freq (int) – Sampling frequency. Defaults to 16000.

Return type

ndarray

Returns

Output signal