'Fit the spatial filters.
.. note : EMS is fitted on data normalized by channel type before the
fitting of the spatial filters.
Parameters
X : array, shape (n_epochs, n_channels, n_times)
The training data.
y : array of int, shape (n_epochs)
The target classes.
Returns
self : returns and instance of self.'

def fit(self, X, y):

    classes = np.unique(y)
    if (len(classes) != 2):
        raise ValueError('EMS    only    works    for    binary    classification.')
    self.classes_ = classes
    filters = (X[(y == classes[0])].mean(0) - X[(y == classes[1])].mean(0))
    filters /= np.linalg.norm(filters, axis=0)[None, :]
    self.filters_ = filters
    return self
