segmentation

class trame_slicer.segmentation.AbstractSegmentationEffectBrush(mode: ModificationMode)

Bases: SegmentationEffect, ABC

Abstract class for segmentation effect implementing a brush behavior in views

decrease_brush_size(decrease_ratio: float | None = None)
get_brush_diameter() float
get_brush_diameter_mode() BrushDiameterMode
increase_brush_size(increase_ratio: float | None = None)
is_sphere_brush() bool
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.BrushShape(*values)

Bases: Enum

Sphere = 0
Cylinder = 1
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_cylinder_height(cylinder_height: float)
set_diameter(diameter: float)
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: object

Display the scissors as 2D lines

add_point(x: int, y: int) None
get_props() list[vtkProp]
property points: vtkPoints
preview_point(x: int, y: int) None
remove_last_point() None
reset() None
set_visible(visible: bool)
class trame_slicer.segmentation.SegmentModifier(segmentation: Segmentation)

Bases: object

Helper 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

create_modifier_labelmap() vtkOrientedImageData | None
get_segment_labelmap(segment_id, *, as_numpy_array=False) ndarray[tuple[Any, ...], dtype[_ScalarT]] | vtkImageData
get_source_image_data() vtkOrientedImageData | None
get_source_volume_intensity_mask_range() tuple[float, float] | None
group_undo_commands(text: str = '') AbstractContextManager[None]
is_source_volume_intensity_mask_enabled() bool
property logic: vtkSlicerSegmentEditorLogic
property modification_mode: ModificationMode
on_segmentation_modified()
paint_glyph_in_labelmap(polydata: vtkPolyData, world_locations: vtkPoints, labelmap: vtkOrientedImageData) list[float]
property segment_editor_node: vtkMRMLSegmentEditorNode | None
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]])
set_source_volume_intensity_mask_enabled(is_enabled: bool) None
set_source_volume_intensity_mask_range(min_value: float, max_value: float) None
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

property color_hex: str
classmethod from_segment(segment: vtkSegment) SegmentProperties | None
terminology_tag: str = ''
to_dict()
to_segment(segment: vtkSegment)
color: list[float]
name: str
label_value: int
class trame_slicer.segmentation.Segmentation(segmentation_node: vtkMRMLSegmentationNode, volume_node, *, editor_logic: vtkSlicerSegmentEditorLogic = None, undo_stack: UndoStack = None)

Bases: object

Wrapper around vtkMRMLSegmentationNode for segmentation access.

add_empty_segment(*, segment_id='', segment_name='', segment_color: list[float] | None = None, segment_value: int | None = None) str
create_modifier_labelmap() vtkOrientedImageData | None
disable_surface_representation() None
property editor_logic: vtkSlicerSegmentEditorLogic | None
enable_surface_representation() None
property first_segment_id: 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_nth_segment(i_segment: int) vtkSegment | None
get_nth_segment_id(i_segment: int) str
get_segment(segment_id: str) vtkSegment | None
get_segment_colors() list[list[float]]
get_segment_ids() list[str]
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_names() list[str]
get_segment_properties(segment_id) SegmentProperties | None
get_segment_value(segment_id) int
get_segment_values()
get_visible_segment_ids() list[str]
group_undo_commands(text: str = '') Generator[None, Any, None]
is_surface_representation_enabled() bool
property n_segments: int
push_undo(cmd)
remove_segment(segment_id) None
property segmentation: vtkSegmentation | None
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 segmentation_node: vtkMRMLSegmentationNode | None
set_active()
set_segment_editor_logic(logic: vtkSlicerSegmentEditorLogic)
set_segment_properties(segment_id, segment_properties: SegmentProperties)
set_segment_value(segment_id, segment_value: int | None)
set_surface_representation_enabled(is_enabled: bool) None
set_undo_stack(undo_stack)
trigger_modified()
property undo_stack: UndoStack | None
property volume_node: vtkMRMLVolumeNode | None
class trame_slicer.segmentation.SegmentationDisplay(slicer_obj: T | None = None)

