Skip to main content

WSIViewport

A viewport which shows a microscopy view using the dicom-microscopy-viewer library. This viewport accepts standard CS3D annotations, and responds similar to how the other types of viewports do for things like zoom/pan.

This viewport required the dicom-microscopy-viewer import to be available from the peerImport function in the CS3D init configuration. See the example initDemo.js for one possible implementation, but the actual implementation of this will depend on your platform.

Hierarchy

Implements

Index

Constructors

constructor

Properties

_actors

_actors: Map<string, any>

a Map containing the actor uid and actors

_suppressCameraModifiedEvents

_suppressCameraModifiedEvents: boolean = false

informs if a new actor was added before a resetCameraClippingRange phase

readonlycanvas

canvas: HTMLCanvasElement

an internal canvas that is created on the provided HTML element

readonlydefaultOptions

defaultOptions: Record<string, any>

Default options for the viewport which includes orientation, viewPlaneNormal and backgroundColor

readonlyelement

element: HTMLDivElement

HTML element in DOM that is used for rendering the viewport

readonlyid

id: string

unique identifier for the viewport

publicisDisabled

isDisabled: boolean

if the viewport has been disabled

publicmodality

modality: any

options

options for the viewport which includes orientation axis, backgroundColor and displayArea

readonlyrenderingEngineId

renderingEngineId: string

renderingEngineId the viewport belongs to

sHeight

sHeight: number

sHeight of viewport on the offscreen canvas

sWidth

sWidth: number

sWidth of viewport on the offscreen canvas

readonlysuppressEvents

suppressEvents: boolean

A flag representing if viewport methods should fire events or not

sx

sx: number

sx of viewport on the offscreen canvas

sy

sy: number

sy of viewport on the offscreen canvas

readonlytype

Type of viewport

readonlyuid

uid: any

updateRenderingPipeline

updateRenderingPipeline: () => void

Type declaration

    • (): void
    • Returns void

publicviewportStatus

viewportStatus: ViewportStatus = ViewportStatus.NO_DATA

Record the rendering status, mostly for testing purposes, but can also be useful for knowing things like whether the viewport is initialized

publicstaticreadonlyCameraViewPresentation

CameraViewPresentation: ViewPresentationSelector = ...

CameraViewPresentation is a view preentation selector that has all the camera related presentation selections, and would typically be used for choosing presentation information between two viewports showing the same type of orientation of a view, such as the CT, PT and fusion views in the same orientation view.

publicstaticreadonlyTransferViewPresentation

TransferViewPresentation: ViewPresentationSelector = ...

TransferViewPresentation is a view presentation selector that selects all the transfer function related attributes. It would typically be used for synchronizing different orientations of the same series, or for synchronizing two views of the same type of series such as a CT.

Accessors

publicstaticuseCustomRenderingPipeline

  • get useCustomRenderingPipeline(): boolean
  • Returns boolean

Methods

_getCorners

  • _getCorners(bounds: number[]): number[][]
  • Parameters

    • bounds: number[]

    Returns number[][]

_getEdges

  • _getEdges(bounds: number[]): [number[], number[]][]
  • Returns a list of edges for the imageData bounds, which are the cube edges in the case of volumeViewport edges. p1: front, bottom, left p2: front, top, left p3: back, bottom, left p4: back, top, left p5: front, bottom, right p6: front, top, right p7: back, bottom, right p8: back, top, right


    Parameters

    • bounds: number[]

      Bounds of the renderer

    Returns [number[], number[]][]

    Edges of the containing bounds

_getFocalPointForResetCamera

  • _getFocalPointForResetCamera(centeredFocalPoint: Point3, previousCamera: ICamera, __namedParameters: Object): Point3
  • Parameters

    • centeredFocalPoint: Point3
    • previousCamera: ICamera
    • __namedParameters: Object

    Returns Point3

