Class VolumeSegmentationContext

The VolumeSegmentationContext class is used to perform a range of segmentation operations, as well as to manupulate existing segmentation data.

A VolumeSegmentationContext object is backed by a native VolumeSegmentation object, associated with this an Fovia.OctreeContext and one or more Fovia.RenderEngineContext3D objects.

Hierarchy

  • VolumeSegmentationContext

Index

Constructors

constructor

Properties

Private octreeContext

octreeContext: OctreeContext

Private segmentationContextID

segmentationContextID: number

Methods

clearCustomKernel

  • clearCustomKernel(callbackFunc?: any): any
  • Unload the Custom Kenrel DLL and free any memory associated with it.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

clearLabels

  • clearLabels(labelMask: number, callbackFunc?: any): any
  • Clears the segmentation state for one ore more label volumes.

    Parameters

    • labelMask: number

      bit mask indicating which labels to clear (e.g. 0x01 will only clear label 0, 0x02 will only clear label 1, and 0xff will clear all 8 labels).

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

colorizeTF

  • colorizeTF(renderEngineContext: RenderEngineContext3D, inIndex: number, outIndex: number, color: Color, callbackFunc?: any): any
  • Take a 3D Transfer Function and make it all a solid color (useful for visualizing the results of segmentation).

    Parameters

    • renderEngineContext: RenderEngineContext3D

      renderEngine to change the TFs of.

    • inIndex: number

      which Label TF to use as the shape of the TF.

    • outIndex: number

      which Label TF to set.

    • color: Color

      Color to use.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

combineLabels

  • combineLabels(inIndex1: number, inIndex2: number, outIndex: number, callbackFunc?: any): any
  • Combine two labels into one using a voxel-wise OR operation.

    Parameters

    • inIndex1: number

      first label to combine.

    • inIndex2: number

      second label to combine.

    • outIndex: number

      label to place the reult in (note it can be the same as one of the input labels).

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

copyLabel

  • copyLabel(inIndex: number, outIndex: number, callbackFunc?: any): any
  • Copy one label to another.

    Parameters

    • inIndex: number

      label to copy from.

    • outIndex: number

      label to copy to.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

dilateOneObject

  • dilateOneObject(segLabelIndex: number, indexToDilate: number, origin: Vector, count: number, callbackFunc?: any): any
  • Expands a segmented region by adding layers to the exterior surface.

    Parameters

    • segLabelIndex: number

      Index of which label to segment into.

    • indexToDilate: number

      Index of which label to dilate.

    • origin: Vector

      Origin point inside the one connected component to dilate. Note: the "closest surface to this point will be dilated even if it is a "hole" inside an object and not the object "outside" surface.

    • count: number

      number of layers to add to the outside

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

enableInteractiveSeg

  • Enables Interactive Segmentation. Specifically setup the render engines that will be rendering the results so that TF can be adjusted for subtractive and other things. As well as set flag for some things that happen automatically inside (e.g. make the working label the same TF as the seg Label).

    Parameters

    • listOfRenderingEngines: Array<RenderEngineContext3D>

      render engines that are used with this segmentation operation

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

erodeOneObject

  • erodeOneObject(segLabelIndex: number, indexToErode: number, origin: Vector, count: number, callbackFunc?: any): any
  • Contracts a segmented region by removing layers from the exterior surface.

    Parameters

    • segLabelIndex: number

      Index of which Label to segment into.

    • indexToErode: number

      Index of which Label to erode.

    • origin: Vector

      Origin point inside the one connected component to erode. Note: the "closest surface to this point will be dilated even if it is a "hole" inside an object and not the object "outside" surface.

    • count: number

      number of layers to take off from the outside.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

freeHandCut

  • Cut a section of the data using a polygon specified by the POINT array in screen space.

    Parameters

    • renderEngineContext: RenderEngineContext3D

      The render engine used to render the image used as the basis for the freeHandCut operation.

    • pointList: Array<Point>

      array of Point objects defining the region to cut.

    • fhcMode: FreeHandCutMode

      The mode to use when performing the cut operation. This defines how deeply the cut penetrates the volume.

    • segLabelIndex: number

      Index of which Label to segment into.

    • ppWidth: number

      The width of the image used for gathering the points.

    • ppHeight: number

      The height of the image used for gathering the points.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

