'Vectorize time samples as trials, apply method and reshape back.
Parameters
X : array, shape (n_epochs, n_dims, n_times)
The data to be inverted.
Returns
X : array, shape (n_epochs, n_dims, n_times)
The transformed data.'

def _apply_method(self, X, method):

    (n_epochs, n_channels, n_times) = X.shape
    X = np.transpose(X, [1, 0, 2])
    X = np.reshape(X, [n_channels, (n_epochs * n_times)]).T
    method = getattr(self.estimator, method)
    X = method(X)
    X = np.reshape(X.T, [(-1), n_epochs, n_times]).transpose([1, 0, 2])
    return X