_isInBounds

  • _isInBounds(point: Point3, bounds: number[]): boolean
  • Determines whether or not the 3D point position is inside the boundaries of the 3D imageData.


    Parameters

    • point: Point3

      3D coordinate

    • bounds: number[]

      Bounds of the image

    Returns boolean

    boolean

_removeActor

  • _removeActor(actorUID: string): void
  • Remove the actor from the viewport


    Parameters

    • actorUID: string

      The unique identifier for the actor.

    Returns void

publicaddActor

  • Add an actor to the viewport including its id, its actor and slabThickness if defined


    Parameters

    • actorEntry: ActorEntry

      ActorEntry

      • actorEntry.uid - The unique identifier for the actor.
      • actorEntry.actor - The volume actor.
      • actorEntry.slabThickness - The slab thickness.

    Returns void

publicaddActors

  • addActors(actors: ActorEntry[], resetCameraPanAndZoom?: boolean): void
  • Add a list of actors (actor entries) to the viewport


    Parameters

    • actors: ActorEntry[]

      An array of ActorEntry objects.

    • resetCameraPanAndZoom: boolean = false

      force reset pan and zoom of the camera, default value is false.

    Returns void

publicaddWidget

  • addWidget(widgetId: any, widget: any): void
  • Parameters

    • widgetId: any
    • widget: any

    Returns void

publiccanvasToWorld

  • Converts a VideoViewport canvas coordinate to a video coordinate.


    Parameters

    Returns Point3

    World position

publiccustomRenderViewportToCanvas

  • customRenderViewportToCanvas(): void
  • whether the viewport has custom rendering


    Returns void

publicgetActor

  • Get an actor by its UID


    Parameters

    • actorUID: string

      The unique ID of the actor.

    Returns ActorEntry

    An ActorEntry object.

publicgetActorByIndex

  • Get an actor by its index


    Parameters

    • index: number

      array index.

    Returns ActorEntry

    actorUID

publicgetActorUIDByIndex

  • getActorUIDByIndex(index: number): string
  • Get an actor UID by its index


    Parameters

    • index: number

      array index.

    Returns string

    actorUID

publicgetActorUIDs

  • getActorUIDs(): string[]
  • Returns an array of unique identifiers for all the actors in the viewport.


    Returns string[]

    An array of strings

publicgetActors

  • Get all the actors in the viewport


    Returns ActorEntry[]

    An array of ActorEntry objects.

publicgetCamera

  • returns camera object


    Returns ICamera

publicgetCanvas

  • getCanvas(): HTMLCanvasElement
  • Gets the target output canvas for the Viewport.


    Returns HTMLCanvasElement

    an HTMLCanvasElement.

publicgetClippingPlanesForActor

  • getClippingPlanesForActor(actorEntry?: ActorEntry): vtkPlane[]
  • Method to get the clipping planes of a given actor


    Parameters

    • optionalactorEntry: ActorEntry

      The actor entry (a specific type you’ll define dependent on your code)

    Returns vtkPlane[]

    vtkPlanes - An array of vtkPlane objects associated with the given actor

publicgetCurrentImageId

  • getCurrentImageId(): string
  • This function returns the imageID associated with either the current frame being displayed, or the range of frames being played. This may not correspond to any particular imageId that has imageId metadata, as the format is one of: <DICOMweb URI>/frames/<Start Frame>(-<End Frame>)? or <Other URI>[?&]frameNumber=<Start Frame>(-<EndFrame>)? for a URL parameter.


    Returns string

    an imageID for video

publicgetCurrentImageIdIndex

  • getCurrentImageIdIndex(): number
  • Gets the index of the current image, it is not guaranteed to be the slice index in the view, use getSliceIndex for positional information


    Returns number

publicgetDefaultActor

  • Get the default actor


    Returns ActorEntry

    An actor entry.

publicgetDisplayArea

  • returns the displayArea


    Returns DisplayArea

publicgetFrameNumber

  • getFrameNumber(): number
  • Gets the current frame, 1 based


    Returns number

