Skip to main content

utilities

Index

References

Namespaces

Classes

Variables

Functions

References

PointsManager

Re-exports PointsManager

triggerEvent

Re-exports triggerEvent

Namespaces

cacheUtils

cacheUtils:

performCacheOptimizationForVolume

  • performCacheOptimizationForVolume(volume: any): void
  • Performs cache optimization for a volume by replacing the pixel data of each image in the image cache (if found) with a view of the volume’s scalar data.


    Parameters

    • volume: any

    Returns void

setupCacheOptimizationEventListener

  • setupCacheOptimizationEventListener(volumeId: any): void
  • This function will check if the cache optimization is enabled and if it is it will check if the created volume was derived from an already cached stack of images, if so it will go back to the image cache and create a view at the correct offset of the bigger volume array buffer, this will save memory.


    Parameters

    • volumeId: any

      The volumeId that will be checked for cache optimization

    Returns void

color

color:

hexToRgb

  • hexToRgb(hex: any): { b: number; g: number; r: number }
  • Converts a hexadecimal color code to an RGB object.


    Parameters

    • hex: any

      The hexadecimal color code to convert.

    Returns { b: number; g: number; r: number }

    An object representing the RGB values of the color, or null if the input is invalid.

    • b: number
    • g: number
    • r: number

rgbToHex

  • rgbToHex(r: any, g: any, b: any): string
  • Converts RGB color values to a hexadecimal color string.


    Parameters

    • r: any

      The red component value (0-255).

    • g: any

      The green component value (0-255).

    • b: any

      The blue component value (0-255).

    Returns string

    The hexadecimal color string representation.

colormap

colormap:

getColormap

  • getColormap(name: any): any
  • Get a colormap by name


    Parameters

    • name: any

      name of the colormap

    Returns any

    colormap object

getColormapNames

  • getColormapNames(): any[]
  • Get all registered colormap names


    Returns any[]

    array of colormap names

registerColormap

eventListener

eventListener:

MultiTargetEventListenerManager

MultiTargetEventListenerManager:

MultiTargetEventListenerManager allows you to add event listeners to multiple HTML elements (targets) with support for event types with namespace, allow removing events without having to pass a callback and makes it possible to remove all event lsiteners from all HTML elements in a much simpler avoiding leaving listeners behind which would result in memory leaks.

@example

Adding and removing event listeners

  const eventListenerManager = new MultiTargetEventListenerManager()
const element1 = document.getElementById('foo');
const element2 = document.getElementById('bar');
const mouseoverCallback = () => { };
const mouseoutCallback = () => { };
const dragCallback = () => { };

eventListenerManager.addEventListener(element1, 'mouseover', mouseoverCallback);
eventListenerManager.addEventListener(element1, 'mouseout', mouseoutCallback);

eventListenerManager.addEventListener(element2, 'voi.mousemove', dragCallback);
eventListenerManager.addEventListener(element2, 'voi.drag', dragCallback);
eventListenerManager.addEventListener(element2, 'voi.mouseup', () => {
// do not need to store a reference of this function
}));

// Removes a specific event listener from element2
eventListenerManager.removeEventListener(element2, 'voi.mousemove', dragCallback)

// Removes all "mouseup" event listeners added to "voi" namespace on element2
eventListenerManager.removeEventListener(element2, 'voi.mouseup')

// Removes all event listeners added to element1 and element2
eventListenerManager.reset();

constructor

  • new MultiTargetEventListenerManager(): MultiTargetEventListenerManager
  • Returns MultiTargetEventListenerManager

publicaddEventListener

  • addEventListener(target: EventTarget, type: string, callback: EventListener, options?: AddEventListenerOptions): void
  • Parameters

    • target: EventTarget
    • type: string
    • callback: EventListener
    • optionaloptions: AddEventListenerOptions

    Returns void

publicremoveEventListener

  • removeEventListener(target: EventTarget, type: string, callback?: EventListener, options?: EventListenerOptions): void
  • Parameters

    • target: EventTarget
    • type: string
    • optionalcallback: EventListener
    • optionaloptions: EventListenerOptions

    Returns void

publicreset

  • reset(): void
  • Returns void

TargetEventListeners

TargetEventListeners:

TargetEventListeners adds support for event types with namespace, allow removing events without having to pass a callback and makes it possible to remove all event listeners in a much simpler way avoiding leaving listeners behind which would result in memory leaks.

@example

Creating a new TargetEventListeners instance

  const element = document.getElementById('foo');
const targetEventListeners = new TargetEventListeners(element)
@example

Adding and removing event listeners

  const dragCallback = () => { };

targetEventListeners.addEventListener('voi.mousemove', dragCallback);
targetEventListeners.addEventListener('voi.drag', dragCallback);
targetEventListeners.addEventListener('voi.mouseup', () => {
// do not need to store a reference of this function
}));

// Removes a specific event listener
targetEventListeners.removeEventListener('voi.mousemove', dragCallback)

// Removes all "mouseup" event listeners added to "colorbar.voi" namespace
targetEventListeners.removeEventListener('voi.mouseup')

// Removes all event listeners added to the element using this targetEventListeners
// instance. A TargetEventListeners instance does not removes the event listeners
// added by another one.
targetEventListeners.reset();
@example

Adding and removing event listeners for capture and bubble phases. Each listener must be removed indenpendently

  const clickCaptureCallback = () => { };
const clickBubbleCallback = () => { };

targetEventListeners.addEventListener('click', clickCaptureCallback, { capture: true });
targetEventListeners.addEventListener('click', clickBubbleCallback);

// Removes the event listener added to the capture phase
targetEventListeners.removeEventListener('click', clickCaptureCallback, { capture: true });

// Removes the event listener added to the bubble phase
targetEventListeners.removeEventListener('click', clickBubbleCallback);

// Removes all event listeners added to the HTML element
targetEventListeners.reset();

constructor

  • new TargetEventListeners(target: EventTarget): TargetEventListeners
  • Parameters

    • target: EventTarget

    Returns TargetEventListeners

publicisEmpty

  • get isEmpty(): boolean
  • Returns boolean

publicaddEventListener

  • addEventListener(type: string, callback: EventListener, options?: AddEventListenerOptions): void
  • Parameters

    • type: string
    • callback: EventListener
    • optionaloptions: AddEventListenerOptions

    Returns void

publicremoveEventListener

  • removeEventListener(type: string, callback?: EventListener, options?: EventListenerOptions): void
  • Remove an event listener with support for namespaces and optional callback which makes it remove all listeners of a given type


    Parameters

    • type: string

      Event type

    • optionalcallback: EventListener

      Event listener

    • optionaloptions: EventListenerOptions

      Event options

    Returns void

