histolab

davila7/claude-code-templates · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/davila7/claude-code-templates --skill histolab
0 commentsdiscussion
summary

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.

skill.md

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.

Installation

uv pip install histolab

Quick Start

Basic workflow for extracting tiles from a whole slide image:

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

# Load slide
slide = Slide("slide.svs", processed_path="output/")

# Configure tiler
tiler = RandomTiler(
    tile_size=(512, 512),
    n_tiles=100,
    level=0,
    seed=42
)

# Preview tile locations
tiler.locate_tiles(slide, n_tiles=20)

# Extract tiles
tiler.extract(slide)

Core Capabilities

1. Slide Management

Load, inspect, and work with whole slide images in various formats.

Common operations:

  • Loading WSI files (SVS, TIFF, NDPI, etc.)
  • Accessing slide metadata (dimensions, magnification, properties)
  • Generating thumbnails for visualization
  • Working with pyramidal image structures
  • Extracting regions at specific coordinates

Key classes: Slide

Reference: references/slide_management.md contains comprehensive documentation on:

  • Slide initialization and configuration
  • Built-in sample datasets (prostate, ovarian, breast, heart, kidney tissues)
  • Accessing slide properties and metadata
  • Thumbnail generation and visualization
  • Working with pyramid levels
  • Multi-slide processing workflows

Example workflow:

from histolab.slide import Slide
from histolab.data import prostate_tissue

# Load sample data
prostate_svs, prostate_path = prostate_tissue()

# Initialize slide
slide = Slide(prostate_path, processed_path="output/")

# Inspect properties
print(f"Dimensions: {slide.dimensions}")
print(f"Levels: {slide.levels}")
print(f"Magnification: {slide.properties.get('openslide.objective-power')}")

# Save thumbnail
slide.save_thumbnail()

2. Tissue Detection and Masks

Automatically identify tissue regions and filter background/artifacts.

Common operations:

  • Creating binary tissue masks
  • Detecting largest tissue region
  • Excluding background and artifacts
  • Custom tissue segmentation
  • Removing pen annotations

Key classes: TissueMask, BiggestTissueBoxMask, BinaryMask

Reference: references/tissue_masks.md contains comprehensive documentation on:

  • TissueMask: Segments all tissue regions using automated filters
  • BiggestTissueBoxMask: Returns bounding box of largest tissue region (default)
  • BinaryMask: Base class for custom mask implementations
  • Visualizing masks with locate_mask()
  • Creating custom rectangular and annotation-exclusion masks
  • Mask integration with tile extraction
  • Best practices and troubleshooting

Example workflow:

from histolab.masks import TissueMask, BiggestTissueBoxMask

# Create tissue mask for all tissue regions
tissue_mask = TissueMask()

# Visualize mask on slide
slide.locate_mask(tissue_mask)

# Get mask array
mask_array = tissue_mask(slide)

# Use largest tissue region (default for most extractors)
biggest_mask = BiggestTissueBoxMask()

When to use each mask:

  • TissueMask: Multiple tissue sections, comprehensive analysis
  • BiggestTissueBoxMask: Single main tissue section, exclude artifacts (default)
  • Custom BinaryMask: Specific ROI, exclude annotations, custom segmentation

3. Tile Extraction

Extract smaller regions from large WSI using different strategies.

Three extraction strategies:

RandomTiler: Extract fixed number of randomly positioned tiles

  • Best for: Sampling diverse regions, exploratory analysis, training data
  • Key parameters: n_tiles, seed for reproducibility

GridTiler: Systematically extract tiles across tissue in grid pattern

  • Best for: Complete coverage, spatial analysis, reconstruction
  • Key parameters: pixel_overlap for sliding windows

ScoreTiler: Extract top-ranked tiles based on scoring functions

  • Best for: Most informative regions, quality-driven selection
  • Key parameters: scorer (NucleiScorer, CellularityScorer, custom)