Bases: SlicerWrapper[vtkMRMLSegmentationDisplayNode]

Wrapper around the segmentation display node.

get_border_thickness() int | None
get_opacity_2d() float | None
get_opacity_mode() SegmentationOpacityEnum | None
set_border_thickness(thickness: float) None
set_opacity_2d(opacity: float) 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

activate() None
create_pipeline(view_node: vtkMRMLAbstractViewNode, parameter: vtkMRMLNode) SegmentationEffectPipeline | None
deactivate() None
property editor: SegmentationEditor | None
property editor_node: vtkMRMLSegmentEditorNode | None
classmethod get_effect_name()
get_parameter_node()
property is_active: bool
is_effect_parameter(parameter: vtkMRMLNode) bool
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

add_island_at_position(world_pos: tuple[float, float, float])
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
get_minimum_island_size() int
is_in_interactive_mode() bool
keep_island_at_position(world_pos: tuple[float, float, float])
keep_largest_island() None
keep_n_largest_islands(number_of_islands: int) None
remove_island_at_position(world_pos: tuple[float, float, float])
remove_small_islands(min_voxel_size: int | None = None) None
select_island_at_position(world_pos: tuple[float, float, float], island_mode: SegmentationIslandsMode | None = None) None
set_island_mode(island_mode: SegmentationIslandsMode) None
set_minimum_island_size(minimum_island_size: int) None
split_islands_to_segments() None
class trame_slicer.segmentation.SegmentationEffectLogicalOperators

Bases: SegmentationEffect

add(segment_id: str | None) None
clear() None
copy(segment_id: str | None) None
fill() None
intersect(segment_id: str | None) None
invert() None
subtract(segment_id: str | None) None
class trame_slicer.segmentation.SegmentationEffectNoTool

Bases: SegmentationEffect

Empty 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]

GetEffectParameterNode() vtkMRMLScriptedModuleNode | None
GetModifier() SegmentModifier | None
GetSegmentation() Segmentation | None
IsActive() bool
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

SetActive(isActive: bool)
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)
set_symmetric_distance(symmetric_distance: float)
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_joint_smoothing(smoothing_factor: float, 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_joint_smoothing_factor(joint_smoothing_factor: float)
set_kernel_size(kernel_size: float)
set_smoothing_mode(mode: SmoothingEffectMode)
set_standard_deviation(standard_deviation: float)
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
get_threshold_min_max_values() tuple[float, float]
set_active(is_active: bool)
set_editor(editor: SegmentationEditor) None
set_threshold_min_max_values(value: tuple[float, float])
use_for_volume_intensity_masking() None
class trame_slicer.segmentation.SegmentationEffectVolumeIntensityMask

Bases: SegmentationEffect

get_mask_range() tuple[float, float]
get_param_proxy() ThresholdParameters
is_mask_enabled() bool
property is_visible: bool
set_editor(editor: SegmentationEditor) None
set_mask_enabled(is_enabled: bool) None
set_mask_range(min_value: float, max_value: float) None
set_mask_visible(is_visible: bool) None
class trame_slicer.segmentation.SegmentationIslandsMode(*values)

Bases: Enum

classmethod get_interactive_modes() list[SegmentationIslandsMode]
is_interactive() bool
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)

Bases: Generic[T], ABC

clear()
get_brush_polydata_port() vtkAlgorithmOutput
get_feedback_polydata_port()
get_paint_glyph() vtkPolyData
is_painting() bool
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.

start_painting() None
stop_painting() None
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)

SetActive(isActive: bool)
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: object

On slice view project 2D points on slice (world pos) On 3D view project 2D points on focal plane (world pos)

add_point(x: int, y: int) None
cancel_painting() None
disable_brush() None
enable_brush() None
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.

is_brush_enabled() bool
is_painting() bool
preview_point(x: int, y: int) None
remove_last_point() None
set_active(is_active: bool) None
set_modifier(modifier: SegmentModifier)
set_renderer(renderer)
set_view_node(view_node)
start_painting(x: int, y: int) None
stop_painting() None
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(*_)
SetView(view: SliceView)
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.

