mne.filter.notch_filter

mne.filter.notch_filter(x, Fs, freqs, filter_length='10s', notch_widths=None, trans_bandwidth=1, method='fft', iir_params=None, mt_bandwidth=None, p_value=0.05, picks=None, n_jobs=1, copy=True, verbose=None)

Notch filter for the signal x.

Applies a zero-phase notch filter to the signal x, operating on the last dimension.

Parameters:

x : array

Signal to filter.

Fs : float

Sampling rate in Hz.

freqs : float | array of float | None

Frequencies to notch filter in Hz, e.g. np.arange(60, 241, 60). None can only be used with the mode ‘spectrum_fit’, where an F test is used to find sinusoidal components.

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. Not used for ‘iir’ filters.

notch_widths : float | array of float | None

Width of the stop band (centred at each freq in freqs) in Hz. If None, freqs / 200 is used.

trans_bandwidth : float

Width of the transition band in Hz. Not used if ‘order’ is specified in iir_params.

method : str

‘fft’ will use overlap-add FIR filtering, ‘iir’ will use IIR forward-backward filtering (via filtfilt). ‘spectrum_fit’ will use multi-taper estimation of sinusoidal components. If freqs=None and method=’spectrum_fit’, significant sinusoidal components are detected using an F test, and noted by logging.

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.

mt_bandwidth : float | None

The bandwidth of the multitaper windowing function in Hz. Only used in ‘spectrum_fit’ mode.

p_value : float

p-value to use in F-test thresholding to determine significant sinusoidal components to remove when method=’spectrum_fit’ and freqs=None. Note that this will be Bonferroni corrected for the number of frequencies, so large p-values may be justified.

picks : array-like of int | None

Indices to filter. If None all indices will be filtered.

n_jobs : int | str

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

copy : bool

If True, a copy of x, filtered, is returned. Otherwise, it operates on x in place.

verbose : bool, str, int, or None

If not None, override default verbose level (see mne.verbose).

Returns:

xf : array

x filtered.

Notes

The frequency response is (approximately) given by:

----------         -----------
         |\       /|
         | \     / |
         |  \   /  |
         |   \ /   |
         |    -    |
         |    |    |
        Fp1 freq  Fp2

For each freq in freqs, where:

Fp1 = freq - trans_bandwidth / 2 in Hz Fs2 = freq + trans_bandwidth / 2 in Hz

References

Multi-taper removal is inspired by code from the Chronux toolbox, see www.chronux.org and the book “Observed Brain Dynamics” by Partha Mitra & Hemant Bokil, Oxford University Press, New York, 2008. Please cite this in publications if method ‘spectrum_fit’ is used.