Common parameters:

  • tile_size: Tile dimensions (e.g., (512, 512))
  • level: Pyramid level for extraction (0 = highest resolution)
  • check_tissue: Filter tiles by tissue content
  • tissue_percent: Minimum tissue coverage (default 80%)
  • extraction_mask: Mask defining extraction region

Reference: references/tile_extraction.md contains comprehensive documentation on:

  • Detailed explanation of each tiler strategy
  • Available scorers (NucleiScorer, CellularityScorer, custom)
  • Tile preview with locate_tiles()
  • Extraction workflows and reporting
  • Advanced patterns (multi-level, hierarchical extraction)
  • Performance optimization and troubleshooting

Example workflows:

from histolab.tiler import RandomTiler, GridTiler, ScoreTiler
from histolab.scorer import NucleiScorer

# Random sampling (fast, diverse)
random_tiler = RandomTiler(
    tile_size=(512, 512),
    n_tiles=100,
    level=0,
    seed=42,
    check_tissue=True,
    tissue_percent=80.0
)
random_tiler.extract(slide)

# Grid coverage (comprehensive)
grid_tiler = GridTiler(
    tile_size=(512, 512),
    level=0,
    pixel_overlap=0,
    check_tissue=True
)
grid_tiler.extract(slide)

# Score-based selection (most informative)
score_tiler = ScoreTiler(
    tile_size=(512, 512),
    n_tiles=50,
    scorer=NucleiScorer(),
    level=0
)
score_tiler.extract(slide, report_path="tiles_report.csv")

Always preview before extracting:

# Preview tile locations on thumbnail
tiler.locate_tiles(slide, n_tiles=20)

4. Filters and Preprocessing

Apply image processing filters for tissue detection, quality control, and preprocessing.

Filter categories:

Image Filters: Color space conversions, thresholding, contrast enhancement

  • RgbToGrayscale, RgbToHsv, RgbToHed
  • OtsuThreshold, AdaptiveThreshold
  • StretchContrast, HistogramEqualization

Morphological Filters: Structural operations on binary images

  • BinaryDilation, BinaryErosion
  • BinaryOpening, BinaryClosing
  • RemoveSmallObjects, RemoveSmallHoles

Composition: Chain multiple filters together

  • Compose: Create filter pipelines

Reference: references/filters_preprocessing.md contains comprehensive documentation on:

  • Detailed explanation of each filter type
  • Filter composition and chaining
  • Common preprocessing pipelines (tissue detection, pen removal, nuclei enhancement)
  • Applying filters to tiles
  • Custom mask filters
  • Quality control filters (blur detection, tissue coverage)
  • Best practices and troubleshooting

Example workflows:

from histolab.filters.compositions import Compose
from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold
from histolab.filters.morphological_filters import (
    BinaryDilation, RemoveSmallHoles, RemoveSmallObjects
)

# Standard tissue detection pipeline
tissue_detection = Compose([
    RgbToGrayscale(),
    OtsuThreshold(),
    BinaryDilation(disk_size=5),
    RemoveSmallHoles(area_threshold=1000),
    RemoveSmallObjects(area_threshold=500)
])

# Use with custom mask
from histolab.masks import TissueMask
custom_mask = TissueMask(filters=tissue_detection)

# Apply filters to tile
from histolab.tile import Tile
filtered_tile = tile.apply_filters(tissue_detection)

5. Visualization

Visualize slides, masks, tile locations, and extraction quality.

Common visualization tasks:

  • Displaying slide thumbnails
  • Visualizing tissue masks
  • Previewing tile locations
  • Assessing tile quality
  • Creating reports and figures

Reference: references/visualization.md contains comprehensive documentation on:

  • Slide thumbnail display and saving
  • Mask visualization with locate_mask()
  • Tile location preview with locate_tiles()
  • Displaying extracted tiles and mosaics
  • Quality assessment (score distributions, top vs bottom tiles)
  • Multi-slide visualization
  • Filter effect visualization
  • Exporting high-resolution figures and PDF reports
  • Interactive visualization in Jupyter notebooks

