squidpy.im.ImageContainer.generate_spot_crops

ImageContainer.generate_spot_crops(adata, spatial_key='spatial', library_id=None, spot_diameter_key='spot_diameter_fullres', spot_scale=1.0, obs_names=None, as_array=False, squeeze=True, return_obs=False, **kwargs)[source]

Iterate over anndata.AnnData.obs_names and extract crops.

Implemented for 10X spatial datasets. For Z-stacks, the specified library_id or list of library_id need to match the name of the Z-dimension. Always extracts 2D crops from the specified Z-dimension.

Parameters:
Yields:
  • If return_obs = True, yields a tuple (crop, obs_name). Otherwise, yields just the crops.

  • The type of the crops depends on as_array and the number of dimensions on squeeze.

Return type:

Union[Iterator[ImageContainer], Iterator[ndarray[Any, dtype[Any]]], Iterator[tuple[ndarray[Any, dtype[Any]], ...]], Iterator[dict[str, ndarray[Any, dtype[Any]]]]]