def get_psg_start_stop_events(events):
    """
    :param events:
    :return:
        List of START/STOP events. Length 2 list of format:
            [[start_sec, 0?? (duration), "START PSG"], [start_sec, 0?? (duration), "STOP PSG"]]
    """
    # Filter to keep only start/stop PSG events
    start_stop_events = list(filter(lambda e: "psg" in e[-1].lower(), events))
    assert len(start_stop_events) == 2, "Found != 2 start/stop PSG events: {}".format(start_stop_events)

    # Make sure events are sorted by init time
    start_stop_events = sorted(start_stop_events, key=lambda x: x[0])
    assert "start" in start_stop_events[0][-1].lower() and "stop" in start_stop_events[-1][-1].lower()

    # Standardize
    return [
        (start_stop_events[0][0], start_stop_events[0][1], "PSG START"),
        (start_stop_events[1][0], start_stop_events[1][1], "PSG STOP"),
    ]