Example workflows:

how to use histolab

How to use histolab on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add histolab
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/davila7/claude-code-templates --skill histolab

The skills CLI fetches histolab from GitHub repository davila7/claude-code-templates and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/histolab

Reload or restart Cursor to activate histolab. Access the skill through slash commands (e.g., /histolab) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

User Story & Requirements Generation

Create detailed user stories, acceptance criteria, and feature specs

Example

Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios

Reduce spec writing time by 50%, ensure comprehensive coverage

Competitive Analysis

Research competitors, compare features, identify gaps

Example

Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities

Complete competitive research in 2 hours instead of 2 days

Roadmap Prioritization

Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs

Example

Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale

Make data-driven prioritization decisions faster

Stakeholder Communication

Draft PRDs, status updates, and stakeholder presentations

Example

Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement

Save 3-5 hours/week on communication overhead

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client
  • Access to product documentation and roadmap tools (Jira, Notion, etc.)
  • Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
  • Stakeholder contact information and communication channels

Time Estimate

30-60 minutes to see productivity improvements

Installation Steps

  1. 1.Install product management skill
  2. 2.Start with user story generation for known feature
  3. 3.Progress to competitive analysis: research 2-3 competitors
  4. 4.Use for roadmap prioritization: apply RICE/ICE scoring
  5. 5.Draft stakeholder communications and refine based on feedback
  6. 6.Build template library for recurring PM tasks
  7. 7.Share effective prompts with product team

Common Pitfalls

  • Not validating competitive research—verify facts before sharing
  • Accepting user stories without involving engineering team
  • Over-relying on frameworks without qualitative judgment
  • Not customizing outputs to company culture and communication style
  • Skipping stakeholder validation of generated requirements

Best Practices

✓ Do

  • +Validate research and competitive analysis with real data
  • +Collaborate with engineering when generating technical requirements
  • +Customize frameworks and templates to your company context
  • +Use skill for first drafts, refine with stakeholder input
  • +Document successful prompt patterns for PM tasks
  • +Combine AI efficiency with human judgment and intuition

✗ Don't

  • Don't publish competitive analysis without fact-checking
  • Don't finalize user stories without engineering review
  • Don't make prioritization decisions solely on AI scoring
  • Don't skip customer validation of generated requirements
  • Don't ignore company-specific context and culture

💡 Pro Tips

  • Provide context: company goals, constraints, customer feedback
  • Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
  • Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
  • Use skill for 70% generation + 30% customization to company needs

When to Use This

✓ Use When

Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.

✗ Avoid When

Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.

Learning Path

  1. 1Basic: user stories, feature specs, status updates
  2. 2Intermediate: competitive analysis, prioritization frameworks, PRDs
  3. 3Advanced: product strategy, go-to-market planning, OKR setting
  4. 4Expert: product vision, market positioning, business model innovation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.550 reviews
  • Shikha Mishra· Dec 28, 2024

    Registry listing for histolab matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Diego Rahman· Dec 24, 2024

    I recommend histolab for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Isabella Thompson· Dec 16, 2024

    Registry listing for histolab matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Hassan Ramirez· Dec 12, 2024

    histolab reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Yuki Sethi· Dec 8, 2024

    Solid pick for teams standardizing on skills: histolab is focused, and the summary matches what you get after install.

  • Aarav Robinson· Nov 27, 2024

    histolab is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Yash Thakker· Nov 19, 2024

    histolab reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Fatima Rahman· Nov 15, 2024

    Keeps context tight: histolab is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Diego Khan· Nov 11, 2024

    Useful defaults in histolab — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Lucas Agarwal· Nov 7, 2024

    histolab reduced setup friction for our internal harness; good balance of opinion and flexibility.

showing 1-10 of 50

1 / 5