Skip to content

label_tiles

Queries the dataset at input_slide_annotation_dataset for a slide_id matching input_slide_tiles

Adds regional_label, intersection_area columns to slide tiles, where the former is the annotation label, and the latter the fraction of intersecting area between the tile and annotation regions

Parameters:

Name Type Description Default
annotation_urlpath str

url/path to parquet annotation dataset

'???'
tiles_urlpath str

url/path to a slide-tile manifest file (.tiles.parquet)

'???'
slide_id str

slide ID

'???'
output_urlpath str

output url/path prefix

'???'
storage_options dict

options to pass to reading functions

{}
output_storage_options dict

options to pass to writing functions

{}
local_config str

url/path to local config YAML file

''

Returns: dict: metadata

Source code in src/luna/pathology/cli/generate_tile_labels.py
@timed
@save_metadata
def cli(
    annotation_urlpath: str = "???",
    tiles_urlpath: str = "???",
    slide_id: str = "???",
    output_urlpath: str = "???",
    storage_options: dict = {},
    output_storage_options: dict = {},
    local_config: str = "",
):
    """Queries the dataset at input_slide_annotation_dataset for a slide_id matching input_slide_tiles

    Adds regional_label, intersection_area columns to slide tiles, where the former is the annotation label, and the latter the fraction of intersecting area between the tile and annotation regions

    Args:
        annotation_urlpath (str): url/path to parquet annotation dataset
        tiles_urlpath (str): url/path to a slide-tile manifest file (.tiles.parquet)
        slide_id (str): slide ID
        output_urlpath (str): output url/path prefix
        storage_options (dict): options to pass to reading functions
        output_storage_options (dict): options to pass to writing functions
        local_config (str): url/path to local config YAML file
    Returns:
        dict: metadata
    """
    config = get_config(vars())

    df_tiles = generate_tile_labels(
        config["annotation_urlpath"],
        config["tiles_urlpath"],
        config["slide_id"],
        config["storage_options"],
    )

    fs, output_urlpath_prefix = fsspec.core.url_to_fs(
        config["output_urlpath"], **config["output_storage_options"]
    )
    output_header_file = (
        Path(output_urlpath_prefix)
        / f"{config['slide_id']}.regional_label.tiles.parquet"
    )
    with fs.open(output_header_file, "wb") as of:
        df_tiles.to_parquet(of)

    properties = {
        "slide_tiles": output_header_file,  # "Tiles" are the metadata that describe them
    }

    return properties