lazyslide.tl.spatial_features#
- spatial_features(wsi, feature_key, method='smoothing', tile_key='tiles', graph_key=None, layer_key='spatial_features')#
Integrate spatial tile graph context with vision model features using spatial feature smoothing.
- Parameters:
- wsi
WSIData The WSIData object.
- feature_keystr
The feature key.
- methodstr, default: ‘smoothing’
The method used for spatial feature smoothing. Currently, only ‘smoothing’ is supported.
- tile_keystr, default: ‘tiles’
The key of the tiles in the shapes slot.
- graph_keystr, optional
The graph key. If None, defaults to ‘{tile_key}_graph’.
- layer_keystr, default: ‘spatial_features’
The key for the output layer in the feature table.
- wsi
- Returns:
- None.
The transformed feature will be added to the
spatial_featureslayer of the feature AnnData.
Examples
>>> import lazyslide as zs >>> wsi = zs.datasets.sample() >>> zs.pp.find_tissues(wsi) >>> zs.pp.tile_tissues(wsi, 256, mpp=0.5) >>> zs.tl.feature_extraction(wsi, "resnet50") >>> zs.pp.tile_graph(wsi) >>> zs.tl.spatial_features(wsi, "resnet50") >>> wsi["resnet50_tiles"].layers["spatial_features"]