‹ 首页

alterlab-histolab

@alterlab-ieu · 收录于 1 周前

Extract and preprocess tiles from whole-slide images (WSI) with histolab — OpenSlide-backed slide loading, tissue detection and masks, Random/Grid/Score tile extraction, and image/morphological filters for H&E preprocessing. Use when the user needs lightweight WSI slide preprocessing — building tile datasets for ML training, tissue segmentation, or quick tile-based inspection of histopathology slides. For end-to-end computational-pathology, deep-learning model training, nucleus segmentation, or multiplexed/spatial-proteomics (CODEX, Vectra) pipelines prefer alterlab-pathml instead. Part of the AlterLab Academic Skills suite.

适合你,如果需要在组织病理学全切片图像上构建瓦片数据集。

/ 下载安装
alterlab-histolab.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add alterlab-ieu/alterlab-academic-skills/alterlab-histolab
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- alterlab-ieu/alterlab-academic-skills/alterlab-histolab
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify alterlab-ieu/alterlab-academic-skills/alterlab-histolab
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
39GitHub stars
~1.4K最小装载
~13.9K含声明引用
~14.8K文本包总量
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · a0064fd

Histolab

Overview

Histolab is a Python library for processing whole slide images (WSI) in digital pathology. It automates tissue detection, extracts informative tiles from gigapixel images, and prepares datasets for deep learning pipelines. The library handles multiple WSI formats, implements sophisticated tissue segmentation, and provides flexible tile extraction strategies.

When to Use This Skill

Use histolab for lightweight WSI tile pipelines: tissue detection, building tile datasets for ML training, H&E stain handling, and quick tile-based analysis of histopathology slides. For advanced spatial proteomics, multiplexed imaging, or full deep-learning pathology pipelines, use pathml instead.

Installation
uv pip install "histolab==0.7.0"

histolab wraps the OpenSlide C library, which is not bundled with the pip package. On macOS install it with brew install openslide; without it, any import histolab.slide fails with Couldn't locate OpenSlide dylib. The examples below are pinned to histolab 0.7.0; the API differs in older releases.

Core Workflow
  1. Load the slide with Slide(path, processed_path=...) and inspect dimensions/levels.
  2. Detect tissue with a mask (TissueMask or BiggestTissueBoxMask).
  3. Preview tile locations with tiler.locate_tiles(slide) before committing.
  4. Extract tiles with one of three tilers (Random/Grid/Score).

Minimal example:

from histolab.slide import Slide
from histolab.tiler import RandomTiler

slide = Slide("slide.svs", processed_path="output/")
# n_tiles, level, seed are CONSTRUCTOR args — not args to locate_tiles/extract.
tiler = RandomTiler(tile_size=(512, 512), n_tiles=100, level=0, seed=42)
tiler.locate_tiles(slide)   # preview locations on the thumbnail first
tiler.extract(slide)        # writes PNGs into processed_path

API gotcha (histolab 0.7.0): locate_tiles() and extract() take only slide, an optional extraction_mask, and logging/styling kwargs — they do not accept n_tiles. Set n_tiles (and seed, level, tile_size, check_tissue, tissue_percent) on the tiler constructor. The extraction_mask is passed to extract()/locate_tiles(), never to the constructor.

Full copy-pasteable pipelines (quick start, 5 end-to-end workflows, and per-capability examples) live in references/workflows.md.

Core Capabilities
1. Slide Management

Load, inspect, and work with WSI files (SVS, TIFF, NDPI, etc.): access metadata (dimensions, magnification, properties), generate thumbnails, and work with pyramidal/multi-level structures. Key class: Slide.

See references/slide_management.md for slide initialization, built-in sample datasets (prostate_tissue, ovarian_tissue, breast_tissue, heart_tissue, aorta_tissue, plus pen-marked and IHC samples), pyramid levels, and multi-slide processing.

2. Tissue Detection and Masks

Automatically identify tissue regions and filter background/artifacts. Key classes: TissueMask (all tissue regions), BiggestTissueBoxMask (bounding box of largest region — the default), and BinaryMask (base class for custom masks).

Choosing a mask:

  • TissueMask: multiple tissue sections, comprehensive analysis
  • BiggestTissueBoxMask: single main section, exclude artifacts (default)
  • Custom BinaryMask: specific ROI, exclude annotations, custom segmentation

See references/tissue_masks.md for how detection filters work, visualizing masks with locate_mask(), and custom rectangular / annotation-exclusion masks.

3. Tile Extraction

Extract smaller regions from large WSI using one of three strategies:

  • RandomTiler — fixed number of randomly positioned tiles. Best for sampling diverse regions, exploration, training data. Key params: n_tiles, seed.
  • GridTiler — systematic grid across tissue. Best for complete coverage, spatial analysis, reconstruction. Key param: pixel_overlap.
  • ScoreTiler — top-ranked tiles by scoring function. Best for informative regions, quality-driven selection. Key param: scorer (NucleiScorer, CellularityScorer, custom).

Common parameters: tile_size, level (0 = highest res), check_tissue, tissue_percent (default 80%), extraction_mask. Always preview with locate_tiles() before extracting.

See references/tile_extraction.md for scorers, reporting, and advanced (multi-level, hierarchical) extraction patterns.

4. Filters and Preprocessing

Apply image-processing filters for tissue detection, QC, and preprocessing:

  • Image filtersRgbToGrayscale, RgbToHsv, RgbToHed, OtsuThreshold, Invert, StretchContrast, HistogramEqualization, Lambda.
  • Morphological filtersBinaryDilation, BinaryErosion, BinaryOpening, BinaryClosing, RemoveSmallObjects, RemoveSmallHoles.
  • CompositionCompose (in histolab.filters.image_filters) chains filters into pipelines. Pass custom filters to a mask as positional varargs: TissueMask(RgbToGrayscale(), OtsuThreshold(), ...).

See references/filters_preprocessing.md for filter chaining, common pipelines (tissue detection, pen removal, nuclei enhancement), and QC filters.

5. Visualization

Display slides, masks, tile locations, and extraction quality: thumbnails, mask overlays via locate_mask(), tile-location previews via locate_tiles(), tile mosaics, and score distributions.

See references/visualization.md for mosaics, quality-assessment plots, multi-slide comparison, and exporting high-resolution figures / PDF reports.

Reference Index
  • references/workflows.md — quick start, per-capability examples, and 5 end-to-end worked workflows (exploratory, grid, score-driven, multi-slide, custom tissue detection).
  • references/slide_management.md — loading/inspecting slides, sample datasets, pyramid levels, multi-slide processing.
  • references/tissue_masks.mdTissueMask/BiggestTissueBoxMask/BinaryMask, custom masks, mask visualization and integration.
  • references/tile_extraction.md — Random/Grid/Score tiler comparison, scorers, CSV reporting, advanced extraction patterns.
  • references/filters_preprocessing.md — image + morphological filters, filter composition, preprocessing pipelines, QC filters.
  • references/visualization.md — thumbnails, mask/tile previews, mosaics, quality plots, figure export.
  • references/best_practices.md — best practices, common use cases, and troubleshooting (no tiles, background tiles, slow extraction, artifacts).

Load the specific reference file you need for detailed implementation guidance, troubleshooting, or advanced features.

按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。