mne.decoding.TemporalFilter

class mne.decoding.TemporalFilter(l_freq=None, h_freq=None, sfreq=1.0, filter_length=’auto’, l_trans_bandwidth=’auto’, h_trans_bandwidth=’auto’, n_jobs=1, method=’fir’, iir_params=None, fir_window=’hamming’, verbose=None)[source]

Estimator to filter data array along the last dimension.

Applies a zero-phase low-pass, high-pass, band-pass, or band-stop filter to the channels.

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

See mne.filter.filter_data().

Parameters:

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.

sfreq : float, defaults to 1.0

Sampling frequency in Hz.

filter_length : str | int, defaults to ‘auto’

Length of the FIR filter to use (if applicable):

  • int: specified length in samples.
  • ‘auto’ (default in 0.14): the filter length is chosen based on the size of the transition regions (7 times the reciprocal of the shortest transition band).
  • str: (default in 0.13 is “10s”) a human-readable time in units of “s” or “ms” (e.g., “10s” or “5500ms”) will be converted to that number of samples if phase="zero", or the shortest power-of-two length at least that duration for phase="zero-double".

l_trans_bandwidth : float | str

Width of the transition band at the low cut-off frequency in Hz (high pass or cutoff 1 in bandpass). Can be “auto” (default in 0.14) to use a multiple of l_freq:

min(max(l_freq * 0.25, 2), l_freq)

Only used for method='fir'.

h_trans_bandwidth : float | str

Width of the transition band at the high cut-off frequency in Hz (low pass or cutoff 2 in bandpass). Can be “auto” (default in 0.14) to use a multiple of h_freq:

min(max(h_freq * 0.25, 2.), info['sfreq'] / 2. - h_freq)

Only used for method='fir'.

n_jobs : int | str, defaults to 1

Number of jobs to run in parallel. Can be ‘cuda’ if scikits.cuda is installed properly, CUDA is initialized, and method=’fft’.

method : str, defaults to ‘fir’

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

iir_params : dict | None, defaults to 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_window : str, defaults to ‘hamming’

The window to use in FIR design, can be “hamming”, “hann”, or “blackman”.

verbose : bool, str, int, or None, defaults to None

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

Methods

__hash__() <==> hash(x)
fit(X[, y]) Do nothing (for scikit-learn compatibility purposes).
fit_transform(X[, y]) Fit to data, then transform it.
transform(X) Filter data along the last dimension.
__hash__() <==> hash(x)
fit(X, y=None)[source]

Do nothing (for scikit-learn compatibility purposes).

Parameters:

X : array, shape (n_epochs, n_channels, n_times) or or shape (n_channels, n_times) # noqa

The data to be filtered over the last dimension. The channels dimension can be zero when passing a 2D array.

y : None

Not used, for scikit-learn compatibility issues.

Returns:

self : instance of Filterer

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 : numpy array of shape [n_samples, n_features]

Training set.

y : numpy array of shape [n_samples]

Target values.

Returns:

X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.

transform(X)[source]

Filter data along the last dimension.

Parameters:

X : array, shape (n_epochs, n_channels, n_times) or shape (n_channels, n_times) # noqa

The data to be filtered over the last dimension. The channels dimension can be zero when passing a 2D array.

Returns:

X : array, shape is same as used in input.

The data after filtering.