def _read_eeglab_events(eeg, event_id=None, event_id_func='strip_to_integer'):
    """Create events array from EEGLAB structure

    An event array is constructed by looking up events in the
    event_id, trying to reduce them to their integer part otherwise, and
    entirely dropping them (with a warning) if this is impossible.
    Returns a 1x3 array of zeros if no events are found."""
    if event_id_func is 'strip_to_integer':
        event_id_func = _strip_to_integer
    if event_id is None:
        event_id = dict()

    types = [event.type for event in eeg.event]
    latencies = [event.latency for event in eeg.event]
    if "boundary" in types and "boundary" not in event_id:
        warn("The data contains 'boundary' events, indicating data "
             "discontinuities. Be cautious of filtering and epoching around "
             "these events.")

    not_in_event_id = set(x for x in types if x not in event_id)
    not_purely_numeric = set(x for x in not_in_event_id if not x.isdigit())
    no_numbers = set([x for x in not_purely_numeric
                      if not any([d.isdigit() for d in x])])
    have_integers = set([x for x in not_purely_numeric
                         if x not in no_numbers])
    if len(not_purely_numeric) > 0:
        basewarn = "Events like the following will be dropped"
        n_no_numbers, n_have_integers = len(no_numbers), len(have_integers)
        if n_no_numbers > 0:
            no_num_warm = " entirely: {0}, {1} in total"
            warn(basewarn + no_num_warm.format(list(no_numbers)[:5],
                                               n_no_numbers))
        if n_have_integers > 0 and event_id_func is None:
            intwarn = (", but could be reduced to their integer part "
                       "instead with the default `event_id_func`: "
                       "{0}, {1} in total")
            warn(basewarn + intwarn.format(list(have_integers)[:5],
                                           n_have_integers))

    events = list()
    for tt, latency in zip(types, latencies):
        try:  # look up the event in event_id and if not, try event_id_func
            event_code = event_id[tt] if tt in event_id else event_id_func(tt)
            events.append([int(latency), 1, event_code])
        except (ValueError, __HOLE__):  # if event_id_func fails
            pass  # We're already raising warnings above, so we just drop

    if len(events) < len(types):
        warn("Some event codes could not be mapped to integers. Use the "
             "`event_id` parameter to map such events to integers manually.")
    if len(events) < 1:
        warn("No events found, consider adding an `event_id`. As is, the "
             "trigger channel will consist entirely of zeros.")
        return np.zeros((0, 3))
    else:
        return np.asarray(events)
dataset/ETHPy150Open mne-tools/mne-python/mne/io/eeglab/eeglab.py/_read_eeglab_events