Skip to main content

segmentation

Index

Namespaces

activeSegmentation

activeSegmentation:

getActiveSegmentationRepresentation

  • Get the active segmentation representation for the tool group with the given toolGroupId.


    Parameters

    • toolGroupId: string

      The Id of the tool group

    Returns ToolGroupSpecificRepresentation

    The active segmentation representation for the tool group.

setActiveSegmentationRepresentation

  • setActiveSegmentationRepresentation(toolGroupId: string, segmentationRepresentationUID: string): void
  • Set the active segmentation for the given tool group for all its viewports


    Parameters

    • toolGroupId: string

      The Id of the tool group to set the active segmentation for.

    • segmentationRepresentationUID: string

      The id of the segmentation representation to set as active.

    Returns void

config

config:

color

color:

addColorLUT

  • addColorLUT(colorLUT: ColorLUT, colorLUTIndex: number): void
  • addColorLUT - Adds a new color LUT to the state at the given colorLUTIndex. If no colorLUT is provided, a new color LUT is generated.


    Parameters

    • colorLUT: ColorLUT

      An array of The colorLUT to set.

    • colorLUTIndex: number

      the index of the colorLUT in the state

    Returns void

getColorForSegmentIndex

  • getColorForSegmentIndex(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number): Color
  • Given a tool group UID, a segmentation representationUID, and a segment index, return the color for that segment. It can be used for segmentation tools that need to display the color of their annotation.


    Parameters

    • toolGroupId: string

      The Id of the tool group that owns the segmentation representation.

    • segmentationRepresentationUID: string

      The uid of the segmentation representation

    • segmentIndex: number

      The index of the segment in the segmentation

    Returns Color

    A color.

setColorForSegmentIndex

  • setColorForSegmentIndex(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number, color: Color): void
  • Parameters

    • toolGroupId: string
    • segmentationRepresentationUID: string
    • segmentIndex: number
    • color: Color

    Returns void

setColorLUT

  • setColorLUT(toolGroupId: string, segmentationRepresentationUID: string, colorLUTIndex: number): void
  • It sets the toolGroup’s segmentationRepresentation to use the provided colorLUT at the given colorLUTIndex.


    Parameters

    • toolGroupId: string

      the id of the toolGroup that renders the representation

    • segmentationRepresentationUID: string

      the representationUID for the segmentation

    • colorLUTIndex: number

      the index of the colorLUT to use

    Returns void

visibility

visibility:

getSegmentationVisibility

  • getSegmentationVisibility(toolGroupId: string, segmentationRepresentationUID: string): boolean | undefined
  • Get the visibility of a segmentation data for a given tool group.


    Parameters

    • toolGroupId: string

      The Id of the tool group that the segmentation data belongs to.

    • segmentationRepresentationUID: string

      The id of the segmentation data to get

    Returns boolean | undefined

    A boolean value that indicates whether the segmentation data is visible or not on the toolGroup

setSegmentVisibility

  • setSegmentVisibility(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number, visibility: boolean): void
  • Parameters

    • toolGroupId: string
    • segmentationRepresentationUID: string
    • segmentIndex: number
    • visibility: boolean

    Returns void

setSegmentationVisibility

  • setSegmentationVisibility(toolGroupId: string, segmentationRepresentationUID: string, visibility: boolean): void
  • Set the visibility of a segmentation representation for a given tool group. It fires a SEGMENTATION_REPRESENTATION_MODIFIED event. Visibility true will show all segments and visibility false will hide all segments”

    @triggers

    SEGMENTATION_REPRESENTATION_MODIFIED


    Parameters

    • toolGroupId: string

      The Id of the tool group that contains the segmentation.

    • segmentationRepresentationUID: string

      The id of the segmentation representation to modify its visibility.

    • visibility: boolean

      boolean

    Returns void

