https://github.com/eidoslab/torchstain

Stain normalization tools for histological analysis and computational pathology

https://github.com/eidoslab/torchstain

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.9%) to scientific vocabulary

Keywords

computational-pathology digital-pathology histopathology medical-imaging numpy python pytorch stain-normalization tensorflow
Last synced: 6 months ago · JSON representation

Repository

Stain normalization tools for histological analysis and computational pathology

Basic Info
  • Host: GitHub
  • Owner: EIDOSLAB
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 2.52 MB
Statistics
  • Stars: 151
  • Watchers: 3
  • Forks: 28
  • Open Issues: 17
  • Releases: 4
Topics
computational-pathology digital-pathology histopathology medical-imaging numpy python pytorch stain-normalization tensorflow
Created about 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.md

torchstain

License Full Tests Pip Downloads DOI

GPU-accelerated stain tools for histopathological images. Compatible with PyTorch, TensorFlow, and Numpy.

Normalization algorithms currently implemented: - Macenko [1] (ported from numpy implementation) - Reinhard [2] - Modified Reinhard [3] - Multi-target Macenko [4]

Augmentation algorithms currently implemented: - Macenko-Aug [1] (inspired by StainTools)

Installation

bash pip install torchstain

To install a specific backend use either torchstain[torch] or torchstain[tf]. The numpy backend is included by default in both.

Example Usage

```python import torch from torchvision import transforms import torchstain import cv2

target = cv2.cvtColor(cv2.imread("./data/target.png"), cv2.COLORBGR2RGB) totransform = cv2.cvtColor(cv2.imread("./data/source.png"), cv2.COLOR_BGR2RGB)

T = transforms.Compose([ transforms.ToTensor(), transforms.Lambda(lambda x: x*255) ])

normalizer = torchstain.normalizers.MacenkoNormalizer(backend='torch') normalizer.fit(T(target))

ttotransform = T(totransform) norm, H, E = normalizer.normalize(I=tto_transform, stains=True) ```

alt text

Implemented algorithms

| Algorithm | numpy | torch | tensorflow | |-|-|-|-| | Macenko | ✓ | ✓ | ✓ | | Reinhard | ✓ | ✓ | ✓ | | Modified Reinhard | ✓ | ✓ | ✓ | | Multi-target Macenko | ✗ | ✓ | ✗ | | Macenko-Aug | ✓ | ✓ | ✓ |

Backend comparison

Runtimes using the Macenko algorithm using different backends. Metrics were calculated from 10 repeated runs for each quadratic image size on an Intel(R) Core(TM) i5-8365U CPU @ 1.60GHz.

| size | numpy avg. time | torch avg. time | tf avg. time | |--------|-------------------|-------------------|------------------| | 224 | 0.0182s ± 0.0016 | 0.0180s ± 0.0390 | 0.0048s ± 0.0002 | | 448 | 0.0880s ± 0.0224 | 0.0283s ± 0.0172 | 0.0210s ± 0.0025 | | 672 | 0.1810s ± 0.0139 | 0.0463s ± 0.0301 | 0.0354s ± 0.0018 | | 896 | 0.3013s ± 0.0377 | 0.0820s ± 0.0329 | 0.0713s ± 0.0008 | | 1120 | 0.4694s ± 0.0350 | 0.1321s ± 0.0237 | 0.1036s ± 0.0042 | | 1344 | 0.6640s ± 0.0553 | 0.1665s ± 0.0026 | 0.1663s ± 0.0021 | | 1568 | 1.1935s ± 0.0739 | 0.2590s ± 0.0088 | 0.2531s ± 0.0031 | | 1792 | 1.4523s ± 0.0207 | 0.3402s ± 0.0114 | 0.3080s ± 0.0188 |

Reference

  • [1] Macenko, Marc et al. "A method for normalizing histology slides for quantitative analysis." 2009 IEEE International Symposium on Biomedical Imaging: From Nano to Macro. IEEE, 2009.
  • [2] Reinhard, Erik et al. "Color transfer between images." IEEE Computer Graphics and Applications. IEEE, 2001.
  • [3] Roy, Santanu et al. "Modified Reinhard Algorithm for Color Normalization of Colorectal Cancer Histopathology Images". 2021 29th European Signal Processing Conference (EUSIPCO), IEEE, 2021.
  • [4] Ivanov, Desislav et al. "Multi-target stain normalization for histology slides". 2nd International Workshop on Medical Optical Imaging and Virtual Microscopy Image Analysis (MOVI 2024), MICCAI. 2024.

Citing

If you find this software useful for your research, please cite it as:

