Coder Social home page Coder Social logo

lucasrla / wsi-tile-cleanup Goto Github PK

View Code? Open in Web Editor NEW
25.0 3.0 4.0 3.69 MB

Image filters for digital pathology: detect pen marks, background, and artifacts. Use them for preprocessing towards deep learning

License: GNU General Public License v3.0

Python 100.00%
libvips pyvips otsu-threshold whole-slide-imaging wsi pathology preprocessing deep-learning fastai pytorch histopathology

wsi-tile-cleanup's Introduction

wsi-tile-cleanup

Simple library for detecting gibberish tiles from histopathological whole-slide images (WSI).

By gibberish tiles I mean tiles with pen marks and similar artifacts:

wsi_tile_cleanup detects background tiles (based on the Otsu algorithm), red / green / blue pen marks, and black artifacts.

The typical use case for wsi_tile_cleanup is preprocessing whole-slide images (WSI) before loading tiles into a neural network (yes, deep learning).

If you are building a deep learning pipeline, the following repositories might be of interest: @lucasrla/wsi-preprocessing and @lucasrla/wsi-preprocessing-sos-workflow.

Installation

Conda

conda create --name YOUR_ENV_NAME --channel conda-forge python=3.6 libvips pyvips numpy
conda activate YOUR_ENV_NAME

python3.6 -m pip install git+https://github.com/lucasrla/wsi-tile-cleanup.git
# note: `python3.6 -m pip` is to make sure we are using pip from python=3.6

pip or poetry

# first of all, install libvips 
# https://libvips.github.io/libvips/install.html
# (tip: have it installed with openslide support)

# next, create a new virtualenv and activate it using your tool of choice
# (e.g., pyenv, virtualenv, etc)

# then, depending on your dependency manager, run either:
poetry add git+https://github.com/lucasrla/wsi-tile-cleanup.git
# or
pip install git+https://github.com/lucasrla/wsi-tile-cleanup.git

Usage

from wsi_tile_cleanup import filters, utils

img = utils.read_image("data/images/tiles/5.jpeg")
bands = utils.split_rgb(img)

colors = ["red", "green", "blue"]

for color in colors:
    perc = filters.pen_percentage(bands, color)
    print(f"{color}: {perc:.5f}")

See also: examples.py.

Credits and Acknowledgments

Please note that wsi_tile_cleanup is just a very thin wrapper around libvips, pyvips and numpy. They are the ones doing the heavy lifting (and doing it amazingly well).

License

wsi-tile-cleanup is Free Software distributed under the GNU General Public License v3.0.

Dependencies have their own licenses, check them out.

wsi-tile-cleanup's People

Contributors

lucasrla 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

Watchers

 avatar  avatar  avatar

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.