def check_box(shape, box):
    """Check if a square/box selection can be applied to an image.
    If not enough corners are specified, the whole dimension is selected.

    Args:
      shape (tuple[int]): image shape.
      box (list): selection square/box corner coordinates.
    """

    # Every dimension in the box should have two coordinates
    if len(shape) >= len(box):
        for i in range(len(box)):
            if len(box[i]) != 2:
                box[i] = (0, shape[i] - 1)
    else:
        box = box[: len(shape)]

    # Fill missing dimensions
    if len(shape) > len(box):
        [box.extend([0, shape[d]]) for d in range(int(len(box) / 2), len(shape))]

    # Remove extra dimensions
    box = box[: len(shape)]

    return box