Widgets Module

The widgets module contains PyQt6-based GUI components for the VISTA application.

Overview

The widgets module provides the graphical user interface components for VISTA, including:

  • Core application widgets (viewers, panels, controls)

  • Algorithm configuration dialogs

  • Data management interfaces

  • Visualization tools

This module follows PyQt6 conventions and extends Qt widgets with VISTA-specific functionality.

Module Structure

The widgets module is organized into several submodules:

  • core - Core application widgets

  • algorithms - Algorithm configuration dialogs

  • utils - Widget utilities and helpers

Core Widgets

Core widgets provide the main application interface:

  • Data Manager: Central widget for managing imagery, detections, and tracks

  • Imagery Panel: Display and control imagery data

  • Playback Controls: Frame navigation and playback

  • Settings Dialog: Application configuration

Algorithm Widgets

Algorithm widgets provide user interfaces for configuring and running algorithms:

  • Detector Widgets: Configuration for detection algorithms

  • Tracker Widgets: Configuration for tracking algorithms

  • Treatment Widgets: Configuration for image treatments

  • Background Removal Widgets: Configuration for background subtraction

Module Reference

Core Widgets

Data manager panel - coordinating panel for managing imagery, tracks, detections, and AOIs

class vista.widgets.core.data.data_manager.DataManagerPanel(*args, **kwargs)[source]

Bases: QWidget

Main panel for managing all data types

__init__(viewer)[source]

Initialize the data manager panel.

Parameters:

viewer (ImageryViewer) – ImageryViewer instance

init_ui()[source]

Initialize the user interface

on_sensor_selected(sensor)[source]

Handle sensor selection change

on_sensor_data_changed()[source]

Handle sensor data changes (e.g., sensor deletion)

refresh()[source]

Refresh all panels

on_track_selected_in_viewer(track)[source]

Handle track selection from viewer click. Forwards to tracks panel or detections panel depending on state.

Parameters:

track (Track) – Track object that was clicked

on_detections_selected_in_viewer(detections)[source]

Handle detection selection from viewer click. Forwards to detections panel.

Parameters:

detections (list of tuple) – List of tuples [(detector, frame, index), …]

refresh_aois_table()[source]

Refresh AOIs table - wrapper for compatibility

Imagery panel for data manager

class vista.widgets.core.data.imagery_panel.ImageryPanel(*args, **kwargs)[source]

Bases: QWidget

Panel for managing imagery

__init__(viewer)[source]
init_ui()[source]

Initialize the user interface

refresh_imagery_table()[source]

Refresh the imagery table, filtering by selected sensor

on_imagery_selection_changed()[source]

Handle imagery selection changes from table

on_imagery_cell_changed(row, column)[source]

Handle imagery cell changes

delete_selected_imagery()[source]

Delete imagery that is selected in the table

PlaybackControls widget for controlling imagery playback

class vista.widgets.core.playback_controls.PlaybackControls(*args, **kwargs)[source]

Bases: QWidget

Widget for playback controls

__init__(parent=None)[source]
init_ui()[source]
set_frame_range(min_frame, max_frame)[source]

Set the range of frame numbers without changing current frame

set_frame(frame_number)[source]

Set current frame by frame number

update_label()[source]

Update frame label and time display

on_slider_changed(value)[source]

Handle slider value change

on_fps_dial_changed(value)[source]

Handle FPS dial change

on_fps_spinbox_changed(value)[source]

Handle FPS spinbox change

toggle_play()[source]

Toggle playback

toggle_reverse()[source]

Toggle reverse playback

play()[source]

Start playback

pause()[source]

Pause playback

on_timer_tick()[source]

Called by timer frequently - checks if enough time has passed to advance frame

advance_frame()[source]

Advance frame based on playback direction and bounce mode

next_frame()[source]

Go to next frame

prev_frame()[source]

Go to previous frame

prev_frame_reverse()[source]

