Preprocessing module for large histological images.
Project description
HistoPrep
Preprocessing large medical images for machine learning made easy!
Description • Installation • Documentation • How To Use • Examples • What's coming?
Description
This module allows you to easily cut and preprocess large histological slides.
- Cut tiles from large slide images.
- Dearray TMA spots (and cut tiles from individual spots).
- Preprocess extracted tiles easily.
Installation
pip install histoprep
You might also have to install OpenSlide and OpenCV from source. Detailed install instructions can be found here.
How To Use
HistoPrep
can be used easily to prepare histologival slide images for machine learning tasks.
You can either use HistoPrep
as a python module...
import histoprep as hp
# Cutting tiles is done with two lines of code
cutter = hp.Cutter('/path/to/slide', width=512, overlap=0.25, max_background=0.7)
metadata = cutter.save('/path/to/output_folder')
or as an excecutable from your command line!
jopo666@MacBookM1$ HistoPrep --help
usage: python3 HistoPrep {step} {arguments}
█ █ █ ██ ███ ███ ███ ███ ███ ███
█ █ █ █ █ █ █ █ █ █ █ █ █ █
████ █ ██ █ █ █ ███ ███ ██ ███
█ █ █ █ █ █ █ █ █ █ █ █
█ █ █ ██ █ ███ █ █ █ ███ █
by Jopo666 (2021)
optional arguments:
-h, --help show this help message and exit
Select one of the below:
cut Cut tiles from large histological slides.
dearray Dearray an tissue microarray (TMA) slide.
Preprocessing
After the tiles have been saved, preprocessing is just a simple outlier detection from the preprocessing metrics saved in metadata.csv
!
from histoprep import preprocess
metadata = preprocess.collect_metadata('/path/to/output_folder')
blurry_tiles = all_metadata['sharpness_max'] < 10
pen_markings = all_metadata['hue_0.1'] < 120
weird_blue_shit = all_metadata['blue_0.05'] > 160
If you're not comfortable working with pandas
dataframes, there's also an Explore()
function that can be used to easily detect and remove outliers from your data.
preprocess.Explore(metadata, channels=True)
Examples
Detailed examples can be found in the docs or the examples folder.
What's coming?
HistoPrep
is under constant development. If there are some features you would like to be added, just submit an issue and we'll start working on the feature!
Requested features:
- Cutting and preprocessing for multichannel images (currently supports only
RGB
-images). - Add automatic detection of outliers from
metadata
.- This could be implemented with dimensionality reduction.
Citation
If you use HistoPrep
in a publication, please cite the github repository.
@misc{histoprep2021,
author = {Pohjonen J. and Ariotta. V},
title = {HistoPrep: Preprocessing large medical images for machine learning made easy!},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/jopo666/HistoPrep}},
}
Changelog
Can be found here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for histoprep-0.0.2.12.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 672267d2ec868270c4c5e259292d543adb0b36efc33cae00d0cb574946fb8bde |
|
MD5 | 3940293014c29746d8dad01d483b2287 |
|
BLAKE2b-256 | a4b6cc6173d1827c524f577aae413d4dee9fdfe7e6905ece6c6cb17af726eb30 |