histolab
Allows your agent to extract and prepare histology images. It's useful for inspecting slides, normalizing colors, and preparing image datasets for analysis.
What it does
Histolab is a tool for preparing microscope slide images. It helps select specific parts (tiles) of these images for analysis, normalize colors for consistency, and organize data for future studies.
When to use it
- ✓When you need to select specific pieces from a slide image for analysis.
- ✓To standardize the color appearance across different slide images.
- ✓To organize a set of slide images for training artificial intelligence models.
Example of what to ask your AI
“Select 100 random 512x512 pixel tiles from the 'example.svs' slide, focusing on areas with at least 80% tissue.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
Histolab first identifies tissue areas in the slide. Then, it uses different methods (random, grid, score-based) to choose which image pieces to extract. It can also adjust colors so all images look similar.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add K-Dense-AI/scientific-agent-skills --skill histolabOr download just the file:
curl -L https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/main/skills/histolab/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Histolab
When to use
Use Histolab to inspect WSI metadata, identify tissue, extract image tiles, and standardize H&E staining. Its masks and scores are image-processing heuristics; they do not diagnose cancer, count individual cells, or establish image quality.
Installation
Histolab 0.7.0 remains the latest published release as of the review date. Its release constraints require Python <3.12, NumPy <=1.24.4, scikit-image <0.19.4, SciPy <1.10.1, Pillow <11, and openslide-python 1.3.1. Keep this stack isolated from modern scientific environments. Windows is not supported by this Histolab release.
Install native OpenSlide for your system, then create a dedicated environment (Python 3.10 was tested):
uv venv --python 3.10 .venv-histolab
uv pip install --python .venv-histolab/bin/python 'histolab==0.7.0' pooch matplotlib
.venv-histolab/bin/python -c 'import openslide; print(openslide.__library_version__)'
On macOS with Homebrew, brew install openslide installs the native library.
If the older Python binding cannot find it, launch Python with the library path
set immediately before Python starts:
env DYLD_FALLBACK_LIBRARY_PATH="$(brew --prefix openslide)/lib" .venv-histolab/bin/python -c 'import openslide; print(openslide.__library_version__)'
pooch is optional for remote examples. Start with a local slide or the tiny
bundled cmu_small_region sample; other sample functions may download hundreds
of megabytes. Exact mpp extraction also needs large-image and a matching
source plugin; see slide management.
Workflow
- Inspect
slide.dimensions,slide.levels(a list), andslide.level_dimensions(level)(a method). Check both MPP axes in metadata. - Select physical field of view and pixel resolution; level numbers are not interchangeable across scanners. Preserve level-0 coordinate bounds.
- Choose
TissueMaskfor all tissue sections orBiggestTissueBoxMaskfor the largest section's bounding box. Inspect the mask at its actual resolution. - Configure a tiler and preview with the same mask passed to extraction. Preview methods return a Pillow image; save or display that return value.
- Extract into a distinct per-slide/per-strategy directory. Count saved files, inspect representative tiles, and retain parameters, source IDs and QC flags.
- Split datasets by patient before training/validation/test tile assignment. Fit stain normalization targets on training data only and validate on held-out scanners. A seed reproduces sampling; it does not prevent patient leakage.
Quick start
Illustrative for a user-provided slide; the same API path is tested with small
local fixtures. n_tiles is an upper bound, not a promise of 100 valid tiles.
from pathlib import Path
from histolab.slide import Slide
from histolab.masks import TissueMask
from histolab.tiler import RandomTiler
output = Path("output/random_tiles")
output.mkdir(parents=True, exist_ok=True)
slide = Slide("slide.svs", processed_path=output)
mask = TissueMask()
slide.locate_mask(mask).save(output / "mask_preview.png")
tiler = RandomTiler(
tile_size=(512, 512), n_tiles=100, level=0, seed=42,
check_tissue=True, tissue_percent=80.0, prefix="random_",
)
tiler.locate_tiles(slide, extraction_mask=mask).save(output / "tile_preview.png")
tiler.extract(slide, extraction_mask=mask)
print("[OK] Saved tiles:", len(list(output.glob("random_tile_*.png"))))
extraction_mask belongs to extract() and locate_tiles(), not to the tiler
constructor. locate_tiles() has no n_tiles argument. Previewing runs tile
selection again, so it may be expensive; use a separate small tiler for initial
exploration, then preview the final configuration before committing a large run.
Choose a strategy
| Tiler | Selection | Important limitation |
|---|---|---|
RandomTiler |
Seeded sampling, at most n_tiles, up to max_iter attempts |
May overlap, repeat, or miss rare structures |
GridTiler |
Grid within the extraction mask | Boundary tiles and tissue checks can leave gaps |
ScoreTiler |
Scores all eligible grid candidates; saves top n_tiles |
Lower output count does not avoid scoring all candidates |
For grids, stride in each axis is tile size minus pixel_overlap; positive
…
FAQ
Can Histolab diagnose diseases?
No, Histolab does not diagnose diseases. It is a tool for preparing and analyzing images, not for making medical diagnoses.
Can I use Histolab on any computer?
The latest version (0.7.0) is not compatible with Windows and requires specific versions of other Python libraries. It's recommended to create a separate environment to use it.
What are 'tiles'?
'Tiles' are small pieces or squares taken from a larger image. In the context of Histolab, they are parts of the microscope slide image extracted for analysis.
Details
Original description by the author
Extracts and preprocesses whole-slide histology image tiles with Histolab. Use for WSI inspection, tissue masks, random/grid/score-based tile extraction, H&E stain normalization, and tile dataset preparation. For multiplexed imaging or deep learning inference pipelines, use pathml.
Popularity
- GitHub stars
- 51k
- Ranking position
- #1884
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
13c-metabolic-flux
Estimates metabolic fluxes using carbon-13 isotope tracing data. It is useful for analyzing cellular metabolism and biochemical pathways.
K-Dense-AI/scientific-agent-skills
adaptyv
Designs protein characterization experiments using the Adaptyv API. It helps estimate costs, submit sequences, and monitor lab results.
K-Dense-AI/scientific-agent-skills
aeon
Performs machine learning tasks on time series data. It is useful for classifying, forecasting, detecting anomalies, and finding patterns in sequential data.
K-Dense-AI/scientific-agent-skills
alphagenome
Looks up precomputed genomic effects for genetic variants. It provides scores and explanations to understand the impact of variants on the genome.
K-Dense-AI/scientific-agent-skills
Similar skills
data-throughput-accelerator
Makes your agent speed up the movement of large data volumes. It finds bottlenecks and ensures data is transferred quickly and correctly.
affaan-m/ECC
inventory-demand-planning
Helps your agent predict product demand in stores. It optimizes stock and plans when to run promotions to sell more.
affaan-m/ECC
market-research
Helps your agent conduct market research and competitive analysis. Provides summaries with source attribution.
affaan-m/ECC