getOctree

  • Return the OctreeContext associated with this object.

    Returns OctreeContext

    OctreeContext associated with this object.

getSegmentationContextID

  • getSegmentationContextID(): number
  • Return the segmentation context ID associated with this object.

    Returns number

    segmentation context ID associated with this object.

initialize

  • initialize(callbackFunc?: any): any
  • Initializes the class. This function must be called before other class functions can be used.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

interactiveSegCancel

  • interactiveSegCancel(callbackFunc?: any): any
  • End the current "cycle", the last segmentation is dropped and the persistent segmentation state remains unaltered from this cycle.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

interactiveSegEnd

  • interactiveSegEnd(callbackFunc?: any): any
  • End the current "cycle", the last segmentation from working label is "or"-ed over to the target label.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

interactiveSegInit

  • Start an interactive segmentation "cycle" (Cycle is defined as a sequence of segments where the use adjusts the parameters to get some desired segmentation that is kept only on "End" without "Escape"). The working label is used for these intermittent segmentations.

    Parameters

    • segmentationParameters: SegmentationParameters

      Initial parameters for the segmentation operation.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then(data) .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode , data)

    data.sizeVoxels - The size of the segmented region (in voxels).
    data.sizeMMs - The size of the segmented region (in cubic millimeters).

interactiveSegReSegment

  • During a "cycle", this is called for each subsequent segment with new parameters into the working label.

    Parameters

    • segmentationParameters: SegmentationParameters

      Parameters for the segmentation operation.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then(data) .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode , data)

    data.sizeVoxels - The size of the segmented region (in voxels).
    data.sizeMMs - The size of the segmented region (in cubic millimeters).

loadCustomKernel

  • The custom Kernel DLL is loaded at runtime since it is unkown at compile time. Also a buffer for and parameters which will be used is allocated (so we an later copy new parameters in, a copy is kept here locally in case the client is remote). Parameters can be updated in SegmentationParameters for subsequent segmentation calls.

    When using a custom kernel, only the min, max, radius, and customKernelParamArray values in the SegmentationParameters object are used.

    Parameters

    • dllPath: string

      The fully (or relative) qualifed pathto the dll file including extension.

    • segmentationParameters: SegmentationParameters

      Segmenataion paramaters to use. For custom kernels, only the min, max, radius, and customKernelParamArray values are used.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

loadSegStateFromGIPL

  • loadSegStateFromGIPL(giplServerFilename: string, callbackFunc?: any): any
  • Load the label Volume (segmentation state) from disk .gipl format on the server.

    Parameters

    • giplServerFilename: string

      File name (either fully qualifed or relative. Also with extension) to load (from server).

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

makeColorLabeledTFsfromWindowLevel

  • makeColorLabeledTFsfromWindowLevel(renderEngineContext: RenderEngineContext3D, windowWidth: number, windowLevel: number, callbackFunc?: any): any
  • Fill in the upper TF's with colorized version of the window/level function.

    Parameters

    • renderEngineContext: RenderEngineContext3D

      RenderEngine to change the TFs.

    • windowWidth: number

      Window width in volume values as stored in the file (e.g. for CT, the HU values are converted using DICOM rescale intercept and scale).

    • windowLevel: number

      Window level in volume values as stroed in the file (e.g. for CT, the HU values are converted using DICOM rescale intercept and scale).

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

makeColorLabelsFromMainTF

  • Fill in the upper TF's with colorized version of the main transfer function at label volume 0.

    Parameters

    • renderEngineContext: RenderEngineContext3D

      RenderEngine to change the TFs of.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