publicgetFrameOfReferenceUID

  • getFrameOfReferenceUID(): string
  • The FOR for whole slide imaging is the frame of reference in the DICOM metadata, and should be the same for all slices being viewed.


    Returns string

publicgetImageData

  • getImageData(): { calibration: IImageCalibration; dimensions: any; direction: any; getScalarData: () => any; hasPixelSpacing: boolean; imageData: { getDimensions: () => any; getDirection: () => any; getRange: () => number[]; getScalarData: () => any; getSpacing: () => any; indexToWorld: (point: Point3) => Point3; worldToIndex: (point: Point3) => number[] }; metadata: { Modality: any }; numComps: number; origin: any; preScale: { scaled: boolean }; spacing: any }
  • Returns { calibration: IImageCalibration; dimensions: any; direction: any; getScalarData: () => any; hasPixelSpacing: boolean; imageData: { getDimensions: () => any; getDirection: () => any; getRange: () => number[]; getScalarData: () => any; getSpacing: () => any; indexToWorld: (point: Point3) => Point3; worldToIndex: (point: Point3) => number[] }; metadata: { Modality: any }; numComps: number; origin: any; preScale: { scaled: boolean }; spacing: any }

    • calibration: IImageCalibration
    • dimensions: any
    • direction: any
    • getScalarData: () => any
        • (): any
        • Returns any

    • hasPixelSpacing: boolean
    • imageData: { getDimensions: () => any; getDirection: () => any; getRange: () => number[]; getScalarData: () => any; getSpacing: () => any; indexToWorld: (point: Point3) => Point3; worldToIndex: (point: Point3) => number[] }
      • getDimensions: () => any
          • (): any
          • Returns any

      • getDirection: () => any
          • (): any
          • Returns any

      • getRange: () => number[]
          • (): number[]
          • Returns number[]

      • getScalarData: () => any
          • (): any
          • Returns any

      • getSpacing: () => any
          • (): any
          • Returns any

      • indexToWorld: (point: Point3) => Point3
      • worldToIndex: (point: Point3) => number[]
          • Parameters

            Returns number[]

    • metadata: { Modality: any }
      • Modality: any
    • numComps: number
    • origin: any
    • preScale: { scaled: boolean }
      • scaled: boolean
    • spacing: any

publicgetNumberOfSlices

  • getNumberOfSlices(): number
  • Gets the number of slices - this will be the number of focal planes, and not hte actual number of slices in the image sets.


    Returns number

publicgetPan

  • Helper function to return the current canvas pan value.


    Parameters

    Returns Point2

    a Point2 containing the current pan values on the canvas, computed from the current camera, where the initial pan value is [0,0].

publicgetProperties

  • Retrieve the viewport properties


    Returns ViewportProperties

publicgetReferenceId

  • getReferenceId(): string
  • Gets a referenced image url of some sort - could be a real image id, or could be a URL with parameters. Regardless it refers to the currently displaying image as a string value.


    Returns string

publicgetRenderer

  • getRenderer(): any
  • Returns the vtkRenderer responsible for rendering the Viewport.


    Returns any

    The vtkRenderer for the Viewport.

publicgetRenderingEngine

  • Returns the rendering engine driving the Viewport.


    Returns default

    The RenderingEngine instance.

publicgetRotation

  • getRotation(): number
  • get the rotation either from the camera provided or the viewport if not provided


    Returns number

publicgetSliceIndex

  • getSliceIndex(): number
  • This can be implemented later when multi-slice WSI is supported


    Returns number

getView

  • getView(): any
  • Gets the internal OpenLayers view object being rendered Note this is not typeds right now, but might add typing later.


    Returns any

