radioviz.tools.profile_tool

Profile tool module for extracting intensity profiles from images.

This module provides functionality for creating, managing, and visualizing intensity profiles extracted from images. It includes tools for selecting line segments on images, computing intensity profiles along those lines, and displaying the results in dedicated windows.

The main components include:

  • ProfileData: Data structure for storing profile information

  • ProfileToolController: Controller managing the profile tool workflow

  • ProfileToolSession: Session handling the profile extraction process

  • ProfileSubWindow: Window for displaying profile plots

  • ProfileExtractionWorker: Background worker for profile computation

Workflow descriptions:

Profile Creation Process:

  1. User clicks “Add Profile” button in the dock widget

  2. ProfileToolController creates a new ProfileToolSession and activates it

  3. Session triggers “create_selection_dialog” event to show PointSelectionDialog

  4. User interacts with PointSelectionDialog to set parameters and draw line on image

  5. LineSelector in the image window captures the line geometry

  6. When the user accepts the profile selection (click on Done), session calls start_profile_computation(), which:

    • Creates a ProfileExtractionWorker in a separate QThread

    • Passes image data, line geometry, and parameters to worker

    • Worker computes profile using skimage.measure.profile_line in background

    • Worker emits finished signal with computed x/y values when done

  7. Session receives finished signal and finalizes profile:

    • Updates ProfileData with computed values and geometry

    • Adds overlay to image window

    • Creates ProfileSubWindow to display the profile plot

    • Stores profile in ProfileStore

Profile Selection Process:

  1. User selects a profile row in the dock’s table view

  2. ProfileToolDock emits profile_selection_changed signal

  3. ProfileToolController handles selection change:

    • Removes highlight from previously selected profile

    • Highlights newly selected profile on image

    • Activates the associated ProfileSubWindow if it exists

Profile Removal Process:

  1. User clicks “Delete Profile” button or uses menu action

  2. ProfileToolController.on_delete_profile_clicked() is called

  3. Controller removes profile from ProfileStore

  4. Controller removes overlay from image window

  5. Controller closes associated ProfileSubWindow if open

  6. Profile is completely removed from all systems

The tool integrates with the application’s overlay system to visualize profile lines on images and supports multiple interpolation methods and reduction functions for profile computation.

Functions

assume_complete_profile(profile)

Treat a profile data as complete (no None) without runtime checks.

draw_highlight_profile(overlay, axes)

Draw a highlighted profile overlay.

draw_label_overlay(overlay, axes)

Draw a label overlay for a profile on matplotlib axes.

draw_profile_arrow(overlay, axes)

Draw a profile arrow overlay.

extract_profile(data, geometry, session_id)

Extract intensity profile from image data along a specified line.

Classes

PointSelectionDialog([parent])

Dialog for selecting profile parameters and points.

ProfileData(name, color[, p1, p2, ...])

Data structure for storing profile information.

ProfileDataCompleteProtocol(*args, **kwargs)

Protocol describing a profile with fully populated numeric data.

ProfileDataWorkspaceSpec(id, name, ...)

Data structure for serializing profile data within workspace specifications.

ProfileSubWindow(controller[, parent])

Window for displaying profile plots.

ProfileTableModel(store[, parent])

Table model for displaying profile data in a table view.

ProfileTool()

Tool for extracting intensity profiles from images.

ProfileToolController(tool_ctx, tool)

Controller for managing the profile tool workflow.

ProfileToolDock(parent, controller)

Dock widget for the profile tool interface.

ProfileToolSession(tool_controller, ...[, ...])

Session for handling profile extraction process.

ProfileWindowController(source, profile_data)

Controller for the profile window.

class radioviz.tools.profile_tool.PointSelectionDialog(parent: QWidget | None = None)[source]

Bases: QDialog

Dialog for selecting profile parameters and points.

Initialize the point selection dialog.

Parameters:

parent (QWidget, optional) – Parent widget

on_parameters_changed() None[source]

Handle parameter changes in the dialog.

class radioviz.tools.profile_tool.ProfileData(name: str, color: Color, p1: tuple[float, float] | None = None, p2: tuple[float, float] | None = None, profile_controller: ProfileWindowController | None = None, image_controller: ImageWindowController | None = None, x_values: ndarray | None = None, y_values: ndarray | None = None, profile_width: int | None = 1, reduce_function: str | None = 'mean', interpolation_order: str | None = 'Bi-linear', session_id: UUID | None = None, profile_id: UUID | None = None, show_overlay: bool | None = True, show_label: bool | None = True, pixel_size_m: tuple[float, float] | None = None, display_properties: dict[str, Any] | None = None)[source]

