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.
(self, inst, event_id=None, include=None, exclude=None)
| 388 | return X |
| 389 | |
| 390 | def apply(self, inst, event_id=None, include=None, exclude=None): |
| 391 | """Remove selected components from the signal. |
| 392 | |
| 393 | Given the unmixing matrix, transform data, |
| 394 | zero out components, and inverse transform the data. |
| 395 | This procedure will reconstruct the signals from which |
| 396 | the dynamics described by the excluded components is subtracted. |
| 397 | |
| 398 | Parameters |
| 399 | ---------- |
| 400 | inst : instance of Raw | Epochs | Evoked |
| 401 | The data to be processed. |
| 402 | event_id : dict | list of str | None (default None) |
| 403 | The kind of event to apply. if None, a dict of inst will be return |
| 404 | one for each type of event xdawn has been fitted. |
| 405 | include : array_like of int | None (default None) |
| 406 | The indices referring to columns in the ummixing matrix. The |
| 407 | components to be kept. If None, the first n_components (as defined |
| 408 | in the Xdawn constructor) will be kept. |
| 409 | exclude : array_like of int | None (default None) |
| 410 | The indices referring to columns in the ummixing matrix. The |
| 411 | components to be zeroed out. If None, all the components except the |
| 412 | first n_components will be exclude. |
| 413 | |
| 414 | Returns |
| 415 | ------- |
| 416 | out : dict |
| 417 | A dict of instance (from the same type as inst input) for each |
| 418 | event type in event_id. |
| 419 | """ |
| 420 | if event_id is None: |
| 421 | event_id = self.event_id_ |
| 422 | |
| 423 | if not isinstance(inst, BaseRaw | BaseEpochs | Evoked): |
| 424 | raise ValueError("Data input must be Raw, Epochs or Evoked type") |
| 425 | picks = _pick_data_channels(inst.info) |
| 426 | |
| 427 | # Define the components to keep |
| 428 | default_exclude = list(range(self.n_components, len(inst.ch_names))) |
| 429 | if exclude is None: |
| 430 | exclude = default_exclude |
| 431 | else: |
| 432 | exclude = list(set(list(default_exclude) + list(exclude))) |
| 433 | |
| 434 | if isinstance(inst, BaseRaw): |
| 435 | out = self._apply_raw( |
| 436 | raw=inst, |
| 437 | include=include, |
| 438 | exclude=exclude, |
| 439 | event_id=event_id, |
| 440 | picks=picks, |
| 441 | ) |
| 442 | elif isinstance(inst, BaseEpochs): |
| 443 | out = self._apply_epochs( |
| 444 | epochs=inst, |
| 445 | include=include, |
| 446 | picks=picks, |
| 447 | exclude=exclude, |