SequenceRecorder
Sequence-based workflow recording using Slicer Sequences.
Records full segmentation workflows for step-by-step playback review: - Segmentation state at each brush stroke - Slice positions (Red/Yellow/Green) - 3D camera position - Effect parameter node - Text notes for reviewer annotations
Integrates with existing ActionRecorder infrastructure to provide visual state capture alongside stroke data.
See ADR-016 for architecture context.
Classes
- class SequenceRecorder
Record full segmentation workflow using Slicer Sequences.
This class captures visual state (how the segmentation looks) at each step, complementing ActionRecorder which captures action data (what happened).
- Usage:
recorder = SequenceRecorder()
# Start recording with a segmentation node recorder.start_recording(segmentation_node, reference_volume)
# Record a step after each brush stroke recorder.record_step(“Geodesic at (128, 100, 45)”)
# Add standalone notes recorder.add_note(“Reviewer noted boundary uncertainty”)
# Navigate to a specific step recorder.goto_step(5)
# Clean up recorder.cleanup()
- Attributes:
step_count: Number of recorded steps. is_recording: True if currently recording.
Methods:
- __init__()
Initialize the sequence recorder.
- step_count()
Return number of recorded steps.
- is_recording()
Return True if currently recording.
- start_recording()
Initialize sequences for recording.
- record_step()
Record current state as a new step.
- add_note()
Add a text note at the current step.
- goto_step()
Navigate to a specific step in the recording.
- get_note_at_step()
Get the note text at a specific step.
- stop_recording()
Stop recording but keep sequences for playback.
- cleanup()
Clean up all sequences and browser node.
- get_browser_node()
Get the sequence browser node for direct manipulation.
- get_sequence()
Get a specific sequence by name.
- class ViewGroupManager
Manage Slicer View Groups for synchronized slice navigation.
Provides native Slicer view linking using ViewGroups and LinkedControl, replacing manual slice synchronization.
- Usage:
manager = ViewGroupManager()
# Enable linked navigation manager.enable_linking()
# Views now sync automatically
# Disable if needed manager.disable_linking()
# Clean up observers on module close manager.cleanup()
Methods:
- __init__()
Initialize the view group manager.
- is_linked()
Return True if view linking is enabled.
- enable_linking()
Enable linked control for all slice views.
- disable_linking()
Disable linked control for all slice views.
- set_linked()
Set the linked state.
- setup_slice_observer()
Set up observer on a slice node for bidirectional sync.
- get_slice_offset()
Get the current slice offset for a view.
- get_slice_range()
Get the slice offset range for a view.
- set_slice_offset()
Set the slice offset for a view.
- cleanup()
Remove all observers.
- class SceneViewBookmarks
Manage Scene View bookmarks for interesting slices.
Scene Views capture complete visualization state: - All slice positions - 3D camera position - Node visibility - Display properties - Window/level
- Usage:
bookmarks = SceneViewBookmarks()
# Create a bookmark idx = bookmarks.add_bookmark(“Interesting boundary at slice 45”)
# List bookmarks for name, desc in bookmarks.list_bookmarks():
print(f”{name}: {desc}”)
# Restore a bookmark bookmarks.restore_bookmark(0)
# Clean up bookmarks.cleanup()
Methods:
- __init__()
Initialize the bookmarks manager.
- count()
Return number of bookmarks.
- add_bookmark()
Save current view as a Scene View bookmark.
- restore_bookmark()
Restore a saved Scene View bookmark.
- list_bookmarks()
List all bookmarks.
- get_bookmark_name()
Get the name of a bookmark.
- remove_bookmark()
Remove a bookmark.
- clear_all()
Remove all bookmarks.
- cleanup()
Clean up all bookmarks.
Functions
- step_count()
Return number of recorded steps.
- is_recording()
Return True if currently recording.
- start_recording()
Initialize sequences for recording.
- Args:
segmentation_node: The segmentation node to record. reference_volume: Optional reference volume for geometry.
- Returns:
True if recording started successfully, False otherwise.
- record_step()
Record current state as a new step.
- Args:
action_description: Optional description of the action.
- Returns:
The step index recorded, or -1 if not recording.
- add_note()
Add a text note at the current step.
- Args:
text: The note text.
- goto_step()
Navigate to a specific step in the recording.
- Args:
step: The step index to navigate to.
- Returns:
True if navigation succeeded, False otherwise.
- get_note_at_step()
Get the note text at a specific step.
- Args:
step: The step index.
- Returns:
The note text, or None if no note at that step.
- stop_recording()
Stop recording but keep sequences for playback.
- cleanup()
Clean up all sequences and browser node.
- get_browser_node()
Get the sequence browser node for direct manipulation.
- Returns:
The vtkMRMLSequenceBrowserNode, or None if not recording.
- get_sequence()
Get a specific sequence by name.
- Args:
name: Sequence name (e.g., “segmentation”, “notes”, “slice_Red”).
- Returns:
The sequence node, or None if not found.
- is_linked()
Return True if view linking is enabled.
- enable_linking()
Enable linked control for all slice views.
This enables Slicer’s native view synchronization: - Slice offset (position) - Zoom/field of view - Pan - Orientation changes
- Args:
view_group: View group ID to use (default 0).
- disable_linking()
Disable linked control for all slice views.
- set_linked()
Set the linked state.
- Args:
linked: True to enable linking, False to disable.
- setup_slice_observer()
Set up observer on a slice node for bidirectional sync.
This allows the UI (e.g., slider) to update when the user navigates by other means (dragging in slice view).
- Args:
callback: Function to call when slice changes: (caller, event) -> None slice_name: Name of slice node to observe (default “Red”).
- Returns:
True if observer was set up, False otherwise.
- get_slice_offset()
Get the current slice offset for a view.
- Args:
slice_name: Name of the slice view.
- Returns:
The slice offset, or None if not available.
- get_slice_range()
Get the slice offset range for a view.
- Args:
slice_name: Name of the slice view.
- Returns:
Tuple of (min_offset, max_offset), or None if not available.
- set_slice_offset()
Set the slice offset for a view.
Note: If view linking is enabled, this will affect all linked views.
- Args:
offset: The slice offset value. slice_name: Name of the slice view to set.
- Returns:
True if set successfully, False otherwise.
- cleanup()
Remove all observers.
- count()
Return number of bookmarks.
- add_bookmark()
Save current view as a Scene View bookmark.
- Args:
description: Description of what’s interesting. name: Optional name for the bookmark.
- Returns:
Index of the created bookmark, or -1 on failure.
- restore_bookmark()
Restore a saved Scene View bookmark.
- Args:
index: Index of the bookmark to restore.
- Returns:
True if restored successfully, False otherwise.
- list_bookmarks()
List all bookmarks.
- Returns:
List of (name, description) tuples.
- get_bookmark_name()
Get the name of a bookmark.
- Args:
index: Bookmark index.
- Returns:
The bookmark name, or None if invalid.
- remove_bookmark()
Remove a bookmark.
- Args:
index: Index of the bookmark to remove.
- Returns:
True if removed successfully, False otherwise.
- clear_all()
Remove all bookmarks.
- cleanup()
Clean up all bookmarks.