makeTFfromWindowLevel

  • makeTFfromWindowLevel(renderEngineContext: RenderEngineContext3D, index: number, windowWidth: number, windowLevel: number, startColor: Color, endColor: Color, callbackFunc?: any): any
  • To display segmentation on 2D Thin display we utilize a fully opaque TF with a Parallel render instead of MPR render Type. This function will create that TF. for unsegmented data use (0,0,0) to (255,255,255) to get a TF whihc looks a a W/L display on a normal MPR 2D display. It is suggested for the segmented labels to use (r/2,g/2,b/2) to (r,g,b) for a given color for that label because then you will still see the different shades of the 2D image below the color.

    Parameters

    • renderEngineContext: RenderEngineContext3D

      RenderEngine to change the TFs of.

    • index: number

      Ehich Label TF to set.

    • windowWidth: number

      Window width in volume values as stored in the file (e.g. for CT, the HU values are converted using DICOM rescale intercept and scale).

    • windowLevel: number

      Window Level in volume values as stroed in the file (e.g. for CT, the HU values are converted using DICOM rescale intercept and scale).

    • startColor: Color

      Color to use for the minimum window value.

    • endColor: Color

      Color to use for the maximum window value.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

Private printNativeSegmentationParameters

  • Private method for printing the supplied segmentation state from the native code. This is used only for internal debugging purposes

    Parameters

    Returns void

    This is a synchronous method that returns void immediately upon emitted the event.

releaseSessionResources

  • releaseSessionResources(callbackFunc?: any): any
  • Releases server side resources assoicated with this SegmentationContext instance.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

saveForUndo

  • saveForUndo(labelIndex: number, callbackFunc?: any): any
  • Save the current state as an "operation" (internally a ring buffer of 10 undo's are stored, so only the last 10 can be undone).

    Parameters

    • labelIndex: number

      Which label to save.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then(numLeft) .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode , numLeft)

    numLeft - The number of undo operations possible after removing this one.

saveSegStateAsGIPL

  • saveSegStateAsGIPL(giplServerFilename: string, callbackFunc?: any): any
  • Save the label Volume (segmentation state) to disk in .gipl format on the server.

    Parameters

    • giplServerFilename: string

      File name (either fully qualifed or relative. Also with extension) to save (on server).

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

segment

  • Performs a segmentation operation, make sure you invoke this method with a Promise or callback so you know when it completes. You should not modify the VolumeSegmentationContext while segmentation is occuring.

    Parameters

    • segmentationParameters: SegmentationParameters

      Data structure containing the paramaters defining the segmentation operation.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then(data) .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode , data)

    data.sizeVoxels - The size of the segmented region (in voxels).
    data.sizeMMs - The size of the segmented region (in cubic millimeters).

setSegLabelIndex

  • setSegLabelIndex(labelIndex: number, callbackFunc?: any): any
  • Set the label for segmentation output (the label value to segment into).

    Parameters

    • labelIndex: number

      the lable index value to segment into (defaults to 1)

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

setSegLabelMask

  • setSegLabelMask(labelMasks0to63: number, labelMasks64to127: number, labelMasks128to191: number, labelMasks192to255: number, callbackFunc?: any): any
  • Set the mask of lables that segmentation will grow through.

    Parameters

    • labelMasks0to63: number

      A bitmask designating which label volumes 0-63 the segmentation will grow through. For up to 256 masks, if 8TF, then only use first 8 its of array[0]. (defaults to 0xfff...)

    • labelMasks64to127: number

      A bitmask designating which label volumes 64-127 the segmentation will grow through. Only used in 256 TF SDK version.

    • labelMasks128to191: number

      A bitmask designating which label volumes 128-191 the segmentation will grow through. Only used in 256 TF SDK version.

    • labelMasks192to255: number

      A bitmask designating which label volumes 192-255 the segmentation will grow through. Only used in 256 TF SDK version.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

setSegType

  • Set the type of segmentation (additive or subtractive).

    Parameters

    • segType: SegmentationType

      Specifies either additive or subtractive segmentation.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

swapLabels

  • swapLabels(index1: number, index2: number, callbackFunc?: any): any
  • Swap contents of two label volumes.

    Parameters

    • index1: number

      first label to swap.

    • index2: number

      second label to swap.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

undoLast

  • undoLast(callbackFunc?: any): any
  • Undo the last "operation" (internally a ring buffer of 10 undo's are stored, so only the last 10 can be undone.)

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then(numLeft) .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode , numLeft)

    numLeft - The number of undo operations possible after removing this one.

Private validateCustomKernelParams

  • validateCustomKernelParams(kernalParamArray: any): boolean
  • confirm that all entries are valid 8-bit values

    Parameters

    • kernalParamArray: any

    Returns boolean