HistomicsTK

repository·master·Indexed 19 days ago

https://github.com/digitalslidearchive/histomicstk

A Python-based toolkit for digital pathology image analysis providing algorithms for segmentation, feature extraction, and color processing. It serves as a standalone library and as a backend for the Digital Slide Archive (DSA) and HistomicsUI. Key capabilities include quantitative nuclei feature extraction (morphometry, Fourier shape descriptors, intensity, gradient, and Haralick texture), Reinhard color normalization, and utilities for backing up and querying Girder annotation data via SQLite.

Tokens
34.2K
Snippets
64
Records
138
Agent score
66%

What's inside histomicstk

  1. Overview of histomicstk capabilities

    master

    The histomicstk package provides a suite of algorithms for fundamental image analysis tasks in digital pathology. Key capabilities include:

    • Color Processing: Color normalization and color deconvolution.
    • Image Enhancement: Filtering to enhance specific objects or structures.
    • Segmentation: Cell and nuclei segmentation.
    • Feature Extraction: Extracting quantitative features from segmented objects.
    • Tissue Analysis: Saliency detection for tissue and cellularity detection.
    • Annotation Management: Workflows to convert annotation polygons into masks (for training/validation) and vice versa.
  2. Overview of histomicstk.segmentation sub-packages

    master

    The histomicstk.segmentation module provides various tools for image segmentation and analysis. It is organized into several specialized sub-packages:

    • histomicstk.segmentation.label: Tools for label mask processing.
    • histomicstk.segmentation.level_set: Implementation of level-set segmentation methods.
    • histomicstk.segmentation.nuclear: Specialized tools for nuclei segmentation.
    • histomicstk.segmentation.positive_pixel_count: Functionality for counting positive pixels within segmented regions.
  3. Overview of ComputeNucleiFeatures Application

    master

    The ComputeNucleiFeatures.py application is used to extract quantitative features from nuclei in an image, which can then be used for nuclei classification tasks.

    It computes several categories of features:

    • Morphometry: Size and shape features.
    • Fourier Shape Descriptors (FSD): Shape descriptors based on Fourier analysis.
    • Intensity: Intensity features from both nucleus and cytoplasm channels.
    • Gradient: Gradient/edge features from both nucleus and cytoplasm channels.
    • Haralick Texture: Texture features for nucleus and cytoplasm channels.

    Each feature group can be toggled on or off via CLI flags. The application outputs a .csv file where each row represents the features of a single detected nucleus.

  4. Overview of HistomicsTK

    master

    HistomicsTK is a Python package designed for the analysis of digital pathology images. It provides fundamental algorithms for tasks such as color normalization, color deconvolution, nuclei segmentation, and feature extraction.

    It can be used in two primary modes:

    1. As a pure Python package: For independent image analysis workflows.
    2. As an image-processing task library: Integrated with HistomicsUI and the Digital Slide Archive (DSA) to allow users to run containerized analysis modules/pipelines via a web interface.

    Developers can extend its functionality using slicer cli web to integrate custom algorithms into the DSA ecosystem.

  5. Explore histomicstk.annotations_and_masks modules

    master

    The histomicstk.annotations_and_masks module provides a suite of tools for managing, converting, and processing annotations and segmentation masks. Key capabilities include:

    • Database Management: Backing up annotation databases and parsing SQLite files.
    • Visualization: Using the Mosaic review gallery to inspect annotations.
    • Conversion (Annotations to Masks): Converting polygon-based annotations into either semantic segmentation masks or object segmentation masks.
    • Conversion (Masks to Annotations): Converting pixel-based masks back into annotation formats.
    • Utilities: General purpose tools for merging polygons and managing annotation/mask data.
  6. Explore histomicstk.preprocessing modules

    master

    The histomicstk.preprocessing package provides a suite of tools for preparing histopathology images for analysis. The available submodules include:

    • Color Space Conversion (histomicstk.preprocessing.color_conversion): Tools for transforming images between different color spaces.
    • Color Deconvolution (histomicstk.preprocessing.color_deconvolution): Methods for separating different stains (e.g., Hematoxylin and Eosin) from a multi-color image.
    • Color Normalization (histomicstk.preprocessing.color_normalization): Techniques to standardize the color appearance of images across different slides or scanners.
    • Data Augmentation (histomicstk.preprocessing.augmentation): Methods to artificially expand training datasets by applying transformations to existing images.
  7. Optimize annotation rendering efficiency by element type

    master

    Not all annotation types are equal in terms of rendering performance. When generating annotations, choose types based on the required complexity and the total number of elements. The order of rendering efficiency (from most efficient to least efficient) is:

    1. Filled polygon (Most efficient)
    2. Unfilled polygon (no opacity)
    3. Rectangle
    4. Line
    5. Point (Least efficient)

    Note: For polygons, efficiency decreases as the number of vertices increases.

  8. Understand the DSA and Girder data model

    master

    Digital Slide Archive (DSA) is built on the girder platform, which uses a MongoDB database to manage data. Developers can programmatically interact with the server to manage the following core elements:

    • Users and Groups: For access control and identity.
    • Collections and Folders: For organizational hierarchy.
    • Items and Files: For storing images and metadata.
    • Annotations: For image markup.
    • Assetstores: For managing large assets.

    Permissions are managed at both the user and group levels, providing granular control over access to data and annotations.

  9. Understand HistomicsUI annotation rendering limits

    master

    HistomicsUI has hard limits to prevent browser crashes when rendering large datasets. If these limits are exceeded, the UI employs sampling or simplification strategies:

    • Annotation Documents Limit: A maximum of 5,000 annotation documents can be displayed. If a slide contains more than 5,000, HistomicsUI will sample 5,000 of them for display.
    • Element Limit: A maximum of 2,000,000 total elements (combined across all documents in a slide) can be displayed. If this limit is exceeded, the smallest elements (determined by bounding box diagonal) are rendered as simple circles to maintain performance.
  10. Understand the annotation schema

    master

    In DSA, annotations follow the schema provided by the large_image library. It is important to distinguish between three levels of abstraction:

    1. Annotation Document: The indivisible unit used for sending and receiving data via the API. It contains a set of elements.
    2. Elements: Individual geometric shapes such as points, rectangles, lines, and polygons. Elements have style attributes (e.g., line and fill color).
    3. Groups: A conceptual grouping of elements (e.g., 'cell types' or 'tissue regions') that can cut across multiple annotation documents. Groups are linked to standard styles to ensure consistency in multi-user studies.
  11. Manage permissions for annotation projects using user groups

    master

    To manage access to folders and annotations effectively, establish user groups at the beginning of a project. This ensures that permissions are maintained as users join or leave. A recommended pattern is to create three distinct groups:

    1. View group: Users who can only see data.
    2. Edit group: Users who can create and modify annotations.
    3. Owner group: Users with full administrative control.

    Permission Inheritance Rules

    • Folders: Inherit permissions from their parent by default. If a folder is moved, it preserves its original permissions. If a folder is copied, it inherits the permissions of the destination parent.
    • Items/Slides: Do not have independent permissions; they inherit permissions from the folder they reside in.
    • Annotation documents: Inherit permissions from the folder containing their associated item. The creator of the annotation has owner permissions by default. Note: If an item is moved to a new folder, the annotations retain their original permissions even though the item itself inherits new folder permissions.
  12. Install Slicer CLI Docker Images for Analysis

    master

    HistomicsTK uses Docker images conforming to the Slicer execution model to perform image analyses. System administrators can install these images via the Girder Web API.

    Steps to add a Docker image:

    1. Access the Girder Web API (link located at the bottom of the Girder web page).
    2. Locate the PUT endpoint: /HistomicsTK/HistomicsTK/docker_image.
    3. Provide a JSON list of Docker images (including specific tags if desired) in the request body.
    4. Click "Try it out" to trigger the pull.

    Once pulled, the image becomes available within the HistomicsTK interface. You can install multiple versions of an image to compare results.

    ["dsarchive/histomicstk:latest"]
    
    # Endpoint: PUT /HistomicsTK/HistomicsTK/docker_image