def create_sequence(events):
    """create sequence from events.

    Create a sequence of non-overlapped States from labels.
    """
    # init variable
    sequence = np.zeros((events.shape[1], 1))

    # get hand start
    handStart = np.int64(_find_stim_steps(np.atleast_2d(events[0]), 0)[::2, 0])

    # lift
    lift_on = np.int64(_find_stim_steps(np.atleast_2d(events[1]), 0)[::2, 0])
    lift_off = np.int64(_find_stim_steps(np.atleast_2d(events[3]), 0)[1::2, 0])

    # replace
    replace_on = np.int64(_find_stim_steps(np.atleast_2d(events[4]), 0)
                          [::2, 0])
    replace_off = np.int64(_find_stim_steps(np.atleast_2d(events[5]), 0)
                           [1::2, 0])

    for i in range(len(handStart)):
        j = 1
        sequence[(handStart[i] - 250):handStart[i]] = j
        j += 1
        sequence[handStart[i]:lift_on[i]] = j
        j += 1
        sequence[lift_on[i]:lift_off[i]] = j
        j += 1
        sequence[lift_off[i]:replace_on[i]] = j
        j += 1
        sequence[replace_on[i]:replace_off[i]] = j
        j += 1
        sequence[replace_off[i]:(replace_off[i] + 250)] = j
        j += 1

    return sequence
dataset/ETHPy150Open alexandrebarachant/Grasp-and-lift-EEG-challenge/preprocessing/covs_alex.py/create_sequence/original