Go to previous frame (for reverse playback with looping)

update_actual_fps()[source]

Calculate and update the actual achieved FPS display

on_bounce_toggled(state)[source]

Handle bounce mode toggle

on_bounce_range_changed()[source]

Handle bounce range change

frame_changed(frame_index)[source]

Override this method to handle frame changes

Algorithm Dialogs

Detector Dialogs

Base classes for detector widgets to reduce code duplication

class vista.widgets.algorithms.detectors.base_detector_widget.BaseDetectorProcessingThread(*args, **kwargs)[source]

Bases: QThread

Base worker thread for running detector algorithms in background

progress_updated

alias of int

processing_complete

alias of object

error_occurred

alias of str

__init__(imagery, algorithm_class, algorithm_params, aoi=None, start_frame=0, end_frame=None, detector_name=None, default_color='r', default_marker='o', default_marker_size=12)[source]

Initialize the processing thread.

Parameters:
  • imagery (Imagery) – Imagery object to process

  • algorithm_class (type) – Detector algorithm class to instantiate (e.g., SimpleThreshold)

  • algorithm_params (dict) – Dictionary of parameters to pass to algorithm constructor

  • aoi (AOI, optional) – AOI object to process subset of imagery, by default None

  • start_frame (int, optional) – Starting frame index, by default 0

  • end_frame (int, optional) – Ending frame index exclusive, by default None for all frames

  • detector_name (str, optional) – Name for the detector, by default None (auto-generated)

  • default_color (str, optional) – Default color for detections, by default ‘r’

  • default_marker (str, optional) – Default marker for detections, by default ‘o’

  • default_marker_size (int, optional) – Default marker size, by default 12

cancel()[source]

Request cancellation of the processing operation

run()[source]

Execute the detector algorithm in background thread

class vista.widgets.algorithms.detectors.base_detector_widget.BaseDetectorWidget(*args, **kwargs)[source]

Bases: QDialog

Base configuration widget for detector algorithms

detector_processed

alias of object

__init__(parent=None, imagery=None, aois=None, algorithm_class=None, settings_name='BaseDetector', window_title='Detector', description='', default_color='r', default_marker='o', default_marker_size=12)[source]

Initialize the base detector configuration widget.

Parameters:
  • parent (QWidget, optional) – Parent widget, by default None

  • imagery (Imagery, optional) – Imagery object to process, by default None

  • aois (list of AOI, optional) – List of AOI objects to choose from, by default None

  • algorithm_class (type, optional) – Detector algorithm class (e.g., SimpleThreshold), by default None

  • settings_name (str, optional) – Name for QSettings storage, by default “BaseDetector”

  • window_title (str, optional) – Window title, by default “Detector”

  • description (str, optional) – HTML description text for the detector, by default “”

  • default_color (str, optional) – Default color for detections, by default ‘r’

  • default_marker (str, optional) – Default marker for detections, by default ‘o’

  • default_marker_size (int, optional) – Default marker size, by default 12

init_ui()[source]

Initialize the user interface

add_algorithm_parameters(layout)[source]

Add algorithm-specific parameters to the layout. Override this method in subclasses to add custom parameters.

Parameters:

layout (QVBoxLayout) – QVBoxLayout to add parameters to

load_settings()[source]

Load previously saved settings. Override this method in subclasses to load custom parameters.

save_settings()[source]

Save current settings for next time. Override this method in subclasses to save custom parameters.

build_algorithm_params()[source]

Build parameter dictionary for the algorithm. Override this method in subclasses to add custom parameters.

Returns:

Dictionary of algorithm parameters

Return type:

dict

validate_parameters()[source]

Validate algorithm parameters before running. Override this method in subclasses for custom validation.

Returns:

Tuple containing (is_valid, error_message)

Return type:

tuple of (bool, str)

run_algorithm()[source]

Start processing the imagery with the configured parameters

set_parameters_enabled(enabled)[source]