setSegmentsVisibility

  • setSegmentsVisibility(toolGroupId: string, segmentationRepresentationUID: string, segmentIndices: number[], visibility: boolean): void
  • Set the visibility of the given segment indices to the given visibility. This is a helper to set the visibility of multiple segments at once and reduces the number of events fired.


    Parameters

    • toolGroupId: string

      The tool group id of the segmentation representation.

    • segmentationRepresentationUID: string

      The UID of the segmentation representation.

    • segmentIndices: number[]

      The indices of the segments to be hidden/shown.

    • visibility: boolean

      The visibility to set the segments to.

    Returns void

getGlobalConfig

  • It returns the global segmentation config.


    Returns SegmentationRepresentationConfig

    The global segmentation config containing the representations config for each representation type and renderInactiveSegmentations flag.

getGlobalRepresentationConfig

  • Given a representation type, return the corresponding global representation config


    Parameters

    Returns RepresentationConfig[LABELMAP]

    A representation configuration object.

getSegmentSpecificConfig

  • getSegmentSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number): RepresentationConfig
  • Get the segment specific configuration for the segmentation representation.


    Parameters

    • toolGroupId: string

      The tool group id where the segmentation representation belongs to.

    • segmentationRepresentationUID: string

      The uid of the segmentation representation

    • segmentIndex: number

      The index of the segment

    Returns RepresentationConfig

    • The configuration for the segment index in the segmentation representation that is shown in the toolGroup’s viewport

getSegmentationRepresentationSpecificConfig

  • getSegmentationRepresentationSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string): RepresentationConfig
  • Give the segmentation representation UID, return the corresponding config which is shared by all segments in the segmentation representation. This is an optional level of configuration that can be set by the user, by default it will fallback to the toolGroup specific config, if not set, it will fallback to the global config.


    Parameters

    • toolGroupId: string
    • segmentationRepresentationUID: string

      The uid of the segmentation representation

    Returns RepresentationConfig

    • The configuration for the representation.

getToolGroupSpecificConfig

  • Get the toolGroup specific segmentation config


    Parameters

    • toolGroupId: string

      The Id of the tool group

    Returns SegmentationRepresentationConfig

    A SegmentationConfig object.

setGlobalConfig

setGlobalRepresentationConfig

  • Set the global configuration for a given representation type. It fires a SEGMENTATION_MODIFIED event.

    @triggers

    SEGMENTATION_MODIFIED


    Parameters

    • representationType: SegmentationRepresentations

      The type of representation to set config for

    • config: LabelmapConfig

      The configuration for the representation.

    Returns void

setSegmentSpecificConfig

  • setSegmentSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string, config: SegmentSpecificRepresentationConfig): void
  • Set the segment specific configuration for the segmentation representation. This configuration, if specified, has higher priority than the segmentation representation specific config, and the toolGroup specific config. The order of priority is: segment specific config > segmentation representation specific config > toolGroup specific config > global config


    Parameters

    • toolGroupId: string

      The tool group id where the segmentation representation belongs to.

    • segmentationRepresentationUID: string

      The uid of the segmentation representation

    • config: SegmentSpecificRepresentationConfig

      The configuration for the representation. This is an object

    Returns void

setSegmentationRepresentationSpecificConfig

  • setSegmentationRepresentationSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string, config: RepresentationConfig): void
  • Set the segmentation representation specific configuration for the segmentation representation. This will apply to all segments in the segmentation representation and has higher priority than the toolGroup specific config.


    Parameters

    • toolGroupId: string
    • segmentationRepresentationUID: string

      The uid of the segmentation representation

    • config: RepresentationConfig

      The configuration for the representation. This is an object only containing the representation type as key and the config as value.

    Returns void

setToolGroupSpecificConfig

  • Sets the tool group specific configuration for the segmentation representation. This will apply to all segmentation representations.


    Parameters

    • toolGroupId: string

      The tool group id where the segmentation representation belongs to.

    • segmentationRepresentationConfig: SegmentationRepresentationConfig

      This is the configuration object that you will use to set the default values for the segmentation representation.

    Returns void

segmentIndex

segmentIndex:

getActiveSegmentIndex

  • getActiveSegmentIndex(segmentationId: string): number | undefined
  • Get the active segment index for a segmentation in the global state


    Parameters

    • segmentationId: string

      The id of the segmentation to get the active segment index from.

    Returns number | undefined

    The active segment index for the given segmentation.

