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

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.

Core Responsibilities

The Larvitar Store serves several key purposes:

  1. Tools Management:

    • Stores the currently active tools for the left and right mouse buttons.
    • Allows dynamic switching and resetting of tools.
  2. Series Management: Tracks series data, including:

    • imageIds: Array of image identifiers for each series.
    • cached: Indicates whether each image in the series has been cached.
    • progress: Tracks the loading progress of the series.
    • elementId: HTML element ID where the series is rendered.
  3. Viewport Management: Keeps viewport-specific data, such as:

    • Slice and time positions (sliceId, timeId).
    • Pixel spacing, dimensions, and modality.
    • Viewer settings like zoom, rotation, and translation.
  4. Error and Logging: Captures errors and logs them for debugging purposes.

Store Structure

The store is defined by the Store type and includes the following key properties:

PropertyTypeDescription
colormapIdstringCurrent colormap identifier (e.g., "gray").
errorLog stringError log for debugging.
leftActiveToolstring (optional)Active tool for the left mouse button.
rightActiveToolstring (optional)Active tool for the right mouse button.
series{ [uniqueUID: string]: StoreSeries }Object mapping uniqueUID to series-specific data.
viewports{ [key: string]: StoreViewport }Object mapping viewport IDs to viewport-specific data.

The StoreSeries type includes the following key properties:

PropertyTypeDescription
imageIdsstringArray of imageIds for the series.
cached{ [imageId: string]: boolean }Tracks whether each imageId in the series has been cached or not.

The StoreViewport type includes the following key properties:

PropertyTypeDescription
loadingnumberCaching progress of the series from 0% to 100 %, initialized to null.
readybooleanTrue when the viewport is ready and imageId has been rendered.
uniqueUIDstring?Unique identifier for the series.
modalitystringModality of the image (e.g., "CT").
isColorbooleanTrue if the image is in color.
isMultiframebooleanTrue if the image is multiframe.
isTimeseriebooleanTrue if the image is a timeserie.
isDSAEnabledbooleanTrue if DSA is enabled.
isPDFbooleanTrue if the image is a PDF.
imageIdstringIdentifier for the image.
rowsnumberRows in the image.
colsnumberColumns in the image.
spacing_xnumberSpacing in the x direction.
spacing_ynumberSpacing in the y direction.
thicknessnumberSlice thickness.
numberOfSlicesnumber?Number of slices in the image.
numberOfFramesnumber?Number of frames in the image.
minPixelValuenumberMinimum pixel value.
maxPixelValuenumberMaximum pixel value.
sliceIdnumberSlice index identifier of the rendered image.
minSliceIdnumberMinimum slice index.
maxSliceIdnumberMaximum slice index.
pendingSliceIdnumber?Pending slice index to be rendered.
timeIdnumberTime index identifier, for timeseries.
timeIndexnumber?Time index, for timeseries.
minTimeIdnumberMinimum time index, for timeseries.
maxTimeIdnumberMaximum time index, for timeseries.
timeIdsnumber[]Array of time index identifiers, for timeseries.
timestampnumberTimestamp of the image, for timeseries.
timestampsnumber[]Array of image timestamps, for timeseries.
numberOfTemporalPositionsnumber?Number of temporal positions, for timeseries.
dsabooleanTrue if DSA is enabled.
pixelShiftnumber[]Pixel shift for the image in DSA mode.
waveformbooleanTrue if the image has waveform data, for ecg
viewportviewportTypeType of the viewport.

The Viewport type includes the following key properties:

PropertyTypeDescription
scalenumberCurrent scale factor for the viewport.
rotationnumberCurrent rotation for the viewport.
translation{x:number, y:number}Current translation for the viewport.
voi{windowCenter:number, windowWidth:number}Current windowing settings for the viewport.
defaultviewportTypeDefault viewport settings.

Initialization

The store must be initialized before use:

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

Viewport Management

A Viewport is a window that displays an image. The store manages viewport-specific data, such as the slice and time positions, pixel spacing, dimensions, and modality. It also stores viewer settings like zoom, rotation, and translation.

To add a viewport to the store, use the addViewport function with the HTML element ID where the viewport is rendered:

import { store } from 'larvitar';
store.addViewport(elementId);

To get the viewport data for a specific element ID, use the get function with the viewport key:

import { store } from 'larvitar';
const viewport = store.get(["viewports", elementId]);

To delete a viewport from the store, use the deleteViewport function with the viewport key:

import { store } from 'larvitar';
store.deleteViewport(elementId);

Series Management

The store tracks series data, including image identifiers, caching status, and loading progress.

To add a set of imageIds to the store, use the addImageIds function with the uniqueUID and imageIds:

import { store } from 'larvitar';
store.addImageIds(uniqueUID, imageIds);

To remove set of imageIds from the store, use the removeImageIds function with the uniqueUID:

import { store } from 'larvitar';
store.removeImageIds(uniqueUID);

To remove all imageIds from the store, use the resetImageIds function:

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

Useful functions

The store provides several utility functions for managing data:

FunctionParametersDescription
setSliceIdelementId, imageIndexSets the slice ID for the viewport identified by elementId.
setPendingSliceIdelementId, timeIndexSets the pending slice ID for the viewport identified by elementId.
setMaxSliceIdelementId, imageIndexSets the max Slice ID for the viewport identified by elementId.
setTimeIdelementId, timeIndexSets the time ID for the viewport identified by elementId.
setDSAEnabledelementId, enabledSets the DSA mode for the viewport identified by elementId.
setDSAPixelShiftelementId, pixelShiftSets the DSA pixel shift for the viewport identified by elementId.
ResetActiveToolselementIdResets the active tools.


D/Vision Lab
Last Updated:
Contributors: Laura Borghesi, Simone "Lateralus" Manini
Prev
Logger