def _extract_ibands(log: str) -> tuple[list[int], ...]:
    """
    Extract ibands from an ``amset wave`` log.

    Note in the log the band indices are 1 indexed but this function returns zero
    indexed band indices.

    Parameters
    ----------
    log : str
        The log from ``amset wave``.

    Returns
    -------
    tuple of list of int
        The bands included in the wavefunction.h5 file. Given as a tuple of one or two
        lists (one for each spin channel). The bands indices are zero indexed.
    """
    result_splits = log.split("\n")
    for i in range(len(result_splits)):
        if "Including bands" in result_splits[i]:
            # non-spin polarised result system
            min_band, max_band = result_splits[i].split(" ")[-1].split("—")
            return (list(range(int(min_band) - 1, int(max_band))),)

        if "Including:" in result_splits[i]:
            amin_band, amax_band = result_splits[i + 1].split(" ")[-1].split("—")
            bmin_band, bmax_band = result_splits[i + 2].split(" ")[-1].split("—")
            aibands = list(range(int(amin_band) - 1, int(amax_band)))
            bibands = list(range(int(bmin_band) - 1, int(bmax_band)))

            if "up" in result_splits[i + 1]:
                # up listed first
                return aibands, bibands
            else:
                # down listed first
                return bibands, aibands
    raise ValueError("Could not find ibands in log.")