'Translate mne_events to epoch zero times (t0).
First mne events (trigger transitions) are converted into DACQ events.
Then the zero times for the epochs are obtained by considering the
reference and conditional (required) events and the delay to stimulus.'

def _mne_events_to_category_t0(self, cat, mne_events, sfreq):

    cat_ev = cat['event']
    cat_reqev = cat['reqevent']
    events = self._events_mne_to_dacq(mne_events)
    times = events[:, 0]
    refEvents_inds = np.where((events[:, 2] & (1 << (cat_ev - 1))))[0]
    refEvents_t = times[refEvents_inds]
    if cat_reqev:
        reqEvents_inds = np.where((events[:, 2] & (1 << (cat_reqev - 1))))[0]
        reqEvents_t = times[reqEvents_inds]
        twin = [0, (((-1) ** cat['reqwhen']) * cat['reqwithin'])]
        win = np.round((np.array(sorted(twin)) * sfreq))
        refEvents_wins = (refEvents_t[:, None] + win)
        req_acc = np.zeros(refEvents_inds.shape, dtype=bool)
        for t in reqEvents_t:
            reqEvent_in_win = np.logical_and((t >= refEvents_wins[:, 0]), (t <= refEvents_wins[:, 1]))
            req_acc |= reqEvent_in_win
        refEvents_inds = refEvents_inds[np.where(req_acc)]
        refEvents_t = times[refEvents_inds]
    refEvents_t += int(np.round((self._events[cat_ev]['delay'] * sfreq)))
    return refEvents_t