publicreset

  • reset(): void
  • Loop through all types, listeners and phases and removing all of them


    Returns void

planar

planar:

linePlaneIntersection

  • It calculates the intersection of a line and a plane. Plane equation is Ax+By+Cz=D


    Parameters

    • p0: Point3

      [x,y,z] of the first point of the line

    • p1: Point3

      [x,y,z] of the second point of the line

    • plane: Plane

      [A, B, C, D] Plane parameter: Ax+By+Cz=D

    Returns Point3

    • [X,Y,Z] coordinates of the intersection

planeDistanceToPoint

  • planeDistanceToPoint(plane: Plane, point: Point3, signed?: boolean): number
  • Computes the distance of a point in 3D space to a plane


    Parameters

    • plane: Plane

      [A, B, C, D] of plane equation AX + BY + C*Z = D

    • point: Point3

      [A, B, C] the plane in World coordinate

    • signed: boolean = false

      if true, the distance is signed

    Returns number

    • the distance of the point to the plane

planeEquation

  • It returns the plane equation defined by a point and a normal vector.


    Parameters

    • normal: Point3

      normal vector

    • point: Point3 | vec3

      a point on the plane

    • normalized: boolean = false

      if true, the values of the plane equation will be normalized

    Returns Plane

    • [A, B,C, D] of plane equation AX + BY + C*Z = D

threePlaneIntersection

  • Computes the intersection of three planes in 3D space with equations: A1X + B1Y + C1Z = D1 A2X + B2Y + C2Z = D2 A3X + B3Y + C3*Z = D3


    Parameters

    Returns Point3

    • [x, y, z] the intersection in the world coordinate

transferFunctionUtils

transferFunctionUtils:

getTransferFunctionNodes

  • getTransferFunctionNodes(transferFunction: any): any[]
  • Parameters

    • transferFunction: any

    Returns any[]

setTransferFunctionNodes

  • setTransferFunctionNodes(transferFunction: any, nodes: any): void
  • Parameters

    • transferFunction: any
    • nodes: any

    Returns void

windowLevel

windowLevel:

toLowHighRange

  • toLowHighRange(windowWidth: number, windowCenter: number): { lower: number; upper: number }
  • Given a window width and center, return the lower and upper bounds of the window The formulas for the calculation are specified in https://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.11.2.1.2.1 if (x <= c - 0.5 - (w-1) /2), then y = ymin else if (x > c - 0.5 + (w-1) /2), then y = ymax else y = ((x - (c - 0.5)) / (w-1) + 0.5) * (ymax- ymin) + ymin


    Parameters

    • windowWidth: number

      the width of the window in HU

    • windowCenter: number

      The center of the window.

    Returns { lower: number; upper: number }

    a JavaScript object with two properties: lower and upper.

    • lower: number
    • upper: number

toWindowLevel

  • toWindowLevel(low: number, high: number): { windowCenter: number; windowWidth: number }
  • Given a low and high window level, return the window width and window center Formulas from note 4 in https://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.11.2.1.2.1 extended to allow for low/high swapping


    Parameters

    • low: number

      The low window level.

    • high: number

      The high window level.

    Returns { windowCenter: number; windowWidth: number }

    a JavaScript object with two properties: windowWidth and windowCenter.

    • windowCenter: number
    • windowWidth: number

Classes

ProgressiveIterator

ProgressiveIterator<T>:

A progressive iterator is an async iterator that can have data delivered to it, with newer ones replacing older iterations which have not yet been consume. That allows iterating over sets of values and delivering updates, but always getting the most recent instance.


Type parameters

  • T

constructor

  • new ProgressiveIterator<T>(name?: any): default<T>
  • Type parameters

    • T

    Parameters

    • optionalname: any

    Returns default<T>

publicdone

done: any

publicoptionalname

name?: string

public[asyncIterator]

  • [asyncIterator](): AsyncGenerator<any, void, unknown>
  • Async iteration where the delivered values are the most recently available ones, so not necessarily all values are ever seen.


    Returns AsyncGenerator<any, void, unknown>

publicadd

  • add(x: T, done?: boolean): void
  • Add a most recent result, indicating if the result is the final one


    Parameters

    • x: T
    • done: boolean = false

    Returns void

donePromise

  • donePromise(): Promise<T>
  • Returns Promise<T>

publicforEach

  • forEach(callback: any, errorCallback: any): Promise<void>
  • Runs the forEach method on this filter


    Parameters

    • callback: any
    • errorCallback: any

    Returns Promise<void>

publicgenerate

  • generate(processFunction: any, errorCallback?: ErrorCallback): Promise<any>
  • Calls an async function to generate the results on the iterator


    Parameters

    • processFunction: any
    • optionalerrorCallback: ErrorCallback

    Returns Promise<any>

publicgetDonePromise

  • getDonePromise(): PromiseIterator<T>
  • Returns PromiseIterator<T>

publicgetNextPromise

  • getNextPromise(): PromiseIterator<T>
  • Returns PromiseIterator<T>

publicgetRecent

  • getRecent(): T
  • Gets the most recent value, without waiting


    Returns T

nextPromise

  • nextPromise(): Promise<T>
  • Returns Promise<T>

publicreject

  • reject(reason: Error): void
  • Reject the fetch. This will prevent further iteration.


    Parameters

    • reason: Error

    Returns void

publicresolve

  • resolve(): void
  • Returns void

publicstaticas

  • as(promise: any): any
  • Casts a promise, progressive iterator or promise iterator to a progressive iterator, creating one if needed to resolve it.


    Parameters

    • promise: any

    Returns any

VoxelManager

VoxelManager<T>:

This is a simple, standard interface to values associated with a voxel.


Type parameters

  • T

constructor

  • new VoxelManager<T>(dimensions: any, _get: (index: number) => T, _set?: (index: number, v: T) => boolean | void): default<T>
  • Creates a generic voxel value accessor, with access to the values provided by the _get and optionally _set values.


    Type parameters

    • T

    Parameters

    • dimensions: any

      for the voxel volume

    • _get: (index: number) => T

      called to get a value by index

    • optional_set: (index: number, v: T) => boolean | void

      called when setting a value

    Returns default<T>

_get

_get: (index: number) => T

Type declaration

    • (index: number): T
    • Parameters

      • index: number

      Returns T

_set

_set: (index: number, v: T) => boolean | void

Type declaration

    • (index: number, v: T): boolean | void
    • Parameters

      • index: number
      • v: T

      Returns boolean | void

