'Fit the spatial filters.
Parameters
X : array, shape (n_epochs, n_channels, n_times)
The data to be filtered.
y : None | array, shape (n_samples,)
Used for scikit-learn compatibility.
Returns
self : Instance of UnsupervisedSpatialFilter
Return the modified instance.'

def fit(self, X, y=None):

    if self.average:
        X = np.mean(X, axis=0).T
    else:
        (n_epochs, n_channels, n_times) = X.shape
        X = np.transpose(X, (1, 0, 2)).reshape((n_channels, (n_epochs * n_times))).T
    self.estimator.fit(X)
    return self