set_active(is_active: bool) None
set_opacity_range(low: float, high: float)
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

is_hatched: bool = False
is_visible: bool = False
max_value: float = 0
min_value: float = 0
preview_opacity: float = 0.5

trame_slicer.segmentation.abstract_segmentation_effect_brush module

class trame_slicer.segmentation.abstract_segmentation_effect_brush.AbstractSegmentationEffectBrush(mode: ModificationMode)

Bases: SegmentationEffect, ABC

Abstract 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)
increase_brush_size(increase_ratio: float | None = None)
decrease_brush_size(decrease_ratio: float | None = None)
is_sphere_brush() bool
get_brush_diameter() float
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()
set_diameter(diameter: float)
set_cylinder_height(cylinder_height: float)
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: float = 6.0
brush_diameter_mode: BrushDiameterMode = 2
use_sphere_brush: bool = False
brush_model_node: vtkMRMLModelNode | None = None
paint_feedback_model_node: vtkMRMLModelNode | None = None

trame_slicer.segmentation.scissors_effect_parameters module

class trame_slicer.segmentation.scissors_effect_parameters.BrushInteractionMode(*values)

Bases: Enum

CONTINUOUS = 1
POINT_BY_POINT = 2
class trame_slicer.segmentation.scissors_effect_parameters.ScissorsEffectFillMode(*values)

Bases: Enum

ERASE_INSIDE = 1
ERASE_OUTSIDE = 2
FILL_INSIDE = 3
FILL_OUTSIDE = 4
class trame_slicer.segmentation.scissors_effect_parameters.ScissorsEffectRangeMode(*values)

Bases: Enum

UNLIMITED = 1
POSITIVE = 2
NEGATIVE = 3
SYMMETRIC = 4

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: object

Helper 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 segment_editor_node: vtkMRMLSegmentEditorNode | None
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()
get_source_image_data() vtkOrientedImageData | None
create_modifier_labelmap() vtkOrientedImageData | None
set_source_volume_intensity_mask_range(min_value: float, max_value: float) None
get_source_volume_intensity_mask_range() tuple[float, float] | None
set_source_volume_intensity_mask_enabled(is_enabled: bool) None
is_source_volume_intensity_mask_enabled() bool
group_undo_commands(text: str = '') AbstractContextManager[None]

trame_slicer.segmentation.segment_properties module

class trame_slicer.segmentation.segment_properties.SegmentProperties(color: 'list[float]', name: 'str', label_value: 'int', terminology_tag: 'str' = '')

Bases: object

color: list[float]
name: str
label_value: int
terminology_tag: str = ''
classmethod from_segment(segment: vtkSegment) SegmentProperties | None
to_segment(segment: vtkSegment)
property color_hex: str
to_dict()

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: object

Wrapper 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.

property editor_logic: vtkSlicerSegmentEditorLogic | None
set_active()
set_undo_stack(undo_stack)
set_segment_editor_logic(logic: vtkSlicerSegmentEditorLogic)
property undo_stack: UndoStack | None
property segmentation: vtkSegmentation | None
property volume_node: vtkMRMLVolumeNode | None
property segmentation_node: vtkMRMLSegmentationNode | None
get_segment_ids() list[str]
get_segment_names() list[str]
get_segment_colors() list[list[float]]
property n_segments: int
get_nth_segment(i_segment: int) vtkSegment | None
get_nth_segment_id(i_segment: int) str
get_segment(segment_id: str) vtkSegment | None
add_empty_segment(*, segment_id='', segment_name='', segment_color: list[float] | None = None, segment_value: int | None = None) str
remove_segment(segment_id) None
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.