setActiveSegmentIndex

  • setActiveSegmentIndex(segmentationId: string, segmentIndex: number): void
  • Set the active segment index for a segmentation Id. It fires a global state modified event.

    @triggers

    SEGMENTATION_MODIFIED


    Parameters

    • segmentationId: string

      The id of the segmentation that the segment belongs to.

    • segmentIndex: number

      The index of the segment to be activated.

    Returns void

segmentLocking

segmentLocking:

getLockedSegments

  • getLockedSegments(segmentationId: string): number[] | []
  • Get the locked segments for a segmentation


    Parameters

    • segmentationId: string

      The id of the segmentation to get locked segments for.

    Returns number[] | []

    An array of locked segment indices.

isSegmentIndexLocked

  • isSegmentIndexLocked(segmentationId: string, segmentIndex: number): boolean
  • Get the locked status for a segment index in a segmentation


    Parameters

    • segmentationId: string

      The id of the segmentation that the segment belongs to.

    • segmentIndex: number

      The index of the segment

    Returns boolean

    A boolean value indicating whether the segment is locked or not.

setSegmentIndexLocked

  • setSegmentIndexLocked(segmentationId: string, segmentIndex: number, locked?: boolean): void
  • Set the locked status of a segment index in a segmentation


    Parameters

    • segmentationId: string

      The id of the segmentation whose segment index is being modified.

    • segmentIndex: number

      The index of the segment to lock/unlock.

    • locked: boolean = true

    Returns void

state

state:

addColorLUT

  • addColorLUT(colorLUT: ColorLUT, index: number): void
  • Add a color LUT to the segmentation state manager


    Parameters

    • colorLUT: ColorLUT

      The color LUT array to add.

    • index: number

      The index of the color LUT to add.

    Returns void

addSegmentation

  • addSegmentation(segmentationInput: SegmentationPublicInput, suppressEvents?: boolean): void
  • It takes a segmentation input and adds it to the segmentation state manager


    Parameters

    • segmentationInput: SegmentationPublicInput

      The segmentation to add.

    • optionalsuppressEvents: boolean

      If true, the event will not be triggered.

    Returns void

addSegmentationRepresentation

  • Add the given segmentation representation data to the given tool group state. It fires SEGMENTATION_REPRESENTATION_MODIFIED event if not suppressed.

    @triggers

    SEGMENTATION_REPRESENTATION_MODIFIED


    Parameters

    • toolGroupId: string

      The Id of the tool group that the segmentation representation is for.

    • segmentationRepresentation: ToolGroupSpecificRepresentation
    • optionalsuppressEvents: boolean

      boolean

    Returns void

getColorLUT

  • getColorLUT(index: number): ColorLUT | undefined
  • Get the color lut for a given index


    Parameters

    • index: number

      The index of the color lut to retrieve.

    Returns ColorLUT | undefined

    A ColorLUT array.

getDefaultSegmentationStateManager

  • getDefaultSegmentationStateManager(): default
  • It returns the defaultSegmentationStateManager.


    Returns default

getGlobalConfig

  • It returns the global segmentation config. Note that the toolGroup-specific configuration has higher priority than the global configuration and overwrites the global configuration for each representation.


    Returns SegmentationRepresentationConfig

    The global segmentation configuration for all segmentations.

getSegmentSpecificRepresentationConfig

  • getSegmentSpecificRepresentationConfig(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number): RepresentationConfig
  • Parameters

    • toolGroupId: string
    • segmentationRepresentationUID: string
    • segmentIndex: number

    Returns RepresentationConfig

getSegmentation

  • getSegmentation(segmentationId: string): Segmentation | undefined
  • Get the segmentation for the given segmentationId


    Parameters

    • segmentationId: string

      The Id of the segmentation

    Returns Segmentation | undefined

    A GlobalSegmentationData object

getSegmentationRepresentationByUID

  • Get the segmentation data object for a given tool group and segmentation data UID. It searches all the toolGroup specific segmentation data objects and returns the first one that matches the UID.


    Parameters

    • toolGroupId: string

      The Id of the tool group that the segmentation data belongs to.

    • segmentationRepresentationUID: string

      The uid of the segmentation representation

    Returns ToolGroupSpecificRepresentation | undefined

    Segmentation Data object.

