'Remove selected components from the signal.
Given the unmixing matrix, transform data,
zero out components, and inverse transform the data.
This procedure will reconstruct the signals from which
the dynamics described by the excluded components is subtracted.
Parameters
inst : instance of Raw | Epochs | Evoked
The data to be processed.
event_id : dict | list of str | None (default None)
The kind of event to apply. if None, a dict of inst will be return
one for each type of event xdawn has been fitted.
include : array_like of int | None (default None)
The indices referring to columns in the ummixing matrix. The
components to be kept. If None, the first n_components (as defined
in the Xdawn constructor) will be kept.
exclude : array_like of int | None (default None)
The indices referring to columns in the ummixing matrix. The
components to be zeroed out. If None, all the components except the
first n_components will be exclude.
Returns
out : dict of instance
A dict of instance (from the same type as inst input) for each
event type in event_id.'

def apply(self, inst, event_id=None, include=None, exclude=None):

    if (event_id is None):
        event_id = self.event_id_
    if (not isinstance(inst, (BaseRaw, BaseEpochs, Evoked))):
        raise ValueError('Data    input    must    be    Raw,    Epochs    or    Evoked    type')
    picks = _pick_data_channels(inst.info)
    default_exclude = list(range(self.n_components, len(inst.ch_names)))
    if (exclude is None):
        exclude = default_exclude
    else:
        exclude = list(set((list(default_exclude) + list(exclude))))
    if isinstance(inst, BaseRaw):
        out = self._apply_raw(raw=inst, include=include, exclude=exclude, event_id=event_id, picks=picks)
    elif isinstance(inst, BaseEpochs):
        out = self._apply_epochs(epochs=inst, include=include, picks=picks, exclude=exclude, event_id=event_id)
    elif isinstance(inst, Evoked):
        out = self._apply_evoked(evoked=inst, include=include, picks=picks, exclude=exclude, event_id=event_id)
    return out