Enable or disable parameter widgets. Override to handle custom parameter widgets.

Parameters:

enabled (bool) – True to enable, False to disable

cancel_processing()[source]

Cancel the ongoing processing

on_progress_updated(current, total)[source]

Handle progress updates from the processing thread.

Parameters:
  • current (int) – Current frame number being processed

  • total (int) – Total number of frames to process

on_processing_complete(detector)[source]

Handle successful completion of processing.

Parameters:

detector (Detector) – The resulting Detector object containing all detections

on_error_occurred(error_message)[source]

Handle errors from the processing thread.

Parameters:

error_message (str) – Error message string, potentially including traceback information

on_thread_finished()[source]

Handle thread completion (cleanup)

reset_ui()[source]

Reset UI to initial state

closeEvent(event)[source]

Handle dialog close event.

Parameters:

event (QCloseEvent) – Close event to accept or ignore

Tracker Dialogs

Base classes for tracker dialogs to reduce code duplication

class vista.widgets.algorithms.trackers.base_tracker_dialog.BaseTrackingWorker(*args, **kwargs)[source]

Bases: QThread

Base worker thread for running trackers in background

progress_updated

alias of str

tracking_complete

alias of object

error_occurred

alias of str

__init__(detectors, tracker_config, algorithm_function)[source]

Initialize the tracking worker.

Parameters:
  • detectors (list of Detector) – List of Detector objects to use for tracking

  • tracker_config (dict) – Dictionary of tracker configuration parameters

  • algorithm_function (callable) – Function to call for tracking (e.g., run_simple_tracker)

cancel()[source]

Request cancellation

run()[source]

Execute tracking in background

class vista.widgets.algorithms.trackers.base_tracker_dialog.BaseTrackingDialog(*args, **kwargs)[source]

Bases: QDialog

Base dialog for configuring tracker parameters

__init__(viewer, parent=None, algorithm_function=None, settings_name='BaseTracker', window_title='Tracker', description='', default_track_color='b', default_track_marker='s', default_track_line_width=2, default_track_marker_size=10)[source]

Initialize the base tracking dialog.

Parameters:
  • viewer (object) – VISTA viewer object

  • parent (QWidget, optional) – Parent widget, by default None

  • algorithm_function (callable, optional) – Function to call for tracking (e.g., run_simple_tracker), by default None

  • settings_name (str, optional) – Name for QSettings storage, by default “BaseTracker”

  • window_title (str, optional) – Window title, by default “Tracker”

  • description (str, optional) – HTML description text for the tracker, by default “”

  • default_track_color (str, optional) – Default color for created tracks, by default ‘b’

  • default_track_marker (str, optional) – Default marker for created tracks, by default ‘s’

  • default_track_line_width (int, optional) – Default line width for created tracks, by default 2

  • default_track_marker_size (int, optional) – Default marker size for created tracks, by default 10

setup_ui()[source]

Setup the dialog UI - can be overridden by subclasses

add_algorithm_parameters(main_layout)[source]

Add algorithm-specific parameters to the form layout. Override this method in subclasses to add custom parameters.

Parameters:

main_layout (QVBoxLayout) – The main QVBoxLayout - use this if you need to add custom group boxes. For simple parameters, add to self.params_layout (QFormLayout).

load_settings()[source]

Load previously saved settings. Override this method in subclasses to load custom parameters.

save_settings()[source]

Save current settings for next time. Override this method in subclasses to save custom parameters.

build_config()[source]

Build configuration dictionary for the tracker. Override this method in subclasses to add custom parameters.

Returns:

Dictionary of tracker configuration parameters

Return type:

dict

run_tracker()[source]

Start the tracking process

on_progress(message)[source]

Update progress dialog

on_complete(track_data_list, tracker_name)[source]

Handle tracking completion

on_error(error_msg)[source]

Handle tracking error

cancel_tracking()[source]

Cancel the tracking process

Treatment Dialogs

