A patch miner for large histopathology images
Project description
OPM
Open Patch Manager: parallel reading/writing of patches.
Installation:
For Usage Only
conda create -p ./venv python=3.8.12 -y
conda activate ./venv
pip install OpenPatchMiner
## alternate
# conda install -c conda-forge openpatchminer
For OPM Development
git clone https://github.com/CBICA/OPM.git
cd OPM/
conda create -p ./venv python=3.8.12 -y
conda activate ./venv
pip install .
Usage
To try an example:
# continue from virtual environment shell
# Extract 10 tissue patches from images/example_slide.tiff
python patch_miner.py -i images/example_slide.tiff -lm images/example_lm.tiff -o example -c opm/config.yml
# Use the output manifest from last run (example/list.csv) to re-extract the same patches for a different replicate
# This is useful if you have multiple slides/label maps and you want corresponding coordinates from each of them
python patch_miner.py -i images/example_slide.tiff -lm images/example_lm.tiff -c opm/config.yml -o example_replicate --input_csv example/list.csv
By default it detects tissue and extracts 1000 random patches from the included .svs file. Play with this number as well as the number of parallel threads in example.py (default patches=1000, default threads=100)
Options
There are also a handful of useful options:
READ_TYPE
: either 'sequential' or 'random'. If sequential, it repeatedly takes the top-leftmost valid index until quota is met or the slide is saturated. If random, it randomly samples a patch from the valid indices until saturated or the quota is hit.
... and various other parameters such as patch size, thumbnail/valid mask scale, and masking thresholds.
Workflow
OPM follows the following workflow:
Project Structure
.
├── images
│ ├── example_lm.tiff
│ ├── example_slide.tiff
│ └── opm_flowchart.png
├── LICENSE.txt
├── opm
│ ├── config.py
│ ├── __init__.py
│ ├── patch_manager.py
│ ├── patch.py
│ └── utils.py
├── patch_miner.py
├── README.md
├── setup.cfg
└── setup.py
Changelog
Dec. 14, 2021:
- Replaced slide library with tifffile
- Made barebones OpenSlide mimic with tifffile, named SlideObject
- Updated requirements, bumped minimum python from 3.6 --> 3.8 (due to zarr requirements)
- Updated README
Dec. 9, 2021:
- Changed backend to Pandas.
- Updated README
Nov. 17, 2020:
- Added support for mining patches from label map along with the slide.
- Updated README
Jul. 31, 2020:
- Changed
ALLOW_OVERLAP
toOVERLAP_FACTOR
.OVERLAP_FACTOR
is a float from 0 to 1 that is the portion of patches that are allowed to overlap. If 0, there is no overlap allowed. If 1, they are totally allowed to overlap (except for the origin pixel).
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
OpenPatchMiner-0.1.8.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file OpenPatchMiner-0.1.8.tar.gz
.
File metadata
- Download URL: OpenPatchMiner-0.1.8.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3fbd42af73027f0c5723352fc40250f94373a16d571b3b8f15b3b4cba54cd2d |
|
MD5 | 8d49fb1862ec5a51e0df3f0ce782efc0 |
|
BLAKE2b-256 | 72b9b084379a9057c0e86a55ab6cdd1b5af1238506c61eb5345ff9834a5116ff |
File details
Details for the file OpenPatchMiner-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: OpenPatchMiner-0.1.8-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ebb1d05e66de280fad87587946dea0807b5a11f7137ec61d0509d2ccfa66e85 |
|
MD5 | e189730187b87e32794d6b712359c3e3 |
|
BLAKE2b-256 | b43a4bb9e5421abb7d80312aebd24bd2cf4e99b4602ef48442077c82287b695a |