def get_bout_indices(activity_list):
    """
    Takes a list, activity_list, and returns a list of tuples of
    the start/end indices in which sleeping bouts occurr.
    I.e. if two sleeping bouts occured, the first from index 5 to 20,
    and the second from index 30 to 40, this function will return
    [(5,20), (30,40)]
    """
    indices = []
    start_index = 1
    end_index = 1
    in_bout = False

    for i in range(len(activity_list)):
        if activity_list[i] == 0 and in_bout == False:
            start_index = i
            in_bout = True
        if (activity_list[i] != 0 or i == len(activity_list)-1) and in_bout == True:
            end_index = i
            in_bout = False
            if i == len(activity_list)-1:
                indices.append((start_index, end_index+1))
            else:
                indices.append((start_index, end_index))

    return indices