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)

Bases: Callable

Stain Extraction by stain matrix estimation.

stain_algorithm: StainAlg

torch_staintools.functional.stain_extraction.utils module

torch_staintools.functional.stain_extraction.utils.cov(x)

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

torch_staintools.functional.stain_extraction.utils.normalize_matrix_rows(a: Tensor) Tensor

Normalize the rows of an array. :param a: An array to normalize

Returns:

Array with rows normalized.

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).

Module contents