publicboundsIJK

boundsIJK: BoundsIJK = ...

publicreadonlydimensions

dimensions: Point3

frameSize

frameSize: number

publicgetPixelData

getPixelData: (sliceIndex?: number, pixelData?: PixelDataTypedArray) => PixelDataTypedArray

Type declaration

publicisInObject

isInObject: (pointIPS: any, pointIJK: any) => boolean

Type declaration

    • (pointIPS: any, pointIJK: any): boolean
    • Parameters

      • pointIPS: any
      • pointIJK: any

      Returns boolean

publicmap

map: Map<number, T> | default<T>

publicmodifiedSlices

modifiedSlices: Set<number> = ...

publicnumComps

numComps: number = 1

points

points: Set<number>

publicscalarData

publicsourceVoxelManager

sourceVoxelManager: default<T>

width

width: number

publicaddPoint

  • addPoint(point: number | Point3): void
  • Adds a point as an array or an index value to the set of points associated with this voxel value. Can be used for tracking clicked points or other modified values.


    Parameters

    Returns void

publicclear

  • clear(): void
  • Clears any map specific data, as wellas the modified slices, points and bounds.


    Returns void

publicforEach

  • forEach(callback: any, options?: any): void
  • Iterate over the points within the bounds, or the modified points if recorded.


    Parameters

    • callback: any
    • optionaloptions: any

    Returns void

publicgetArrayOfSlices

  • getArrayOfSlices(): number[]

  • Returns number[]

    The array of modified k indices

publicgetAtIJK

  • getAtIJK(i: any, j: any, k: any): T
  • Gets the voxel value at position i,j,k.


    Parameters

    • i: any
    • j: any
    • k: any

    Returns T

publicgetAtIJKPoint

  • getAtIJKPoint(__namedParameters: [any, any, any]): T
  • Gets the voxel value at the given Point3 location.


    Parameters

    • __namedParameters: [any, any, any]

    Returns T

publicgetAtIndex

  • getAtIndex(index: any): T
  • Gets the value at the given index.


    Parameters

    • index: any

    Returns T

publicgetBoundsIJK

  • Gets the bounds for the modified set of values.


    Returns BoundsIJK

publicgetPointIndices

  • getPointIndices(): number[]
  • Gets the points added using addPoint as an array of indices.


    Returns number[]

publicgetPoints

  • Gets the list of added points as an array of Point3 values


    Returns Point3[]

publicsetAtIJK

  • setAtIJK(i: number, j: number, k: number, v: any): void
  • Sets the voxel value at position i,j,k and records the slice that was modified.


    Parameters

    • i: number
    • j: number
    • k: number
    • v: any

    Returns void

publicsetAtIJKPoint

  • setAtIJKPoint(__namedParameters: Point3, v: any): void
  • Sets the voxel value at the given point3 location to the specified value. Records the z index modified. Will record the index value if the VoxelManager is backed by a map.


    Parameters

    • __namedParameters: Point3
    • v: any

    Returns void

publicsetAtIndex

  • setAtIndex(index: any, v: any): void
  • Sets the value at the given index


    Parameters

    • index: any
    • v: any

    Returns void

publictoIJK

  • Converts an index value to a Point3 IJK value


    Parameters

    • index: number

    Returns Point3

publictoIndex

  • Converts an IJK Point3 value to an index value


    Parameters

    Returns number

publicstaticaddBounds

  • Extends the bounds of this object to include the specified point


    Parameters

    Returns void

publicstaticaddInstanceToImage

  • addInstanceToImage(image: IImage): void
  • This method adds a voxelManager instance to the image object where the object added is of type:

    1. RLE map if the scalar data is missing or too small (dummy data)
    2. Volume VoxelManager scalar data representations

    Parameters

    Returns void

publicstaticcreateHistoryVoxelManager

  • createHistoryVoxelManager<T>(sourceVoxelManager: default<T>): default<T>
  • Creates a history remembering voxel manager. This will remember the original values in the voxels, and will apply the update to the underlying source voxel manager.


    Type parameters

    • T

    Parameters

    Returns default<T>

publicstaticcreateLazyVoxelManager

  • createLazyVoxelManager<T>(dimensions: Point3, planeFactory: (width: number, height: number) => T): default<T>
  • Creates a lazy voxel manager that will create an image plane as required for each slice of a volume as it gets changed. This can be used to store image data that gets created as required.


    Type parameters

    • T

    Parameters

    • dimensions: Point3
    • planeFactory: (width: number, height: number) => T

    Returns default<T>

publicstaticcreateMapVoxelManager

  • Creates a volume map value accessor. This is initially empty and the map stores the index to value instances. This is useful for sparse matrices containing pixel data.


    Type parameters

    • T

    Parameters

    Returns default<T>

publicstaticcreateNumberVolumeVoxelManager

  • createNumberVolumeVoxelManager(dimensions: Point3, scalarData: any): default<number>
  • Creates a volume voxel manager that works on single numeric values stored in an array like structure of numbers.


    Parameters

    • dimensions: Point3
    • scalarData: any

    Returns default<number>

publicstaticcreateRGBVolumeVoxelManager

  • createRGBVolumeVoxelManager(dimensions: Point3, scalarData: any, numComponents: any): default<RGB>
  • Creates a voxel manager backed by an array of scalar data having the given number of components. Note that the number of components can be larger than three, in case data is stored in additional pixels. However, the return type is still RGB.


    Parameters

    • dimensions: Point3
    • scalarData: any
    • numComponents: any

    Returns default<RGB>

publicstaticcreateRLEVoxelManager

  • Creates a RLE based voxel manager. This is effective for storing segmentation maps or already RLE encoded data such as ultrasounds.


    Type parameters

    • T

    Parameters

    Returns default<T>

publicstaticcreateVolumeVoxelManager

  • createVolumeVoxelManager(dimensions: Point3, scalarData: any, numComponents?: number): default<number> | default<RGB>
  • Creates a volume value accessor, based on a volume scalar data instance. This also works for image value accessors for single plane (k=0) accessors.


    Parameters

    • dimensions: Point3
    • scalarData: any
    • numComponents: number = 0

    Returns default<number> | default<RGB>

Variables

constcalibratedPixelSpacingMetadataProvider

calibratedPixelSpacingMetadataProvider: { add: (imageId: string, payload: IImageCalibration) => void; get: (type: string, imageId: string) => IImageCalibration } = ...

Simple metadataProvider object to store metadata for calibrated spacings. This can be added via cornerstone.metaData.addProvider(…) in order to store and return calibrated pixel spacings when metaData type is “calibratedPixelSpacing”.