set_surface_representation_enabled(is_enabled: bool) None
is_surface_representation_enabled() bool
enable_surface_representation() None
disable_surface_representation() None
get_visible_segment_ids() list[str]
get_segment_value(segment_id) int
set_segment_value(segment_id, segment_value: int | None)
property first_segment_id: str
create_modifier_labelmap() vtkOrientedImageData | None
trigger_modified()
get_segment_properties(segment_id) SegmentProperties | None
set_segment_properties(segment_id, segment_properties: SegmentProperties)
push_undo(cmd)
get_display() SegmentationDisplay | None
group_undo_commands(text: str = '') Generator[None, Any, 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_border_thickness() int | None
set_border_thickness(thickness: float) None
get_opacity_2d() float | None
set_opacity_2d(opacity: float) None
get_opacity_mode() SegmentationOpacityEnum | None
set_opacity_mode(opacity_mode: SegmentationOpacityEnum) None

trame_slicer.segmentation.segmentation_editable_area_mode module

class trame_slicer.segmentation.segmentation_editable_area_mode.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

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 editor_node: vtkMRMLSegmentEditorNode | None
property modifier: SegmentModifier | None
property pipelines: list[ref[SegmentationEffectPipeline]]
property is_active: bool
set_scene(scene: vtkMRMLScene)
set_mode(mode: ModificationMode)
classmethod get_effect_name()
get_parameter_node()
is_effect_parameter(parameter: vtkMRMLNode) bool
activate() None
deactivate() None
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]
is_interactive() bool
class trame_slicer.segmentation.segmentation_effect_islands.SegmentationEffectIslands

Bases: SegmentationEffect

is_in_interactive_mode() bool
set_island_mode(island_mode: SegmentationIslandsMode) None
get_island_mode() SegmentationIslandsMode
set_minimum_island_size(minimum_island_size: int) None
get_minimum_island_size() int
apply(island_mode: SegmentationIslandsMode | None = None) None
select_island_at_position(world_pos: tuple[float, float, float], island_mode: SegmentationIslandsMode | None = None) None
remove_island_at_position(world_pos: tuple[float, float, float])
keep_island_at_position(world_pos: tuple[float, float, float])
add_island_at_position(world_pos: tuple[float, float, float])
remove_small_islands(min_voxel_size: int | None = None) None
keep_n_largest_islands(number_of_islands: int) None
keep_largest_island() None
split_islands_to_segments() None
get_island_labelmap(*, min_voxel_size: int = 0, segment_id: str | None = None) vtkOrientedImageData

trame_slicer.segmentation.segmentation_effect_logical_operators module

class trame_slicer.segmentation.segmentation_effect_logical_operators.SegmentationEffectLogicalOperators

Bases: SegmentationEffect

add(segment_id: str | None) None
subtract(segment_id: str | None) None
copy(segment_id: str | None) None
intersect(segment_id: str | None) None
invert() None
clear() None
fill() None

trame_slicer.segmentation.segmentation_effect_no_tool module

class trame_slicer.segmentation.segmentation_effect_no_tool.SegmentationEffectNoTool

Bases: SegmentationEffect

Empty 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
IsActive() bool
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)
SetActive(isActive: bool)
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()
GetEffectParameterNode() vtkMRMLScriptedModuleNode | None

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_symmetric_distance(symmetric_distance: float)
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: object

Display the scissors as 2D lines

set_visible(visible: bool)
preview_point(x: int, y: int) None
add_point(x: int, y: int) None
remove_last_point() None
reset() None
property points: vtkPoints
get_props() list[vtkProp]
class trame_slicer.segmentation.segmentation_effect_scissors_widget.SegmentationScissorsWidget

Bases: object

On 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)
preview_point(x: int, y: int) None
add_point(x: int, y: int) None
set_active(is_active: bool) None
enable_brush() None
disable_brush() None
is_brush_enabled() bool
start_painting(x: int, y: int) None
stop_painting() None
cancel_painting() None
remove_last_point() None
is_painting() bool
class trame_slicer.segmentation.segmentation_effect_scissors_widget.SegmentationScissorsPipeline

Bases: SegmentationEffectPipeline[SegmentationEffectScissors]

