Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

GlassCut

A lightweight, extensible toolkit for preprocessing and analyzing whole slide images (WSI) in digital pathology. GlassCut combines efficient WSI reading, and tiling into a modular pipeline, with optional GPU acceleration via CuCim.

Pipeline Overview

Features

  • Multi-backend WSI reading — OpenSlide (CPU) and CuCim (GPU) backends with automatic fallback
  • Grid tiling — Regular grid extraction with overlap, tissue-prescreening via integral images, and parallel processing
  • Tissue detection — Otsu-based segmentation (Experimental - Custom detectors can be implemented by subclassing TissueDetector)
  • Stain normalization — Macenko and Reinhardt methods (Experimental - Custom normalizers can be implemented by subclassing StainNormalizer)
  • Dataset generation — Multi-slide tile extraction with checkpoint/resume and structured metadata
  • Live dataset — In-memory slide dataset for interactive exploration
  • Extensible design — Abstract base classes for tilers, tissue detectors, and stain normalizers make it easy to plug in custom strategies
  • Sample data — Built-in downloader for public WSI samples (TCGA, Aperio, IDR)

Installation

Install from PyPI (recommended):

pip install glasscut

For GPU acceleration:

pip install "glasscut[gpu]"

Install from source (development):

git clone https://github.com/CamiloSinningUN/GlassCut.git
cd GlassCut
uv sync

Quick Start

from glasscut import Slide, GridTiler, OtsuTissueDetector

# Open a slide
slide = Slide("slide.svs")

# Configure tiling
tiler = GridTiler(
    tile_size=(512, 512),
    magnification=20
)

# Extract tiles
for tile in tiler.extract(slide):
    tile.save(f"tiles/{tile.coords}.png")

slide.close()

Architecture

glasscut
├── Slide              — WSI reader with backend abstraction
│   └── Backends       — OpenSlide (CPU), CuCim (GPU)
├── Tile               — Individual tile with metadata
├── Tiler              — Abstract tiling strategy
│   └── GridTiler      — Regular grid tiler with overlap
├── TissueDetector     — Abstract tissue detection
│   └── OtsuTissueDetector
├── StainNormalizer    — Abstract stain normalization
│   ├── MacenkoStainNormalizer
│   └── ReinhardtStainNormalizer
├── DatasetGenerator   — Multi-slide → disk dataset pipeline
├── LiveSlideDataset   — In-memory slide dataset
└── DataFetcher        — Sample WSI downloader

Documentation

Full documentation is available at https://CamiloSinningUN.github.io/GlassCut.

References

This project draws inspiration from:

  • Marcolini, A., Bussola, N., Arbitrio, E., Amgad, M., Jurman, G., & Furlanello, C. (2022). histolab: A Python library for reproducible Digital Pathology preprocessing with automated testing. SoftwareX, 20(101237).
  • Hörst, F., Schaheer, S. H., Baldini, G., Bahnsen, F. H., Egger, J., & Kleesiek, J. (2024). Accelerating Artificial Intelligence-based Whole Slide Image Analysis with an Optimized Preprocessing Pipeline. Bildverarbeitung für die Medizin 2024, pp. 356–361. https://doi.org/10.1007/978-3-658-44037-4_91
  • kaiko.ai et al. (2024). Towards Large-Scale Training of Pathology Foundation Models. arXiv preprint arXiv:2404.15217.

Author

Camilo José Sinning López

License

This project is licensed under the MIT License — see the LICENSE file for details.

Metadata

Release files for glasscut 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glasscut 0.1.0a1
File Size Uploaded
glasscut-0.1.0a1.tar.gz 25.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for glasscut 0.1.0a1
File Interpreter ABI Platform
glasscut-0.1.0a1-py3-none-any.whl Python 3 none any Details

Total release size: 25.8 MB

Release files / glasscut-0.1.0a1.tar.gz

Download URL glasscut-0.1.0a1.tar.gz
Size 25.8 MB
Tags Source
SHA-256 checksum
How to use checksums
28a643ac4528d52c779e58e314267ab4e545038cc68df7861a8dfc436b443845
BLAKE2b-256 checksum
How to use checksums
5f077fa6bb00f66bd3d5508009b777a1592914a5e119d9163d1c9dc3a43ac657
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / glasscut-0.1.0a1-py3-none-any.whl

Download URL glasscut-0.1.0a1-py3-none-any.whl
Size 46.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
560f1ae2121a10d53ddbaeb710afb182a7ef44c04c2029bd677134f282c6be11
BLAKE2b-256 checksum
How to use checksums
fdb5de954f09485d3f7a3f01f6dbf4ebe080945b174644aede5ec4e5f536ceb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.0a1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page