Type declaration

  • add: (imageId: string, payload: IImageCalibration) => void
      • Adds metadata for an imageId.


        Parameters

        • imageId: string

          the imageId for the metadata to store

        • payload: IImageCalibration

          the payload composed of new calibrated pixel spacings

        Returns void

  • get: (type: string, imageId: string) => IImageCalibration
      • Returns the metadata for an imageId if it exists.


        Parameters

        • type: string

          the type of metadata to enquire about

        • imageId: string

          the imageId to enquire about

        Returns IImageCalibration

        the calibrated pixel spacings for the imageId if it exists, otherwise undefined

constgenericMetadataProvider

genericMetadataProvider: { add: (imageId: string, payload: any) => void; clear: () => void; get: (type: string, imageId: string) => any } = ...

Simple metadata provider that stores some sort of meta data for each imageId.


Type declaration

  • add: (imageId: string, payload: any) => void
      • (imageId: string, payload: any): void
      • Adds metadata for an imageId.


        Parameters

        • imageId: string

          the imageId for the metadata to store

        • payload: any

          the payload

        Returns void

  • clear: () => void
      • (): void
      • Clears all metadata.


        Returns void

  • get: (type: string, imageId: string) => any
      • (type: string, imageId: string): any
      • Returns the metadata for an imageId if it exists.


        Parameters

        • type: string

          the type of metadata to enquire about

        • imageId: string

          the imageId to enquire about

        Returns any

constimageRetrieveMetadataProvider

imageRetrieveMetadataProvider: { IMAGE_RETRIEVE_CONFIGURATION: string; add: (key: string, payload: any) => void; clear: () => void; get: (type: string, ...queries: string[]) => any } = ...

Simple metadataProvider object to store metadata for the image retrieval.


Type declaration

  • IMAGE_RETRIEVE_CONFIGURATION: string
  • add: (key: string, payload: any) => void
      • (key: string, payload: any): void
      • Parameters

        • key: string
        • payload: any

        Returns void

  • clear: () => void
      • (): void
      • Empty the metadata state


        Returns void

  • get: (type: string, ...queries: string[]) => any
      • (type: string, ...queries: string[]): any
      • Parameters

        • type: string
        • rest...queries: string[]

        Returns any

constspatialRegistrationMetadataProvider

spatialRegistrationMetadataProvider: { add: (query: string[], payload: mat4) => void; get: (type: string, viewportId1: string, viewportId2: string) => mat4 } = ...

Simple metadataProvider object to store metadata for spatial registration module.


Type declaration

  • add: (query: string[], payload: mat4) => void
      • (query: string[], payload: mat4): void
      • Parameters

        • query: string[]
        • payload: mat4

        Returns void

  • get: (type: string, viewportId1: string, viewportId2: string) => mat4
      • (type: string, viewportId1: string, viewportId2: string): mat4
      • Parameters

        • type: string
        • viewportId1: string
        • viewportId2: string

        Returns mat4

Functions

actorIsA

  • actorIsA(actorEntry: ActorEntry, actorType: actorTypes): boolean
  • Parameters

    Returns boolean

applyPreset

  • Applies a preset to a volume actor.


    Parameters

    • actor: vtkVolume

      The volume actor to apply the preset to.

    • preset: ViewportPreset

      The preset to apply.

    Returns void

calculateViewportsSpatialRegistration

  • It calculates the registration matrix between two viewports (currently only translation is supported) If the viewports are in the same frame of reference, it will return early, but otherwise it will use the current image’s metadata to calculate the translation between the two viewports and adds it to the spatialRegistrationModule metadata provider


    Parameters

    Returns void

clamp

  • clamp(value: number, min: number, max: number): number
  • Parameters

    • value: number
    • min: number
    • max: number

    Returns number

convertStackToVolumeViewport

  • Converts a stack viewport to a volume viewport.


    Parameters

    • params: { options: { background?: Point3; orientation?: OrientationAxis; viewportId?: string; volumeId: string }; viewport: default }

      The parameters for the conversion.

    Returns Promise<IVolumeViewport>

    The converted volume viewport.

convertToGrayscale

  • convertToGrayscale(scalarData: any, width: number, height: number): any
  • Parameters

    • scalarData: any
    • width: number
    • height: number

    Returns any

convertVolumeToStackViewport

  • Converts a volume viewport to a stack viewport.


    Parameters

    • params: { options: { background?: Point3; viewportId?: string }; viewport: default }

      The parameters for the conversion.

    Returns Promise<Types.IStackViewport>

    The converted stack viewport.

publiccreateFloat32SharedArray

  • createFloat32SharedArray(length: number): Float32Array
  • A helper function that creates a new Float32Array that utilized a shared array buffer. This allows the array to be updated simultaneously in workers or the main thread. Depending on the system (the CPU, the OS, the Browser) it can take a while until the change is propagated to all contexts.

    @see

    SharedArrayBuffer

    @remarks

    We use SharedArrayBuffers in our ImageCache class. It’s what allows us to stream data to build a volume. It’s important to note that SharedArrayBuffer does not work out of the box for all web browsers. In some, it is disabled behind a flag; in others, it has been removed entirely.

    @example

    Creating an array for a Volume with known dimensions:

    const dimensions = [512, 512, 25];
    const scalarData = createFloat32SharedArray(dimensions[0] * dimensions[1] * dimensions[2]);

    Parameters

    • length: number

      frame size * number of frames

    Returns Float32Array

    a Float32Array with an underlying SharedArrayBuffer

publiccreateInt16SharedArray

  • createInt16SharedArray(length: number): Int16Array
  • A helper function that creates a new Int16 that utilized a shared array buffer. This allows the array to be updated simultaneously in workers or the main thread. Depending on the system (the CPU, the OS, the Browser) it can take a while until the change is propagated to all contexts.

    @see

    SharedArrayBuffer

    @remarks

    We use SharedArrayBuffers in our ImageCache class. It’s what allows us to stream data to build a volume. It’s important to note that SharedArrayBuffer does not work out of the box for all web browsers. In some, it is disabled behind a flag; in others, it has been removed entirely.

    @example

    Creating an array for a Volume with known dimensions:

    const dimensions = [512, 512, 25];
    const scalarData = createInt16SharedArray(dimensions[0] * dimensions[1] * dimensions[2]);

    Parameters

    • length: number

      frame size * number of frames

    Returns Int16Array

    a Int8Array with an underlying SharedArrayBuffer

