segmentation
- class trame_slicer.segmentation.AbstractSegmentationEffectBrush(mode: ModificationMode)
Bases:
SegmentationEffect,ABCAbstract class for segmentation effect implementing a brush behavior in views
- get_brush_diameter_mode() BrushDiameterMode
- abstractmethod paint_glyph_at_world_coordinates(polydata: vtkPolyData, paint_coordinates_world: vtkPoints)
- set_active(is_active)
- set_brush_diameter(diameter: float, diameter_mode: BrushDiameterMode | None = None)
- set_use_sphere_brush(use_sphere_brush)
- class trame_slicer.segmentation.AutoThresholdMethod(*values)
Bases:
Enum- HUANG = 1
- INTERMODES = 2
- ISO_DATA = 3
- KITTLER_ILLINGWORTH = 4
- LI = 5
- MAXIMUM_ENTROPY = 6
- MOMENTS = 7
- OTSU = 8
- RENYI_ENTROPY = 9
- SHANBHAG = 10
- TRIANGLE = 11
- YEN = 12
- class trame_slicer.segmentation.AutoThresholdMode(*values)
Bases:
IntFlag- UPPER = 1
- LOWER = 2
- MIN = 4
- MAX = 8
- MIN_UPPER = 5
- LOWER_MAX = 10
- class trame_slicer.segmentation.BrushDiameterMode(*values)
Bases:
Enum- Absolute = 1
- ScreenRelative = 2
- class trame_slicer.segmentation.BrushInteractionMode(*values)
Bases:
Enum- CONTINUOUS = 1
- POINT_BY_POINT = 2
- class trame_slicer.segmentation.BrushSource(shape: BrushShape, diameter: float = 16.0, cylinder_height: float = 1.0)
Bases:
object- property brush_to_world_origin_transform: vtkTransform
- get_diameter()
- get_transformed_polydata_output_port() vtkAlgorithmOutput
Return the output port of transformed brush model
- get_untransformed_output_port() vtkAlgorithmOutput
Return the output port of untransformed brush model Useful for feedback actors
- set_brush_rotation(slice_to_ras: vtkMatrix4x4)
- set_brush_to_world_position(world_pos)
- set_shape(shape: BrushShape) None
- property world_origin_to_world_transform: vtkTransform
- class trame_slicer.segmentation.ModificationMode(*values)
Bases:
IntEnum- Set = 1
- Add = 2
- Remove = 3
- RemoveAll = 4
- class trame_slicer.segmentation.ScissorsEffectFillMode(*values)
Bases:
Enum- ERASE_INSIDE = 1
- ERASE_OUTSIDE = 2
- FILL_INSIDE = 3
- FILL_OUTSIDE = 4
- class trame_slicer.segmentation.ScissorsEffectRangeMode(*values)
Bases:
Enum- UNLIMITED = 1
- POSITIVE = 2
- NEGATIVE = 3
- SYMMETRIC = 4
- class trame_slicer.segmentation.ScissorsPolygonBrush
Bases:
objectDisplay the scissors as 2D lines
- property points: vtkPoints
- class trame_slicer.segmentation.SegmentModifier(segmentation: Segmentation)
Bases:
objectHelper class to apply modifications to a given segment in the segmentation of a segmentation node. Should be used by segmentation widgets.
- property active_segment_id
- apply_glyph(poly: vtkPolyData, world_locations: vtkPoints) None
- Parameters:
poly – in world origin coordinates (no transform but world-coords sized)
world_locations – each location where glyph will be rendered at (world-coords)
- apply_labelmap(modifier_labelmap: vtkOrientedImageData, *, segment_id: str | None = None, modification_mode: ModificationMode | None = None, modifier_extent=None, is_per_segment: bool = True, do_bypass_masking: bool = False)
Modify active segment using input modifier labelmap in source IJK coordinates. When applying, pushes the modifications to the current undo stack if any is defined.
- apply_polydata_world(poly_world: vtkPolyData)
- Parameters:
poly_world – Poly in world coordinates
- get_segment_labelmap(segment_id, *, as_numpy_array=False) ndarray[tuple[Any, ...], dtype[_ScalarT]] | vtkImageData
- group_undo_commands(text: str = '') AbstractContextManager[None]
- property logic: vtkSlicerSegmentEditorLogic
- property modification_mode: ModificationMode
- on_segmentation_modified()
- paint_glyph_in_labelmap(polydata: vtkPolyData, world_locations: vtkPoints, labelmap: vtkOrientedImageData) list[float]
- property segmentation: Segmentation
- segmentation_modified
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- set_segment_labelmap(segment_id, label_map: vtkImageData | ndarray[tuple[Any, ...], dtype[_ScalarT]])
- trigger_active_segment_modified()
- property volume_node
- class trame_slicer.segmentation.SegmentProperties(color: 'list[float]', name: 'str', label_value: 'int', terminology_tag: 'str' = '')
Bases:
object- classmethod from_segment(segment: vtkSegment) SegmentProperties | None
- to_dict()
- to_segment(segment: vtkSegment)
- class trame_slicer.segmentation.Segmentation(segmentation_node: vtkMRMLSegmentationNode, volume_node, *, editor_logic: vtkSlicerSegmentEditorLogic = None, undo_stack: UndoStack = None)
Bases:
objectWrapper around vtkMRMLSegmentationNode for segmentation access.
- add_empty_segment(*, segment_id='', segment_name='', segment_color: list[float] | None = None, segment_value: int | None = None) str
- get_display() SegmentationDisplay | None
- get_merged_segment_labelmap(*, only_visible_segments: bool = False, as_numpy_array: bool = False) ndarray[tuple[Any, ...], dtype[_ScalarT]] | vtkImageData | None
- get_segment_labelmap(segment_id: str, *, as_numpy_array: bool = False) ndarray[tuple[Any, ...], dtype[_ScalarT]] | vtkOrientedImageData
Returns the labelmap corresponding to the input segment ID. Labelmap is guaranteed to have the same dimensions as the reference volume.
- get_segment_properties(segment_id) SegmentProperties | None
- get_segment_values()
- push_undo(cmd)
- segmentation_modified
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- set_active()
- set_segment_editor_logic(logic: vtkSlicerSegmentEditorLogic)
- set_segment_properties(segment_id, segment_properties: SegmentProperties)
- set_undo_stack(undo_stack)
- trigger_modified()
- class trame_slicer.segmentation.SegmentationDisplay(slicer_obj: T | None = None)
Bases:
SlicerWrapper[vtkMRMLSegmentationDisplayNode]Wrapper around the segmentation display node.
- get_opacity_mode() SegmentationOpacityEnum | None
- set_opacity_mode(opacity_mode: SegmentationOpacityEnum) None
- class trame_slicer.segmentation.SegmentationEditableAreaMode(*values)
Bases:
Enum- EVERYWHERE = 0
- INSIDE_SINGLE_SEGMENT = 5
- INSIDE_ALL_SEGMENTS = 1
- INSIDE_ALL_VISIBLE_SEGMENTS = 2
- OUTSIDE_ALL_SEGMENTS = 3
- OUTSIDE_ALL_VISIBLE_SEGMENTS = 4
- class trame_slicer.segmentation.SegmentationEffect
Bases:
ABC- create_pipeline(view_node: vtkMRMLAbstractViewNode, parameter: vtkMRMLNode) SegmentationEffectPipeline | None
- property editor: SegmentationEditor | None
- classmethod get_effect_name()
- get_parameter_node()
- property modifier: SegmentModifier | None
- parameters_changed
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- property pipelines: list[ref[SegmentationEffectPipeline]]
- set_active(is_active)
- set_editor(editor: SegmentationEditor) None
- set_mode(mode: ModificationMode)
- set_scene(scene: vtkMRMLScene)
- trigger_pipeline_parameter_change(*_)
- class trame_slicer.segmentation.SegmentationEffectDraw
Bases:
SegmentationEffectScissors
- class trame_slicer.segmentation.SegmentationEffectErase
Bases:
SegmentationEffectPaintErase
- class trame_slicer.segmentation.SegmentationEffectIslands
Bases:
SegmentationEffect- apply(island_mode: SegmentationIslandsMode | None = None) None
- get_island_labelmap(*, min_voxel_size: int = 0, segment_id: str | None = None) vtkOrientedImageData
- get_island_mode() SegmentationIslandsMode
- select_island_at_position(world_pos: tuple[float, float, float], island_mode: SegmentationIslandsMode | None = None) None
- set_island_mode(island_mode: SegmentationIslandsMode) None
- class trame_slicer.segmentation.SegmentationEffectLogicalOperators
Bases:
SegmentationEffect
- class trame_slicer.segmentation.SegmentationEffectNoTool
Bases:
SegmentationEffectEmpty implementation when no segmentation effect is selected.
- class trame_slicer.segmentation.SegmentationEffectPaint
Bases:
SegmentationEffectPaintErase
- class trame_slicer.segmentation.SegmentationEffectPaintErase(mode: ModificationMode)
Bases:
AbstractSegmentationEffectBrush- paint_glyph_at_world_coordinates(polydata: vtkPolyData, paint_coordinates_world: vtkPoints)
- class trame_slicer.segmentation.SegmentationEffectPipeline
Bases:
vtkMRMLLayerDMScriptedPipeline,Generic[T]- GetModifier() SegmentModifier | None
- GetSegmentation() Segmentation | None
- OnEffectParameterUpdate()
- OnUpdate(obj: vtkObject, _eventId: int, _callData: Any | None) None
Observer update callback. Triggered when any object & events observed using UpdateObserver is triggered.
- Parameters:
obj – vtkObject instance which triggered the callback
eventId – Event id which triggered the callback
callData – Optional observer call data. Use self.CastCallData(callData, vtkType) to convert to Python
- SetDisplayNode(displayNode: vtkMRMLNode) None
Set the display node for the pipeline has changed (initialization). default behavior: Stored and display node is observed for vtkCommand::ModifiedEvent. See also: self.UpdateObserver(prevObj, newObj, eventIds) See also: self.OnUpdate(obj, eventId, callData)
- Parameters:
displayNode – The new instance of display node for the pipeline
- SetSegmentationEffect(effect: T)
- SetView(view: AbstractViewChild)
- class trame_slicer.segmentation.SegmentationEffectScissors
Bases:
SegmentationEffect- apply_points_display_coordinates(points_display: vtkPoints, view: AbstractView) None
Apply scissors points as defined in display coordinates in the input view.
- property brush_interaction_mode: BrushInteractionMode
- set_brush_interaction_mode(mode: BrushInteractionMode)
- set_fill_mode(fill_mode: ScissorsEffectFillMode)
- set_range_mode(range_mode: ScissorsEffectRangeMode)
- class trame_slicer.segmentation.SegmentationEffectSmoothing
Bases:
AbstractSegmentationEffectBrush- apply_closing(kernel_size: float, segment_id: str, mask_labelmap: vtkOrientedImageData | None = None)
- apply_gaussian_smoothing(std: float, segment_id: str, mask_labelmap: vtkOrientedImageData | None = None)
- apply_median_smoothing(kernel_size: float, segment_id: str, mask_labelmap: vtkOrientedImageData | None = None)
- apply_opening(kernel_size: float, segment_id: str, mask_labelmap: vtkOrientedImageData | None = None)
- apply_smoothing(mask_labelmap: vtkOrientedImageData | None = None, smoothing_mode: SmoothingEffectMode | None = None)
- paint_glyph_at_world_coordinates(polydata: vtkPolyData, paint_coordinates_world: vtkPoints)
- set_smoothing_mode(mode: SmoothingEffectMode)
- class trame_slicer.segmentation.SegmentationEffectThreshold
Bases:
SegmentationEffect- apply()
- auto_threshold(auto_method: ~trame_slicer.segmentation.segmentation_effect_threshold.AutoThresholdMethod = AutoThresholdMethod.OTSU, mode: ~trame_slicer.segmentation.segmentation_effect_threshold.AutoThresholdMode = <AutoThresholdMode.LOWER_MAX: 10>)
Use auto threshold to set the threshold min / max values. Does nothing if the segmentation effect is not currently active.
- get_param_proxy() ThresholdParameters
- set_editor(editor: SegmentationEditor) None
- class trame_slicer.segmentation.SegmentationEffectVolumeIntensityMask
Bases:
SegmentationEffect- get_param_proxy() ThresholdParameters
- set_editor(editor: SegmentationEditor) None
- class trame_slicer.segmentation.SegmentationIslandsMode(*values)
Bases:
Enum- classmethod get_interactive_modes() list[SegmentationIslandsMode]
- KEEP_LARGEST_ISLAND = 1
- REMOVE_SMALL_ISLANDS = 2
- SPLIT_TO_SEGMENTS = 3
- KEEP_SELECTED = 4
- REMOVE_SELECTED = 5
- ADD_SELECTED = 6
- class trame_slicer.segmentation.SegmentationIslandsPipeline
Bases:
SegmentationEffectPipeline[SegmentationEffectIslands]- CanProcessInteractionEvent(eventData: vtkMRMLInteractionEventData) tuple[bool, float]
Should return true + distance2 to interaction if the pipeline can process the input event data. :param eventData: The MRML event needing to be processed :return: (bool, distance2) default = False, float_max
- IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
- ProcessInteractionEvent(event_data: vtkMRMLInteractionEventData) bool
Triggered when the pipeline can process the interaction and is at the top of the priority list. default behavior: does nothing and returns false.
- Parameters:
eventData – The MRML event needing to be processed
- Returns:
True if event was processed. False otherwise (default = false)
- class trame_slicer.segmentation.SegmentationOpacityEnum(*values)
Bases:
Flag- FILL = 1
- OUTLINE = 2
- BOTH = 3
- class trame_slicer.segmentation.SegmentationOverwriteMode(*values)
Bases:
Enum- OVERWRITE_ALL = 0
- OVERWRITE_ALL_VISIBLE_SEGMENTS = 1
- ALLOW_OVERLAP = 2
- class trame_slicer.segmentation.SegmentationPaintPipeline2D
Bases:
SegmentationPaintPipeline- CreateWidget()
- IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
- class trame_slicer.segmentation.SegmentationPaintPipeline3D
Bases:
SegmentationPaintPipeline- CreateWidget()
- HasLastPickPosition()
- IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
- Pick(event_data)
- class trame_slicer.segmentation.SegmentationPaintWidget(view: T)
-
- clear()
- get_brush_polydata_port() vtkAlgorithmOutput
- get_feedback_polydata_port()
- get_paint_glyph() vtkPolyData
- paint_interaction_stopped
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- update_paint_parameters(params: PaintEffectParameters)
- update_widget_position(position)
- class trame_slicer.segmentation.SegmentationPaintWidget2D(view: T)
Bases:
SegmentationPaintWidget[SliceView]
- class trame_slicer.segmentation.SegmentationPaintWidget3D(view: T)
Bases:
SegmentationPaintWidget[ThreeDView]
- class trame_slicer.segmentation.SegmentationScissorsPipeline
Bases:
SegmentationEffectPipeline[SegmentationEffectScissors]- CanProcessInteractionEvent(eventData: vtkMRMLInteractionEventData) tuple[bool, float]
Should return true + distance2 to interaction if the pipeline can process the input event data. :param eventData: The MRML event needing to be processed :return: (bool, distance2) default = False, float_max
- IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
- OnRendererAdded(renderer: vtkRenderer | None) None
Triggered when the pipeline is displayed on a new renderer. default behavior: does nothing. See also: self.GetRenderer() See also: self.ResetDisplay() See also: self.RequestRender()
- Parameters:
renderer – Optional instance or renderer on which the pipeline is added
- OnRendererRemoved(_renderer: vtkRenderer) None
Triggered when the pipeline is removed from its previous renderer. default behavior: does nothing. See also: self.GetRenderer()
- Parameters:
renderer – Optional instance or renderer from which the pipeline was removed
- Returns:
- ProcessInteractionEvent(event_data: vtkMRMLInteractionEventData) bool
Triggered when the pipeline can process the interaction and is at the top of the priority list. default behavior: does nothing and returns false.
- Parameters:
eventData – The MRML event needing to be processed
- Returns:
True if event was processed. False otherwise (default = false)
- SetDisplayNode(displayNode: vtkMRMLNode) None
Set the display node for the pipeline has changed (initialization). default behavior: Stored and display node is observed for vtkCommand::ModifiedEvent. See also: self.UpdateObserver(prevObj, newObj, eventIds) See also: self.OnUpdate(obj, eventId, callData)
- Parameters:
displayNode – The new instance of display node for the pipeline
- SetViewNode(viewNode: vtkMRMLAbstractViewNode) None
Set the pipeline view node (initialization). default behavior: Stored and view node is observed for vtkCommand::ModifiedEvent. :param viewNode: The instance of viewNode the pipeline is attached to
- property brush_interaction_mode: BrushInteractionMode
- class trame_slicer.segmentation.SegmentationScissorsWidget
Bases:
objectOn slice view project 2D points on slice (world pos) On 3D view project 2D points on focal plane (world pos)
- interaction_stopped
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- set_modifier(modifier: SegmentModifier)
- set_renderer(renderer)
- set_view_node(view_node)
- class trame_slicer.segmentation.SegmentationThresholdPipeline2D
Bases:
SegmentationEffectPipeline- OnEffectParameterUpdate()
- OnRendererAdded(renderer: vtkRenderer | None) None
Triggered when the pipeline is displayed on a new renderer. default behavior: does nothing. See also: self.GetRenderer() See also: self.ResetDisplay() See also: self.RequestRender()
- Parameters:
renderer – Optional instance or renderer on which the pipeline is added
- OnRendererRemoved(renderer: vtkRenderer) None
Triggered when the pipeline is removed from its previous renderer. default behavior: does nothing. See also: self.GetRenderer()
- Parameters:
renderer – Optional instance or renderer from which the pipeline was removed
- Returns:
- OnViewModified(*_)
- class trame_slicer.segmentation.ThresholdOpacityBlinker
Bases:
object- opacity_changed
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- start()
- stop()
- class trame_slicer.segmentation.ThresholdParameters(min_value: 'float' = 0, max_value: 'float' = 0, preview_opacity: 'float' = 0.5, is_visible: 'bool' = False, is_hatched: 'bool' = False)
Bases:
object
trame_slicer.segmentation.abstract_segmentation_effect_brush module
- class trame_slicer.segmentation.abstract_segmentation_effect_brush.AbstractSegmentationEffectBrush(mode: ModificationMode)
Bases:
SegmentationEffect,ABCAbstract class for segmentation effect implementing a brush behavior in views
- set_active(is_active)
- set_use_sphere_brush(use_sphere_brush)
- set_brush_diameter(diameter: float, diameter_mode: BrushDiameterMode | None = None)
- get_brush_diameter_mode() BrushDiameterMode
- abstractmethod paint_glyph_at_world_coordinates(polydata: vtkPolyData, paint_coordinates_world: vtkPoints)
trame_slicer.segmentation.brush_source module
- class trame_slicer.segmentation.brush_source.BrushSource(shape: BrushShape, diameter: float = 16.0, cylinder_height: float = 1.0)
Bases:
object- property brush_to_world_origin_transform: vtkTransform
- property world_origin_to_world_transform: vtkTransform
- set_shape(shape: BrushShape) None
- get_diameter()
- get_transformed_polydata_output_port() vtkAlgorithmOutput
Return the output port of transformed brush model
- get_untransformed_output_port() vtkAlgorithmOutput
Return the output port of untransformed brush model Useful for feedback actors
- set_brush_rotation(slice_to_ras: vtkMatrix4x4)
- set_brush_to_world_position(world_pos)
trame_slicer.segmentation.paint_effect_parameters module
- class trame_slicer.segmentation.paint_effect_parameters.BrushShape(*values)
Bases:
Enum- Sphere = 0
- Cylinder = 1
- class trame_slicer.segmentation.paint_effect_parameters.BrushDiameterMode(*values)
Bases:
Enum- Absolute = 1
- ScreenRelative = 2
- class trame_slicer.segmentation.paint_effect_parameters.PaintEffectParameters(brush_diameter: 'float' = 6.0, brush_diameter_mode: 'BrushDiameterMode' = <BrushDiameterMode.ScreenRelative: 2>, use_sphere_brush: 'bool' = False, brush_model_node: 'vtkMRMLModelNode | None' = None, paint_feedback_model_node: 'vtkMRMLModelNode | None' = None)
Bases:
object- brush_diameter_mode: BrushDiameterMode = 2
trame_slicer.segmentation.scissors_effect_parameters module
- class trame_slicer.segmentation.scissors_effect_parameters.BrushInteractionMode(*values)
Bases:
Enum- CONTINUOUS = 1
- POINT_BY_POINT = 2
trame_slicer.segmentation.segment_modifier module
- class trame_slicer.segmentation.segment_modifier.ModificationMode(*values)
Bases:
IntEnum- Set = 1
- Add = 2
- Remove = 3
- RemoveAll = 4
- class trame_slicer.segmentation.segment_modifier.SegmentModifier(segmentation: Segmentation)
Bases:
objectHelper class to apply modifications to a given segment in the segmentation of a segmentation node. Should be used by segmentation widgets.
- segmentation_modified
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- property logic: vtkSlicerSegmentEditorLogic
- property active_segment_id
- property modification_mode: ModificationMode
- property segmentation: Segmentation
- property volume_node
- paint_glyph_in_labelmap(polydata: vtkPolyData, world_locations: vtkPoints, labelmap: vtkOrientedImageData) list[float]
- apply_glyph(poly: vtkPolyData, world_locations: vtkPoints) None
- Parameters:
poly – in world origin coordinates (no transform but world-coords sized)
world_locations – each location where glyph will be rendered at (world-coords)
- apply_polydata_world(poly_world: vtkPolyData)
- Parameters:
poly_world – Poly in world coordinates
- apply_labelmap(modifier_labelmap: vtkOrientedImageData, *, segment_id: str | None = None, modification_mode: ModificationMode | None = None, modifier_extent=None, is_per_segment: bool = True, do_bypass_masking: bool = False)
Modify active segment using input modifier labelmap in source IJK coordinates. When applying, pushes the modifications to the current undo stack if any is defined.
- get_segment_labelmap(segment_id, *, as_numpy_array=False) ndarray[tuple[Any, ...], dtype[_ScalarT]] | vtkImageData
- set_segment_labelmap(segment_id, label_map: vtkImageData | ndarray[tuple[Any, ...], dtype[_ScalarT]])
- trigger_active_segment_modified()
- on_segmentation_modified()
- group_undo_commands(text: str = '') AbstractContextManager[None]
trame_slicer.segmentation.segment_properties module
trame_slicer.segmentation.segmentation module
- class trame_slicer.segmentation.segmentation.Segmentation(segmentation_node: vtkMRMLSegmentationNode, volume_node, *, editor_logic: vtkSlicerSegmentEditorLogic = None, undo_stack: UndoStack = None)
Bases:
objectWrapper around vtkMRMLSegmentationNode for segmentation access.
- segmentation_modified
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- set_active()
- set_undo_stack(undo_stack)
- set_segment_editor_logic(logic: vtkSlicerSegmentEditorLogic)
- add_empty_segment(*, segment_id='', segment_name='', segment_color: list[float] | None = None, segment_value: int | None = None) str
- get_merged_segment_labelmap(*, only_visible_segments: bool = False, as_numpy_array: bool = False) ndarray[tuple[Any, ...], dtype[_ScalarT]] | vtkImageData | None
- get_segment_values()
- get_segment_labelmap(segment_id: str, *, as_numpy_array: bool = False) ndarray[tuple[Any, ...], dtype[_ScalarT]] | vtkOrientedImageData
Returns the labelmap corresponding to the input segment ID. Labelmap is guaranteed to have the same dimensions as the reference volume.
- trigger_modified()
- get_segment_properties(segment_id) SegmentProperties | None
- set_segment_properties(segment_id, segment_properties: SegmentProperties)
- push_undo(cmd)
- get_display() SegmentationDisplay | None
trame_slicer.segmentation.segmentation_display module
- class trame_slicer.segmentation.segmentation_display.SegmentationOpacityEnum(*values)
Bases:
Flag- FILL = 1
- OUTLINE = 2
- BOTH = 3
- class trame_slicer.segmentation.segmentation_display.SegmentationDisplay(slicer_obj: T | None = None)
Bases:
SlicerWrapper[vtkMRMLSegmentationDisplayNode]Wrapper around the segmentation display node.
- get_opacity_mode() SegmentationOpacityEnum | None
- set_opacity_mode(opacity_mode: SegmentationOpacityEnum) None
trame_slicer.segmentation.segmentation_editable_area_mode module
trame_slicer.segmentation.segmentation_effect module
- class trame_slicer.segmentation.segmentation_effect.SegmentationEffect
Bases:
ABC- parameters_changed
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- property editor: SegmentationEditor | None
- set_editor(editor: SegmentationEditor) None
- property modifier: SegmentModifier | None
- property pipelines: list[ref[SegmentationEffectPipeline]]
- set_scene(scene: vtkMRMLScene)
- set_mode(mode: ModificationMode)
- classmethod get_effect_name()
- get_parameter_node()
- set_active(is_active)
- create_pipeline(view_node: vtkMRMLAbstractViewNode, parameter: vtkMRMLNode) SegmentationEffectPipeline | None
- trigger_pipeline_parameter_change(*_)
trame_slicer.segmentation.segmentation_effect_draw module
- class trame_slicer.segmentation.segmentation_effect_draw.SegmentationEffectDraw
Bases:
SegmentationEffectScissors
trame_slicer.segmentation.segmentation_effect_islands module
- class trame_slicer.segmentation.segmentation_effect_islands.SegmentationIslandsMode(*values)
Bases:
Enum- KEEP_LARGEST_ISLAND = 1
- REMOVE_SMALL_ISLANDS = 2
- SPLIT_TO_SEGMENTS = 3
- KEEP_SELECTED = 4
- REMOVE_SELECTED = 5
- ADD_SELECTED = 6
- classmethod get_interactive_modes() list[SegmentationIslandsMode]
- class trame_slicer.segmentation.segmentation_effect_islands.SegmentationEffectIslands
Bases:
SegmentationEffect- set_island_mode(island_mode: SegmentationIslandsMode) None
- get_island_mode() SegmentationIslandsMode
- apply(island_mode: SegmentationIslandsMode | None = None) None
trame_slicer.segmentation.segmentation_effect_logical_operators module
- class trame_slicer.segmentation.segmentation_effect_logical_operators.SegmentationEffectLogicalOperators
Bases:
SegmentationEffect
trame_slicer.segmentation.segmentation_effect_no_tool module
- class trame_slicer.segmentation.segmentation_effect_no_tool.SegmentationEffectNoTool
Bases:
SegmentationEffectEmpty implementation when no segmentation effect is selected.
trame_slicer.segmentation.segmentation_effect_paint_erase module
- class trame_slicer.segmentation.segmentation_effect_paint_erase.SegmentationEffectPaintErase(mode: ModificationMode)
Bases:
AbstractSegmentationEffectBrush- paint_glyph_at_world_coordinates(polydata: vtkPolyData, paint_coordinates_world: vtkPoints)
- class trame_slicer.segmentation.segmentation_effect_paint_erase.SegmentationEffectPaint
Bases:
SegmentationEffectPaintErase
- class trame_slicer.segmentation.segmentation_effect_paint_erase.SegmentationEffectErase
Bases:
SegmentationEffectPaintErase
trame_slicer.segmentation.segmentation_effect_pipeline module
- class trame_slicer.segmentation.segmentation_effect_pipeline.SegmentationEffectPipeline
Bases:
vtkMRMLLayerDMScriptedPipeline,Generic[T]- GetModifier() SegmentModifier | None
- GetSegmentation() Segmentation | None
- SetSegmentationEffect(effect: T)
- SetDisplayNode(displayNode: vtkMRMLNode) None
Set the display node for the pipeline has changed (initialization). default behavior: Stored and display node is observed for vtkCommand::ModifiedEvent. See also: self.UpdateObserver(prevObj, newObj, eventIds) See also: self.OnUpdate(obj, eventId, callData)
- Parameters:
displayNode – The new instance of display node for the pipeline
- SetView(view: AbstractViewChild)
- OnUpdate(obj: vtkObject, _eventId: int, _callData: Any | None) None
Observer update callback. Triggered when any object & events observed using UpdateObserver is triggered.
- Parameters:
obj – vtkObject instance which triggered the callback
eventId – Event id which triggered the callback
callData – Optional observer call data. Use self.CastCallData(callData, vtkType) to convert to Python
- OnEffectParameterUpdate()
trame_slicer.segmentation.segmentation_effect_scissors module
- class trame_slicer.segmentation.segmentation_effect_scissors.SegmentationEffectScissors
Bases:
SegmentationEffect- property brush_interaction_mode: BrushInteractionMode
- set_brush_interaction_mode(mode: BrushInteractionMode)
- set_fill_mode(fill_mode: ScissorsEffectFillMode)
- set_range_mode(range_mode: ScissorsEffectRangeMode)
- apply_points_display_coordinates(points_display: vtkPoints, view: AbstractView) None
Apply scissors points as defined in display coordinates in the input view.
trame_slicer.segmentation.segmentation_effect_scissors_widget module
- class trame_slicer.segmentation.segmentation_effect_scissors_widget.ScissorsPolygonBrush
Bases:
objectDisplay the scissors as 2D lines
- property points: vtkPoints
- class trame_slicer.segmentation.segmentation_effect_scissors_widget.SegmentationScissorsWidget
Bases:
objectOn slice view project 2D points on slice (world pos) On 3D view project 2D points on focal plane (world pos)
- interaction_stopped
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- set_view_node(view_node)
- set_modifier(modifier: SegmentModifier)
- set_renderer(renderer)
- class trame_slicer.segmentation.segmentation_effect_scissors_widget.SegmentationScissorsPipeline
Bases:
SegmentationEffectPipeline[SegmentationEffectScissors]- property brush_interaction_mode: BrushInteractionMode
- OnRendererAdded(renderer: vtkRenderer | None) None
Triggered when the pipeline is displayed on a new renderer. default behavior: does nothing. See also: self.GetRenderer() See also: self.ResetDisplay() See also: self.RequestRender()
- Parameters:
renderer – Optional instance or renderer on which the pipeline is added
- OnRendererRemoved(_renderer: vtkRenderer) None
Triggered when the pipeline is removed from its previous renderer. default behavior: does nothing. See also: self.GetRenderer()
- Parameters:
renderer – Optional instance or renderer from which the pipeline was removed
- Returns:
- SetViewNode(viewNode: vtkMRMLAbstractViewNode) None
Set the pipeline view node (initialization). default behavior: Stored and view node is observed for vtkCommand::ModifiedEvent. :param viewNode: The instance of viewNode the pipeline is attached to
- SetDisplayNode(displayNode: vtkMRMLNode) None
Set the display node for the pipeline has changed (initialization). default behavior: Stored and display node is observed for vtkCommand::ModifiedEvent. See also: self.UpdateObserver(prevObj, newObj, eventIds) See also: self.OnUpdate(obj, eventId, callData)
- Parameters:
displayNode – The new instance of display node for the pipeline
- CanProcessInteractionEvent(eventData: vtkMRMLInteractionEventData) tuple[bool, float]
Should return true + distance2 to interaction if the pipeline can process the input event data. :param eventData: The MRML event needing to be processed :return: (bool, distance2) default = False, float_max
- ProcessInteractionEvent(event_data: vtkMRMLInteractionEventData) bool
Triggered when the pipeline can process the interaction and is at the top of the priority list. default behavior: does nothing and returns false.
- Parameters:
eventData – The MRML event needing to be processed
- Returns:
True if event was processed. False otherwise (default = false)
- IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
trame_slicer.segmentation.segmentation_effect_smoothing module
- class trame_slicer.segmentation.segmentation_effect_smoothing.SmoothingEffectMode(*values)
Bases:
Enum- MEDIAN = 1
- OPENING = 2
- CLOSING = 3
- GAUSSIAN = 4
- JOINT = 5
- class trame_slicer.segmentation.segmentation_effect_smoothing.SegmentationEffectSmoothing
Bases:
AbstractSegmentationEffectBrush- set_smoothing_mode(mode: SmoothingEffectMode)
- apply_median_smoothing(kernel_size: float, segment_id: str, mask_labelmap: vtkOrientedImageData | None = None)
- apply_opening(kernel_size: float, segment_id: str, mask_labelmap: vtkOrientedImageData | None = None)
- apply_closing(kernel_size: float, segment_id: str, mask_labelmap: vtkOrientedImageData | None = None)
- apply_gaussian_smoothing(std: float, segment_id: str, mask_labelmap: vtkOrientedImageData | None = None)
- apply_smoothing(mask_labelmap: vtkOrientedImageData | None = None, smoothing_mode: SmoothingEffectMode | None = None)
- paint_glyph_at_world_coordinates(polydata: vtkPolyData, paint_coordinates_world: vtkPoints)
trame_slicer.segmentation.segmentation_effect_threshold module
- class trame_slicer.segmentation.segmentation_effect_threshold.AutoThresholdMethod(*values)
Bases:
Enum- HUANG = 1
- INTERMODES = 2
- ISO_DATA = 3
- KITTLER_ILLINGWORTH = 4
- LI = 5
- MAXIMUM_ENTROPY = 6
- MOMENTS = 7
- OTSU = 8
- RENYI_ENTROPY = 9
- SHANBHAG = 10
- TRIANGLE = 11
- YEN = 12
- class trame_slicer.segmentation.segmentation_effect_threshold.AutoThresholdMode(*values)
Bases:
IntFlag- UPPER = 1
- LOWER = 2
- MIN = 4
- MAX = 8
- MIN_UPPER = 5
- LOWER_MAX = 10
- class trame_slicer.segmentation.segmentation_effect_threshold.SegmentationEffectThreshold
Bases:
SegmentationEffect- set_editor(editor: SegmentationEditor) None
- apply()
- auto_threshold(auto_method: ~trame_slicer.segmentation.segmentation_effect_threshold.AutoThresholdMethod = AutoThresholdMethod.OTSU, mode: ~trame_slicer.segmentation.segmentation_effect_threshold.AutoThresholdMode = <AutoThresholdMode.LOWER_MAX: 10>)
Use auto threshold to set the threshold min / max values. Does nothing if the segmentation effect is not currently active.
- get_param_proxy() ThresholdParameters
trame_slicer.segmentation.segmentation_effect_volume_intensity_mask module
- class trame_slicer.segmentation.segmentation_effect_volume_intensity_mask.SegmentationEffectVolumeIntensityMask
Bases:
SegmentationEffect- set_editor(editor: SegmentationEditor) None
- get_param_proxy() ThresholdParameters
trame_slicer.segmentation.segmentation_islands_pipeline module
- class trame_slicer.segmentation.segmentation_islands_pipeline.SegmentationIslandsPipeline
Bases:
SegmentationEffectPipeline[SegmentationEffectIslands]- IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
- ProcessInteractionEvent(event_data: vtkMRMLInteractionEventData) bool
Triggered when the pipeline can process the interaction and is at the top of the priority list. default behavior: does nothing and returns false.
- Parameters:
eventData – The MRML event needing to be processed
- Returns:
True if event was processed. False otherwise (default = false)
trame_slicer.segmentation.segmentation_overwrite_mode module
trame_slicer.segmentation.segmentation_paint_pipeline module
- class trame_slicer.segmentation.segmentation_paint_pipeline.SegmentationPaintPipeline
Bases:
SegmentationEffectPipeline- OnEffectParameterUpdate()
- CreateWidget()
- OnPaintInteractionStopped()
- IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
- ProcessInteractionEvent(event_data: vtkMRMLInteractionEventData) bool
Triggered when the pipeline can process the interaction and is at the top of the priority list. default behavior: does nothing and returns false.
- Parameters:
eventData – The MRML event needing to be processed
- Returns:
True if event was processed. False otherwise (default = false)
- CanProcessInteractionEvent(eventData: vtkMRMLInteractionEventData) tuple[bool, float]
Should return true + distance2 to interaction if the pipeline can process the input event data. :param eventData: The MRML event needing to be processed :return: (bool, distance2) default = False, float_max
- LoseFocus(eventData: vtkMRMLInteractionEventData | None) None
Triggered when the pipeline had focus (processed an interaction) and loses the focus (other pipeline handled the new interaction or window leave event). default behavior: does nothing. :param eventData: Optional event data which triggered the lose focus
- class trame_slicer.segmentation.segmentation_paint_pipeline.SegmentationPaintPipeline2D
Bases:
SegmentationPaintPipeline- IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
- CreateWidget()
trame_slicer.segmentation.segmentation_paint_widget module
- class trame_slicer.segmentation.segmentation_paint_widget.SegmentationPaintWidget(view: T)
-
- paint_interaction_stopped
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- clear()
- get_brush_polydata_port() vtkAlgorithmOutput
- get_feedback_polydata_port()
- update_widget_position(position)
- get_paint_glyph() vtkPolyData
- update_paint_parameters(params: PaintEffectParameters)
- class trame_slicer.segmentation.segmentation_paint_widget.SegmentationPaintWidget2D(view: T)
Bases:
SegmentationPaintWidget[SliceView]
- class trame_slicer.segmentation.segmentation_paint_widget.SegmentationPaintWidget3D(view: T)
Bases:
SegmentationPaintWidget[ThreeDView]
trame_slicer.segmentation.segmentation_state_stack module
- class trame_slicer.segmentation.segmentation_state_stack.SegmentationStateStack(segmentation: vtkSegmentation, max_size: int)
Bases:
objectSimple segmentation stack. Deep copies input segmentation when saving state. Not optimized by any means.
- has_next()
- has_previous()
- restore_next()
Restore next saved state if stack has following states.
- restore_previous()
Restore previous state if stack has previous states.
trame_slicer.segmentation.segmentation_threshold_pipeline module
- class trame_slicer.segmentation.segmentation_threshold_pipeline.ThresholdParameters(min_value: 'float' = 0, max_value: 'float' = 0, preview_opacity: 'float' = 0.5, is_visible: 'bool' = False, is_hatched: 'bool' = False)
Bases:
object
- class trame_slicer.segmentation.segmentation_threshold_pipeline.SegmentationThresholdPipeline2D
Bases:
SegmentationEffectPipeline- OnRendererAdded(renderer: vtkRenderer | None) None
Triggered when the pipeline is displayed on a new renderer. default behavior: does nothing. See also: self.GetRenderer() See also: self.ResetDisplay() See also: self.RequestRender()
- Parameters:
renderer – Optional instance or renderer on which the pipeline is added
- OnRendererRemoved(renderer: vtkRenderer) None
Triggered when the pipeline is removed from its previous renderer. default behavior: does nothing. See also: self.GetRenderer()
- Parameters:
renderer – Optional instance or renderer from which the pipeline was removed
- Returns:
- OnEffectParameterUpdate()
- OnViewModified(*_)
trame_slicer.segmentation.segmentation_undo_command module
- class trame_slicer.segmentation.segmentation_undo_command.SegmentationRemoveUndoCommand(segmentation: Segmentation, segment_id)
Bases:
UndoCommand
- class trame_slicer.segmentation.segmentation_undo_command.SegmentationAddUndoCommand(segmentation: Segmentation, segment_id, segment_name, segment_color, segment_value)
Bases:
UndoCommand
- class trame_slicer.segmentation.segmentation_undo_command.SegmentPropertyChangeUndoCommand(segmentation: Segmentation, segment_id: str, segment_properties: SegmentProperties)
Bases:
UndoCommandUndo / Redo command for segment property changes. Property changes can be compressed if they apply to the same segment.
- class trame_slicer.segmentation.segmentation_undo_command.SegmentationLabelMapUndoCommand(segmentation_stack: SegmentationStateStack, segmentation: Segmentation)
Bases:
UndoCommand- classmethod push_state_change(segmentation: Segmentation)
trame_slicer.segmentation.threshold_opacity_blinker module
- class trame_slicer.segmentation.threshold_opacity_blinker.ThresholdOpacityBlinker
Bases:
object- opacity_changed
Signal implementation. Can be connected to one or more callables. When called, will call associated callables with the provided args and kwargs.
Provides utility methods and contextmanager to control signal execution. Can be used both as class property and instance.
- Parameters:
type_info – Types of arguments expected by the signal.
- start()
- stop()