core
- class trame_slicer.core.DisplayManager(view_manager: ViewManager, volume_rendering: VolumeRendering)
Bases:
objectHelper class to display volume nodes in given view group
- show_volume(volume_node: vtkMRMLVolumeNode, view_group: int | None = None, vr_preset: str = '', do_reset_views: bool = False) None
- class trame_slicer.core.IOManager(scene: vtkMRMLScene, app_logic: vtkMRMLApplicationLogic, segmentation_editor: SegmentationEditor)
Bases:
objectClass responsible for loading files in the scene.
- load_model(model_file: str | Path, do_convert_to_slicer_coord: bool = True) vtkMRMLModelNode | None
- load_segmentation(segmentation_file: str | Path, do_convert_to_slicer_coord=True) vtkMRMLSegmentationNode | None
- classmethod write_model(model_node, model_file: str | Path, do_convert_from_slicer_coord: bool = True) None
- class trame_slicer.core.LayoutManager(scene: vtkMRMLScene, view_manager: ViewManager, server: Server, *, virtual_node: VirtualNode | None = None, is_virtual_node_initialized: bool = False)
Bases:
object- Class responsible for instantiating views depending on the layout node.
Creates a singleton layout node at initialization.
Observes layout node changes to notify observers of layout id changes.
Can register layouts with their associated descriptions
Notifies view manager of requested view on layout change
- current_layout_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.
- initialize_layout_grid(layout: AbstractLayout)
Initialize the LayoutGrid placeholder in the layout at the call position.
- register_layout(layout_id: str, layout: Layout, lazy_initialization: bool = False) None
Registers the given layout id to the associated layout. Will overwrite any pre existing layout with this ID. If lazy_initialization is False, the views will not be instantiated unless the passed layout id matches the current selected layout id.
- register_layout_dict(layout_dict: dict[str, Layout], lazy_initialization: bool = False) None
- Parameters:
layout_dict – Layout dictionary to register to the layout manager
lazy_initialization – If True, the layout views will not be created until explicitly requested by set_layout or create_layout_views_if_needed
- registered_layouts_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.
- class trame_slicer.core.SegmentationEditor(scene: vtkMRMLScene, logic: vtkSlicerSegmentationsModuleLogic, view_manager: ViewManager, *, builtin_effects: list[type[SegmentationEffect]] | None = None)
Bases:
SignalContainerClass responsible for editing the segmentation. Meant to be used by the application to activate / deactivate segmentation effects.
- property active_effect: SegmentationEffect | None
- active_effect_name_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.
- active_segment_id_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 active_segment_modifier: SegmentModifier | None
- property active_segmentation: Segmentation | None
- property active_segmentation_display: SegmentationDisplay | None
- property active_segmentation_node
- add_empty_segment(*, segment_id='', segment_name='', segment_color: list[float] | None = None, segment_value: int | None = None) str
- builtin_effects: ClassVar[list[type[SegmentationEffect]]] = [<class 'trame_slicer.segmentation.segmentation_effect_draw.SegmentationEffectDraw'>, <class 'trame_slicer.segmentation.segmentation_effect_paint_erase.SegmentationEffectErase'>, <class 'trame_slicer.segmentation.segmentation_effect_islands.SegmentationEffectIslands'>, <class 'trame_slicer.segmentation.segmentation_effect_logical_operators.SegmentationEffectLogicalOperators'>, <class 'trame_slicer.segmentation.segmentation_effect_no_tool.SegmentationEffectNoTool'>, <class 'trame_slicer.segmentation.segmentation_effect_paint_erase.SegmentationEffectPaint'>, <class 'trame_slicer.segmentation.segmentation_effect_scissors.SegmentationEffectScissors'>, <class 'trame_slicer.segmentation.segmentation_effect_smoothing.SegmentationEffectSmoothing'>, <class 'trame_slicer.segmentation.segmentation_effect_threshold.SegmentationEffectThreshold'>, <class 'trame_slicer.segmentation.segmentation_effect_volume_intensity_mask.SegmentationEffectVolumeIntensityMask'>]
- clear()
- create_empty_segmentation_node() vtkMRMLSegmentationNode
- create_segmentation_node_from_labelmap(labelmap_node: vtkMRMLLabelMapVolumeNode) vtkMRMLSegmentationNode
- create_segmentation_node_from_model_node(model_node: vtkMRMLModelNode) vtkMRMLSegmentationNode
- deactivate_effect()
- property editor_logic: vtkSlicerSegmentEditorLogic
- property editor_node: vtkMRMLSegmentEditorNode
- editor_node_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.
- export_segmentation_to_labelmap(segmentation_node: vtkMRMLSegmentationNode, labelmap: vtkMRMLLabelMapVolumeNode = None) vtkMRMLLabelMapVolumeNode
- export_segmentation_to_models(segmentation_node: vtkMRMLSegmentationNode, folder_item_id: int) None
- export_segmentation_to_stl(segmentation_node: vtkMRMLSegmentationNode, out_folder: str, segment_ids: list[str] | None = None) None
- get_all_segment_properties() dict[str, SegmentProperties]
- get_editable_area() SegmentationEditableAreaMode
- get_effect_parameter_node(effect: SegmentationEffect | type[SegmentationEffect]) vtkMRMLScriptedModuleNode
returns segmentation effect parameter node as used by this segment editor. When passing effect types as inputs, this method will ensure the effect has been registered. If the parameter node doesn’t exist in the current scene, the parameter node will be added automatically.
- get_overwrite_mode() SegmentationOverwriteMode
- get_segment_labelmap(segment_id: str, *, as_numpy_array: bool = False) vtkImageData | ndarray[tuple[Any, ...], dtype[_ScalarT]] | None
- get_segment_properties(segment_id)
- is_3d_shown()
- is_effect_type_registered(effect_type: type[SegmentationEffect]) bool
- parameter_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.
- register_effect_type(effect_type: type[SegmentationEffect]) None
Registers the input segment editor effect type for the segmentation editor.
- remove_segment(segment_id)
- segmentation_display_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.
- 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_effect(effect: SegmentationEffect | None) SegmentationEffect | None
- set_active_effect_name(effect_id: str) SegmentationEffect | None
- set_active_effect_type(effect_type: type[SegmentationEffect]) SegmentationEffect | None
- set_active_segment_id(segment_id)
- set_active_segmentation(segmentation_node: vtkMRMLSegmentationNode, volume_node: vtkMRMLVolumeNode) Segmentation
- set_editable_area(editable_area: SegmentationEditableAreaMode) None
- set_overwrite_mode(overwrite_mode: SegmentationOverwriteMode) None
- set_segment_properties(segment_id, segment_properties: SegmentProperties)
- set_undo_stack(undo_stack: UndoStack)
- show_3d_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.
- trigger_all_signals()
- class trame_slicer.core.SlicerApp(share_directory: str | None = None)
Bases:
objectContainer for the core components of a Slicer application. Instantiates the scene, application logic and layout manager. Configures the default nodes present in the scene.
- register_module_logic(logic: vtkSlicerModuleLogic, *, logic_name: str = '', share_sub_folder: str = '')
Configure the input module logic with the application scene, logic and share directory. Registers the logic to the application logic with the given input logic name if any, module name otherwise.
- Parameters:
logic – instance of logic to register
logic_name – name of the logic in the application logic
share_sub_folder – sub folder of the share directory (if no sub folder, common share directory is used)
- Returns:
instance of logic
- class trame_slicer.core.ViewManager(scene: vtkMRMLScene, application_logic: vtkMRMLApplicationLogic)
Bases:
objectClass responsible for creating views given view descriptions and factories. Create views with the first factory available which can create view spec. Provides access to created views but doesn’t hold strong ownership of the views.
- create_view(view: ViewLayoutDefinition) AbstractViewChild | None
Uses the best registered factory to create the view with given id / type. Overwrites view stored if it exists. Returns created view.
- filter_visible_views(views: list[AbstractViewChild]) list[AbstractViewChild]
Filter input view list by ones currently displayed in the layout.
- get_threed_views(view_group: int | None = None) list[ThreeDView]
- get_view(view_id: str | vtkMRMLAbstractViewNode) AbstractViewChild | None
Get view associated with input view ID.
- get_views(view_group: int | None = None) list[AbstractView]
Return all Slicer views matching view group in the view manager.
- register_factory(view_factory: IViewFactory) None
Allows to register a factory for given view type.
- class trame_slicer.core.VolumeRendering(slicer_app: SlicerApp)
Bases:
SlicerWrapper[vtkSlicerVolumeRenderingLogic]Simple facade for volume rendering logic.
- static apply_vr_node_property(display: vtkMRMLVolumeRenderingDisplayNode, property_node: vtkMRMLVolumePropertyNode)
- create_display_node(volume_node: vtkMRMLVolumeNode, preset_name: str = '') vtkMRMLVolumeRenderingDisplayNode
- property crop_logic: vtkSlicerCropVolumeLogic
- get_cropping_roi_node(volume_node: vtkMRMLVolumeNode | None) vtkMRMLMarkupsROINode | None
Returns the ROI node instance attached to the input volume node’s VR display node if any.
- get_cropping_roi_visiblity(volume_node: vtkMRMLVolumeNode | None) bool
Returns the input volume node’s VR crop ROI node’s visibility. If the input volume node doesn’t have a ROI node, returns False.
- get_preset_property(preset_name) VolumeProperty
- get_volume_node_property(volume_node: vtkMRMLVolumeNode) VolumeProperty
- set_absolute_vr_shift_from_preset(volume_node: ~slicer_core.MRMLCore.vtkMRMLVolumeNode, preset_name: str | None, shift: float, shift_mode: ~trame_slicer.core.volume_property.VRShiftMode = <VRShiftMode.BOTH: 3>) None
Shift the volume rendering opacity and colors by a given value. The shift is a scalar value representing how much the preset should be moved compared to a preset default.
Which
- See also:
- ref:
set_relative_vr_shift
- set_cropping_enabled(volume_node: vtkMRMLVolumeNode, roi_node: vtkMRMLMarkupsROINode | None, is_enabled: bool) vtkMRMLMarkupsROINode | None
Enable or disable the VR cropping for the input volume node. If the volume node doesn’t have a cropping ROI node and is_enabled is True, a new ROI node will be initialized and encompass the full volume node.
The ROI Node attached to the display node will be returned.
- set_cropping_roi_node_visibile(volume_node: vtkMRMLVolumeNode | None, is_visible: bool) bool
Sets the inputs volume node’s VR cropping ROI visible. If the input volume node doesn’t have a cropping node, does nothgin.
:return visibility state of the ROI node
- set_relative_vr_shift(volume_node: ~slicer_core.MRMLCore.vtkMRMLVolumeNode, shift: float, shift_mode: ~trame_slicer.core.volume_property.VRShiftMode = <VRShiftMode.BOTH: 3>) None
Shift the volume rendering opacity and colors by a given value for the current scalar/opacity values.
- See also:
- ref:
set_absolute_vr_shift_from_preset
- set_volume_node_property(volume_node: vtkMRMLVolumeNode, property_node: vtkMRMLVolumePropertyNode)
- set_vr_opacity(volume_node: vtkMRMLVolumeNode, opacity: float, gradient_threshold_hu: float = 0)
Update volume node gradient opacity function applied on RBG value. Copied from: https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-volume-rendering-making-soft-tissues-transparent
Updates the Volume property node gradient opacity with 0 opacity below a given HU value and the updated slider position opacity value above.
By default, the gradient threshold is set to around water HU value https://www.sciencedirect.com/topics/medicine-and-dentistry/hounsfield-scale
- Parameters:
volume_node – volume node on which the VR opacity will be applied
opacity – Opacity value between [0, 1]. 1 = fully opaque, 0 = fully transparent.
gradient_threshold_hu – Cut off for opacity gradient.
- class trame_slicer.core.VolumeWindowLevel
Bases:
objectCollection of helper functions to update a volume’s window / level
- classmethod get_volume_display_node(volume_node: vtkMRMLVolumeNode) vtkMRMLVolumeDisplayNode
- classmethod set_volume_node_display_min_max_range(volume_node: vtkMRMLVolumeNode, min_value: float, max_value: float) None
- class trame_slicer.core.VolumesReader
Bases:
objectAdapted from Modules/Scripted/DICOMPlugins/DICOMScalarVolumePlugin.py
- dcm_read_lru_cache_size = 5000
- classmethod load_single_dcm_volume(scene: vtkMRMLScene, volume_files: list[str]) vtkMRMLVolumeNode | None
- classmethod load_single_file_volume(scene: vtkMRMLScene, app_logic: vtkMRMLApplicationLogic, volume_file: str) vtkMRMLVolumeNode | None
- classmethod load_volumes(scene: vtkMRMLScene, app_logic: vtkMRMLApplicationLogic, volume_files: list[str] | str) list[vtkMRMLVolumeNode]
- classmethod tag_value_to_vector(value)
trame_slicer.core.display_manager module
- class trame_slicer.core.display_manager.DisplayManager(view_manager: ViewManager, volume_rendering: VolumeRendering)
Bases:
objectHelper class to display volume nodes in given view group
- show_volume(volume_node: vtkMRMLVolumeNode, view_group: int | None = None, vr_preset: str = '', do_reset_views: bool = False) None
- show_volume_in_slice_background(volume_node: vtkMRMLVolumeNode | None, view_group: int | None = None)
trame_slicer.core.io_manager module
- class trame_slicer.core.io_manager.IOManager(scene: vtkMRMLScene, app_logic: vtkMRMLApplicationLogic, segmentation_editor: SegmentationEditor)
Bases:
objectClass responsible for loading files in the scene.
- load_model(model_file: str | Path, do_convert_to_slicer_coord: bool = True) vtkMRMLModelNode | None
- classmethod write_model(model_node, model_file: str | Path, do_convert_from_slicer_coord: bool = True) None
- load_segmentation(segmentation_file: str | Path, do_convert_to_slicer_coord=True) vtkMRMLSegmentationNode | None
trame_slicer.core.layout_manager module
- class trame_slicer.core.layout_manager.LayoutManager(scene: vtkMRMLScene, view_manager: ViewManager, server: Server, *, virtual_node: VirtualNode | None = None, is_virtual_node_initialized: bool = False)
Bases:
object- Class responsible for instantiating views depending on the layout node.
Creates a singleton layout node at initialization.
Observes layout node changes to notify observers of layout id changes.
Can register layouts with their associated descriptions
Notifies view manager of requested view on layout change
- registered_layouts_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.
- current_layout_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.
- register_layout(layout_id: str, layout: Layout, lazy_initialization: bool = False) None
Registers the given layout id to the associated layout. Will overwrite any pre existing layout with this ID. If lazy_initialization is False, the views will not be instantiated unless the passed layout id matches the current selected layout id.
- register_layout_dict(layout_dict: dict[str, Layout], lazy_initialization: bool = False) None
- Parameters:
layout_dict – Layout dictionary to register to the layout manager
lazy_initialization – If True, the layout views will not be created until explicitly requested by set_layout or create_layout_views_if_needed
- initialize_layout_grid(layout: AbstractLayout)
Initialize the LayoutGrid placeholder in the layout at the call position.
trame_slicer.core.markups_logic module
- class trame_slicer.core.markups_logic.MarkupsLogic(slicer_app: SlicerApp)
Bases:
SlicerWrapper[vtkSlicerMarkupsLogic]Thin wrapper around vtkSlicerMarkupsLogic
- disable_place_mode()
trame_slicer.core.segmentation_editor module
- class trame_slicer.core.segmentation_editor.SegmentationEditor(scene: vtkMRMLScene, logic: vtkSlicerSegmentationsModuleLogic, view_manager: ViewManager, *, builtin_effects: list[type[SegmentationEffect]] | None = None)
Bases:
SignalContainerClass responsible for editing the segmentation. Meant to be used by the application to activate / deactivate segmentation effects.
- builtin_effects: ClassVar[list[type[SegmentationEffect]]] = [<class 'trame_slicer.segmentation.segmentation_effect_draw.SegmentationEffectDraw'>, <class 'trame_slicer.segmentation.segmentation_effect_paint_erase.SegmentationEffectErase'>, <class 'trame_slicer.segmentation.segmentation_effect_islands.SegmentationEffectIslands'>, <class 'trame_slicer.segmentation.segmentation_effect_logical_operators.SegmentationEffectLogicalOperators'>, <class 'trame_slicer.segmentation.segmentation_effect_no_tool.SegmentationEffectNoTool'>, <class 'trame_slicer.segmentation.segmentation_effect_paint_erase.SegmentationEffectPaint'>, <class 'trame_slicer.segmentation.segmentation_effect_scissors.SegmentationEffectScissors'>, <class 'trame_slicer.segmentation.segmentation_effect_smoothing.SegmentationEffectSmoothing'>, <class 'trame_slicer.segmentation.segmentation_effect_threshold.SegmentationEffectThreshold'>, <class 'trame_slicer.segmentation.segmentation_effect_volume_intensity_mask.SegmentationEffectVolumeIntensityMask'>]
- 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.
- segmentation_display_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.
- active_segment_id_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.
- active_effect_name_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.
- show_3d_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.
- parameter_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.
- editor_node_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
- property editor_node: vtkMRMLSegmentEditorNode
- is_effect_type_registered(effect_type: type[SegmentationEffect]) bool
- register_effect_type(effect_type: type[SegmentationEffect]) None
Registers the input segment editor effect type for the segmentation editor.
- set_undo_stack(undo_stack: UndoStack)
- property active_segmentation: Segmentation | None
- property active_segmentation_display: SegmentationDisplay | None
- property active_segmentation_node
- property active_segment_modifier: SegmentModifier | None
- property active_effect: SegmentationEffect | None
- set_active_segmentation(segmentation_node: vtkMRMLSegmentationNode, volume_node: vtkMRMLVolumeNode) Segmentation
- create_segmentation_node_from_model_node(model_node: vtkMRMLModelNode) vtkMRMLSegmentationNode
- create_segmentation_node_from_labelmap(labelmap_node: vtkMRMLLabelMapVolumeNode) vtkMRMLSegmentationNode
- create_empty_segmentation_node() vtkMRMLSegmentationNode
- set_active_effect_type(effect_type: type[SegmentationEffect]) SegmentationEffect | None
- set_active_effect_name(effect_id: str) SegmentationEffect | None
- set_active_effect(effect: SegmentationEffect | None) SegmentationEffect | None
- deactivate_effect()
- get_all_segment_properties() dict[str, SegmentProperties]
- get_segment_properties(segment_id)
- set_segment_properties(segment_id, segment_properties: SegmentProperties)
- add_empty_segment(*, segment_id='', segment_name='', segment_color: list[float] | None = None, segment_value: int | None = None) str
- remove_segment(segment_id)
- set_active_segment_id(segment_id)
- get_segment_labelmap(segment_id: str, *, as_numpy_array: bool = False) vtkImageData | ndarray[tuple[Any, ...], dtype[_ScalarT]] | None
- export_segmentation_to_labelmap(segmentation_node: vtkMRMLSegmentationNode, labelmap: vtkMRMLLabelMapVolumeNode = None) vtkMRMLLabelMapVolumeNode
- export_segmentation_to_models(segmentation_node: vtkMRMLSegmentationNode, folder_item_id: int) None
- export_segmentation_to_stl(segmentation_node: vtkMRMLSegmentationNode, out_folder: str, segment_ids: list[str] | None = None) None
- is_3d_shown()
- trigger_all_signals()
- set_editable_area(editable_area: SegmentationEditableAreaMode) None
- get_editable_area() SegmentationEditableAreaMode
- set_overwrite_mode(overwrite_mode: SegmentationOverwriteMode) None
- get_overwrite_mode() SegmentationOverwriteMode
- get_effect_parameter_node(effect: SegmentationEffect | type[SegmentationEffect]) vtkMRMLScriptedModuleNode
returns segmentation effect parameter node as used by this segment editor. When passing effect types as inputs, this method will ensure the effect has been registered. If the parameter node doesn’t exist in the current scene, the parameter node will be added automatically.
- clear()
trame_slicer.core.slicer_app module
- class trame_slicer.core.slicer_app.SlicerApp(share_directory: str | None = None)
Bases:
objectContainer for the core components of a Slicer application. Instantiates the scene, application logic and layout manager. Configures the default nodes present in the scene.
- register_module_logic(logic: vtkSlicerModuleLogic, *, logic_name: str = '', share_sub_folder: str = '')
Configure the input module logic with the application scene, logic and share directory. Registers the logic to the application logic with the given input logic name if any, module name otherwise.
- Parameters:
logic – instance of logic to register
logic_name – name of the logic in the application logic
share_sub_folder – sub folder of the share directory (if no sub folder, common share directory is used)
- Returns:
instance of logic
trame_slicer.core.view_manager module
- class trame_slicer.core.view_manager.ViewManager(scene: vtkMRMLScene, application_logic: vtkMRMLApplicationLogic)
Bases:
objectClass responsible for creating views given view descriptions and factories. Create views with the first factory available which can create view spec. Provides access to created views but doesn’t hold strong ownership of the views.
- set_current_view_ids(view_ids: list[str]) None
Set which views are currently displayed in the application. To be used by layout manager or equivalent classes.
- register_factory(view_factory: IViewFactory) None
Allows to register a factory for given view type.
- get_view(view_id: str | vtkMRMLAbstractViewNode) AbstractViewChild | None
Get view associated with input view ID.
- create_view(view: ViewLayoutDefinition) AbstractViewChild | None
Uses the best registered factory to create the view with given id / type. Overwrites view stored if it exists. Returns created view.
- get_views(view_group: int | None = None) list[AbstractView]
Return all Slicer views matching view group in the view manager.
- get_threed_views(view_group: int | None = None) list[ThreeDView]
trame_slicer.core.volume_property module
- class trame_slicer.core.volume_property.VRShiftMode(*values)
Bases:
Flag- OPACITY = 1
- COLOR = 2
- BOTH = 3
- class trame_slicer.core.volume_property.VolumeProperty(volume_property_node: vtkMRMLVolumePropertyNode | None)
Bases:
SlicerWrapper[vtkMRMLVolumePropertyNode]Thin facade for volume property node. Allows more pythonic access to the scalar / opacity properties of a volume rendering display node.
- property volume_property: vtkVolumeProperty
- property property_node: vtkMRMLVolumePropertyNode
- property opacity_map: vtkPiecewiseFunction
- property color_map: vtkColorTransferFunction
- static shift_values(values, shift)
- set_vr_shift(shift: float, shift_mode: VRShiftMode, ref_prop: VolumeProperty | None = None)
trame_slicer.core.volume_rendering module
- class trame_slicer.core.volume_rendering.VolumeRendering(slicer_app: SlicerApp)
Bases:
SlicerWrapper[vtkSlicerVolumeRenderingLogic]Simple facade for volume rendering logic.
- property crop_logic: vtkSlicerCropVolumeLogic
- create_display_node(volume_node: vtkMRMLVolumeNode, preset_name: str = '') vtkMRMLVolumeRenderingDisplayNode
- set_volume_node_property(volume_node: vtkMRMLVolumeNode, property_node: vtkMRMLVolumePropertyNode)
- static apply_vr_node_property(display: vtkMRMLVolumeRenderingDisplayNode, property_node: vtkMRMLVolumePropertyNode)
- get_preset_property(preset_name) VolumeProperty
- set_absolute_vr_shift_from_preset(volume_node: ~slicer_core.MRMLCore.vtkMRMLVolumeNode, preset_name: str | None, shift: float, shift_mode: ~trame_slicer.core.volume_property.VRShiftMode = <VRShiftMode.BOTH: 3>) None
Shift the volume rendering opacity and colors by a given value. The shift is a scalar value representing how much the preset should be moved compared to a preset default.
Which
- See also:
- ref:
set_relative_vr_shift
- set_relative_vr_shift(volume_node: ~slicer_core.MRMLCore.vtkMRMLVolumeNode, shift: float, shift_mode: ~trame_slicer.core.volume_property.VRShiftMode = <VRShiftMode.BOTH: 3>) None
Shift the volume rendering opacity and colors by a given value for the current scalar/opacity values.
- See also:
- ref:
set_absolute_vr_shift_from_preset
- get_volume_node_property(volume_node: vtkMRMLVolumeNode) VolumeProperty
- set_cropping_enabled(volume_node: vtkMRMLVolumeNode, roi_node: vtkMRMLMarkupsROINode | None, is_enabled: bool) vtkMRMLMarkupsROINode | None
Enable or disable the VR cropping for the input volume node. If the volume node doesn’t have a cropping ROI node and is_enabled is True, a new ROI node will be initialized and encompass the full volume node.
The ROI Node attached to the display node will be returned.
- get_cropping_roi_node(volume_node: vtkMRMLVolumeNode | None) vtkMRMLMarkupsROINode | None
Returns the ROI node instance attached to the input volume node’s VR display node if any.
- get_cropping_roi_visiblity(volume_node: vtkMRMLVolumeNode | None) bool
Returns the input volume node’s VR crop ROI node’s visibility. If the input volume node doesn’t have a ROI node, returns False.
- set_cropping_roi_node_visibile(volume_node: vtkMRMLVolumeNode | None, is_visible: bool) bool
Sets the inputs volume node’s VR cropping ROI visible. If the input volume node doesn’t have a cropping node, does nothgin.
:return visibility state of the ROI node
- toggle_cropping_visibility(volume_node: vtkMRMLVolumeNode | None) bool
Toggle input volume node cropping visibility. Toggling the visibility will activate and initialize the cropping ROI Node if needed.
- Returns:
New visibility state of the Cropping ROI Node
- set_vr_opacity(volume_node: vtkMRMLVolumeNode, opacity: float, gradient_threshold_hu: float = 0)
Update volume node gradient opacity function applied on RBG value. Copied from: https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-volume-rendering-making-soft-tissues-transparent
Updates the Volume property node gradient opacity with 0 opacity below a given HU value and the updated slider position opacity value above.
By default, the gradient threshold is set to around water HU value https://www.sciencedirect.com/topics/medicine-and-dentistry/hounsfield-scale
- Parameters:
volume_node – volume node on which the VR opacity will be applied
opacity – Opacity value between [0, 1]. 1 = fully opaque, 0 = fully transparent.
gradient_threshold_hu – Cut off for opacity gradient.
trame_slicer.core.volume_window_level module
- class trame_slicer.core.volume_window_level.VolumeWindowLevel
Bases:
objectCollection of helper functions to update a volume’s window / level
- classmethod set_volume_node_window_level(volume_node: vtkMRMLVolumeNode, window: float, level: float) None
- classmethod set_volume_node_display_min_max_range(volume_node: vtkMRMLVolumeNode, min_value: float, max_value: float) None
- classmethod get_volume_display_node(volume_node: vtkMRMLVolumeNode) vtkMRMLVolumeDisplayNode
trame_slicer.core.volumes_reader module
- class trame_slicer.core.volumes_reader.VolumesReader
Bases:
objectAdapted from Modules/Scripted/DICOMPlugins/DICOMScalarVolumePlugin.py
- dcm_read_lru_cache_size = 5000
- classmethod load_volumes(scene: vtkMRMLScene, app_logic: vtkMRMLApplicationLogic, volume_files: list[str] | str) list[vtkMRMLVolumeNode]
- classmethod load_single_file_volume(scene: vtkMRMLScene, app_logic: vtkMRMLApplicationLogic, volume_file: str) vtkMRMLVolumeNode | None
- classmethod tag_value_to_vector(value)