property brush_interaction_mode: BrushInteractionMode
SetActive(isActive: bool)
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)
set_kernel_size(kernel_size: float)
set_standard_deviation(standard_deviation: float)
set_joint_smoothing_factor(joint_smoothing_factor: float)
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_joint_smoothing(smoothing_factor: float, 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
set_active(is_active: bool)
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
get_threshold_min_max_values() tuple[float, float]
set_threshold_min_max_values(value: tuple[float, float])
use_for_volume_intensity_masking() None

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
set_mask_visible(is_visible: bool) None
set_mask_enabled(is_enabled: bool) None
set_mask_range(min_value: float, max_value: float) None
get_mask_range() tuple[float, float]
is_mask_enabled() bool
get_param_proxy() ThresholdParameters
property is_visible: bool

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)

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

trame_slicer.segmentation.segmentation_overwrite_mode module

class trame_slicer.segmentation.segmentation_overwrite_mode.SegmentationOverwriteMode(*values)

Bases: Enum

OVERWRITE_ALL = 0
OVERWRITE_ALL_VISIBLE_SEGMENTS = 1
ALLOW_OVERLAP = 2

trame_slicer.segmentation.segmentation_paint_pipeline module

class trame_slicer.segmentation.segmentation_paint_pipeline.SegmentationPaintPipeline

Bases: SegmentationEffectPipeline

OnEffectParameterUpdate()
CreateWidget()
SetActive(isActive: bool)
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

GetWidgetState() int

Current widget state of the pipeline. :return: default = WidgetStateIdle

class trame_slicer.segmentation.segmentation_paint_pipeline.SegmentationPaintPipeline2D

Bases: SegmentationPaintPipeline

IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
CreateWidget()
class trame_slicer.segmentation.segmentation_paint_pipeline.SegmentationPaintPipeline3D

Bases: SegmentationPaintPipeline

Pick(event_data)
HasLastPickPosition()
IsSupportedEvent(event_data: vtkMRMLInteractionEventData)
CreateWidget()

trame_slicer.segmentation.segmentation_paint_widget module

class trame_slicer.segmentation.segmentation_paint_widget.SegmentationPaintWidget(view: T)

Bases: Generic[T], ABC

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()
start_painting() None
stop_painting() None
is_painting() bool
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: object

Simple segmentation stack. Deep copies input segmentation when saving state. Not optimized by any means.

save_state() None
clear() None
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.

remove_next_states() None

Pops all next states.

set_max_size(max_size: int) None
get_max_size() int

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

min_value: float = 0
max_value: float = 0
preview_opacity: float = 0.5
is_visible: bool = False
is_hatched: bool = False
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()
SetView(view: SliceView)
OnViewModified(*_)

trame_slicer.segmentation.segmentation_undo_command module

class trame_slicer.segmentation.segmentation_undo_command.SegmentationRemoveUndoCommand(segmentation: Segmentation, segment_id)

Bases: UndoCommand

undo() None
redo() None
class trame_slicer.segmentation.segmentation_undo_command.SegmentationAddUndoCommand(segmentation: Segmentation, segment_id, segment_name, segment_color, segment_value)

Bases: UndoCommand

undo() None
redo() None
merge_with(command: UndoCommand) bool

Try to merge current command with provided input command. If merge is successful, only one undo action will be kept in the stack.

do_try_merge(command: UndoCommand) bool
class trame_slicer.segmentation.segmentation_undo_command.SegmentPropertyChangeUndoCommand(segmentation: Segmentation, segment_id: str, segment_properties: SegmentProperties)

Bases: UndoCommand

Undo / Redo command for segment property changes. Property changes can be compressed if they apply to the same segment.

is_obsolete() bool
undo() None
redo() None
merge_with(command: UndoCommand) bool

Try to merge current command with provided input command. If merge is successful, only one undo action will be kept in the stack.

class trame_slicer.segmentation.segmentation_undo_command.SegmentationLabelMapUndoCommand(segmentation_stack: SegmentationStateStack, segmentation: Segmentation)

Bases: UndoCommand

undo() None
redo() None
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.

set_active(is_active: bool) None
set_opacity_range(low: float, high: float)
start()
stop()