def task_percentages(data, n_tasks=9):
    """
    Takes a 3D array of strings representing binary numbers and calculates
    the percentage of organisms in each cell (across multiple files)
    that were doing a given task.

    Returns an m x n x n_tasks array indicating the percentages of organisms
    at each location (across the 3rd dimension) that were doing each task.
    """
    pdata = deepcopy(data)
    for i in range(len(data)):
        for j in range(len(data[0])):
            percentages = [0.0]*n_tasks
            for k in range(len(data[i][j])):
                b_ind = data[i][j][k].find("b")
                for l in range(b_ind+1, len(data[i][j][k])):
                    percentages[l-2] += int(data[i][j][k][l])
            for p in range(len(percentages)):
                percentages[p] /= len(data[i][j])
            pdata[i][j] = percentages

    return pdata