def crop_to_extent(data, xyz, extent):
    """Limits the data to the volume's extent
    data is z, y, x ordered
    xyz and extent are xyz ordered
    """

    diff_extent = [e - i for e, i in zip(extent, xyz)]

    data_clip = data[: diff_extent[2], : diff_extent[1], : diff_extent[0]]

    return data_clip