Giter Site home page Giter Site logo

chenyuhang243 / stain-normalizer Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 25 KB

A color normalization method for whole slide image(WSI) tiles, coded with cupy and tifffile, accerated by GPU, inspired by torchstain.

License: Apache License 2.0

Python 100.00%

stain-normalizer's Introduction

stain-normalizer

A color normalization method for whole slide image(WSI) tiles, using cupy and tiffile with GPU to accerate the process, which result in a at least 100X faster speed.

Requirements

  1. cupy
  2. one GPU with according cuda installed

How to use

import tifffile as tif
from stain-normalizer import Normalizer  #if u copy stain-normalizer.py file in working directory
template_tile = tif.TiffSeqence(template_path).asarray() ## u can choose one or several template tiles, but make sure shape of template_tile is 4-D array
target_tile = tif.imread(target_tile_lists) ## return a 4-D array
normalizer = Normalizer()
normalizer.fit(template_tile)     
normalizer.normalize(target_tile) 

Comparement

  • read 2000 tiles(512* 512 * 3) into numpy
    • tifffile.imread read: 1m17s
    • Image.open read: 9m38s
    • cv2.imread : 10m46s
  • color normalization 30k tiles with chunksize=100,V100(16G) without writing tiles to disk: 21m 46s.

Suggestions

  1. use tifffile to load image
  2. use multi GPU. Cupy uses one GPU by default.
  3. Use LMDB or H5DF to load or save image. Or save as numpy format data ".npy". If use tensorflow, tfrecords is suggested. Single image format is least recommeded.
  4. Use multiprocessing or simply cut images into several chunks and run several jobs.

Other implements

  1. pytorch implement: https://github.com/EIDOSlab/torchstain
  2. numpy: https://github.com/schaugf/HEnorm_python
  3. matlab: https://github.com/mitkovetta/staining-normalization
  4. python modules with different methods:https://github.com/Peter554/StainTools

Referrence

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

stain-normalizer's People

Contributors

chenyuhang243 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

wangyh97

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.