createLinearRGBTransferFunction

  • createLinearRGBTransferFunction(voiRange: VOIRange): vtkColorTransferFunction
  • Parameters

    Returns vtkColorTransferFunction

createSigmoidRGBTransferFunction

  • createSigmoidRGBTransferFunction(voiRange: VOIRange, approximationNodes?: number): vtkColorTransferFunction
  • A utility that can be used to generate an Sigmoid RgbTransferFunction. Sigmoid transfer functions are used in the dicom specification: https://dicom.nema.org/medical/dicom/2018b/output/chtml/part03/sect_C.11.2.html

    @example

    Setting an RGB Transfer function from the viewport:

    const sigmoidRGBTransferFunction = createSigmoidRGBTransferFunction(0, 255, { lower: 0, upper: 255} );
    viewport
    .getActor()
    .getProperty()
    .setRGBTransferFunction(0, sigmoidRGBTransferFunction);
    @see

    ColorTransferFunction


    Parameters

    • voiRange: VOIRange
    • approximationNodes: number = 1024

    Returns vtkColorTransferFunction

publiccreateUint16SharedArray

  • createUint16SharedArray(length: number): Uint16Array
  • A helper function that creates a new Uint16 that utilized a shared array buffer. This allows the array to be updated simultaneously in workers or the main thread. Depending on the system (the CPU, the OS, the Browser) it can take a while until the change is propagated to all contexts.

    @see

    SharedArrayBuffer

    @remarks

    We use SharedArrayBuffers in our ImageCache class. It’s what allows us to stream data to build a volume. It’s important to note that SharedArrayBuffer does not work out of the box for all web browsers. In some, it is disabled behind a flag; in others, it has been removed entirely.

    @example

    Creating an array for a Volume with known dimensions:

    const dimensions = [512, 512, 25];
    const scalarData = createUint16SharedArray(dimensions[0] * dimensions[1] * dimensions[2]);

    Parameters

    • length: number

      frame size * number of frames

    Returns Uint16Array

    a Uint8Array with an underlying SharedArrayBuffer

publiccreateUint8SharedArray

  • createUint8SharedArray(length: number): Uint8Array
  • A helper function that creates a new Float32Array that utilized a shared array buffer. This allows the array to be updated simultaneously in workers or the main thread. Depending on the system (the CPU, the OS, the Browser) it can take a while until the change is propagated to all contexts.

    @see

    SharedArrayBuffer

    @remarks

    We use SharedArrayBuffers in our ImageCache class. It’s what allows us to stream data to build a volume. It’s important to note that SharedArrayBuffer does not work out of the box for all web browsers. In some, it is disabled behind a flag; in others, it has been removed entirely.

    @example

    Creating an array for a Volume with known dimensions:

    const dimensions = [512, 512, 25];
    const scalarData = createUint8SharedArray(dimensions[0] * dimensions[1] * dimensions[2]);

    Parameters

    • length: number

      frame size * number of frames

    Returns Uint8Array

    a Uint8Array with an underlying SharedArrayBuffer

decimate

  • decimate(list: unknown[], interleave: number, offset?: number): number[]
  • Return the decimated indices for the given list.


    Parameters

    • list: unknown[]

      to decimate the indices for

    • interleave: number

      the interleave interval for decimation

    • offset: number = 0

      where to start the interleave from

    Returns number[]

deepMerge

  • deepMerge(target?: {}, source?: {}, optionsArgument?: any): any
  • Merge two objects, recursively merging any objects that are arrays


    Parameters

    • target: {} = {}

      The target object.

    • source: {} = {}

      The source object to merge into the target object.

    • optionsArgument: any = undefined

      The options object.

    Returns any

    The merged object.

generateVolumePropsFromImageIds

  • generateVolumePropsFromImageIds(imageIds: string[], volumeId: string): ImageVolumeProps

getBufferConfiguration

  • getBufferConfiguration(targetBufferType: PixelDataTypedArrayString, length: number, options?: { isVolumeBuffer?: boolean; use16BitTexture?: boolean }): { TypedArrayConstructor: new (length: number | SharedArrayBuffer) => PixelDataTypedArray; numBytes: number }
  • Creates a target buffer based on the provided options.


    Parameters

    • targetBufferType: PixelDataTypedArrayString

      The type of the target buffer.

    • length: number

      The length of the target buffer.

    • options: { isVolumeBuffer?: boolean; use16BitTexture?: boolean } = {}

      Options for the target buffer. Currently supports use16BitTexture and isVolumeBuffer.

    Returns { TypedArrayConstructor: new (length: number | SharedArrayBuffer) => PixelDataTypedArray; numBytes: number }

    Returns an object containing the number of bytes and the type array constructor of the target buffer, which you then use to create the target buffer with new TypedArrayConstructor(length).

getClosestImageId

  • Given an image, a point in space and the viewPlaneNormal it returns the closest imageId of the image volume that is within half voxel spacing of the point in space.


    Parameters

    • imageVolume: IImageVolume

      The image volume

    • worldPos: Point3

      The position in the world coordinate system (from mouse click)

    • viewPlaneNormal: Point3

      The normal vector of the viewport

    Returns string

    The imageId for the tool.

getClosestStackImageIndexForPoint

  • getClosestStackImageIndexForPoint(point: Point3, viewport: default): number | null
  • Given a point in 3D space and a viewport it returns the index of the closest imageId, it assumes that stack images are sorted according to their sliceLocation


    Parameters

    • point: Point3

      [A, B, C] coordinates of the point in 3D space

    • viewport: default

      The StackViewport to search for the closest imageId

    Returns number | null

    The imageId index of the closest imageId or null if no imageId is found

getCurrentVolumeViewportSlice

  • getCurrentVolumeViewportSlice(viewport: default): { height: number; indexToSliceMatrix: mat4; scalarData: any; sliceToIndexMatrix: mat4; width: number }
  • Get the image data for the current slice rendered on the viewport. The image data returned is the full slice and not only the region that is visible on the viewport. It does not work for oblique views.


    Parameters

    Returns { height: number; indexToSliceMatrix: mat4; scalarData: any; sliceToIndexMatrix: mat4; width: number }

    Slice image dataand matrices to convert from volume to slice and vice-versa

    • height: number
    • indexToSliceMatrix: mat4
    • scalarData: any
    • sliceToIndexMatrix: mat4
    • width: number

getImageLegacy

  • getImageLegacy(element: HTMLDivElement): Types.IImage | undefined
  • Gets the IImage rendered by the given element. This is provided as a convenience for the legacy cornerstone getImage function. However it is encouraged for IStackViewport.getImage to be used instead.


    Parameters

    • element: HTMLDivElement

      the element rendering/containing the image

    Returns Types.IImage | undefined

    the image

