RawDataView

class RawDataView(*args, **kwargs)

Bases: MetaView, WalkthroughMixin

Subclass of MetaView for visualizing raw signal data and PSD plots.

Handles plot rendering, signal responses, and interactions with readers, filters, and event finders.

Public Methods

RawDataView.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.

RawDataView.get_save_filename() str

Open a dialog to save a CSV file.

Returns:

Selected file path, or an empty string if cancelled.

Return type:

str

RawDataView.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.

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

Handle parameter changes triggered by RawDataControls and dispatch the corresponding action.

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

  • action_name (str) – Action identifier string.

  • args (tuple) – Tuple of arguments passed with the signal.

RawDataView.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

RawDataView.set_data_filter_function(data_filter: Callable) None

Set the callcable function to filter data

Parameters:

data_filter (Callable) – a callable function

RawDataView.set_eventfinding_status(status: bool) None

Set the current event finding status.

Parameters:

status (bool) – Whether event finding is complete.

RawDataView.set_num_events_allowed(num_events: int) None

Set the number of events available for display.

Parameters:

num_events (int) – Maximum valid event index + 1.

RawDataView.set_psd(Pxx_list: List[ndarray[tuple[int, ...], dtype[float64]]], rms_list: List[ndarray[tuple[int, ...], dtype[float64]]], frequency: ndarray[tuple[int, ...], dtype[float64]] | None, kept_indices: List[int]) None

Set the PSD and RMS lists for visualization.

Parameters:
  • Pxx_list (List[npt.NDArray[np.float64]]) – Power spectral density data, one array per kept channel.

  • rms_list (List[npt.NDArray[np.float64]]) – RMS noise data, one array per kept channel.

  • frequency (Optional[npt.NDArray[np.float64]]) – Frequency axis data, or None if no channel was processed.

  • kept_indices (List[int]) – Indices into the channel list passed to calculate_psd that were successfully processed, since some channels may have been skipped.

RawDataView.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.

RawDataView.update_channels(channels: Sequence[int]) None

Update the channel combo box with available channels.

Parameters:

channels (Sequence[int]) – Available channel identifiers.

RawDataView.update_plot(data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], channels: Sequence[int], start: float = 0, baseline: bool = False) None

Update the plot area with the provided data across multiple channels in a grid layout.

Parameters:
  • data (Sequence[npt.NDArray[np.float64]]) – One array of current samples per channel.

  • channels (Sequence[int]) – List of channel identifiers corresponding to the data.

  • start (float) – Time offset added to the plotted time axis, in seconds.

  • baseline (bool) – If True, overlay baseline mean and standard deviation statistics on each subplot.

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

Update the stored plot data for future use.

Parameters:

data (Optional[Any]) – Data dictionary or raw array to store.

RawDataView.update_plot_samplerate(samplerate: float) None

Update the sampling rate used for plotting.

Parameters:

samplerate (float) – Sampling frequency in Hz.

RawDataView.update_psd(psd_data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], rms_data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], frequency: ndarray[tuple[int, ...], dtype[float64]], channels: Sequence[int]) None

Update the plot area with the provided psd and frequency data across multiple channels in a grid layout.

Parameters:
  • psd_data (Sequence[npt.NDArray[np.float64]]) – Power spectral density values, one array for each channel.

  • rms_data (Sequence[npt.NDArray[np.float64]]) – Integrated RMS noise values corresponding to psd_data, one array for each channel.

  • frequency (npt.NDArray[np.float64]) – Frequency axis shared across all channels.

  • channels (Sequence[int]) – List of channel identifiers corresponding to the data.

RawDataView.update_timer_channels(channels: Sequence[int]) None

Update the list of channels for event timing.

Parameters:

channels (Sequence[int]) – Valid channel indices.

RawDataView.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

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

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

RawDataView._apply_filter(data_filter: str, channel_data: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]]

Apply a data filter using a signal-based plugin system.

Parameters:
  • data_filter (str) – Name of the filter plugin.

  • channel_data (npt.NDArray[np.float64]) – Data to filter.

Returns:

Filtered data if successful, else the original data.

Return type:

npt.NDArray[np.float64]

RawDataView._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]]

RawDataView._extract_event_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:

(eventfinder, data_filter, channels)

Return type:

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

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

Extract event plotting parameters from input.

Parameters:

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

Returns:

(eventfinder, data_filter, channels, events)

Return type:

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

RawDataView._extract_plot_parameters(parameters: Dict[str, Any]) Tuple[str | None, List[int], float, float]

Extract reader, channel, start time, and length from parameters.

Parameters:

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

Returns:

(reader, channels, start, length)

Return type:

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

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

Determine the factor pair (rows, cols) closest to a square layout.

Parameters:

n (int) – Total number of plots.

Returns:

(rows, columns) representing subplot grid dimensions.

Return type:

Tuple[int, int]

RawDataView._gaussian(x: float, A: float, m: float, s: float) float

Calculate the value of a 1D gaussian distribution at a location x with the given paramters

Parameters:
  • x (float) – location to calculate the value

  • A (float) – amplitude of the gaussian

  • m (float) – mean of the gaussian

  • s (float) – standard deviation of the gaussian

Returns:

value of the gaussian distribution at x

Return type:

float

RawDataView._gaussian_fit(histogram: ndarray[tuple[int, ...], dtype[float64]], bins: ndarray[tuple[int, ...], dtype[float64]], mean_guess: float, stdev_guess: float) tuple[float, float, float]

Fit a Gaussian function to histogram data using a linearized least squares approach.

