Apply Xdawn dim reduction. Parameters ---------- inst : Epochs | Evoked | ndarray, shape ([n_epochs, ]n_channels, n_times) Data on which Xdawn filters will be applied. Returns ------- X : ndarray, shape ([n_epochs, ]n_components * n_event
(self, inst)
| 357 | return self |
| 358 | |
| 359 | def transform(self, inst): |
| 360 | """Apply Xdawn dim reduction. |
| 361 | |
| 362 | Parameters |
| 363 | ---------- |
| 364 | inst : Epochs | Evoked | ndarray, shape ([n_epochs, ]n_channels, n_times) |
| 365 | Data on which Xdawn filters will be applied. |
| 366 | |
| 367 | Returns |
| 368 | ------- |
| 369 | X : ndarray, shape ([n_epochs, ]n_components * n_event_types, n_times) |
| 370 | Spatially filtered signals. |
| 371 | """ # noqa: E501 |
| 372 | if isinstance(inst, BaseEpochs): |
| 373 | X = inst.get_data(copy=False) |
| 374 | elif isinstance(inst, Evoked): |
| 375 | X = inst.data |
| 376 | elif isinstance(inst, np.ndarray): |
| 377 | X = inst |
| 378 | if X.ndim not in (2, 3): |
| 379 | raise ValueError(f"X must be 2D or 3D, got {X.ndim}") |
| 380 | else: |
| 381 | raise ValueError("Data input must be of Epoch type or numpy array") |
| 382 | |
| 383 | filters = [filt[: self.n_components] for filt in self.filters_.values()] |
| 384 | filters = np.concatenate(filters, axis=0) |
| 385 | X = np.dot(filters, X) |
| 386 | if X.ndim == 3: |
| 387 | X = X.transpose((1, 0, 2)) |
| 388 | return X |
| 389 | |
| 390 | def apply(self, inst, event_id=None, include=None, exclude=None): |
| 391 | """Remove selected components from the signal. |