GithubHelp home page GithubHelp logo

tcxxxx / wsi-analysis Goto Github PK

View Code? Open in Web Editor NEW
35.0 3.0 13.0 4.56 MB

Python scripts for automatic Whole-Slide Image preprocessing.

Python 2.34% HTML 97.66%
medical wholeslide-imaging wsi patches multipleinstance imageprocessing

wsi-analysis's Introduction

Whole-Slide Image Analysis


Background

Whole-Slide images(WSI) are gigapixel high-resolution histopathology images. Traditional analysis procedures could not work efficiently if directly applied to WSIs. Most successful solutions adopted patch-based paradigm.


Overview 

This repo currently contains codes for patch extraction (from WSI) and will be updated constantly. :) (Deep-learning based codes for classification and segmentation will be added when they are ready).

Patch extraction 

There are several tricky parts when extracting patches from WSIs:

  1. Memory limit.
    The RAM size of our lab is 31 GB, and it could hardly hold a level0 WSI. So be careful when loading the whole image.
    It is also helpful to use del and gc.collect() to free up memory.
    And in order to process level0/1/2 WSIs, we need to split the original image up.
  2. Coordinates scaling level/reference frame.
    The read_region() method in OpenSlide processes WSIs in level 0 reference frame. So necessary transformation is needed when we crop patches from WSIs using read_region() method.
  3. Shape difference between Pillow Image object and NumPy arrays.
    numpy.asarray() / numpy.array() would switch the position of WIDTH and HEIGHT in shape, and vice versa. If an Image object' shape is (WIDTH, HEIGHT, CHANNEL), the shape will be (HEIGHT, WIDTH, CHANNEL) after the np.asarray() transformation.
  4. Magnification level choice
    Below is an patch-extraction example (performed on one sample from Camelyon 2017 dataset). Red boxes are selected patches and green ones annotated tumor areas. As we can see, when we extract 500 x 500 patches from a WSI in level3 scale, the portion of tumor areas are too small, which means discriminative information could be significantly diluted if we use all these selected patches to train CNN.
    This urges us to use smaller magnification level (higher resolution scale). slide09-1

wsi-analysis's People

Contributors

abhinavdhere avatar tcxxxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wsi-analysis's Issues

Hard coded constants

Constants are hard coded as global variables. When importing the tools from an external code, it gets hard to pass different parameters. Reading these constants from a user defined config text file can fix this issue. I'll work on it and send a PR.

Verbosity parameter

The patch extraction module prints a lot of information during the process which may not be desirable, depending on how the code is used. Adding a verbose parameter to control the level of output should sort this. I'm working on this and would send a PR.

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.