MneExperiment.label_events(self, ds)

Add event labels to events loaded from raw files

ds : Dataset

A Dataset containing events (with variables as returned by


Override this method in MneExperiment subclasses to add event labels more flexibly than through the variables attribute. The session that the events are from can be determined with['session']. Calling the original (super-class) method is not necessary.


Add a label whenever trigger 2 follows trigger 1:

class Experiment(MneExperiment):

    def label_events(self, ds):
        # assign 'no' to all events
        ds[:, 'new'] = 'no'
        # assign 'yes' to events where trigger 2 follows trigger 1
        for i in range(1, ds.n_cases):
            if ds[i, 'trigger'] == 2 and ds[i-1, 'trigger'] == 1:
                ds[i, 'new'] = 'yes'
        return ds