Need help with StainTools?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

Peter554
195 Stars 80 Forks MIT License 28 Commits 9 Opened issues

Description

Tools for tissue image stain normalisation and augmentation in Python 3

Services available

!
?

Need anything else?

Contributors list

# 224,144
Python
medical...
task-ru...
Go
24 commits

StainTools

Tools for tissue image stain normalization and augmentation in Python 3.

Install

  1. pip install staintools
  2. Install SPAMS. This is a dependency to staintools and is technically available on PyPI (see here). However, personally I have had some issues with the PyPI install and would instead recommend using conda (see here).

Quickstart

Normalization

Original images:

Stain normalized images:

# Read data
target = staintools.read_image("./data/my_target_image.png")
to_transform = staintools.read_image("./data/my_image_to_transform.png")

Standardize brightness (optional, can improve the tissue mask calculation)

target = staintools.LuminosityStandardizer.standardize(target) to_transform = staintools.LuminosityStandardizer.standardize(to_transform)

Stain normalize

normalizer = staintools.StainNormalizer(method='vahadane') normalizer.fit(target) transformed = normalizer.transform(to_transform)

Augmentation

# Read data
to_augment = staintools.read_image("./data/my_image_to_augment.png")

Standardize brightness (optional, can improve the tissue mask calculation)

to_augment = staintools.LuminosityStandardizer.standardize(to_augment)

Stain augment

augmentor = staintools.StainAugmentor(method='vahadane', sigma1=0.2, sigma2=0.2) augmentor.fit(to_augment) augmented_images = [] for _ in range(100): augmented_image = augmentor.pop() augmented_images.append(augmented_image)

More examples

For more examples see files inside of the

examples
directory.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.