Bases: object

Data structure for storing profile information.

Stores all relevant information about a profile including its geometric properties, visualization settings, and computed values.

Initialize a ProfileData instance.

Parameters:
  • name (str) – Name of the profile

  • color (Color) – Color of the profile line

  • p1 (tuple[float, float], optional) – Start point of the profile line (x, y)

  • p2 (tuple[float, float], optional) – End point of the profile line (x, y)

  • profile_controller (ProfileWindowController, optional) – Controller for the profile window

  • image_controller (ImageWindowController, optional) – Controller for the image window

  • x_values (np.ndarray, optional) – X coordinates of profile points

  • y_values (np.ndarray, optional) – Y coordinates (intensity values) of profile points

  • profile_width (int, optional) – Width of the profile extraction line

  • reduce_function (str, optional) – Function to reduce multiple pixel values

  • interpolation_order (str, optional) – Interpolation order for profile calculation

  • session_id (UUID, optional) – ID of the session that created this profile

  • profile_id (UUID, optional) – Unique identifier for this profile

  • pixel_size_m (tuple[float, float], optional) – Pixel size in meters (x, y) for calibration

  • display_properties (dict[str, Any], optional) – Display properties for the profile window

calculate_properties() None[source]

Calculate derived properties from profile data.

Computes length, minimum and maximum y values from the stored x and y arrays.

length_display() str[source]

Format the calibrated profile length for display.

Returns:

Formatted length string or ‘n/a’ if unavailable.

Return type:

str

length_m() float | None[source]

Compute the physical length of the profile in meters.

Returns:

Profile length in meters or None if calibration is missing.

Return type:

float | None

pixel_distance_m() float | None[source]

Compute the physical size per profile pixel along the profile direction.

Returns:

Meters per profile pixel or None if calibration is missing.

Return type:

float | None

set_profile_data(x_values: ndarray, y_values: ndarray) None[source]

Set the profile data arrays.

Parameters:
  • x_values (np.ndarray) – X coordinates of profile points

  • y_values (np.ndarray) – Y coordinates (intensity values) of profile points

to_workspace_spec(include_data: bool) ProfileDataWorkspaceSpec[source]

Convert this ProfileData instance to a workspace specification.

Creates a ProfileDataWorkspaceSpec instance containing all necessary information to serialize this profile for workspace persistence. If include_data is True, the actual profile data arrays (x_values and y_values) are included in the specification.

Parameters:

include_data (bool) – Whether to include profile data arrays in the spec

Returns:

Workspace specification for this profile

Return type:

ProfileDataWorkspaceSpec

Raises:

RuntimeError – If attempting to serialize incomplete profile data or if include_data is True but profile data is missing.

class radioviz.tools.profile_tool.ProfileDataCompleteProtocol(*args, **kwargs)[source]

Bases: Protocol

Protocol describing a profile with fully populated numeric data.

It contains only a subset of all the attributes and methods used by the ProfileWindowController.

This protocol is used to express the invariant that profile arrays are available after a session completes, without adding runtime checks.

length_display() str[source]

Format the calibrated profile length for display.

Returns:

Formatted length string or ‘n/a’ if unavailable.

Return type:

str

length_m() float | None[source]

Compute the physical length of the profile in meters.

Returns:

Profile length in meters or None if calibration is missing.

Return type:

float | None

pixel_distance_m() float | None[source]

Compute the physical size per profile pixel along the profile direction.

Returns:

Meters per profile pixel or None if calibration is missing.

Return type:

float | None

set_profile_data(x_values: ndarray, y_values: ndarray) None[source]

Set the profile data arrays.

Parameters:
  • x_values (numpy.ndarray) – X coordinates of profile points

  • y_values (numpy.ndarray) – Y coordinates (intensity values) of profile points

to_workspace_spec(include_data: bool) ProfileDataWorkspaceSpec[source]

Convert this ProfileData instance to a workspace specification.

Parameters:

include_data (bool) – Whether to include profile data arrays in the spec

Returns:

Workspace specification for this profile

Return type:

ProfileDataWorkspaceSpec

