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

Initializing the Image Loader(s)

Before loading and rendering DICOM images, you must initialize the image loader using the initializeImageLoader function. This function configures the DICOMImageLoader, allowing you to specify parameters such as the maximum concurrency for decoding operations, which controls how many tasks can run simultaneously.

Initialization Function

initializeImageLoader(maxConcurrency?: number): void
Initializes the DICOM image loader and optionally sets the maximum concurrency for image decoding tasks.

  • maxConcurrency: (optional) Specifies the maximum number of concurrent decoding tasks. Defaults to the number of CPU cores -1 if not provided.

Example Initialization

Here’s an example of how to initialize the image loader and configure the maximum concurrency:

import { initializeImageLoader } from 'larvitar';

// Initialize the image loader with a specific concurrency limit
initializeImageLoader(4);

console.log('Image loader initialized with max concurrency of 4');

Registering the multi-frame custom image loader

To effectively handle multiframe DICOM images in Larvitar, it's essential to register a custom image loader. This process involves defining a loader function that can process multiframe images and then registering it with Cornerstone. This step is optional but mandatory for applications that need to support multiframe images. Here's how you can achieve this:

import { registerMultiFrameImageLoader } from 'larvitar';

// Register the custom image loader for multiframe images
registerMultiFrameImageLoader();

Initializing the Cornestone Tools

What is a CornerstoneTool? A CornerstoneTool is an interactive feature that enables users to perform various operations on medical images within a viewer. These tools are part of the Cornerstone ecosystem and provide functionalities like zooming, panning, measuring, and annotating images. They are essential for building interactive and dynamic medical imaging applications.

CornerstoneTools supports a wide variety of operations, such as:

  • Navigation Tools: Zoom, pan, and scroll through images.
  • Annotation Tools: Add text, mark regions, and measure distances or angles.
  • Segmentation Tools: Isolate and highlight specific regions of interest.
  • Custom Tools: Extend functionality with custom, user-defined interactions.

Before using CornerstoneTools, you need to initialize them by calling the initializeCSTools function. This function sets up the environment for tools, allowing you to configure their behavior (toolSettings) and appearance (toolStyle). Both parameters are optional, but providing custom configurations helps tailor the tools to your specific needs.

import { initializeCSTools } from 'larvitar';

initializeCSTools(toolSettings?: ToolSettings, toolStyle?: ToolStyle): void

ToolSettings

PropertyDescriptionDefault Value
mouseEnabledEnables tools for mouse interactions.true
touchEnabledEnables tools for touch interactions.false
showSVGCursorsEnables SVG cursors for better visualization of tools.true
globalToolSyncEnabledSynchronizes tool settings across all viewports.true
autoResizeViewportsAutomatically resizes viewports when the browser window changes.true
lineDashDefines the dash pattern for line tools (e.g., [4, 4]).[4, 4]

ToolStyle

PropertyDescriptionDefault Value
widthStroke width for tools (e.g., lines, circles).1
colorDefault color for tools."#00FF00"
activeColorColor for active tools (e.g., when selected)."#FF0000"
fillColorFill color for shapes like circles."#0000FF"
fontFamilyFont family for text annotations."Arial"
fontSizeFont size for text annotations.12
backgroundColorBackground color for text annotations."rgba(0, 0, 0, 0.5)"

Initializing the Larvitar store

The Larvitar Store is a centralized data configuration store that manages the state and settings required for the application. It keeps track of information related to tools, series, viewports, and other imaging-related data, enabling dynamic interaction with the viewer.

The store must be initialized before use:

import { store } from 'larvitar';
store.initialize();


D/Vision Lab
Last Updated:
Contributors: Laura Borghesi, Simone "Lateralus" Manini
Next
Parsing