getImageSliceDataForVolumeViewport

  • It calculates the number of slices and the current slice index for a given Volume viewport


    Parameters

    Returns ImageSliceData

    An object with two properties: numberOfSlices and imageIndex.

getMinMax

  • getMinMax(storedPixelData: number[]): { max: number; min: number }
  • Calculate the minimum and maximum values in an Array


    Parameters

    • storedPixelData: number[]

      The pixel data to calculate the min and max values for

    Returns { max: number; min: number }

    an object with two properties: min and max

    • max: number
    • min: number

getRandomSampleFromArray

  • getRandomSampleFromArray<T>(array: T[], size: number): T[]
  • Gets a random sample of specified size from the array. If the requested size is greater than the array length, returns a shuffled clone of the original array.


    Type parameters

    • T

    Parameters

    • array: T[]

      The source array from which to sample.

    • size: number

      The number of elements to sample from the array.

    Returns T[]

    A new array containing the random sample.

getRuntimeId

  • getRuntimeId(context?: unknown, separator?: string, max?: number): string
  • Generate a unique numeric ID string valid during a single runtime session;


    Parameters

    • optionalcontext: unknown

      An optional object to be used as context. Defaults to a global context;

    • optionalseparator: string

      The component separator. Defaults to “-“;

    • optionalmax: number

      The maximum component value. Defaults to 4294967295;

    Returns string

    The string representation of the the unique ID;

