def _normaliseBounds(shape, bounds):
    """Adjust the given ``bounds`` so that it is compatible with the given
    ``shape``.

    Bounds must be specified for at least three dimensions - if the shape
    has more than three dimensions, additional bounds are added.

    A :exc:`ValueError` is raised if the provided bounds are invalid.

    :arg bounds: Sequence of ``(lo, hi)`` bounds - see :func:`roi`.
    :returns:    An adjusted sequence of bounds.
    """
    bounds = list(bounds)
    if len(bounds) < 3:
        raise ValueError('')
    if len(bounds) > len(shape):
        raise ValueError('')
    for b in bounds:
        if len(b) != 2 or b[0] >= b[1]:
            raise ValueError('')
    if len(bounds) < len(shape):
        for s in shape[len(bounds):]:
            bounds.append((0, s))
    return bounds