class radioviz.tools.profile_tool.ProfileDataWorkspaceSpec(id: ~uuid.UUID, name: str, image_controller_id: ~uuid.UUID | None = None, profile_controller_id: ~uuid.UUID | None = None, color: tuple[float, float, float] = <factory>, p1: tuple[float, float] = <factory>, p2: tuple[float, float] = <factory>, profile_width: int = 1, reduce_function: str = 'mean', interpolation_order: str = 'Bi-linear', show_overlay: bool = True, show_label: bool = True, x_values: ~numpy.ndarray | None = None, y_values: ~numpy.ndarray | None = None, pixel_size_m: tuple[float, float] | None = None, display_properties: dict[str, ~typing.Any] = <factory>)[source]

Bases: object

Data structure for serializing profile data within workspace specifications.

This class defines the structure used to store profile information in a workspace context, enabling persistence and restoration of profile configurations across application sessions. It contains all essential profile properties needed for serialization while maintaining compatibility with the ProfileData structure.

class radioviz.tools.profile_tool.ProfileSubWindow(controller: ProfileWindowController, parent: QWidget | None = None)[source]

Bases: CanvasWindow[ProfileWindowController, SimpleCanvas]

Window for displaying profile plots.

Initialize the profile sub-window.

Parameters:
_apply_axis_label_mode() None[source]

Apply axis label mode to the profile axes.

_on_context(pos: QPoint) None[source]

Handle context menu requests on the profile canvas.

Parameters:

pos (QPoint) – Position of the context menu request

_on_view_change(_axes: Axes) None[source]

Handle view change events on the profile axes.

Parameters:

_axes (matplotlib.axes.Axes) – The matplotlib axes that triggered the event

create_canvas() SimpleCanvas[source]

Create the profile plot canvas used by this window.

Returns:

A new SimpleCanvas instance configured for profiles.

Return type:

SimpleCanvas

export_to_path(path: Path) None[source]

Export the current image display to a file.

Saves the current figure displayed in the canvas to the specified path using matplotlib’s savefig functionality.

Parameters:

path (pathlib.Path) – The file path where the image should be saved

on_data_state_changed() None[source]

Update the window title when data state changes.

This method is called when the underlying data state changes, such as when the data is modified or saved. It updates the window title to reflect the current persistence status.

on_name_changed(new_name: str) None[source]

Handle a change of profile name

Parameters:

new_name (str) – The new profile name

plot_profile() None[source]

Plot the profile data on the canvas.

set_canvas_title() None[source]

Set the title of the canvas

set_window_title() None[source]

Set the window title based on controller name and dirty state.

Updates the window title to include an asterisk (*) suffix if the controller indicates that the data has been modified but not yet saved. The title is derived from the profile’s name property.

class radioviz.tools.profile_tool.ProfileTableModel(store: ItemStore[ProfileData], parent: QObject | None = None)[source]

Bases: ItemModel

Table model for displaying profile data in a table view.

Initialize the profile table model.

Parameters:
  • store (ItemStore[ProfileData]) – Store containing profile data

  • parent (QObject, optional) – Parent widget

data_for(profile: ProfileData, column: int, role: int = ItemDataRole.DisplayRole) Any[source]

Get data for a specific profile cell.

Parameters:
  • profile (ProfileData) – Profile data object

  • column (int) – Column index

  • role (Qt.ItemDataRole) – Item data role

Returns:

Data for the specified cell

Return type:

Any

flags(index: QModelIndex | QPersistentModelIndex, /) ItemFlag[source]

Return the item flags for the given index.

Parameters:

index (QModelIndex) – Index of the item

Returns:

Item flags for the specified index

Return type:

Qt.ItemFlag

set_data_for(profile: ProfileData, column: int, value: Any, role: int = ItemDataRole.DisplayRole) bool[source]

Set data for a specific profile cell.

Parameters:
  • profile (ProfileData) – Profile data object

  • column (int) – Column index

  • value (Any) – Value to set

  • role (Qt.ItemDataRole) – Item data role

Returns:

True if successful, False otherwise

Return type:

bool

class radioviz.tools.profile_tool.ProfileTool[source]

Bases: Tool[ProfileToolController]

Tool for extracting intensity profiles from images.

_increment_item_counter(item_count: int) None[source]

Increment the internal item counter.

Advances the profile counter by the specified number of items to maintain consistent naming for restored profiles.

