Cornerstone3D

repository·main·Indexed 22 days ago

https://github.com/cornerstonejs/cornerstone3d

A high-performance JavaScript framework for building web-based medical imaging applications using WebGL and WebAssembly. The ecosystem includes @cornerstonejs/core for CPU and GPU rendering, @cornerstonejs/ai for ONNX Runtime Web integration (including SAM), @cornerstonejs/adapters for DICOM SR conversion, and @cornerstonejs/labelmap-interpolation for 3D segmentation workflows. It is compatible with DICOMweb standards and provides codemods for migrating to v5 generic viewports.

Tokens
215.5K
Snippets
627
Records
959
Agent score
77%

What's inside cornerstone3d

  1. Overview of @cornerstonejs/core

    main

    @cornerstonejs/core is the central library in the Cornerstone ecosystem used for building web-based medical imaging applications. It provides the foundational framework for rendering medical images and volumes, supporting both CPU and GPU-based rendering.

    Key capabilities include:

    • Rendering Support: High-performance CPU and GPU-based rendering engines.
    • Loading API: Interfaces for loading medical images and volumes.
    • Caching Utilities: Built-in utilities to manage image and data caching for improved performance.
  2. Overview of Cornerstone3D capabilities

    main

    Cornerstone3D is a lightweight JavaScript library designed for the visualization of medical images in modern web browsers using HTML5 canvas.

    By combining @cornerstonejs/core with accompanying libraries like @cornerstonejs/tools, developers can implement a comprehensive medical imaging suite including:

    • Rendering: Support for various transfer syntaxes (JPEG2000, JPEG Lossless), real-time volume slice streaming, multi-orientation viewing (axial, sagittal, coronal, oblique), MIP/average intensity projections, and image fusion (e.g., PET/CT).
    • Manipulation: Tools for zooming, panning, scrolling through orientations, and adjusting window levels.
    • Annotation: SVG-based annotations stored in physical image space for multi-viewport consistency. Includes distance measurements, ROI statistics (mean, standard deviation), crosshairs, and custom tool creation via ToolGroups.
    • Segmentation: Labelmap rendering in stack, volume, and 3D viewports, including surface conversion, orientation flexibility, and editing via scissor tools (Rectangle, Ellipse).
    • Synchronization: Built-in synchronizers for WindowLevel and Camera states across multiple viewports.
  3. Get started with Cornerstone.js

    main

    Cornerstone is a set of JavaScript libraries for building web-based medical imaging applications. It uses WebGL for high-performance rendering and WebAssembly for fast image decompression. It is standards-compliant with DICOMweb out-of-the-box.

    To learn how to integrate Cornerstone3D into your specific project, visit the official Getting Started Overview.

  4. Explore the Cornerstone3D Monorepo Packages

    main

    The Cornerstone3D project is organized as a monorepo. The following packages are the primary building blocks:

    • @cornerstonejs/core (/packages/core): The core library responsible for rendering images and volumes and managing caching.
    • @cornerstonejs/tools (/packages/tools): The tool library for manipulation, annotation, and segmentation rendering/tools.
    • @cornerstonejs/dicom-image-loader (/packages/dicom-image-loader): Provides image loading for wadors and wadouri DICOM P10 instances over HTTP.
    • @cornerstonejs/nifti-volume-loader (/packages/nifti-volume-loader): Provides image loading for NIfTI files.
    • @cornerstonejs/docs (/packages/docs): Contains documentation, guides, examples, and API references.
  5. Use @cornerstonejs/tools for medical imaging applications

    main

    The @cornerstonejs/tools library provides a specialized set of tools for building interactive web-based medical imaging applications. It includes functionality for:

    • Manipulation: Tools to interact with and view medical images.
    • Annotation: Tools to draw and manage annotations on images.
    • Segmentation: Tools for defining and managing segmented regions within medical data.
    • Tool Framework: A foundational framework that allows developers to build custom interactive imaging applications.

    It is designed to work within the Cornerstone ecosystem and is used as a core component in applications like the OHIF Viewer.

  6. What is Streaming ImageVolume?

    main
    Streaming ImageVolume is a specialized volume loader designed for efficient rendering of large datasets. It implements progressive loading of volume data to the GPU, allowing the renderer to start displaying data as it becomes available rather than waiting for the entire volume to be loaded into memory. This is particularly useful for optimizing performance and perceived latency when working with high-resolution or large-scale volumetric data.
  7. What is VoxelManager and how does it work?

    main

    The VoxelManager is a core component in Cornerstone's architecture designed for efficient voxel data access and volume management. Instead of relying on large, monolithic scalar arrays that consume significant memory, VoxelManager acts as an adapter that interacts with individual images.

    Key architectural shifts include:

    • Single Source of Truth: It uses the image cache as the primary data source, eliminating the need for separate volume caches and reducing synchronization issues.
    • Efficient Streaming: It enables loading images one by one, caching only what is necessary, and streaming data directly to the GPU.
    • Optimized Caching: Data is kept in its native format and only converted when required, minimizing overhead.
    • Simplified Web Workers: It removes dependencies on SharedArrayBuffer, making implementation easier and more secure.
  8. What is an ImageId in Cornerstone3D

    main

    An ImageId is a URL-based identifier that uniquely identifies a single medical image for display in Cornerstone3D.

    Cornerstone3D uses the URL scheme within the ImageId to determine which Image Loader plugin to invoke. This design allows Cornerstone to simultaneously display images from diverse sources and protocols—such as a DICOM CT image retrieved via WADO alongside a JPEG dermatology image from a local file system—by delegating the actual loading logic to specialized plugins.

  9. What is Progressive Loading in Cornerstone3D

    main

    Progressive Loading is a system designed to incrementally load medical images to enable faster initial display. Instead of waiting for a full-resolution dataset to arrive, the system displays lower-quality versions first and enhances the image quality as more data is received.

    There are two primary modes of progressive loading:

    1. Stack Images: The loader can fetch smaller or lossy versions of the images to provide an immediate preview.
    2. Volumes: The loader can fetch smaller/lossy images or fully interleaved versions to accelerate the loading process of volumetric data.
  10. Overview of Cornerstone3D (@cornerstonejs/core) capabilities

    main

    The @cornerstonejs/core package serves as the foundation of the Cornerstone3D library. It is a comprehensive framework for medical imaging applications that extends beyond simple rendering. Its core responsibilities include:

    • Rendering: Handles image rendering using both GPU and CPU-based approaches.
    • Data Management: Provides caching mechanisms for both image data and metadata.
    • Loading Framework: Provides the necessary APIs and framework for implementing image and volume loaders.
    • Metadata Support: Provides a dedicated API for managing and accessing medical imaging metadata.
  11. Source vs Overlay ownership in Render Paths

    main

    In the context of render paths, the distinction between Source and Overlay determines how navigation state is handled:

    • Source Binding: Defines the active resolved view for the viewport. In planar rendering, the source binding is the only entity that writes to ctx.view.activeSourceICamera.
    • Overlay Binding: Receives the same viewState as the source but does not replace the active source view. Overlays read ctx.view.activeSourceICamera solely to align their sampling or actors to the source.

    Example: Segmentation Slice Rendering When useSliceRendering is enabled, the source volume slice defines the active view. The labelmap representation is mounted as an overlay binding and rendered through the slice path. It follows the source navigation without becoming the source view itself.