getSegmentationRepresentationSpecificConfig

  • getSegmentationRepresentationSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string): RepresentationConfig
  • It returns the segmentation representation specific config which is the same for all the segments


    Parameters

    • toolGroupId: string
    • segmentationRepresentationUID: string

      The unique identifier of the segmentation representation.

    Returns RepresentationConfig

    • The segmentation representation specific config.

getSegmentationRepresentations

  • getSegmentationRepresentations(toolGroupId: string): ToolGroupSpecificRepresentations | []
  • Get the segmentation state for a tool group. It will return an array of segmentation representation objects.


    Parameters

    • toolGroupId: string

      The unique identifier of the tool group.

    Returns ToolGroupSpecificRepresentations | []

    An array of segmentation representation objects.

getSegmentations

  • Get the segmentations inside the state


    Returns Segmentation[] | []

    Segmentation array

getToolGroupIdsWithSegmentation

  • getToolGroupIdsWithSegmentation(segmentationId: string): string[]
  • Get the tool group IDs that have a segmentation representation with the given segmentationId


    Parameters

    • segmentationId: string

      The id of the segmentation

    Returns string[]

    An array of tool group IDs.

getToolGroupSpecificConfig

  • Get the segmentation representations config for a given tool group


    Parameters

    • toolGroupId: string

      The Id of the tool group that the segmentation config belongs to.

    Returns SegmentationRepresentationConfig

    A SegmentationConfig object.

removeColorLUT

  • removeColorLUT(colorLUTIndex: number): void
  • Add a color LUT to the segmentation state manager


    Parameters

    • colorLUTIndex: number

    Returns void

removeSegmentation

  • removeSegmentation(segmentationId: string): void
  • It removes the segmentation from the segmentation state manager

    @triggers

    SEGMENTATION_REMOVED


    Parameters

    • segmentationId: string

      The id of the segmentation

    Returns void

removeSegmentationRepresentation

  • removeSegmentationRepresentation(toolGroupId: string, segmentationRepresentationUID: string): void
  • Remove a segmentation representation from the segmentation state manager for a toolGroup. It fires SEGMENTATION_REPRESENTATION_MODIFIED event.

    @triggers

    SEGMENTATION_REPRESENTATION_REMOVED


    Parameters

    • toolGroupId: string

      The Id of the tool group that the segmentation data belongs to.

    • segmentationRepresentationUID: string

      The uid of the segmentation representation to remove. remove.

    Returns void

setGlobalConfig

  • Set the global segmentation configuration. It fires SEGMENTATION_MODIFIED event if not suppressed.

    @triggers

    SEGMENTATION_MODIFIED


    Parameters

    • config: SegmentationRepresentationConfig

      The new global segmentation config.

    • optionalsuppressEvents: boolean

      If true, the segmentationGlobalStateModified event will not be triggered.

    Returns void

setSegmentSpecificRepresentationConfig

  • setSegmentSpecificRepresentationConfig(toolGroupId: string, segmentationRepresentationUID: string, config: SegmentSpecificRepresentationConfig, suppressEvents?: boolean): void
  • Parameters

    • toolGroupId: string
    • segmentationRepresentationUID: string
    • config: SegmentSpecificRepresentationConfig
    • suppressEvents: boolean = false

    Returns void

setSegmentationRepresentationSpecificConfig

  • setSegmentationRepresentationSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string, config: RepresentationConfig, suppressEvents?: boolean): void
  • It sets the segmentation representation specific config for all the segments inside the segmentation.


    Parameters

    • toolGroupId: string
    • segmentationRepresentationUID: string

      The unique identifier of the segmentation representation.

    • config: RepresentationConfig

      The new configuration for the segmentation representation it is an object with keys of different representation types, and values of the configuration for each representation type.

    • suppressEvents: boolean = false

    Returns void