Parameters:

item_count (int) – Number of items to increment the counter by

_on_profile_restore_completed() None[source]

Complete the profile restoration process.

Finalizes the workspace restoration by reordering the profile store, restoring the previously selected profile, and redrawing all profile labels to ensure proper visualization after restoration.

_redraw_all_labels() None[source]

Redraw all profile labels in their respective image windows.

Triggers a complete refresh of all profile label overlays across all image windows to ensure proper positioning and visibility after workspace restoration or other state changes.

_reorder_store() None[source]

Reorder the profile store according to workspace specification.

Restores the original ordering of profiles as specified in the workspace by reorganizing the profile store based on the saved order sequence.

Note

This method assumes that all profiles in the workspace specification exist in the current store and maintains the relative ordering.

_restore_completed() None[source]

Signal that the workspace restoration process has been completed.

Emits the restore_completed signal to notify observers that the profile tool restoration process is finished and all profiles have been properly restored from the workspace specification.

This method is called internally by the workspace restoration mechanism to indicate completion of the restoration sequence.

_restore_selected_item() None[source]

Restore the previously selected profile item.

Selects the profile that was active before workspace restoration by finding it in the store and emitting a selection change event to update the UI accordingly.

Note

This method handles both UUID and string representations of profile IDs and gracefully handles cases where the profile may no longer exist.

create_controller(ctx: ToolContext) ProfileToolController[source]

Create a controller for this tool.

Parameters:

ctx (ToolContext) – Tool context

Returns:

Profile tool controller

Return type:

ProfileToolController

from_workspace(spec: ToolWorkspace, context: WorkspaceReferenceManager) None[source]

Restore the tool state from a workspace specification.

Initializes the profile tool from a serialized ToolWorkspace specification, recreating all profile data and their associated controllers. Handles workspace reference resolution and manages asynchronous session creation for profile restoration.

Parameters:
Raises:

RuntimeError – If no controller is available for tool restoration

to_workspace(include_data: bool) ToolWorkspace[source]

Convert the current tool state to a workspace specification.

Serializes the profile tool’s current state including all profile data, their configuration, and the currently selected profile into a ToolWorkspace object. This allows for persistent storage and restoration of the tool’s state across application sessions.

Parameters:

include_data (bool) – Flag indicating whether to include profile data arrays

Returns:

Workspace specification containing the tool’s state

Return type:

ToolWorkspace

description: str = 'A tool to extract profiles from images'

Tooltip or description

name: str = 'Profile Tool'

Human-readable name

overlays_to_be_registered: list[OverlaySpec] = [OverlaySpec(overlay_type='profile_arrow', overlay_role=<OverlayRole.Permanent: 'permanent'>, renderer=<function draw_profile_arrow>), OverlaySpec(overlay_type='profile_arrow', overlay_role=<OverlayRole.Highlight: 'highlight'>, renderer=<function draw_highlight_profile>), OverlaySpec(overlay_type='profile_label', overlay_role=<OverlayRole.Label: 'label'>, renderer=<function draw_label_overlay>)]

List of overlay specifications to register

tool_id: str = 'profile'

Unique identifier of the tool

windows_to_be_registered: list[WindowSpec] = [WindowSpec(window_type='profile', view_cls=<class 'radioviz.tools.profile_tool.ProfileSubWindow'>, overwrite=False)]

List of window specifications to register

class radioviz.tools.profile_tool.ProfileToolController(tool_ctx: ToolContext, tool: Tool[ProfileToolController])[source]

Bases: ToolController[ImageWindowController, ProfileToolSession]

Controller for managing the profile tool workflow.

Initialize the profile tool controller.

Parameters:
_activate_profile_window(window_controller: ProfileWindowController) None[source]

Activate the profile window.

Parameters:

window_controller (ProfileWindowController) – Profile window controller

_on_active_image_changed(new_window_controller: SubWindowController[Any] | None) None[source]

Handle active image change event.

Parameters:

new_window_controller (SubWindowController) – New window controller

_on_image_about_to_close(image_controller: ImageWindowController) None[source]

Handle image window about to close event.

Parameters:

image_controller (ImageWindowController) – Image window controller

_sync_profile(profile_data: ProfileData) None[source]

Synchronize profile data with its associated controllers and overlays.

Updates the profile name in the controller and label overlay, and synchronizes the visibility settings for permanent, highlight, and label overlays. If the profile is currently selected, ensures the highlight overlay is properly managed.

