pyntbci.utilities.filterbank

pyntbci.utilities.filterbank(X: ndarray[Any, dtype[_ScalarType_co]], passbands: list[tuple[float, float]], fs: float, tmin: float | None = None, ftype: str = 'butterworth', N: int | list[int] | None = None, stopbands: list[tuple[float, float]] | None = None, gpass: float | list[float] = 3.0, gstop: float | list[float] = 40.0) ndarray[Any, dtype[_ScalarType_co]][source]

Apply a filterbank. Note, the order of the filter is set according to the maximum loss in the passband and the minimum loss in the stopband.

Parameters:
  • X (NDArray) – The matrix of EEG data of shape (n_trials, n_channels, n_samples).

  • passbands (list[tuple[float, float]]) – A list of tuples with passbands defined as (lower, higher) cutoff in Hz.

  • fs (int) – The sampling frequency of the EEG data in Hz.

  • tmin (float (default: None)) – The window before trial onset that can catch any filter artefacts and will be cut off after filtering. If None, no data will be cut away.

  • ftype (str (default: "butterworth")) – The filter type: “butterworth” | “chebyshev1”

  • N (int | list[int] (default: None)) – The filter order. If a list is provided, it is the order for each passband. If None, the order is set given the stopbands, gpass and gstop.

  • stopbands (list[tuple[float, float]] (default: None)) – A tuple of tuples with a stopband for each passband defined as (lower, higher) cutoff in Hz. If None, the stopbands default to (lower-2, higher+7) of the passbands. Only used if N=None.

  • gpass (float | list[float] (default: 3.0)) – The maximum loss in the passband (dB). If a list is provided, it is the gpass for each passband. Only used if N=None.

  • gstop (float | list[float] (default: 30.0)) – The minimum attenuation in the stopband (dB). If a list is provided, it is the gstop for each stopband. Only used if N=None.

Returns:

X – The matrix of EEG data of shape (n_trials, n_channels, n_samples, n_passbands). If tmin is not None, n_samples will be reduced with tmin * fs number of samples.

Return type:

NDArray