Skip to main content

A toolkit for preprocessing and analyzing whole slide images combining approaches from Histolab and PathoPatcher with GPU acceleration via CuCim

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glasscut-0.1.0a1.tar.gz (25.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glasscut-0.1.0a1-py3-none-any.whl (46.7 kB view details)

Uploaded Python 3

File details

Details for the file glasscut-0.1.0a1.tar.gz.

File metadata

  • Download URL: glasscut-0.1.0a1.tar.gz
  • Upload date:
  • Size: 25.8 MB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for glasscut-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 28a643ac4528d52c779e58e314267ab4e545038cc68df7861a8dfc436b443845
MD5 db11ce723d56bd25032d81a840074412
BLAKE2b-256 5f077fa6bb00f66bd3d5508009b777a1592914a5e119d9163d1c9dc3a43ac657

See more details on using hashes here.

File details

Details for the file glasscut-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: glasscut-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 46.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for glasscut-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 560f1ae2121a10d53ddbaeb710afb182a7ef44c04c2029bd677134f282c6be11
MD5 45ae05cfba7439d9573ede3529512e34
BLAKE2b-256 fdb5de954f09485d3f7a3f01f6dbf4ebe080945b174644aede5ec4e5f536ceb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page