<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def eeg_add_events(raw, events_channel, conditions=None, treshold="auto", cut="higher", time_index=None, number="all", after=0, before=None, min_duration=1):
 """ Find events on a channel, convert them into an MNE compatible format, and add them to the raw data. Parameters raw : mne.io.Raw Raw EEG data. events_channel : str or array Name of the trigger channel if in the raw, or array of equal length if externally supplied. conditions : list List containing the stimuli types/conditions. treshold : float The treshold value by which to select the events. If "auto", takes the value between the max and the min. cut : str "higher" or "lower", define the events as above or under the treshold. For photosensors, a white screen corresponds usually to higher values. Therefore, if your events were signalled by a black colour, events values would be the lower ones, and you should set the cut to "lower". Add a corresponding datetime index, will return an addional array with the onsets as datetimes. number : str or int How many events should it select. after : int If number different than "all", then at what time should it start selecting the events. before : int If number different than "all", before what time should it select the events. min_duration : int The minimum duration of an event (in timepoints). Returns (raw, events, event_id) : tuple The raw file with events, the mne-formatted events and event_id. Example Notes *Authors* - `Dominique Makowski <https://dominiquemakowski.github.io/>`_ *Dependencies* - pandas *See Also* - mne: http://martinos.org/mne/dev/index.html References - None """

    # Extract the events_channel from raw if needed
    if isinstance(events_channel, str):
        try:
            events_channel = eeg_select_channels(raw, events_channel)
        except:
            print("NeuroKit error: eeg_add_events(): Wrong events_channel name provided.")

    # Find event onsets
    events = find_events(events_channel, treshold=treshold, cut=cut, time_index=time_index, number=number, after=after, before=before, min_duration=min_duration)

    # Create mne compatible events
    events, event_id = eeg_create_mne_events(events["onsets"], conditions)

    # Add them
    raw.add_events(events)

    return(raw, events, event_id)