'Create list of DACQ events based on mne trigger transitions list.
mne_events is typically given by mne.find_events (use consecutive=True
to get all transitions). Output consists of rows in the form
[t, 0, event_codes] where t is time in samples and event_codes is all
DACQ events compatible with the transition, bitwise ORed together:
e.g. [t1, 0, 5] means that events 1 and 3 occurred at time t1,
as 2**(1 - 1) + 2**(3 - 1) = 5.'

def _events_mne_to_dacq(self, mne_events):

    events_ = mne_events.copy()
    events_[:, 1:3] = 0
    for (n, ev) in self._events.items():
        if ev['in_use']:
            pre_ok = (np.bitwise_and(ev['oldmask'], mne_events[:, 1]) == ev['oldbits'])
            post_ok = (np.bitwise_and(ev['newmask'], mne_events[:, 2]) == ev['newbits'])
            ok_ind = np.where((pre_ok & post_ok))
            events_[(ok_ind, 2)] |= (1 << (n - 1))
    return events_
