MCPcopy Index your code
hub / github.com/mne-tools/mne-python / fit

Method fit

mne/decoding/csp.py:836–866  ·  view source on GitHub ↗

Estimate the SPoC decomposition on epochs. Parameters ---------- X : ndarray, shape (n_epochs, n_channels, n_times) The data on which to estimate the SPoC. y : array, shape (n_epochs,) The class for each epoch. Returns -------

(self, X, y)

Source from the content-addressed store, hash-verified

834 self.R_func = None
835
836 def fit(self, X, y):
837 """Estimate the SPoC decomposition on epochs.
838
839 Parameters
840 ----------
841 X : ndarray, shape (n_epochs, n_channels, n_times)
842 The data on which to estimate the SPoC.
843 y : array, shape (n_epochs,)
844 The class for each epoch.
845
846 Returns
847 -------
848 self : instance of SPoC
849 Returns the modified instance.
850 """
851 X, y = self._check_data(X, y=y, fit=True, return_y=True)
852 self._validate_params(y=y)
853
854 super(CSP, self).fit(X, y)
855
856 pick_filters = self.filters_[: self.n_components]
857 X = np.asarray([np.dot(pick_filters, epoch) for epoch in X])
858
859 # compute features (mean band power)
860 X = (X**2).mean(axis=-1)
861
862 # To standardize features
863 self.mean_ = X.mean(axis=0)
864 self.std_ = X.std(axis=0)
865
866 return self
867
868 def transform(self, X):
869 """Estimate epochs sources given the SPoC filters.

Callers 1

test_spocFunction · 0.95

Calls 4

_check_dataMethod · 0.45
_validate_paramsMethod · 0.45
fitMethod · 0.45
meanMethod · 0.45

Tested by 1

test_spocFunction · 0.76