histocartography.preprocessing.stain_normalizers module

This module handles everything related to stain normalization

Summary

Classes:

MacenkoStainNormalizer

Stain normalization based on the method of: M.

StainNormalizer

Base class for creating fancy stain normalizers

VahadaneStainNormalizer

Stain normalization inspired by method of: A.

class StainNormalizer(target_path: Optional[str] = None, precomputed_normalizer_path: Optional[str] = None, **kwargs)[source]

Bases: histocartography.pipeline.PipelineStep

Base class for creating fancy stain normalizers

__init__(target_path: Optional[str] = None, precomputed_normalizer_path: Optional[str] = None, **kwargs)None[source]

Create a stain normalizer

Parameters
  • target_path (str, optional) – Path of the target image for identification

  • precomputed_normalizer_path (str, optional) – Path of the precomputed normalizer

abstract fit(target_image: numpy.ndarray)[source]

Fit a normalizer by precomputing the required information

Parameters

target_image (np.array) – Input image

process_and_save(*args, output_name: str, **kwargs)numpy.ndarray[source]

Process and save in the provided path as a png image

Parameters

output_name (str) – Name of output file

precompute(link_path: Union[None, str, pathlib.Path] = None, precompute_path: Union[None, str, pathlib.Path] = None)None[source]

Precompute all necessary information

Parameters
  • link_path (Union[None, str, Path], optional) – Path to link to. Defaults to None.

  • precompute_path (Union[None, str, Path], optional) – Path to save precomputation outputs. Defaults to None.

class MacenkoStainNormalizer(alpha: float = 1.0, beta: float = 0.15, **kwargs)[source]

Bases: histocartography.preprocessing.stain_normalizers.StainNormalizer

Stain normalization based on the method of: M. Macenko et al., ‘A method for normalizing histology slides for quantitative analysis’, in 2009 IEEE International Symposium on Biomedical Imaging: From Nano to Macro, 2009, pp. 1107–1110.

__init__(alpha: float = 1.0, beta: float = 0.15, **kwargs)None[source]

Apply the stain normalization with a given target and parameters

Parameters
  • alpha (float, optional) – Alpha parameter. Defaults to 1.0.

  • beta (float, optional) – Beta parameter. Defaults to 0.15.

fit(target_image: numpy.ndarray)None[source]

Fit the normalizer to a target value and save it for the future

Parameters

target_image (np.array) – Target image

class VahadaneStainNormalizer(threshold: float = 0.8, lambda_s: float = 0.1, **kwargs)[source]

Bases: histocartography.preprocessing.stain_normalizers.StainNormalizer

Stain normalization inspired by method of: A. Vahadane et al., ‘Structure-Preserving Color Normalization and Sparse Stain Separation for Histological Images’, IEEE Transactions on Medical Imaging, vol. 35, no. 8, pp. 1962–1971, Aug. 2016.

__init__(threshold: float = 0.8, lambda_s: float = 0.1, **kwargs)None[source]

Create a Vahadame normalizer for a given target image

Parameters
  • threshold (float, optional) – Threshold for the non-white mask in lab color space. Defaults to 0.8.

  • lambda_s (float, optional) – Optimization parameter for the stain extraction. Defaults to 0.1.

fit(target_image: numpy.ndarray)None[source]

Fit the normalizer to a target value and save it for the future

Parameters

target_image (np.array) – Target image

Reference

If you use histocartography in your projects, please cite the following:

@inproceedings{pati2021,
    title = {Hierarchical Graph Representations for Digital Pathology},
    author = {Pushpak Pati, Guillaume Jaume, Antonio Foncubierta, Florinda Feroce, Anna Maria Anniciello, Giosuè Scognamiglio, Nadia Brancati, Maryse Fiche, Estelle Dubruc, Daniel Riccio, Maurizio Di Bonito, Giuseppe De Pietro, Gerardo Botti, Jean-Philippe Thiran, Maria Frucci, Orcun Goksel, Maria Gabrani},
    booktitle = {https://arxiv.org/pdf/2102.11057},
    year = {2021}
}