Parameters:

profile_data (ProfileData) – The profile data to synchronize

count_dependencies_for_image(window_controller: SubWindowController[Any]) int[source]

Count profile items attached to window_controller.

create_dock(parent_window: QWidget) ProfileToolDock[source]

Create the tool dock widget.

Parameters:

parent_window (QWidget) – Parent window

Returns:

Profile tool dock widget

Return type:

ProfileToolDock

create_profile_from_points() None[source]

Create profile from selected points.

create_session(window_controller: ImageWindowController, input_data: ProfileData | None = None) ProfileToolSession[source]

Create a new profile tool session.

Parameters:

window_controller (SubWindowController) – Image window controller

Returns:

New profile tool session

Return type:

BaseToolSession

finalize_profile(session_result: ToolSessionResult) None[source]

Finalize the profile creation process.

invalidate_dependencies_for_image(window_controller: SubWindowController[Any]) int[source]

Remove profile items attached to window_controller.

menu_specs() List[ToolMenuSpec][source]

Get menu specifications for the tool.

Returns:

List of menu specifications

Return type:

List[ToolMenuSpec]

on_cancelled_profile_definition() None[source]

Handle cancelled profile definition.

on_delete_profile_clicked() None[source]

Handle delete profile click event.

on_dock_event(event: ToolEvent) None[source]

Handle dock events.

Parameters:

event (ToolEvent) – Tool event

on_profile_selection_changed(selected: ProfileData | None, deselected: ProfileData | None) None[source]

Handle profile selection change event.

Parameters:
remove_profile(profile: ProfileData) None[source]

Remove a profile from the store.

Parameters:

profile (ProfileData) – Profile to remove

set_profile_params(params: dict[str, Any]) None[source]

Set profile parameters.

Parameters:

params (dict[str, Any]) – Profile parameters dictionary

start_add_profile() None[source]

Start adding a new profile.

update_editable_fields(data: ProfileData, index: int = 0) None[source]

Update editable fields when a profile is updated in the store.

This method is triggered by update events and synchronizes the profile data with its associated controllers and overlays. It handles name updates and visibility changes for both permanent and highlight overlays.

Parameters:
  • data (ProfileData) – The profile data that was updated

  • index (int) – The index of the updated item in the store

class radioviz.tools.profile_tool.ProfileToolDock(parent: QWidget, controller: ProfileToolController)[source]

Bases: ToolDockWidget[ProfileToolController]

Dock widget for the profile tool interface.

Initialize the profile tool dock.

Parameters:
create_selection_dialog() None[source]

Create and show the point selection dialog.

delete_profile() None[source]

Handle profile deletion request.

enable_redraw_label(enable: bool) None[source]

Set wheter the redraw label button is enabled

handle_event(event: ToolEvent) None[source]

Handle tool events.

Parameters:

event (ToolEvent) – Tool event

on_profile_selected(selected: QItemSelection, deselected: QItemSelection) None[source]

Handle profile selection events.

Parameters:
  • selected (QItemSelection) – Selected indexes

  • deselected (QItemSelection) – Deselected indexes

on_request_to_change_selection(index: QModelIndex, flags: SelectionFlag) None[source]

Handle a request to change the selected item in the table view.

on_window_controller_changed(is_image_controller: bool) None[source]

Handle window controller changes.

Parameters:

is_image_controller (bool) – Whether the current window is an image controller

set_can_remove(can_remove: bool) None[source]

Set whether deletion is enabled for the selected profile.

Parameters:

can_remove (bool) – Whether removal is enabled

class radioviz.tools.profile_tool.ProfileToolSession(tool_controller: ProfileToolController, window_controller: ImageWindowController, input_data: ProfileData | None = None)[source]

Bases: BaseToolSession[ProfileToolController, ImageWindowController]

Session for handling profile extraction process.

Initialize the profile tool session.

Parameters:
_define_initial_condition() None[source]

Define profile parameters from pre-existing data.

Initializes the session using existing profile data instead of interactive creation. Sets up the geometry from the provided start and end points, and copies the profile parameters from the input data to the session’s parameters dictionary.

This method is used when restoring a profile from workspace data or when initializing a profile with predefined parameters.

Raises:

TypeError – If _input_data is None (should not occur in normal flow)

_on_error(e: Exception) None[source]