Parameters:
  • histogram (npt.NDArray[np.float64]) – Array of counts in each histogram bin.

  • bins (npt.NDArray[np.float64]) – Center positions of histogram bins.

  • mean_guess (float) – Initial estimate of the Gaussian mean.

  • stdev_guess (float) – Initial estimate of the Gaussian standard deviation.

Returns:

Tuple containing (amplitude, mean, standard deviation) of the fitted Gaussian.

Return type:

tuple[float, float, float]

Raises:

ValueError – If standard deviation guess is invalid or the fit fails.

RawDataView._get_baseline_stats(data: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]]

Get the local amplitude, mean, and standard deviation for a chunk of data. Assumes data is rectified.

Parameters:

data (npt.NDArray[np.float64]) – Chunk of timeseries data to compute statistics on.

Returns:

Array of local amplitude, mean, and standard deviation, in that order.

Return type:

npt.NDArray[np.float64]

Raises:

ValueError – If a baseline histogram width cannot be estimated for this chunk (no variation in the data), or if the underlying Gaussian fit fails.

RawDataView._get_event_index_text() str

Get the event index input from the UI.

Returns:

The current text from the event index input field.

Return type:

str

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

Handle committing of found events to the selected writer plugin.

Parameters:

parameters (Dict[str, Any]) – Dictionary containing writer and channels.

RawDataView._handle_find_events(parameters: Dict[str, Any]) None

Handle the initiation of the event finding process using the given parameters.

Parameters:

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

RawDataView._handle_load_data_and_update_plot(parameters: Dict[str, Any], baseline: bool = False) None

Handle data loading and update the main signal plot.

This method: - Extracts plot parameters (reader, channels, start, length) - Loads data using the specified reader for each channel - Optionally applies a filter to the data - Updates the main plot area with the retrieved data

Parameters:
  • parameters (Dict[str, Any]) – Dictionary containing reader, channels, start time, length, and optional filter.

  • baseline (bool) – If True, overlay baseline mean/std statistics on the plot.

RawDataView._handle_load_data_and_update_psd(parameters: Dict[str, Any]) None

Handle data loading and update the PSD (Power Spectral Density) plot.

This method extracts plotting parameters, loads data from the reader, optionally applies a filter, emits the signal to calculate PSD, and updates the PSD plot.

Parameters:

parameters (Dict[str, Any]) – Dictionary containing reader, channels, start time, length, and optional filter.

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

Handle plugin-specific actions not otherwise accounted for.

Parameters:
  • action_name (str) – Action to execute.

  • parameters (Dict[str, Any]) – Parameters needed for the action.

RawDataView._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.

Raises:

Exception – If retrieving the eventfinding status or the number of found events fails.

RawDataView._handle_timer(parameters: Dict[str, Any]) None

Open a time range selection dialog for a given event finder and update the internal time limits.

Parameters:

parameters (Dict[str, Any]) – Dictionary containing the ‘eventfinder’ key.

RawDataView._init() None

Initialize the RawDataView-specific attributes.

RawDataView._load_data(reader: str | None, channels: int | List[int], start: float, length: float) None

Load data from the specified reader plugin.

Parameters:
  • reader (Optional[str]) – Reader plugin name.

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

  • start (float) – Start time.

  • length (float) – Duration.

RawDataView._load_event_data(eventfinder: str | None, channel: int, event: int, data_filter: Callable | None) None

Load data for a single event from the eventfinder.

Parameters:
  • eventfinder (Optional[str]) – Name of the event finder plugin.

  • channel (int) – Channel number.

  • event (int) – Event index.

  • data_filter (Optional[Callable]) – Callable filter to apply, if any.

RawDataView._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.

RawDataView._set_control_area(layout: QBoxLayout) None

Set up the control area layout by embedding the RawDataControls widget.

Parameters:

layout (QBoxLayout) – The layout where controls will be added.

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

Shift selected event index ranges left or right and update the plot accordingly.

Parameters:
  • parameters (Dict[str, Any]) – Dictionary containing current event plotting parameters.

  • direction (str) – Direction to shift (‘left’ or ‘right’).

RawDataView._shift_range_and_update_trace(parameters: Dict[str, Any], direction: str) None

Shift numeric range left or right and update the plot and GUI input.

Parameters:
  • parameters (Dict[str, Any]) – Dictionary containing current trace plotting parameters.

  • direction (str) – Direction to shift (‘left’ or ‘right’).

RawDataView._start_eventfinder(eventfinder: str, data_filter: str, channels: int | List[int]) None

Start the event finding operation on the specified channels with an optional filter.

Parameters:
  • eventfinder (str) – Identifier for the event finder plugin.

  • data_filter (str) – Identifier for the filter plugin, or ‘No Filter’.

  • channels (Union[int, List[int]]) – Channel index, or list of channel indices, to run the event finder on.

Raises:

Exception – If setting up the data filter fails.

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

Start a writer plugin to commit events for the specified channels.

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

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

RawDataView._update_event_plot(event_data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], event_indices: Sequence[int]) None

Plot the event data in a grid that gets as close to square as possible

Parameters:
  • event_data (Sequence[npt.NDArray[np.float64]]) – a list of event data to plot in a grid

  • event_indices (Sequence[int]) – the indices of the events to plot

RawDataView._validate_plot_parameters(reader: str | None, channel: List[int] | None, start: float | None, length: float | None) bool

Validate the extracted parameters for plotting.

Parameters:
  • reader (Optional[str]) – Reader plugin name.

  • channel (Optional[List[int]]) – List of channel numbers.

  • start (Optional[float]) – Start time.

  • length (Optional[float]) – Duration.

Returns:

True if all parameters are valid, else False.

Return type:

bool