#NEWLINE# @ verbose #NEWLINE# def filter( self , l_freq , h_freq , picks = None , filter_length = '10s' , l_trans_bandwidth = 0.5 , h_trans_bandwidth = 0.5 , n_jobs = 1 , method = 'fft' , iir_params = None , verbose = None ) : #NEWLINE# #INDENT# 'Filter a subset of channels.\n\n        Applies a zero-phase low-pass, high-pass, band-pass, or band-stop\n        filter to the channels selected by ``picks``. By default the data\n        of the Raw object is modified inplace.\n\n        The Raw object has to have the data loaded e.g. with ``preload=True``\n        or ``self.load_data()``.\n\n        ``l_freq`` and ``h_freq`` are the frequencies below which and above\n        which, respectively, to filter out of the data. Thus the uses are:\n\n            * ``l_freq < h_freq``: band-pass filter\n            * ``l_freq > h_freq``: band-stop filter\n            * ``l_freq is not None and h_freq is None``: high-pass filter\n            * ``l_freq is None and h_freq is not None``: low-pass filter\n\n        ``self.info[\'lowpass\']`` and ``self.info[\'highpass\']`` are only\n        updated with picks=None.\n\n        .. note:: If n_jobs > 1, more memory is required as\n                  ``len(picks) * n_times`` additional time points need to\n                  be temporaily stored in memory.\n\n        Parameters\n        ----------\n        l_freq : float | None\n            Low cut-off frequency in Hz. If None the data are only low-passed.\n        h_freq : float | None\n            High cut-off frequency in Hz. If None the data are only\n            high-passed.\n        picks : array-like of int | None\n            Indices of channels to filter. If None only the data (MEG/EEG)\n            channels will be filtered.\n        filter_length : str (Default: \'10s\') | int | None\n            Length of the filter to use. If None or "len(x) < filter_length",\n            the filter length used is len(x). Otherwise, if int, overlap-add\n            filtering with a filter of the specified length in samples) is\n            used (faster for long signals). If str, a human-readable time in\n            units of "s" or "ms" (e.g., "10s" or "5500ms") will be converted\n            to the shortest power-of-two length at least that duration.\n            Not used for \'iir\' filters.\n        l_trans_bandwidth : float\n            Width of the transition band at the low cut-off frequency in Hz\n            (high pass or cutoff 1 in bandpass). Not used if \'order\' is\n            specified in iir_params.\n        h_trans_bandwidth : float\n            Width of the transition band at the high cut-off frequency in Hz\n            (low pass or cutoff 2 in bandpass). Not used if \'order\' is\n            specified in iir_params.\n        n_jobs : int | str\n            Number of jobs to run in parallel. Can be \'cuda\' if scikits.cuda\n            is installed properly, CUDA is initialized, and method=\'fft\'.\n        method : str\n            \'fft\' will use overlap-add FIR filtering, \'iir\' will use IIR\n            forward-backward filtering (via filtfilt).\n        iir_params : dict | None\n            Dictionary of parameters to use for IIR filtering.\n            See mne.filter.construct_iir_filter for details. If iir_params\n            is None and method="iir", 4th order Butterworth will be used.\n        verbose : bool, str, int, or None\n            If not None, override default verbose level (see mne.verbose).\n            Defaults to self.verbose.\n\n        Returns\n        -------\n        raw : instance of Raw\n            The raw instance with filtered data.\n\n        See Also\n        --------\n        mne.Epochs.savgol_filter\n        mne.io.Raw.notch_filter\n        mne.io.Raw.resample\n        ' #NEWLINE# fs = float ( self . info [ 'sfreq' ] ) #NEWLINE# if ( l_freq == 0 ) : #NEWLINE# #INDENT# l_freq = None #NEWLINE# #UNINDENT# if ( ( h_freq is not None ) and ( h_freq > ( fs / 2.0 ) ) ) : #NEWLINE# #INDENT# h_freq = None #NEWLINE# #UNINDENT# if ( ( l_freq is not None ) and ( not isinstance ( l_freq , float ) ) ) : #NEWLINE# #INDENT# l_freq = float ( l_freq ) #NEWLINE# #UNINDENT# if ( ( h_freq is not None ) and ( not isinstance ( h_freq , float ) ) ) : #NEWLINE# #INDENT# h_freq = float ( h_freq ) #NEWLINE# #UNINDENT# _check_preload ( self , 'raw.filter' ) #NEWLINE# if ( picks is None ) : #NEWLINE# #INDENT# picks = _pick_data_or_ica ( self . info ) #NEWLINE# if ( len ( picks ) < 1 ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Could not find any valid channels for your Raw object. Please contact the MNE-Python developers.' ) #NEWLINE# #UNINDENT# if ( h_freq is not None ) : #NEWLINE# #INDENT# if ( ( ( l_freq is None ) or ( l_freq < h_freq ) ) and ( ( self . info [ 'lowpass' ] is None ) or ( h_freq < self . info [ 'lowpass' ] ) ) ) : #NEWLINE# #INDENT# self . info [ 'lowpass' ] = h_freq #NEWLINE# #UNINDENT# #UNINDENT# if ( l_freq is not None ) : #NEWLINE# #INDENT# if ( ( ( h_freq is None ) or ( l_freq < h_freq ) ) and ( ( self . info [ 'highpass' ] is None ) or ( l_freq > self . info [ 'highpass' ] ) ) ) : #NEWLINE# #INDENT# self . info [ 'highpass' ] = l_freq #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( h_freq is not None ) or ( l_freq is not None ) ) : #NEWLINE# #INDENT# logger . info ( 'Filtering a subset of channels. The highpass and lowpass values in the measurement info will not be updated.' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( l_freq is None ) and ( h_freq is not None ) ) : #NEWLINE# #INDENT# logger . info ( ( 'Low-pass filtering at %0.2g Hz' % h_freq ) ) #NEWLINE# low_pass_filter ( self . _data , fs , h_freq , filter_length = filter_length , trans_bandwidth = h_trans_bandwidth , method = method , iir_params = iir_params , picks = picks , n_jobs = n_jobs , copy = False ) #NEWLINE# #UNINDENT# if ( ( l_freq is not None ) and ( h_freq is None ) ) : #NEWLINE# #INDENT# logger . info ( ( 'High-pass filtering at %0.2g Hz' % l_freq ) ) #NEWLINE# high_pass_filter ( self . _data , fs , l_freq , filter_length = filter_length , trans_bandwidth = l_trans_bandwidth , method = method , iir_params = iir_params , picks = picks , n_jobs = n_jobs , copy = False ) #NEWLINE# #UNINDENT# if ( ( l_freq is not None ) and ( h_freq is not None ) ) : #NEWLINE# #INDENT# if ( l_freq < h_freq ) : #NEWLINE# #INDENT# logger . info ( ( 'Band-pass filtering from %0.2g - %0.2g Hz' % ( l_freq , h_freq ) ) ) #NEWLINE# self . _data = band_pass_filter ( self . _data , fs , l_freq , h_freq , filter_length = filter_length , l_trans_bandwidth = l_trans_bandwidth , h_trans_bandwidth = h_trans_bandwidth , method = method , iir_params = iir_params , picks = picks , n_jobs = n_jobs , copy = False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . info ( ( 'Band-stop filtering from %0.2g - %0.2g Hz' % ( h_freq , l_freq ) ) ) #NEWLINE# self . _data = band_stop_filter ( self . _data , fs , h_freq , l_freq , filter_length = filter_length , l_trans_bandwidth = h_trans_bandwidth , h_trans_bandwidth = l_trans_bandwidth , method = method , iir_params = iir_params , picks = picks , n_jobs = n_jobs , copy = False ) #NEWLINE# #UNINDENT# #UNINDENT# return self