publicgetViewPresentation

  • Gets a view presentation information specifying HOW a viewport displays something, but not what is being displayed. See getViewReference to get information on WHAT is being displayed.

    This is intended to have information on how an image is presented to the user, without specifying what image s displayed. All of this information is available externally, but this method combines the parts of this that are appropriate for remember or applying to other views, without necessarily needing to know what all the atributes are. That differs from methods like getCamera which fetch exact view details that are not likely to be identical between viewports as they change sizes or apply to different images.

    Note that the results of this can be used on different viewports, for example, the pan values can be applied to a volume viewport showing a CT, and a stack viewport showing an ultrasound.

    The selector allows choosing which view presentation attributes to return. Some default values are available from Viewport.CameraViewPresentation and Viewport.TransferViewPresentation


    Parameters

    Returns ViewPresentation

publicgetViewReference

  • Gets a view target specifying WHAT a view is displaying, allowing for checking if a given image is displayed or could be displayed in a given viewport. See getViewPresentation for HOW a view is displayed.


    Parameters

    • viewRefSpecifier: ViewReferenceSpecifier = {}

      choose an alternate view to be specified, typically a different slice index in the same set of images.

    Returns ViewReference

publicgetWidget

  • getWidget(id: any): any
  • Parameters

    • id: any

    Returns any

publicgetWidgets

  • getWidgets(): any[]
  • Returns any[]

publicgetZoom

  • getZoom(): any
  • returns the parallel zoom relative to the default (eg returns 1 after reset)


    Returns any

publichasImageURI

  • hasImageURI(imageURI: string): boolean
  • Checks to see if the imageURI is currently being displayed. The imageURI may contain frame numbers according to the DICOM standard format, which will be stripped to compare the base image URI, and then the values used to check if that frame is currently being displayed.

    The DICOM standard allows for comma separated values as well, however, this is not supported here, with only a single range or single value being tested.

    For a single value, the time range +/- 5 frames is permitted to allow the detection to actually succeed when nearby without requiring an exact time frame to be matched.


    Parameters

    • imageURI: string

      containing frame number or range.

    Returns boolean

publicisReferenceViewable

  • Find out if this viewport does or could show this view reference.


    Parameters

    Returns boolean

    true if the viewport could show this view reference

publicpostrender

  • postrender(): void
  • Returns void

publicremoveActors

  • removeActors(actorUIDs: string[]): void
  • Remove the actors with the given UIDs from the viewport


    Parameters

    • actorUIDs: string[]

      An array of actor UIDs to remove.

    Returns void

publicremoveAllActors

  • removeAllActors(): void
  • Remove all actors from the renderer


    Returns void

publicremoveWidgets

  • removeWidgets(): void
  • Returns void

publicrender

  • render(): void
  • Renders the Viewport using the RenderingEngine.


    Returns void

publicreset

  • reset(immediate?: boolean): void
  • Resets the options the Viewport‘s defaultOptions


    Parameters

    • immediate: boolean = false

      If true, renders the viewport after the options are reset.

    Returns void

publicresetCamera

  • resetCamera(): boolean
  • Centers Pan and resets the zoom for stack viewport.


    Returns boolean

publicresetProperties

  • resetProperties(): void
  • Reset the viewport properties to the default values


    Returns void

publicresize

  • resize(): void
  • Resizes the viewport - only used in CPU fallback for StackViewport. The GPU resizing happens inside the RenderingEngine.


    Returns void

publicscroll

  • scroll(delta: number): void
  • Scrolls the image - for WSI, this changes the zoom ratio since different images are used to represent different zoom levels, although this also allows fractional zoom levels


    Parameters

    • delta: number

    Returns void

publicsetActors

  • It removes all actors from the viewport and then adds the actors from the array.


    Parameters

    • actors: ActorEntry[]

      An array of ActorEntry objects.

    Returns void

publicsetCamera

  • sets the camera


    Parameters

    Returns void

publicsetDataIds

  • setDataIds(imageIds: string[]): Promise<void>
  • This is a wrapper for setWSI to allow generic behaviour


    Parameters

    • imageIds: string[]

    Returns Promise<void>