Handle error events.

Parameters:

e (Exception) – Exception that occurred

_on_interactive_definition() None[source]

Initialize interactive profile definition mode.

Sets up the interactive profile creation process by: 1. Sending a status message to the user 2. Emitting an event to create the point selection dialog 3. Creating a new ProfileData instance with a generated name and color 4. Setting up a LineSelector for capturing user-drawn line geometry 5. Connecting the selector signals to appropriate handler methods

This method is called when starting an interactive profile definition session where the user will manually draw the profile line on the image.

cleanup() None[source]

Clean up resources used by the session.

create_label_overlay() OverlayModel[source]

Create an overlay for the arrow label

on_cancel(reason: str) None[source]

Cancel the session.

Parameters:

reason (str) – Reason for cancellation

on_finish() None[source]

Finish the session.

on_profile_ready(profile_results: tuple[ndarray, ndarray, UUID]) None[source]

Handle profile ready event.

Parameters:
  • x (np.ndarray) – X coordinates of profile points

  • y (np.ndarray) – Y coordinates (intensity values) of profile points

  • session_id (UUID) – Session identifier

on_selector_accepted() None[source]

Handle selector acceptance event.

on_selector_canceled() None[source]

Handle selector cancellation event.

on_selector_created() None[source]

Handle selector creation event.

on_start() None[source]

Start the profile extraction session.

overlay_from_geometry() OverlayModel[source]

Create overlay from geometry.

Returns:

Overlay model for the profile

Return type:

OverlayModel

start_profile_computation() None[source]

Start the profile computation process.

class radioviz.tools.profile_tool.ProfileWindowController(source: DataSource, profile_data: ProfileData, storage: DataStorage | None = None, view: ProfileSubWindow | None = None)[source]

Bases: SubWindowController[ProfileSubWindow]

Controller for the profile window.

Initialize the profile window controller.

Parameters:
_save_profile_data_csv(path: Path) None[source]

Save profile data to a CSV file with metadata headers.

Writes the profile data along with metadata comments to a CSV file. The metadata includes profile name, start and end points, profile width, and reduction function. The data is written in x,y format.

Parameters:

path (pathlib.Path) – The file path where the CSV data should be saved

_save_profile_data_hdf5(path: Path) None[source]

Save profile data to an HDF5 file with metadata attributes.

Creates an HDF5 file containing the profile data as datasets and metadata as attributes. The dataset structure includes x and y values while attributes store profile metadata such as name, start/end points, width, and reduction function.

Parameters:

path (pathlib.Path) – The file path where the HDF5 data should be saved

_set_axis_label_mode_checked(mode: str, checked: bool) None[source]

Set axis label mode when a menu action is checked.

Parameters:
  • mode (str) – Axis label mode.

  • checked (bool) – Whether the menu action is checked.

_set_default_display_properties() dict[str, Any][source]

Initialize default display properties for the profile window.

Returns:

Dictionary containing default display properties

Return type:

dict[str, Any]

can_export_as() bool[source]

Check if the current image can be exported.

Returns:

True if the image can be exported, False otherwise

Return type:

bool

context_menu_specs() List[ToolMenuSpec][source]

Provide context menu specifications for profile windows.

Returns:

List of menu specifications

Return type:

List[ToolMenuSpec]

default_file_name() str[source]

Get the default file name for saving the profile data.

Returns:

Default file name based on profile name

Return type:

str

distance_unit() DistanceUnit | None[source]

Select a suitable distance unit based on profile length.

Returns:

Distance unit or None when unavailable.

Return type:

DistanceUnit | None

export_to_path(path: Path) None[source]

Export the current view to the specified path.

Parameters:

path (Path) – The file path where the export will be saved

get_export_specs() list[ExportSpec][source]

Get the list of available export specifications for the image.

Returns:

List of export specifications or empty list if no image data exists

Return type:

list[ExportSpec]

get_save_specs() list[SaveSpec][source]

Get the available save specifications for this profile.

Returns:

List of save specifications

Return type:

list[SaveSpec]

has_distance() bool[source]

Check if distance calibration is available for this profile.

Returns:

True if calibration is available, False otherwise.

Return type:

bool

on_view_closed() None[source]

Handle view closing event.

pixel_distance_m() float | None[source]

Physical size per profile pixel along the profile direction.

Returns:

Meters per profile pixel or None.

Return type:

float | None

