spateo.segmentation.external.stardist ===================================== .. py:module:: spateo.segmentation.external.stardist .. autoapi-nested-parse:: Use StarDist for cell identification and labeling. https://github.com/stardist/stardist [Schmidt18]_ and [Weigert20]_ Attributes ---------- .. autoapisummary:: spateo.segmentation.external.stardist.StarDist2D Functions --------- .. autoapisummary:: spateo.segmentation.external.stardist._stardist spateo.segmentation.external.stardist._stardist_big spateo.segmentation.external.stardist._sanitize_labels spateo.segmentation.external.stardist.stardist Module Contents --------------- .. py:data:: StarDist2D :value: None .. py:function:: _stardist(img: numpy.ndarray, model: Union[typing_extensions.Literal[2D_versatile_fluo, 2D_versatile_he, 2D_paper_dsb2018], stardist.models.StarDist2D] = '2D_versatile_fluo', **kwargs) -> numpy.ndarray Run StarDist on the provided image. :param img: Image as a Numpy array. :param model: Stardist model to use. Can be one of the three pretrained models from StarDist2D: 1. '2D_versatile_fluo': 'Versatile (fluorescent nuclei)' 2. '2D_versatile_he': 'Versatile (H&E nuclei)' 3. '2D_paper_dsb2018': 'DSB 2018 (from StarDist 2D paper)' Or any generic Stardist2D model. :param \*\*kwargs: Additional keyword arguments to :func:`StarDist2D.predict_instances` function. :returns: Numpy array containing cell labels. .. py:function:: _stardist_big(img: numpy.ndarray, model: Union[typing_extensions.Literal[2D_versatile_fluo, 2D_versatile_he, 2D_paper_dsb2018], stardist.models.StarDist2D] = '2D_versatile_fluo', **kwargs) -> numpy.ndarray Run StarDist on the provided image. :param img: Image as a Numpy array. :param model: Stardist model to use. Can be one of the three pretrained models from StarDist2D: 1. '2D_versatile_fluo': 'Versatile (fluorescent nuclei)' 2. '2D_versatile_he': 'Versatile (H&E nuclei)' 3. '2D_paper_dsb2018': 'DSB 2018 (from StarDist 2D paper)' Or any generic Stardist2D model. :param \*\*kwargs: Additional keyword arguments to :func:`StarDist2D.predict_instances_big` function. :returns: Numpy array containing cell labels. .. py:function:: _sanitize_labels(labels: numpy.ndarray) -> numpy.ndarray Sanitize labels obtained from StarDist. StarDist sometimes yields disconnected labels. This function removes these problems by selecting the largest area. :param labels: Numpy array containing labels :returns: Sanitized labels. .. py:function:: stardist(adata: anndata.AnnData, model: Union[typing_extensions.Literal[2D_versatile_fluo, 2D_versatile_he, 2D_paper_dsb2018], stardist.models.StarDist2D] = '2D_versatile_fluo', tilesize: int = 2000, min_overlap: Optional[int] = None, context: Optional[int] = None, normalizer: Optional[csbdeep.data.Normalizer] = PercentileNormalizer(), equalize: float = 2.0, sanitize: bool = True, layer: str = SKM.STAIN_LAYER_KEY, out_layer: Optional[str] = None, **kwargs) Run StarDist to label cells from a staining image. .. note:: When using `min_overlap`, the crucial assumption is that all predicted object instances are smaller than the provided `min_overlap`. Also, it must hold that: min_overlap + 2*context < tilesize. https://github.com/stardist/stardist/blob/858cae17cf17f979122000ad2294a156d0547135/stardist/models/base.py#L776 :param adata: Input Anndata :param img: Image as a Numpy array. :param model: Stardist model to use. Can be one of the three pretrained models from StarDist2D: 1. '2D_versatile_fluo': 'Versatile (fluorescent nuclei)' 2. '2D_versatile_he': 'Versatile (H&E nuclei)' 3. '2D_paper_dsb2018': 'DSB 2018 (from StarDist 2D paper)' Or any generic Stardist2D model. :param tilesize: Run prediction separately on tiles of size `tilesize` x `tilesize` and merge them afterwards. Useful to avoid out-of-memory errors. Can be set to <= 0 to disable tiling. When `min_overlap` is also provided, this becomes the `block_size` parameter to :func:`StarDist2D.predict_instances_big`. :param min_overlap: Amount of guaranteed overlaps between tiles. :param context: Amount of image context on all sides of a tile, which is dicarded. Only used when `min_overlap` is not None. By default, an automatic estimate is used. :param normalizer: Normalizer to use to perform normalization prior to prediction. By default, percentile-based normalization is performed. `None` may be provided to disable normalization. :param equalize: Controls the `clip_limit` argument to the :func:`clahe` function. Set this value to a non-positive value to turn off equalization. :param sanitize: Whether to sanitize disconnected labels. :param layer: Layer that contains staining image. Defaults to `stain`. :param out_layer: Layer to put resulting labels. Defaults to `{layer}_labels`. :param \*\*kwargs: Additional keyword arguments to pass to :func:`StarDist2D.predict_instances`.