SOAPy_st.tl.get_mask_from_domain
- SOAPy_st.tl.get_mask_from_domain(adata: AnnData, clusters: list | str | int, KSize: int, cluster_key: str | None = 'domain', k_blur: int | None = 7, scale: str | float = 'hires', eliminate_hole: bool = False, remove_small_objects: bool = False, minsize: int = 1000, connectivity: int = 1, inplace: bool = True) ndarray
A mask image is generated according to the selected category, and the mask can be processed using morphological methods such as dilation and erosion, removal of holes, and removal of small connected components
The size of mask is based on adata.obsm[‘spatial’]
Parameters
- adataanndata.AnnData
An AnnData object containing spatial omics data and spatial information.
- clusters
Making mask in this clusters
- KSize
The size of convolution kernel in function dilate
- cluster_key
Label to which the param ‘clusters’ belongs
- k_blur
The size of convolution kernel in function cv2.blur()
- scale
The spatial scale used by the operation
- eliminate_hole
If True, use cv.bitwise_not() to eliminate hole
- remove_small_objects
If True, use morphology.remove_small_objects() to remove small domains
- minsize
The shortest perimeter of removed domains. Used during labelling if RemoveSmallObjects is True.
- connectivity
The connectivity defining the neighborhood of a pixel. Used during labelling if RemoveSmallObjects is True. 1 is four neighborhood, 2 is eight neighborhood.
- inplacebool, optional
If True, Modify directly in the original adata.
Returns
numpy.ndarray, mask of the selected domain