pixel_size_m() tuple[float, float] | None[source]

Pixel size in meters derived from profile calibration, if available.

Returns:

Tuple of pixel sizes in meters or None.

Return type:

tuple[float, float] | None

save_profile_data(path: Path) None[source]

Save the profile data to a file in CSV or HDF5 format.

This method dispatches the saving operation to either CSV or HDF5 specific save methods based on the file extension of the provided path. It handles the file writing process and marks the data as saved upon successful completion.

Parameters:

path (pathlib.Path) – The file path where the profile data should be saved

Raises:

Exception – If an error occurs during the saving process

set_display_properties(params: dict[str, Any]) None[source]

Update display properties with the provided parameters.

Parameters:

params (dict[str, Any]) – Dictionary containing display property updates

set_view(view: ProfileSubWindow) None[source]

Set the view associated with this controller.

Connects the view’s context menu signal to the controller’s signal.

Parameters:

view (T_SubWindow) – The view to associate with this controller

sync_context_menu_state() None[source]

Sync context menu check state for profile-specific entries.

property axis_label_mode: str

Current axis label mode.

Returns:

Axis label mode.

Return type:

str

radioviz.tools.profile_tool.assume_complete_profile(profile: ProfileData) ProfileDataCompleteProtocol[source]

Treat a profile data as complete (no None) without runtime checks.

Parameters:

profile (ProfileData) – The profile data assumed to be complete

Returns:

A view of the profile with non-optional attributes

Return type:

ProfileDataCompleteProtocol

radioviz.tools.profile_tool.draw_highlight_profile(overlay: OverlayModel, axes: Axes) list[Artist][source]

Draw a highlighted profile overlay.

Parameters:
  • overlay (OverlayModel) – Overlay model

  • axes (Axes) – Matplotlib axes

Returns:

List of patches drawn

Return type:

list

radioviz.tools.profile_tool.draw_label_overlay(overlay: OverlayModel, axes: Axes) list[Artist][source]

Draw a label overlay for a profile on matplotlib axes.

Calculates the appropriate text rotation and positioning based on the profile line geometry to ensure proper label placement and orientation.

Parameters:
  • overlay (OverlayModel) – The overlay model containing label configuration

  • axes (Axes) – The matplotlib axes to draw on

Returns:

List of artists created for the overlay

Return type:

list[Artist]

radioviz.tools.profile_tool.draw_profile_arrow(overlay: OverlayModel, axes: Axes) list[Artist][source]

Draw a profile arrow overlay.

Parameters:
  • overlay (OverlayModel) – Overlay model

  • axes (Axes) – Matplotlib axes

Returns:

List of patches drawn

Return type:

list

radioviz.tools.profile_tool.extract_profile(data: ndarray, geometry: LineGeometry, session_id: UUID, profile_width: int = 1, reduce_function: str = 'mean', interpolation_order: str = 'bi-linear', **kwargs: Any) tuple[ndarray, ndarray, UUID][source]

Extract intensity profile from image data along a specified line.

Computes an intensity profile along a line segment defined by start and end points in the image data. Uses skimage.measure.profile_line for the actual computation with configurable interpolation and reduction methods.

This function is decorated with the superqt thread_worker, so it is not possible to call it directly because it will be executed in a separated thread. The typical usage is as follows:

worker = extract_profile(
    data=self.window_controller.image_data,
    geometry=self.geometry,
    session_id=self.session_id,
    profile_width=self.profile_parameters['line_width'],
    interpolation_order=self.profile_parameters[
        'interpolation_order'
    ],
    reduce_function=self.profile_parameters[
        'reduce_function'
    ],
)

worker.returned.connect(self.on_profile_ready)
worker.errored.connect(self._on_error)
worker.start()
Parameters:
  • data (np.ndarray) – Input image data array

  • geometry (LineGeometry) – Line geometry defining start and end points

  • session_id (UUID) – Identifier for the profile extraction session

  • profile_width (int) – Width of the profile extraction line (default: 1)

  • reduce_function (str) – Function to reduce multiple pixel values (default: ‘mean’)

  • interpolation_order (str) – Interpolation order for profile calculation (default: ‘bi-linear’)

  • kwargs – Additional keyword arguments passed to profile_line

Returns:

Tuple of (x_coordinates, y_coordinates, session_id)

Return type:

tuple[np.ndarray, np.ndarray, UUID]