MCPcopy
hub / github.com/mne-tools/mne-python / fit

Method fit

mne/decoding/csp.py:246–278  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 15

test_cspFunction · 0.95
test_regularized_cspFunction · 0.95
muscle_ica.pyFile · 0.45
eog_regression.pyFile · 0.45
xdawn_denoising.pyFile · 0.45

Calls 3

_validate_paramsMethod · 0.95
_check_dataMethod · 0.45
meanMethod · 0.45

Tested by 7

test_cspFunction · 0.76
test_regularized_cspFunction · 0.76
test_tpsFunction · 0.36
test_manual_report_2dFunction · 0.36