agentsclimarketplace

Alterlab histolab

Skill AlterLab-IEU/AlterLab-Academic-Skills/skills/bioinformatics/alterlab-histolab

239 evaluated academic Claude/agent skills across 17 research domains (bioinformatics, data science, clinical, social-science methods, Turkish academia & more). Executable eval per skill, deterministic citation verifier, research→write→review→publish pipeline, and a skill-finder front door. Claude Code, Cursor, Codex, Gemini CLI & Copilot.

Install
npx -y skills add AlterLab-IEU/AlterLab-Academic-Skills --skill alterlab-histolab

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

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.

The file declares its own license as Apache-2.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

7.5 KB, as published. Nobody here has run it

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.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.