bibtex @software{barbano2022torchstain, author = {Carlo Alberto Barbano and André Pedersen}, title = {EIDOSLAB/torchstain: v1.2.0-stable}, month = aug, year = 2022, publisher = {Zenodo}, version = {v1.2.0-stable}, doi = {10.5281/zenodo.6979540}, url = {https://doi.org/10.5281/zenodo.6979540} }

Torchstain was originally developed within the UNITOPATHO data collection, which you can cite as:

bibtex @inproceedings{barbano2021unitopatho, title={UniToPatho, a labeled histopathological dataset for colorectal polyps classification and adenoma dysplasia grading}, author={Barbano, Carlo Alberto and Perlo, Daniele and Tartaglione, Enzo and Fiandrotti, Attilio and Bertero, Luca and Cassoni, Paola and Grangetto, Marco}, booktitle={2021 IEEE International Conference on Image Processing (ICIP)}, pages={76--80}, year={2021}, organization={IEEE} }

Owner

  • Name: EIDOSLAB
  • Login: EIDOSLAB
  • Kind: organization
  • Email: eidos@di.unito.it
  • Location: University of Turin

Digital image processing, computer vision and virtual reality.

GitHub Events

Total
  • Create event: 6
  • Release event: 3
  • Issues event: 3
  • Watch event: 34
  • Delete event: 1
  • Issue comment event: 13
  • Push event: 18
  • Pull request event: 25
  • Fork event: 6
Last Year
  • Create event: 6
  • Release event: 3
  • Issues event: 3
  • Watch event: 34
  • Delete event: 1
  • Issue comment event: 13
  • Push event: 18
  • Pull request event: 25
  • Fork event: 6

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 207
  • Total Committers: 5
  • Avg Commits per committer: 41.4
  • Development Distribution Score (DDS): 0.454
Past Year
  • Commits: 27
  • Committers: 3
  • Avg Commits per committer: 9.0
  • Development Distribution Score (DDS): 0.407
Top Committers
Name Email Commits
André Pedersen a****4@g****m 113
Carlo Alberto Barbano c****o@o****m 84
Raphael Attias r****s@o****m 5
Ajinkya Kulkarni k****a@g****m 3
evolveyourmind 2****v 2

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 27
  • Total pull requests: 55
  • Average time to close issues: 4 months
  • Average time to close pull requests: 5 months
  • Total issue authors: 13
  • Total pull request authors: 7
  • Average comments per issue: 5.85
  • Average comments per pull request: 1.55
  • Merged pull requests: 42
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 18
  • Average time to close issues: 4 days
  • Average time to close pull requests: about 10 hours
  • Issue authors: 4
  • Pull request authors: 5
  • Average comments per issue: 4.5
  • Average comments per pull request: 0.33
  • Merged pull requests: 11
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • andreped (13)
  • carloalbertobarbano (2)
  • vahvero (1)
  • swamidass (1)
  • raphaelattias (1)
  • biagio-lunit (1)
  • CielAl (1)
  • nabilapuspit (1)
  • gafaua (1)
  • bertrandchauveau (1)
  • RECranston (1)
  • yuvfried (1)
Pull Request Authors
  • andreped (32)
  • carloalbertobarbano (10)
  • wouterzwerink (5)
  • ajinkya-kulkarni (4)
  • desi-ivanov (2)
  • raphaelattias (1)
  • gitexa (1)
Top Labels
Issue Labels
enhancement (9) documentation (5) good first issue (2) bug (2) duplicate (1)
Pull Request Labels
release (3) enhancement (3) bug (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 3,143 last-month
  • Total docker downloads: 439
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 5
  • Total maintainers: 1
pypi.org: torchstain

Stain normalization tools for histological analysis and computational pathology

  • Versions: 5
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 3,143 Last month
  • Docker Downloads: 439
Rankings
Docker downloads count: 2.2%
Downloads: 4.2%
Dependent packages count: 4.7%
Stargazers count: 7.6%
Average: 8.1%
Forks count: 8.1%
Dependent repos count: 21.7%
Maintainers (1)
Last synced: 6 months ago

Dependencies

setup.py pypi
  • numpy *
.github/workflows/build.yaml actions
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v3 composite
  • actions/upload-artifact v3 composite
  • pypa/gh-action-pypi-publish v1.5.0 composite
.github/workflows/tests_full.yml actions
  • actions/checkout v1 composite
  • actions/download-artifact master composite
  • actions/setup-python v2 composite
  • actions/upload-artifact v2 composite
.github/workflows/tests_quick.yml actions
  • actions/checkout v1 composite
  • actions/download-artifact master composite
  • actions/setup-python v2 composite
  • actions/upload-artifact v2 composite