EventAnalysisView

class EventAnalysisView(*args, **kwargs)

Bases: MetaView, WalkthroughMixin

Subclass of MetaView for visualizing and interacting with event-based signal analysis.

Handles event plotting, plugin integration, and user-triggered actions.

Public Methods

EventAnalysisView.get_current_view() str

Abstract method to get the name of the current view.

Subclasses must override this to return the current view name.

Returns:

The name of the view currently displayed.

Return type:

str

Raises:

NotImplementedError – Always, unless overridden by a subclass.

EventAnalysisView.get_save_filename() str

Open a file dialog to let the user select a filename for saving a CSV file.

Returns:

Absolute path to the selected file.

Return type:

str

EventAnalysisView.get_walkthrough_steps() List[Tuple[str, str, str, Callable[[], QWidget | List[QWidget]]]]

Abstract method to retrieve the walkthrough steps for the current view.

Subclasses must override this to return a list of walkthrough steps, each a (title, description, view name, widget getter) tuple.

Returns:

The ordered walkthrough steps for this view.

Return type:

List[WalkthroughStep]

Raises:

NotImplementedError – Always, unless overridden by a subclass.

EventAnalysisView.handle_parameter_change(submodel_name: str, action_name: str, args: tuple) None

Handle changes triggered by UI controls such as updates to axis selection or filters.

Parameters:
  • submodel_name (str) – Name of the submodel that triggered the action.

  • action_name (str) – Name of the action triggered.

  • args (tuple) – Tuple containing action-specific arguments.

EventAnalysisView.notify_plugin_state_changed(metaclass: str, plugin_key: str, reason: str) None

This tab does not currently react to any plugin_state_changed notifications.

Parameters:
  • metaclass (str) – The metaclass of the plugin instance whose state changed.

  • plugin_key (str) – The unique key identifying the plugin instance that changed.

  • reason (str) – A short string identifying what kind of change occurred.

Returns:

None

Return type:

None

EventAnalysisView.set_data_filter_function(data_filter: Callable) None

Set the callcable function to filter data

Parameters:

data_filter (Callable) – a callable function

EventAnalysisView.set_eventfitting_status(status: bool) None

Set the internal event fitting status.

Parameters:

status (bool) – Boolean indicating fitting completion status.

EventAnalysisView.set_num_events_allowed(num_events: int) None

Set the maximum number of events allowed to be plotted.

Parameters:

num_events (int) – Number of events allowed.

EventAnalysisView.update_available_plugins(available_plugins: Dict[str, List[str]]) None

Called whenever a new plugin is instantiated elsewhere in the app, to keep an up-to-date list of possible data sources for use by this plugin.

Parameters:

available_plugins (Dict[str, List[str]]) – dict of lists keyed by MetaClass, listing the identifiers of all instantiated plugins throughout the app.

EventAnalysisView.update_channels(channels: List[int]) None

Update the channel list in the event analysis control widget.

Parameters:

channels (List[int]) – List of available channel indices.

EventAnalysisView.update_plot() None

Update the main plot with the latest data and features. This method should be called after data and parameters are updated.

EventAnalysisView.update_plot_data(data: Any | None = None) None

Update internal storage of plot data. Can be used by signal handlers receiving data.

Parameters:

data (Optional[Any]) – The data to be stored, can be a dict or array.

EventAnalysisView.update_plot_features(vertical: List[float] | None = None, horizontal: List[float] | None = None, points: List[Tuple[float, float]] | None = None, vlabels: List[str] | None = None, hlabels: List[str] | None = None, plabels: List[str] | None = None) None

Update feature overlays for the plot, such as vertical/horizontal lines and labeled points.

Parameters:
  • vertical (Optional[List[float]]) – List of vertical line positions.

  • horizontal (Optional[List[float]]) – List of horizontal line positions.

  • points (Optional[List[Tuple[float, float]]]) – List of (x, y) point coordinates.

  • vlabels (Optional[List[str]]) – Labels for vertical lines.

  • hlabels (Optional[List[str]]) – Labels for horizontal lines.

  • plabels (Optional[List[str]]) – Labels for points.

EventAnalysisView.update_plot_samplerate(samplerate: float) None

Update the sampling rate used to convert time units in plots.

Parameters:

samplerate (float) – Sampling rate in Hz.

EventAnalysisView.validate_single_channel(channels: Sequence[int]) None

Ensure only one channel is selected.

Parameters:

channels (Sequence[int]) – List of selected channel indices.

Raises:

ValueError – If more than one channel is selected.

Private Methods

EventAnalysisView.__init__(*args: Any, **kwargs: Any) None

Initialize the MetaTab with a blank plot canvas and a space for controls.

EventAnalysisView._extract_commit_event_parameters(parameters: Dict[str, Any]) Tuple[str | None, List[int]]

Extract writer and channels from parameters.

Parameters:

parameters (Dict[str, Any]) – Input dictionary.

Returns:

(writer, channels)

Return type:

Tuple[Optional[str], List[int]]

EventAnalysisView._extract_event_fit_parameters(parameters: Dict[str, Any]) Tuple[str | None, str | None, List[int]]

Extract parameters used for event finding.

Parameters:

parameters (Dict[str, Any]) – Dictionary of parameters.

Returns:

(eventfitter, data_filter, channels)

Return type:

Tuple[Optional[str], Optional[str], List[int]]

EventAnalysisView._extract_plot_event_parameters(parameters: Dict[str, Any]) Tuple[str | None, str | None, str | None, List[int], List[int] | None]

Extract event plotting parameters from input.

Parameters:

parameters (Dict[str, Any]) – Input parameter dictionary.

Returns:

(loader, eventfitter, data_filter, channels, events)

Return type:

Tuple[Optional[str], Optional[str], Optional[str], List[int], Optional[List[int]]]

EventAnalysisView._factors(n: int) Tuple[int, int]

Compute a pair of factors of n that are closest to each other. Useful for determining subplot grid dimensions.

Parameters:

n (int) – Integer to factor.

Returns:

Tuple of two integers whose product is close to n and have minimal difference.

Return type:

Tuple[int, int]

EventAnalysisView._get_event_index_text() str

Get the current text from the event index input field.

Returns:

Stripped text content of the event index field.

Return type:

str

EventAnalysisView._handle_commit_events(parameters: Dict[str, Any]) None

Handle commit actions by triggering the selected writer to store events.

Parameters:

parameters (Dict[str, Any]) – Dictionary containing selected writer and channel info.

EventAnalysisView._handle_fit_events(parameters: Dict[str, Any]) None

Handle the fitting of events using the selected event fitter and data filter.

Parameters:

parameters (Dict[str, Any]) – Dictionary of parameters from the GUI controls.

EventAnalysisView._handle_other_actions(action_name: str, parameters: Dict[str, Any]) None

Handle non-standard or plugin-specific actions that do not fall into predefined handlers.

Parameters:
  • action_name (str) – Action identifier.

  • parameters (Dict[str, Any]) – Dictionary of parameters for the action.

EventAnalysisView._handle_plot_events(parameters: Dict[str, Any]) None

Handle loading and plotting of selected events based on provided parameters.

Parameters:

parameters (Dict[str, Any]) – Dictionary containing eventfinder, filter, channels, and event indices.

EventAnalysisView._init() None

Initialize the EventAnalysisView. Called after constructor. Used to set up internal variables or state as needed.

EventAnalysisView._reset_actions(axis_type: str = '2d') None

Clears the figure and reinitializes axes. This will also add a flag to the tab action history if @register_action is being used to keep track of actions. Only actions applied after the most recent call to this function will be recreated if the related file is loaded.

Parameters:

axis_type (str) – Either ‘2d’ or ‘3d’ to determine plot projection.

EventAnalysisView._set_control_area(layout: QBoxLayout) None

Set up the control area with widgets for user interaction.

Parameters:

layout (QBoxLayout) – Layout to which the controls will be added.

EventAnalysisView._shift_range_and_update_plot(parameters: Dict[str, Any], direction: str) None

Shift ranges in the GUI and update plot and input if valid.

Parameters:
  • parameters (Dict[str, Any]) – Parameter dictionary collected from the control widgets.

  • direction (str) – Either ‘left’ or ‘right’.

EventAnalysisView._start_eventfitter(eventfitter: str, data_filter: str, channels: int | List[int]) None

Start the event fitting process for the selected channel(s) using the given fitter and filter.

Parameters:
  • eventfitter (str) – Identifier of the event fitter plugin.

  • data_filter (str) – Identifier of the filter plugin to apply to the data.

  • channels (Union[int, List[int]]) – Channel index, or list of integer channel indices.

EventAnalysisView._start_writer(writer: str, channels: int | List[int]) None

Start the process of writing committed events to the database for the given channels.

Parameters:
  • writer (str) – Identifier of the database writer plugin.

  • channels (Union[int, List[int]]) – Channel index, or list of channel indices, for which to write events.

EventAnalysisView._update_event_plot(event_data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], labels: Sequence[str], num_events: int, vertical_lines: Sequence[List[float] | None], horizontal_lines: Sequence[List[float] | None], points: Sequence[List[Tuple[float, float]] | None], vlabels: Sequence[Sequence[str | None] | None], hlabels: Sequence[Sequence[str | None] | None], plabels: Sequence[Sequence[str | None] | None], use_raw: bool = False) None

Update the event plot with raw data, annotations, and formatting.

This method generates subplots for each event, displays time-series data, and optionally overlays vertical/horizontal lines and annotated points.

Parameters:
  • event_data (Sequence[npt.NDArray[np.float64]]) – List of 1D arrays containing current traces for each event.

  • labels (Sequence[str]) – List of strings for each subplot’s title.

  • num_events (int) – Total number of events to plot (i.e., number of subplots).

  • vertical_lines (Sequence[Optional[List[float]]]) – List of lists of x-values for vertical line annotations per subplot.

  • horizontal_lines (Sequence[Optional[List[float]]]) – List of lists of y-values for horizontal line annotations per subplot.

  • points (Sequence[Optional[List[Tuple[float, float]]]]) – List of lists of (x, y) coordinate tuples for marker points per subplot.

  • vlabels (Sequence[Optional[Sequence[Optional[str]]]]) – One entry per subplot, each a list of labels for that subplot’s vertical lines, or None if the fitter supplied no labels. Individual labels may also be None.

  • hlabels (Sequence[Optional[Sequence[Optional[str]]]]) – One entry per subplot, each a list of labels for that subplot’s horizontal lines, or None if the fitter supplied no labels. Individual labels may also be None.

  • plabels (Sequence[Optional[Sequence[Optional[str]]]]) – One entry per subplot, each a list of labels for that subplot’s points, or None if the fitter supplied no labels. Individual labels may also be None.

  • use_raw (bool) – Whether to plot/cache the raw (unfiltered) trace entries in event_data (labeled “Raw”) alongside the filtered/fit ones. Entries so labeled are skipped entirely when this is False, regardless of whether the caller included them.

Returns:

None

Return type:

None