Estimate the CSP decomposition on epochs. Parameters ---------- X : ndarray, shape (n_epochs, n_channels, n_times) The data on which to estimate the CSP. y : array, shape (n_epochs,) The class for each epoch. Returns -------
(self, X, y)
| 244 | _validate_type(self.cov_method_params, (abc.Mapping, None), "cov_method_params") |
| 245 | |
| 246 | def fit(self, X, y): |
| 247 | """Estimate the CSP decomposition on epochs. |
| 248 | |
| 249 | Parameters |
| 250 | ---------- |
| 251 | X : ndarray, shape (n_epochs, n_channels, n_times) |
| 252 | The data on which to estimate the CSP. |
| 253 | y : array, shape (n_epochs,) |
| 254 | The class for each epoch. |
| 255 | |
| 256 | Returns |
| 257 | ------- |
| 258 | self : instance of CSP |
| 259 | Returns the modified instance. |
| 260 | """ |
| 261 | X, y = self._check_data(X, y=y, fit=True, return_y=True) |
| 262 | self._validate_params(y=y) |
| 263 | |
| 264 | # Covariance estimation, GED/AJD |
| 265 | # and evecs/evals sorting happen here |
| 266 | super().fit(X, y) |
| 267 | |
| 268 | pick_filters = self.filters_[: self.n_components] |
| 269 | X = np.asarray([np.dot(pick_filters, epoch) for epoch in X]) |
| 270 | |
| 271 | # compute features (mean power) |
| 272 | X = (X**2).mean(axis=2) |
| 273 | |
| 274 | # To standardize features |
| 275 | self.mean_ = X.mean(axis=0) |
| 276 | self.std_ = X.std(axis=0) |
| 277 | |
| 278 | return self |
| 279 | |
| 280 | def transform(self, X): |
| 281 | """Estimate epochs sources given the CSP filters. |