def _next_segment(truth, start_index):
    """ Find the end of the segment

    Args:
        truth (:obj:`numpy.ndarray`): Ground truth
        start_index (:obj:`int`): start index of current segment

    Returns:
        :obj:`int`: end index of current segment
    """
    stop_index = start_index + 1
    while stop_index < truth.size:
        if truth[stop_index] == truth[start_index]:
            stop_index += 1
        else:
            return stop_index
    return stop_index