publicsetDisplayArea

  • setDisplayArea(displayArea: DisplayArea, suppressEvents?: boolean): void
  • Sets the camera to an initial bounds. If resetPan and resetZoom are true it places the focal point at the center of the volume (or slice); otherwise, only the camera zoom and camera Pan or Zoom is reset for the current view.


    Parameters

    • displayArea: DisplayArea

      The display area of interest.

    • suppressEvents: boolean = false

      If true, don’t fire displayArea event.

    Returns void

publicsetFrameNumber

  • setFrameNumber(frame: number): Promise<void>
  • Sets the current frame


    Parameters

    • frame: number

    Returns Promise<void>

publicsetOptions

  • Sets new options and (TODO) applies them.


    Parameters

    • options: ViewportInputOptions

      The viewport options to set.

    • immediate: boolean = false

      If true, renders the viewport after the options are set.

    Returns void

publicsetOrientationOfClippingPlanes

  • setOrientationOfClippingPlanes(vtkPlanes: vtkPlane[], slabThickness: number, viewPlaneNormal: Point3, focalPoint: Point3): void
  • Parameters

    • vtkPlanes: vtkPlane[]
    • slabThickness: number
    • viewPlaneNormal: Point3
    • focalPoint: Point3

    Returns void

publicsetPan

  • setPan(pan: Point2, storeAsInitialCamera?: boolean): void
  • Sets the canvas pan value relative to the initial view position of 0,0 Modifies the camera to perform the pan.


    Parameters

    • pan: Point2
    • storeAsInitialCamera: boolean = false

    Returns void

publicsetProperties

  • Sets the properties for the viewport on the default actor.


    Parameters

    Returns void

publicsetRendered

  • setRendered(): void
  • Indicate that the image has been rendered. This will set the viewportStatus to RENDERED if there is image data available to actually be rendered - otherwise, the rendering simply showed the background image.


    Returns void

publicsetViewPresentation

  • Applies the display area, zoom, pan and rotation from the view presentation. No-op is viewPres isn’t defined.


    Parameters

    Returns void

publicsetViewReference

  • Navigates to the image specified by the viewRef.


    Parameters

    Returns void

publicsetWSI

  • setWSI(imageIds: string[], client: any): Promise<void>
  • Sets the WSI to play. The WSI should have at least some metadata in the metadata provider, including:

    • study/series/sop common module for UIDs
    • cineModule for information on number of frames and playback rate
    • imageUrlModule - to get the URL for the image under the rendered attribute

    Without these, other tools requiring metadata wont work, although basic playback does work if the setWSIURL is used instead.


    Parameters

    • imageIds: string[]
    • client: any

    Returns Promise<void>

publicsetZoom

  • setZoom(zoom: number): void
  • Sets the relative zoom - set to 1 to reset it


    Parameters

    • zoom: number

    Returns void

publictriggerCameraModifiedEventIfNecessary

  • triggerCameraModifiedEventIfNecessary(previousCamera: ICamera, updatedCamera: ICamera): void
  • Trigger camera modified event


    Parameters

    Returns void

publicupdateCameraClippingPlanesAndRange

  • updateCameraClippingPlanesAndRange(): void
  • Updates the camera’s clipping planes and range.


    Returns void

publicworldToCanvas

  • Converts and [x,y] video coordinate to a Cornerstone3D VideoViewport.


    Parameters

    • worldPos: Point3

      world coord to convert to canvas

    Returns Point2

    Canvas position

staticboundsRadius

  • boundsRadius(bounds: number[]): number
  • Computes the bounds radius value


    Parameters

    • bounds: number[]

    Returns number

publicstaticgetDicomMicroscopyViewer

  • getDicomMicroscopyViewer(): Promise<any>
  • Encapsulate the dicom microscopy fetch so that it can be replaced with the browser import function. Webpack munges this and then throws exceptions trying to get this working, so this has to be provided externally as a globalThis.browserImportFunction taking the package name, and a set of options defining how to get the value out of the package.


    Returns Promise<any>