setToolGroupSpecificConfig

  • Set the segmentation representation config for the provided toolGroup. ToolGroup specific configuration overwrites the global configuration for each representation. It fires SEGMENTATION_REPRESENTATION_MODIFIED event if not suppressed.

    @triggers

    SEGMENTATION_REPRESENTATION_MODIFIED


    Parameters

    • toolGroupId: string

      The Id of the tool group that the segmentation config is being set for.

    • config: SegmentationRepresentationConfig

      The new configuration for the tool group.

    • optionalsuppressEvents: boolean

      If true, the event will not be triggered.

    Returns void

triggerSegmentationEvents

triggerSegmentationEvents:

triggerSegmentationDataModified

  • triggerSegmentationDataModified(segmentationId: string, modifiedSlicesToUse?: number[]): void
  • Trigger an event that a segmentation data has been modified


    Parameters

    • segmentationId: string

      The Id of segmentation

    • optionalmodifiedSlicesToUse: number[]

    Returns void

triggerSegmentationModified

  • triggerSegmentationModified(segmentationId?: string): void
  • Triggers segmentation global state updated event, notifying all toolGroups that the global state has been updated, If a segmentationId is provided the event will only be triggered for that segmentation, otherwise it will be triggered for all segmentations.


    Parameters

    • optionalsegmentationId: string

      The id of the segmentation that has been updated

    Returns void

triggerSegmentationRemoved

  • triggerSegmentationRemoved(segmentationId: string): void
  • Trigger an event that a segmentation is removed


    Parameters

    • segmentationId: string

      The Id of segmentation

    Returns void

triggerSegmentationRepresentationModified

  • triggerSegmentationRepresentationModified(toolGroupId: string, segmentationRepresentationUID?: string): void
  • Trigger an event on the eventTarget that the segmentation representation for toolGroupId has been updated


    Parameters

    • toolGroupId: string

      The Id of the toolGroup

    • optionalsegmentationRepresentationUID: string

    Returns void

triggerSegmentationRepresentationRemoved

  • triggerSegmentationRepresentationRemoved(toolGroupId: string, segmentationRepresentationUID: string): void
  • Trigger an event that a segmentation representation was removed


    Parameters

    • toolGroupId: string

      The id of the tool group that the segmentation representation was removed from.

    • segmentationRepresentationUID: string

      The UID of the segmentation representation that was removed.

    Returns void

Functions

addSegmentationRepresentations

  • Set the specified segmentation representations on the viewports of the specified toolGroup. It accepts a second argument which is a toolGroup specific representation configuration.


    Parameters

    • toolGroupId: string

      The Id of the toolGroup to add the segmentation representations to

    • representationInputArray: RepresentationPublicInput[]

      An array of segmentation representations to add to the toolGroup

    • optionaltoolGroupSpecificRepresentationConfig: SegmentationRepresentationConfig

      The toolGroup specific configuration for the segmentation representations

    Returns Promise<string[]>

addSegmentations

  • addSegmentations(segmentationInputArray: SegmentationPublicInput[]): void
  • Adds the segmentation to the cornerstone3D segmentation state. It should be noted that segmentations are not added to any toolGroup’s viewports. In order to do so, you should add a “representation” of the segmentation to the toolGroup using addSegmentationRepresentations helper. The reason for this is that there can be multiple representations of the same segmentation (e.g. Labelmap and Contour, etc. - Currently only Labelmap representations is supported).


    Parameters

    • segmentationInputArray: SegmentationPublicInput[]

      The array of segmentation input, each of which defining the segmentationId and the main representation data for the segmentation.

    Returns void

removeSegmentationsFromToolGroup

  • removeSegmentationsFromToolGroup(toolGroupId: string, segmentationRepresentationUIDs?: string[], immediate?: boolean): void
  • Remove the segmentation representation (representation) from the viewports of the toolGroup.


    Parameters

    • toolGroupId: string

      The Id of the toolGroup to remove the segmentation from.

    • optionalsegmentationRepresentationUIDs: string[]

      The UIDs of the segmentation representations to remove.

    • optionalimmediate: boolean

      if True the viewport will be re-rendered immediately.

    Returns void