torch_staintools.functional.stain_extraction package

Submodules

torch_staintools.functional.stain_extraction.extractor module

class torch_staintools.functional.stain_extraction.extractor.StainAlg(*args, **kwargs)

Bases: Protocol

Interface of stain separation algorithms.

cfg: object
class torch_staintools.functional.stain_extraction.extractor.StainExtraction(stain_algorithm: StainAlg, num_stains: int, rng: Generator | None)

Bases: Callable

Stain Extraction by stain matrix estimation.

num_stains: int
rng: Generator | None
stain_algorithm: StainAlg

torch_staintools.functional.stain_extraction.utils module

torch_staintools.functional.stain_extraction.utils.batch_masked_cov(od_flatten: Tensor, mask_flatten: Tensor) Tensor
torch_staintools.functional.stain_extraction.utils.batch_masked_perc(phi: Tensor, mask: Tensor, q: int, dim: int) Tensor
torch_staintools.functional.stain_extraction.utils.cov(x: Tensor) Tensor

Covariance matrix for eigen decomposition. https://en.wikipedia.org/wiki/Covariance_matrix

torch_staintools.functional.stain_extraction.utils.percentile(t: Tensor, q: float, dim: int) Tensor

Author: adapted from https://gist.github.com/spezold/42a451682422beb42bc43ad0c0967a30

Return the q-th percentile of the flattenepip d input tensor’s data.

Caution

  • Needs PyTorch >= 1.1.0, as torch.kthvalue() is used.

  • Values are not interpolated, which corresponds to numpy.percentile(..., interpolation="nearest").

Parameters:
  • t – Input tensor.

  • q – Percentile to compute, which must be between 0 and 100 inclusive.

  • dim – which dim to operate for function tensor.kthvalue.

Returns:

Resulting value (scalar).

torch_staintools.functional.stain_extraction.utils.post_proc_dict(dictionary: Tensor)
torch_staintools.functional.stain_extraction.utils.sort_stain(sm: Tensor) Tensor
torch_staintools.functional.stain_extraction.utils.validate_shape(od: Tensor, tissue_mask: Tensor)

Module contents