Base classes for treatment widgets to reduce code duplication

class vista.widgets.algorithms.treatments.base_treatment_widget.BaseTreatmentThread(*args, **kwargs)[source]

Bases: QThread

Base worker thread for running treatment algorithms

progress_updated

alias of int

processing_complete

alias of object

error_occurred

alias of str

__init__(imagery, aoi=None)[source]

Initialize the processing thread.

Parameters:
  • imagery (Imagery) – Imagery object to process

  • aoi (AOI, optional) – AOI object to process subset of imagery, by default None

cancel()[source]

Request cancellation of the processing operation

process_frame(frame_data, frame_index, frame_number)[source]

Process a single frame. Override this method in subclasses.

Parameters:
  • frame_data (ndarray) – The image data for this frame

  • frame_index (int) – Index in the temp_imagery arrays

  • frame_number (int) – Actual frame number from original imagery

Returns:

Processed frame data

Return type:

ndarray

get_processed_name_suffix()[source]

Get the suffix to add to the processed imagery name. Override in subclasses (e.g., “BR”, “NUC”).

Returns:

String suffix for processed imagery name

Return type:

str

run()[source]

Execute the treatment in background thread

class vista.widgets.algorithms.treatments.base_treatment_widget.BaseTreatmentWidget(*args, **kwargs)[source]

Bases: QDialog

Base configuration widget for treatment algorithms

imagery_processed

alias of object

__init__(parent=None, imagery=None, aois=None, window_title='Treatment', description='')[source]

Initialize the base treatment configuration widget.

Parameters:
  • parent (QWidget, optional) – Parent widget, by default None

  • imagery (Imagery, optional) – Imagery object to process, by default None

  • aois (list of AOI, optional) – List of AOI objects to choose from, by default None

  • window_title (str, optional) – Window title, by default “Treatment”

  • description (str, optional) – Description text for the treatment, by default “”

init_ui()[source]

Initialize the user interface

add_treatment_ui(layout)[source]

Add treatment-specific UI elements. Override this method in subclasses if needed.

Parameters:

layout (QVBoxLayout) – QVBoxLayout to add elements to

create_processing_thread(imagery, aoi)[source]

Create the processing thread for this treatment. Must be implemented by subclasses.

Parameters:
  • imagery (Imagery) – Imagery object to process

  • aoi (AOI, optional) – AOI object

Returns:

BaseTreatmentThread instance

Return type:

BaseTreatmentThread

validate_sensor_requirements()[source]

Validate that the sensor has required data for this treatment. Override in subclasses to check for specific sensor properties.

Returns:

Tuple containing (is_valid, error_message)

Return type:

tuple of (bool, str)

run_treatment()[source]

Start processing the imagery

set_treatment_ui_enabled(enabled)[source]

Enable or disable treatment-specific UI elements. Override in subclasses if there are custom UI elements.

Parameters:

enabled (bool) – True to enable, False to disable

cancel_processing()[source]

Cancel the ongoing processing

on_progress_updated(current, total, label=None)[source]

Handle progress updates from the processing thread

on_processing_complete(processed_imagery)[source]

Handle successful completion of processing

on_error_occurred(error_message)[source]

Handle errors from the processing thread

on_thread_finished()[source]

Handle thread completion (cleanup)

reset_ui()[source]

Reset UI to initial state

closeEvent(event)[source]

Handle dialog close event

Extending Widgets

To create custom algorithm widgets, inherit from the appropriate base class:

from vista.widgets.algorithms.detectors.base_detector_widget import BaseDetectorWidget

class MyDetectorWidget(BaseDetectorWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setup_ui()

    def setup_ui(self):
        # Add custom UI elements
        pass

    def get_parameters(self):
        # Return algorithm parameters
        return {
            'threshold': self.threshold_spinbox.value(),
            'min_area': self.area_spinbox.value()
        }

See Extending VISTA for more details on extending VISTA widgets.