WSIPreToolkit is a python package that provides tools for enhancing medical images.
Project description
WSIPreToolkit Documentation
The WSIPreToolkit
is a Python package that provides various tools for working with tissue images, particularly whole slide images (WSIs). It offers functionality for detecting tissue regions, cropping images, generating patches, and more. This document provides an overview of the package and its usage.
Installation
To install the WSIPreToolkit
package, you can use pip
:
pip install WSIPreToolkit
Usage
Importing the Package
To use the WSIPreToolkit
package, you need to import it in your Python script or notebook:
from WSIPreToolkit import WSIPreToolkit
Tissue Detection
The WSIPreToolkit
class provides a method detect_tissue
for detecting tissue regions in a whole slide image (WSI). It takes the path to the WSI file as input and returns the contours outlining the detected tissue regions, the computed tier array from the mask, the RGB image of the downsampled WSI, and the actual downsampling factor used. Here's an example:
toolkit = WSIPreToolkit()
mask_contours, tier, slide, downsampling_factor = toolkit.detect_tissue(image_location)
Drawing Tissue Polygons
The WSIPreToolkit
class includes a method draw_tissue_polygons
for drawing tissue polygons on a mask image. It takes the input mask image, a list of polygons to be drawn, the type of polygons ('line' or 'area'), and an optional line thickness for 'line' type polygons. Here's an example:
mask = toolkit.draw_tissue_polygons(mask, polygons, polygon_type='line', line_thickness=2)
Cropping Tissue Regions
The WSIPreToolkit
class provides a method tissue_cutout
for extracting the tissue region from a slide image based on tissue contours. It takes the tissue slide image, the list of tissue contours, and the original slide image as input and returns the extracted tissue region. Here's an example:
tissue_only = toolkit.tissue_cutout(tissue_slide, tissue_contours, slide)
Cropping and Removing Empty Space
The WSIPreToolkit
class includes a method detect_and_crop
for detecting tissue in an image, cropping it, and removing empty space. It takes the path or location of the image file as input, along with optional parameters such as sensitivity, downsample rate, and show plot type. It returns the cropped image with removed empty space or None if no tissue contours were found. Here's an example:
cropped_image = toolkit.detect_and_crop(image_location, sensitivity=1500, downsample_rate=4, show_plots='simple')
Generating Patches
The WSIPreToolkit
class provides a method generate_patches
for generating patches from an image with specified patch size and overlap. It takes the image location, patch size, overlap, and TIL score threshold as input and returns an array containing the generated patches or None if the image cannot be loaded. Here's an example:
patches = toolkit.generate_patches(image_location, patch_size=(224, 224, 3), overlap=(112, 112, 0), til_score=0)
Conclusion
The WSI_Pre_Toolkit
package offers a range of tools for working with tissue images, including tissue detection, cropping, patch generation, and more. By using this package, you can streamline your workflow when working with tissue images and extract relevant information efficiently.
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
File details
Details for the file WSIPreToolkit-0.0.2.tar.gz
.
File metadata
- Download URL: WSIPreToolkit-0.0.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6547a69d1eb7969b3d0f0730af7caa5841f9602fa63b3c1a8490ac38c3d8bd78 |
|
MD5 | 667df209fa708cf922f2bf902bf73041 |
|
BLAKE2b-256 | c085790975189f8a899a197628ce81be95eee581fc570f82c62b4bd7ea89d324 |