Skip to content

extract_stain_texture

Compute GLCM texture features on a de-convolved slide image

Parameters:

Name Type Description Default
slide_image_urlpath str

url/path to slide image (virtual slide formats compatible with openslide, .svs, .tif, .scn, ...)

'???'
slide_mask_urlpath str

url/path to slide mask (.tif)

'???'
stain_sample_factor float

downsample factor to use for stain vector estimation

'???'
stain_channel int

which channel of the deconvovled image to use for texture analysis

'???'
tile_size int

size of tiles to use (at the requested magnification) (500-1000 recommended)

'???'
output_urlpath str

output/working directory

'.'

Returns:

Name Type Description
dict

metadata about function call

Source code in src/luna/pathology/cli/extract_stain_texture.py
@timed
@save_metadata
def cli(
    slide_image_urlpath: str = "???",
    slide_mask_urlpath: str = "???",
    stain_sample_factor: float = "???",  # type: ignore
    stain_channel: int = "???",  # type: ignore
    tile_size: int = "???",  # type: ignore
    output_urlpath: str = ".",
    storage_options: dict = {},
    output_storage_options: dict = {},
    local_config: str = "",
):
    """Compute GLCM texture features on a de-convolved slide image

    Args:
        slide_image_urlpath (str): url/path to slide image (virtual slide formats compatible with openslide, .svs, .tif, .scn, ...)
        slide_mask_urlpath (str): url/path to slide mask (.tif)
        stain_sample_factor (float): downsample factor to use for stain vector estimation
        stain_channel (int): which channel of the deconvovled image to use for texture analysis
        tile_size (int): size of tiles to use (at the requested magnification) (500-1000 recommended)
        output_urlpath (str): output/working directory

    Returns:
        dict: metadata about function call

    """
    config = get_config(vars())
    df_result = extract_stain_texture(
        config["slide_image_urlpath"],
        config["slide_mask_urlpath"],
        config["stain_sample_factor"],
        config["stain_channel"],
        config["tile_size"],
        config["output_urlpath"],
        config["storage_options"],
        config["output_storage_options"],
    )

    fs, urlpath_prefix = fsspec.core.url_to_fs(
        config["output_urlpath"], **config["output_storage_options"]
    )
    output_filename = Path(urlpath_prefix) / "stainomics.parquet"
    with fs.open(output_filename, "wb") as of:
        df_result.to_parquet(of, index=False)

    properties = {
        # "num_pixel_observations": n,
        "feature_data": output_filename,
    }

    return properties