This documentation is for development version 0.18.dev0.

mne.decoding.FilterEstimator

class mne.decoding.FilterEstimator(info, l_freq, h_freq, picks=None, filter_length='auto', l_trans_bandwidth='auto', h_trans_bandwidth='auto', n_jobs=1, method='fir', iir_params=None, fir_design='firwin', verbose=None)[source]

Estimator to filter RtEpochs.

Applies a zero-phase low-pass, high-pass, band-pass, or band-stop filter to the channels selected by “picks”.

l_freq and h_freq are the frequencies below which and above which, respectively, to filter out of the data. Thus the uses are:

  • l_freq < h_freq: band-pass filter
  • l_freq > h_freq: band-stop filter
  • l_freq is not None, h_freq is None: low-pass filter
  • l_freq is None, h_freq is not None: high-pass filter

If n_jobs > 1, more memory is required as “len(picks) * n_times” additional time points need to be temporarily stored in memory.

Parameters:
info : instance of Info

Measurement info.

l_freq : float | None

Low cut-off frequency in Hz. If None the data are only low-passed.

h_freq : float | None

High cut-off frequency in Hz. If None the data are only high-passed.

picks : str | list | slice | None

Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g., ['MEG0111', 'MEG2623'] will pick the given channels. Can also be the string values “all” to pick all channels, or “data” to pick data channels. None (default) will pick good data channels.

filter_length : str (Default: ’10s’) | int | None

Length of the filter to use. If None or “len(x) < filter_length”, the filter length used is len(x). Otherwise, if int, overlap-add filtering with a filter of the specified length in samples) is used (faster for long signals). If str, a human-readable time in units of “s” or “ms” (e.g., “10s” or “5500ms”) will be converted to the shortest power-of-two length at least that duration.

l_trans_bandwidth : float

Width of the transition band at the low cut-off frequency in Hz.

h_trans_bandwidth : float

Width of the transition band at the high cut-off frequency in Hz.

n_jobs : int | str

Number of jobs to run in parallel. Can be ‘cuda’ if cupy is installed properly and method=’fir’.

method : str

‘fir’ will use overlap-add FIR filtering, ‘iir’ will use IIR forward-backward filtering (via filtfilt).

iir_params : dict | None

Dictionary of parameters to use for IIR filtering. See mne.filter.construct_iir_filter for details. If iir_params is None and method=”iir”, 4th order Butterworth will be used.

fir_design : str

Can be “firwin” (default in 0.16) to use scipy.signal.firwin(), or “firwin2” (default in 0.15 and before) to use scipy.signal.firwin2(). “firwin” uses a time-domain design technique that generally gives improved attenuation using fewer samples than “firwin2”.

..versionadded:: 0.15

verbose : bool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).

See also

TemporalFilter

Notes

This is primarily meant for use in conjunction with mne.realtime.RtEpochs. In general it is not recommended in a normal processing pipeline as it may result in edge artifacts. Use with caution.

Methods

__hash__($self, /) Return hash(self).
fit(epochs_data, y) Filter data.
fit_transform(X[, y]) Fit to data, then transform it.
transform(epochs_data) Filter data.
__hash__($self, /)

Return hash(self).

fit(epochs_data, y)[source]

Filter data.

Parameters:
epochs_data : array, shape (n_epochs, n_channels, n_times)

The data.

y : array, shape (n_epochs,)

The label for each epoch.

Returns:
self : instance of FilterEstimator

Returns the modified instance

fit_transform(X, y=None, **fit_params)[source]

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters:
X : array, shape (n_samples, n_features)

Training set.

y : array, shape (n_samples,)

Target values.

Returns:
X_new : array, shape (n_samples, n_features_new)

Transformed array.

transform(epochs_data)[source]

Filter data.

Parameters:
epochs_data : array, shape (n_epochs, n_channels, n_times)

The data.

Returns:
X : array, shape (n_epochs, n_channels, n_times)

The data after filtering