Histopathology whole slide image library
17
stars
456
commits
Python
primary language
Jul 15, 2026
updated

PySlyde is a comprehensive Python package for preprocessing pathology whole slide images (WSIs). Built as a wrapper around OpenSlide, it provides powerful, user-friendly functionality for working with high-resolution pathology images, making it ideal for researchers and data scientists in the medical imaging domain.
Before installing the Python package, make sure the following system libraries are installed:
sudo apt update
sudo apt install libopenslide0 openslide-tools
pip install pyslyde
git clone https://github.com/PharosKCL/pyslyde.git
cd pyslyde
pip install -e .
git clone https://github.com/PharosKCL/pyslyde.git
cd pyslyde
pip install -e ".[dev]"
git clone https://github.com/PharosKCL/pyslyde.git
cd pyslyde
pip install -e ".[docs]"
from pyslyde import Slide, Annotations
# Load a slide
slide = Slide("path/to/your/slide.svs")
# Load annotations
annotations = Annotations("path/to/annotations.json", source="json")
# Create slide with annotations
slide_with_annotations = Slide(
"path/to/your/slide.svs",
annotations=annotations
)
# Generate mask
mask = slide_with_annotations.generate_mask()
# Extract a region
region, region_mask = slide_with_annotations.generate_region(
x=(1000, 2000),
y=(1500, 2500),
x_size=1000,
y_size=1000
)
from pyslyde import WSIParser
# Create parser
parser = WSIParser(
slide=slide,
tile_dim=256,
border=slide.get_border(),
mag_level=0
)
# Generate tiles
num_tiles = parser.tiler(stride=128)
# Extract features
for coords, features in parser.extract_features(
model_name="resnet50",
model_path="path/to/model.pth"
):
print(f"Tile {coords}: {features.shape}")
# Save tiles to disk
parser.save(
parser.extract_tiles(),
tile_path="output/tiles/"
)
from pyslyde.util.utilities import TissueDetect
# Detect tissue regions
detector = TissueDetect("path/to/slide.svs")
tissue_mask = detector.detect_tissue()
# Get tissue border
border = detector.border()
# Visualize tissue regions
thumbnail = detector.tissue_thumbnail
📖 📚 Documentation
The documentation includes:
To build the documentation locally:
# Install documentation dependencies
pip install -e ".[docs]"
# Build documentation
cd docs
make html
# View documentation
open _build/html/index.html
Or use the provided script:
python build_docs.py
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)The project uses several development tools:
This project is licensed under the MIT License - see the LICENSE file for details.
If you use PySlyde in your research, please cite:
@software{pyslyde2024,
title={PySlyde: A Lightweight, Open-Source Toolkit for Pathology Preprocessing},
authors={Gregory Verghese, Anthony Baptista, Chima Eke, Holly Rafique, Liz Ing-Simmons, Enrico Parisini, Mengyuan Li, Fathima Mohamed, Ananya Bhalla, Lucy Ryan, Michael Pitcher, Concetta Piazzese, James Graham, Dinis Calado, Christopher Banerji, Anita Grigoriadis},
year={2024},
url={https://github.com/PharosKCL/pyslyde}
}
Python
100.0%
Histopathology whole slide image library
17
stars
456
commits
Python
primary language
Jul 15, 2026
updated

PySlyde is a comprehensive Python package for preprocessing pathology whole slide images (WSIs). Built as a wrapper around OpenSlide, it provides powerful, user-friendly functionality for working with high-resolution pathology images, making it ideal for researchers and data scientists in the medical imaging domain.
Before installing the Python package, make sure the following system libraries are installed:
sudo apt update
sudo apt install libopenslide0 openslide-tools
pip install pyslyde
git clone https://github.com/PharosKCL/pyslyde.git
cd pyslyde
pip install -e .
git clone https://github.com/PharosKCL/pyslyde.git
cd pyslyde
pip install -e ".[dev]"
git clone https://github.com/PharosKCL/pyslyde.git
cd pyslyde
pip install -e ".[docs]"
from pyslyde import Slide, Annotations
# Load a slide
slide = Slide("path/to/your/slide.svs")
# Load annotations
annotations = Annotations("path/to/annotations.json", source="json")
# Create slide with annotations
slide_with_annotations = Slide(
"path/to/your/slide.svs",
annotations=annotations
)
# Generate mask
mask = slide_with_annotations.generate_mask()
# Extract a region
region, region_mask = slide_with_annotations.generate_region(
x=(1000, 2000),
y=(1500, 2500),
x_size=1000,
y_size=1000
)
from pyslyde import WSIParser
# Create parser
parser = WSIParser(
slide=slide,
tile_dim=256,
border=slide.get_border(),
mag_level=0
)
# Generate tiles
num_tiles = parser.tiler(stride=128)
# Extract features
for coords, features in parser.extract_features(
model_name="resnet50",
model_path="path/to/model.pth"
):
print(f"Tile {coords}: {features.shape}")
# Save tiles to disk
parser.save(
parser.extract_tiles(),
tile_path="output/tiles/"
)
from pyslyde.util.utilities import TissueDetect
# Detect tissue regions
detector = TissueDetect("path/to/slide.svs")
tissue_mask = detector.detect_tissue()
# Get tissue border
border = detector.border()
# Visualize tissue regions
thumbnail = detector.tissue_thumbnail
📖 📚 Documentation
The documentation includes:
To build the documentation locally:
# Install documentation dependencies
pip install -e ".[docs]"
# Build documentation
cd docs
make html
# View documentation
open _build/html/index.html
Or use the provided script:
python build_docs.py
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)The project uses several development tools:
This project is licensed under the MIT License - see the LICENSE file for details.
If you use PySlyde in your research, please cite:
@software{pyslyde2024,
title={PySlyde: A Lightweight, Open-Source Toolkit for Pathology Preprocessing},
authors={Gregory Verghese, Anthony Baptista, Chima Eke, Holly Rafique, Liz Ing-Simmons, Enrico Parisini, Mengyuan Li, Fathima Mohamed, Ananya Bhalla, Lucy Ryan, Michael Pitcher, Concetta Piazzese, James Graham, Dinis Calado, Christopher Banerji, Anita Grigoriadis},
year={2024},
url={https://github.com/PharosKCL/pyslyde}
}
Python
100.0%