def mask_filter_bounding_boxes(mask, bbList):
    """Keeps only bounding boxes that have overlap with mask
    Args:
        mask (np.array, 2-dim): binary mask
        bbList (list of (x,xp,y,yp))
    Returns:
        reduced bounding boxes list (list of (x, xp,y, yp)), convention of bounding box
        (top, bottom, left, right)
    """
    bbListFiltered = []
    for bb in bbList:
        mask_patch = mask[bb[0]:bb[1],bb[2]:bb[3]]
        if (mask_patch).sum() > 0:  
            bbListFiltered.append(bb)
    return bbListFiltered