squidpy.im.calculate_image_features
- squidpy.im.calculate_image_features(adata, img, layer=None, library_id=None, features='summary', features_kwargs=mappingproxy({}), key_added='img_features', copy=False, n_jobs=None, backend='loky', show_progress_bar=True, **kwargs)[source]
Calculate image features for all observations in
adata
.- Parameters
adata (
AnnData
) – Annotated data object.img (
ImageContainer
) – High-resolution image.layer (
Optional
[str
]) – Image layer inimg
that should be processed. If None and only 1 layer is present, it will be selected.library_id (
Union
[str
,Sequence
[str
],None
]) –If None, there should only exist one entry in
anndata.AnnData.uns
['{spatial_key}']
.If a
str
, first searchanndata.AnnData.obs
['{library_id}']
which contains the mapping from observations to library ids, then searchanndata.AnnData.uns
['{spatial_key}']
.
features (
Union
[str
,Sequence
[str
]]) –Features to be calculated. Valid options are:
’texture’ - summary stats based on repeating patterns
squidpy.im.ImageContainer.features_texture()
.’summary’ - summary stats of each image channel
squidpy.im.ImageContainer.features_summary()
.’histogram’ - counts in bins of image channel’s histogram
squidpy.im.ImageContainer.features_histogram()
.’segmentation’ - stats of a cell segmentation mask
squidpy.im.ImageContainer.features_segmentation()
.’custom’ - extract features using a custom function
squidpy.im.ImageContainer.features_custom()
.
features_kwargs (
Mapping
[str
,Mapping
[str
,Any
]]) – Keyword arguments for the different features that should be generated, such as{ 'texture': { ... }, ... }
.key_added (
str
) – Key inanndata.AnnData.obsm
where to store the calculated features.copy (
bool
) – IfTrue
, return the result, otherwise save it to theadata
object.backend (
str
) – Parallelization backend to use. Seejoblib.Parallel
for available options.show_progress_bar (
bool
) – Whether to show the progress bar or not.kwargs (
Any
) – Keyword arguments forsquidpy.im.ImageContainer.generate_spot_crops()
.
- Return type
- Returns
: If
copy = True
, returns apandas.DataFrame
where columns correspond to the calculated features.Otherwise, modifies the
adata
object with the following key:anndata.AnnData.uns
['{key_added}']
- the above mentioned dataframe.
- Raises
ValueError – If a feature is not known.