getScalarDataType

  • If the scalar data is a Uint8Array, return ‘Uint8Array’. If the scalar data is a Float32Array, return ‘Float32Array’. If the scalar data is a Int16Array, return ‘Int16Array’. If the scalar data is a Uint16Array, return ‘Uint16Array’. If the scalar data is none of the above, throw an error.


    Parameters

    • scalingParameters: ScalingParameters

      {

    • optionalscalarData: any

      The data to be converted.

    Returns string

    The data type of the scalar data.

getScalingParameters

  • It returns the scaling parameters for the image with the given imageId. This can be used to get passed (as an option) to the imageLoader in order to apply scaling to the image inside the imageLoader.


    Parameters

    • imageId: string

      The imageId of the image

    Returns ScalingParameters

    ScalingParameters

getSliceRange

  • Given a vtkVolumeActor, and a normal direction, calculate the range of slices in the focal normal direction that encapsulate the volume. Also project the focalPoint onto this range.


    Parameters

    • volumeActor: vtkVolume

      The vtkVolumeActor.

    • viewPlaneNormal: Point3

      The normal to the camera view.

    • focalPoint: Point3

      The focal point of the camera.

    Returns ActorSliceRange

    an object containing the min, max and current positions in the normal direction.

getSpacingInNormalDirection

  • getSpacingInNormalDirection(imageVolume: IImageVolume | { direction: mat3; spacing: Point3 }, viewPlaneNormal: Point3): number
  • Given an imageVolume and a normal direction (viewPlaneNormal), calculates the spacing between voxels in the normal direction. If (viewPlaneNormal) is parallel to one of the directions you will obtain the spacing in that direction. Otherwise each of the imageVolume‘s directions are projected onto the volume, so that you obtain a spacing of the order of “seeing a new set of voxels if the camera where to dolly”.


    Parameters

    • imageVolume: IImageVolume | { direction: mat3; spacing: Point3 }

      The image volume to calculate the spacing in the normal direction.

    • viewPlaneNormal: Point3

      The normal direction of the view plane.

    Returns number

getTargetVolumeAndSpacingInNormalDir

  • getTargetVolumeAndSpacingInNormalDir(viewport: default, camera: ICamera, targetId?: string, useSlabThickness?: boolean): { actorUID: string; imageVolume: IImageVolume; spacingInNormalDirection: number }
  • Given a volume viewport and camera, find the target volume. The imageVolume is retrieved from cache for the specified targetId or in case it is not provided, it chooses the volumeId on the viewport (there might be more than one in case of fusion) that has the finest resolution in the direction of view (normal).


    Parameters

    • viewport: default

      volume viewport

    • camera: ICamera

      current camera

    • optionaltargetId: string

      If a targetId is forced to be used.

    • useSlabThickness: boolean = false

      If true, the number of steps will be calculated based on the slab thickness instead of the spacing in the normal direction

    Returns { actorUID: string; imageVolume: IImageVolume; spacingInNormalDirection: number }

    An object containing the imageVolume and spacingInNormalDirection.

    • actorUID: string
    • imageVolume: IImageVolume
    • spacingInNormalDirection: number

getViewportImageCornersInWorld

  • Given a viewport, return the corners of the image in the viewport in world coordinates. Note that this is different than the corners of the canvas in world coordinates since an image can be zoomed out and the canvas can be larger than the image; hence, the corners of the canvas in world coordinates will be outside the image.


    Parameters

    Returns Point3[]

    The corners of the image in the viewport in world coordinates.

getViewportImageIds

  • getViewportImageIds(viewport: IViewport): string[]
  • Retrieves the image IDs from the given viewport.


    Parameters

    • viewport: IViewport

      The viewport to retrieve the image IDs from.

    Returns string[]

    An array of image IDs.

getViewportModality

  • getViewportModality(viewport: IViewport, volumeId?: string): string
  • Parameters

    Returns string

getViewportsWithImageURI

  • getViewportsWithImageURI(imageURI: string, renderingEngineId?: string): Viewport[]
  • Get the viewport that is rendering the image with the given imageURI (imageId without the loader schema), this can be a stackViewport or a volumeViewport.


    Parameters

    • imageURI: string

      The imageURI of the image that is requested

    • optionalrenderingEngineId: string

    Returns Viewport[]

    A Viewport

getViewportsWithVolumeId

  • getViewportsWithVolumeId(volumeId: string, renderingEngineId?: string): IVolumeViewport[]

getVoiFromSigmoidRGBTransferFunction

  • getVoiFromSigmoidRGBTransferFunction(cfun: vtkColorTransferFunction): [number, number]
  • Parameters

    • cfun: vtkColorTransferFunction

    Returns [number, number]

getVolumeActorCorners

  • getVolumeActorCorners(volumeActor: any): Point3[]
  • Converts vtkVolumeActor bounds to corners in world space.


    Parameters

    • volumeActor: any

      The vtkVolumeActor.

    Returns Point3[]

    An array of the corners of the volumeActor in world space.

getVolumeId

  • getVolumeId(targetId: string): string
  • Retrieves the volume ID from a target ID. Target Id is not only volumeId but might include other information, but it starts with volumeId.


    Parameters

    • targetId: string

      The target ID from which to extract the volume ID.

    Returns string

    The volume ID extracted from the target ID.

getVolumeSliceRangeInfo

  • getVolumeSliceRangeInfo(viewport: default, volumeId: string, useSlabThickness?: boolean): { camera: ICamera; sliceRange: ActorSliceRange; spacingInNormalDirection: number }
  • Calculates the slice range for the given volume based on its orientation


    Parameters

    • viewport: default

      Volume viewport

    • volumeId: string

      Id of one of the volumes loaded on the given viewport

    • useSlabThickness: boolean = false

      If true, the slice range will be calculated based on the slab thickness instead of the spacing in the normal direction

    Returns { camera: ICamera; sliceRange: ActorSliceRange; spacingInNormalDirection: number }

    slice range information

getVolumeViewportScrollInfo

  • getVolumeViewportScrollInfo(viewport: default, volumeId: string, useSlabThickness?: boolean): { currentStepIndex: number; numScrollSteps: number; sliceRangeInfo: { camera: ICamera; sliceRange: ActorSliceRange; spacingInNormalDirection: number } }
  • Calculates the number os steps the volume can scroll based on its orientation


    Parameters

    • viewport: default

      Volume viewport

    • volumeId: string

      Id of one of the volumes loaded on the given viewport

    • useSlabThickness: boolean = false

      If true, the number of steps will be calculated based on the slab thickness instead of the spacing in the normal direction

    Returns { currentStepIndex: number; numScrollSteps: number; sliceRangeInfo: { camera: ICamera; sliceRange: ActorSliceRange; spacingInNormalDirection: number } }

    number of steps the volume can scroll and its current position

getVolumeViewportsContainingSameVolumes

  • getVolumeViewportsContainingSameVolumes(targetViewport: default, renderingEngineId?: string): IVolumeViewport[]
  • Returns the viewports containing the same volume actors (all actors) the same as the target viewport. If renderingEngineId is provided, it will only return viewports that are associated with the renderingEngineId; otherwise, it will return search in all rendering engines.

    This method is useful for finding viewports that are associated with the same volume (e.g., for tools that share state between viewports).


    Parameters

    • targetViewport: default
    • optionalrenderingEngineId: string

    Returns IVolumeViewport[]

    array of viewports that have the same volume actor as the target viewport

hasFloatScalingParameters

  • Checks if the scaling parameters contain a float rescale value.


    Parameters

    Returns boolean

    True if the scaling parameters contain a float rescale value, false otherwise.

hasNaNValues

  • hasNaNValues(input: number | number[]): boolean
  • A function that checks if there is a value in the array that is NaN. or if the input is a number it just checks if it is NaN.


    Parameters

    • input: number | number[]

      The input to check if it is NaN.

    Returns boolean

    • True if the input is NaN, false otherwise.

imageIdToURI

  • imageIdToURI(imageId: string): string
  • Removes the data loader scheme from the imageId


    Parameters

    • imageId: string

      Image ID

    Returns string

    imageId without the data loader scheme

imageToWorldCoords

  • imageToWorldCoords(imageId: string, imageCoords: Point2): Point3 | undefined
  • Given the imageId and a 2d coordinates on the image space with [0,0] being the top left corner of the top left pixel, and options which includes the imageId, it returns the 3d coordinates on the world space.


    Parameters

    • imageId: string

      The image id

    • imageCoords: Point2

      The 2d coordinates on the image

    Returns Point3 | undefined

    The 3d coordinates on the world.

indexWithinDimensions

  • indexWithinDimensions(index: Point3, dimensions: Point3): boolean
  • Returns true if the specified index is within the given dimensions.


    Parameters

    • index: Point3

      The index to check.

    • dimensions: Point3

      The dimensions to check against.

    Returns boolean

    True if the index is in-bounds.

invertRgbTransferFunction

  • invertRgbTransferFunction(rgbTransferFunction: any): void
  • A utility that can be used to invert (in place) an RgbTransferFunction.

    @example

    Grabbing a reference to the RGB Transfer function from the viewport:

    const rgbTransferFunction = viewport
    .getActor()
    .getProperty()
    .getRGBTransferFunction(0);

    rgbTransferFunction.setRange(0, 5);

    invertRgbTransferFunction(rgbTransferFunction);
    @see

    ColorTransferFunction


    Parameters

    • rgbTransferFunction: any

    Returns void

isEqual

  • isEqual<ValueType>(v1: ValueType, v2: ValueType, tolerance?: number): boolean
  • Returns whether two values are equal or not, based on epsilon comparison. For array comparison, it does NOT strictly compare them but only compare its values. It can compare array of numbers and also typed array. Otherwise it will just return false.


    Type parameters

    • ValueType

    Parameters

    • v1: ValueType

      The first value to compare

    • v2: ValueType

      The second value to compare

    • tolerance: number = 1e-5

      The acceptable tolerance, the default is 0.00001

    Returns boolean

    True if the two values are within the tolerance levels.

isImageActor

  • Checks if a vtk Actor is an image actor (vtkVolume or vtkImageSlice) otherwise returns false.


    Parameters

    Returns boolean

    A boolean value.

isOpposite

  • isOpposite(v1: Point3, v2: Point3, tolerance?: number): boolean
  • returns equal if the two vec3s are opposite within the given tolerance in each dimension.


    Parameters

    • v1: Point3

      The first 3 vector

    • v2: Point3

      The second 3 vector.

    • tolerance: number = 1e-5

      The acceptable tolerance.

    Returns boolean

    True if the two values are within the tolerance levels.

isPTPrescaledWithSUV

  • isPTPrescaledWithSUV(image: IImage): number
  • Parameters

    Returns number

isValidVolume

  • isValidVolume(imageIds: string[]): boolean
  • Checks if the given imageIds form a valid volume. A volume is considered valid if all imageIds have the same series instance UID, modality, columns, rows, image orientation patient, and pixel spacing.


    Parameters

    • imageIds: string[]

      The imageIds to check.

    Returns boolean

    true if the imageIds form a valid volume, false otherwise.

isVideoTransferSyntax

  • isVideoTransferSyntax(uidOrUids: string | string[]): string | false
  • Parameters

    • uidOrUids: string | string[]

    Returns string | false

loadImageToCanvas

  • loadImageToCanvas(options: LoadImageOptions): Promise<string>
  • Loads and renders an imageId to a Canvas. It will use the GPU rendering pipeline for image by default but you can force the CPU rendering pipeline by setting the useCPURendering parameter to true.

    @example
    const canvas = document.getElementById('myCanvas')
    const imageId = 'myImageId'

    loadImageToCanvas(canvas, imageId)

    Parameters

    • options: LoadImageOptions

    Returns Promise<string>

    • A promise that resolves when the image has been rendered with the imageId

makeVolumeMetadata

  • makeVolumeMetadata(imageIds: string[]): Metadata
  • It creates a metadata object for a volume given the imageIds that compose it. It uses the first imageId to get the metadata.


    Parameters

    • imageIds: string[]

      array of imageIds

    Returns Metadata

    The volume metadata

renderToCanvasCPU

  • renderToCanvasCPU(canvas: HTMLCanvasElement, image: IImage, modality?: string, _renderingEngineId?: string, _viewportOptions?: ViewportInputOptions): Promise<string>
  • Renders a cornerstone image object to a canvas. Note: this does not load the image but only takes care of the rendering pipeline


    Parameters

    • canvas: HTMLCanvasElement

      Canvas element to render to

    • image: IImage

      Cornerstone image object

    • optionalmodality: string
    • optional_renderingEngineId: string
    • optional_viewportOptions: ViewportInputOptions

    Returns Promise<string>

renderToCanvasGPU

  • renderToCanvasGPU(canvas: HTMLCanvasElement, image: IImage, modality?: any, renderingEngineId?: string, viewportOptions?: ViewportInputOptions): Promise<string>
  • Renders an cornerstone image to a Canvas. This method will handle creation of a temporary enabledElement, setting the imageId, and rendering the image via a StackViewport, copying the canvas drawing to the given canvas Element, and disabling the created temporary element. SuppressEvents argument is used to prevent events from firing during the render process (e.g. during a series of renders to a thumbnail image).

    @example
    const canvas = document.getElementById('myCanvas')

    renderToCanvasGPU(canvas, image)

    Parameters

    • canvas: HTMLCanvasElement

      Canvas element to render to

    • image: IImage

      The image to render

    • modality: any = undefined

      [Default = undefined] The modality of the image

    • renderingEngineId: string = '_thumbnails'
    • viewportOptions: ViewportInputOptions = ...

    Returns Promise<string>

    • A promise that resolves when the image has been rendered with the imageId

roundNumber

  • roundNumber(value: string | number | (string | number)[], precision?: number): string
  • Truncates decimal points to that there is at least 1+precision significant digits.

    For example, with the default precision 2 (3 significant digits)

    • Values larger than 100 show no information after the decimal point
    • Values between 10 and 99 show 1 decimal point
    • Values between 1 and 9 show 2 decimal points

    Parameters

    • value: string | number | (string | number)[]

      to return a fixed measurement value from

    • precision: number = 2

      defining how many digits after 1..9 are desired

    Returns string

roundToPrecision

  • roundToPrecision(value: any): number
  • Rounds a number to the nearest multiple of EPSILON.


    Parameters

    • value: any

      The number to round.

    Returns number

    The rounded number.

scaleRgbTransferFunction

  • scaleRgbTransferFunction(rgbTransferFunction: any, scalingFactor: number): void
  • A utility that can be used to scale (in place) an RgbTransferFunction. We often use this to scale the transfer function based on a PET calculation.

    @example

    Grabbing a reference to the RGB Transfer function from the viewport:

    const rgbTransferFunction = viewport
    .getActor()
    .getProperty()
    .getRGBTransferFunction(0);

    scaleRgbTransferFunction(rgbTransferFunction, 2);
    @see

    ColorTransferFunction


    Parameters

    • rgbTransferFunction: any
    • scalingFactor: number

    Returns void

snapFocalPointToSlice

  • Given a number of frames, deltaFrames, move the focalPoint and camera position so that it moves forward/backwards deltaFrames in the camera’s normal direction, and snaps to the nearest frame.


    Parameters

    • focalPoint: Point3

      The focal point to move.

    • position: Point3

      The camera position to move.

    • sliceRange: ActorSliceRange

      The scroll range used to find the current position in the stack, as well as prevent scrolling past the extent of the volume.

    • viewPlaneNormal: Point3

      The normal direction of the camera.

    • spacingInNormalDirection: number

      The spacing of frames the normal direction of the camera.

    • deltaFrames: number

      The number of frames to jump.

    Returns { newFocalPoint: Point3; newPosition: Point3 }

    The newFocalPoint and newPosition of the camera.

sortImageIdsAndGetSpacing

  • sortImageIdsAndGetSpacing(imageIds: string[], scanAxisNormal?: vec3): SortedImageIdsItem
  • Given an array of imageIds, sort them based on their imagePositionPatient, and also returns the spacing between images and the origin of the reference image


    Parameters

    • imageIds: string[]

      array of imageIds

    • optionalscanAxisNormal: vec3

      [x, y, z] array or gl-matrix vec3

    Returns SortedImageIdsItem

    The sortedImageIds, zSpacing, and origin of the first image in the series.

transformIndexToWorld

  • transformIndexToWorld(imageData: any, voxelPos: Point3): any
  • Given an imageData object and a position in voxel space, return a point in world space.


    Parameters

    • imageData: any

      The image data object.

    • voxelPos: Point3

      Point in voxel space index space.

    Returns any

    A point in world space.

transformWorldToIndex

  • transformWorldToIndex(imageData: any, worldPos: Point3): any
  • Given an imageData object and a point in physical space, return the index of the voxel that contains the point. TODO: this should be pushed to vtk upstream.


    Parameters

    • imageData: any

      The image data object.

    • worldPos: Point3

    Returns any

    An array of integers.

updateVTKImageDataWithCornerstoneImage

  • updateVTKImageDataWithCornerstoneImage(sourceImageData: vtkImageData, image: IImage): void
  • Parameters

    • sourceImageData: vtkImageData
    • image: IImage

    Returns void

uuidv4

  • uuidv4(): string
  • Generates a unique id that has limited chance of collision

    @see

    Source


    Returns string

    a v4 compliant GUID

worldToImageCoords

  • worldToImageCoords(imageId: string, worldCoords: Point3): Point2 | undefined
  • Given the imageId, and 3d coordinates on the world space, it returns the continuos image coordinates (IJ) on the image space. The image space is defined with [0,0] being on the top left corner of the top left pixel, the [1,1] being on the bottom right corner of the top left pixel.


    Parameters

    • imageId: string

      The image id

    • worldCoords: Point3

      The 3d coordinates on the world.

    Returns Point2 | undefined

    The 2d coordinates on the image.