Larvitar Documentation
Home
Guide
API
GitHub
Home
Guide
API
GitHub
  • API

    • Initializing
    • Parsing
    • Loading
    • Rendering
    • Interacting
    • Testing
    • Modules

      • Logger
      • Store
      • Managers

        • Image Manager
        • GSPS Manager
        • File Manager
      • Parsers

        • PDF Parser
        • NRRD Parser
        • ECG Parser
      • Loaders
        • DICOM Loader
        • MultiFrame Loader
        • SingleFrame Loader
        • DSA Image Loader
        • File Loader
        • Nrrd Loader
      • Interaction Tools

        • Initialize and manage Tools
        • Default and Custom Tools
        • Segmentation Tools
        • DvTools
      • Utilities

        • DICOM Anonymization
        • DICOM Customization
        • Tags
        • Utils
        • Memory
      • Post Processing

        • DSA
      • Visualizations

        • Layers
        • ECG
        • Color Maps
        • Greyscale Presentation States
      • Testing
Larvitar

Single Frame Loader

The singleFrameLoader module is a custom DICOM loader designed to cache and render a single frame buffer with its metadata. It enables efficient retrieval and display of single-frame images extracted from multi-frame DICOM objects.

Key Responsibilities

  • Caches pixel data and metadata for quick access: Stores pixel data and metadata for single-frame images in an internal cache to optimize performance.
  • Converts RGB to RGBA format for rendering: Converts RGB pixel data to RGBA format for compatibility with Cornerstone rendering.
  • Clears cached frames to free memory: Removes cached frames from memory to prevent memory leaks and optimize performance.
  • Creates custom image objects for rendering: Generates Cornerstone-compatible image objects for rendering single-frame images.

Internal Workflow

  1. Metadata Conversion:
    • Metadata for the single frame is converted and stored in the Image Manager.
  2. Image ID Management:
    • Custom image IDs are generated for each single frame.
  3. Frame Caching:
    • Single frames are cached to avoid subsequent requests.
  4. Custom Image Creation:
    • The single frame is processed into a Cornerstone-compatible image object, including pixel data extraction and scaling.
  5. Memory Management:
    • Cached frames are cleared from memory to optimize performance and prevent memory leaks.

Main Functions

setSingleFrameCache

Syntax:

setSingleFrameCache(data: Uint8ClampedArray, metadata: Metadata): ImageObject

Parameters:

ParameterTypeDescription
dataUint8ClampedArrayThe pixel data for the single frame.
metadataMetadataThe metadata object.

Returns:

ImageObject – An object containing the ID of the cached single frame, its metadata and its SOP Instance UID.


clearSingleFrameCache

Syntax:

clearSingleFrameCache(imageId?: string): void

Parameters:

ParameterTypeDescription
imageIdstringOptional ID of the single frame to be cleared.

Returns:

void – Clears the cached single frame from memory. If no ID is provided, all cached frames are cleared.


loadSingleFrameImage

Syntax:

loadSingleFrameImage(imageId: string): ImageLoadObject

Parameters:

ParameterTypeDescription
imageIdstringThe ID of the image/frame to be loaded.

Returns:

ImageLoadObject – An object containing a Promise that resolves to the loaded image.


D/Vision Lab
Last Updated:
Contributors: Laura Borghesi, Simone "Lateralus" Manini
Prev
MultiFrame Loader
Next
DSA Image Loader