MetaView¶
class MetaView()
Bases: QWidget
Abstract base class designed to provide a unified interface for different analysis tabs.
This class includes a blank plot canvas for visualizing data, a dedicated space for control elements, and an interface for dynamically updating the plot based on user interactions or analysis results.
Public Methods¶
Abstract Methods¶
These methods must be implemented by subclasses.
- abstractmethod MetaView.notify_plugin_state_changed(metaclass: str, plugin_key: str, reason: str) None¶
Called by MainController whenever any plugin instance’s internal state changed elsewhere in the app (e.g. new columns committed to a loader’s table). Must be implemented by subclasses, even if the correct implementation is a no-op (pass).
Where the implementation is not a no-op, it must make a deliberate decision about whether the notification applies to this tab, filter accordingly, and determine what the specific reaction should be.
Currently known (metaclass, reason) combinations in use:
(“MetaDatabaseLoader”, <loader_key>, “columns”) — emitted after columns are added to a loader’s table (see ClusteringView._commit_clusters, ProteinView._commit_fits).
- Parameters:
metaclass (str) – The metaclass of the plugin instance whose state changed (e.g. “MetaDatabaseLoader”).
plugin_key (str) – The unique key identifying the plugin instance that changed (e.g. “SQLiteDBLoader_0”).
reason (str) – A short string identifying what kind of change occurred (e.g. “columns”). Free-form; the emitter and every receiver must agree on the exact string used.
- Returns:
None
- Return type:
None
Concrete Methods¶
- MetaView.handle_add_triggered(metaclass: str) None¶
Trigger addition of a new plugin by prompting for a subclass.
- Parameters:
metaclass (str) – The type of plugin to add (e.g., ‘MetaReader’)
- MetaView.handle_delete_triggered(metaclass: str, key: str) None¶
Emit a signal to trigger the delete process for a data plugin, passing the identifier.
- MetaView.handle_edit_triggered(metaclass: str, key: str) None¶
Emit a signal to trigger the saving process for a data plugin, passing the appropriate arguments to handle editing plugin settings.
- MetaView.handle_kill_button(identifier: str) None¶
Handle the kill button click event for individual workers.
- MetaView.remove_progress_bar(identifier: str) None¶
Remove a specific progress bar and its components when a task is complete.
Private Methods¶
Abstract Methods¶
These methods must be implemented by subclasses.
- abstractmethod MetaView._init() None¶
Perform additional initialization specific to the algorithm being implemented. Must be implemented by subclasses.
This function is called at the end of the class constructor to perform additional initialization specific to the algorithm being implemented. kwargs provided to the base class constructor are available as class attributes.
- abstractmethod MetaView._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.
- abstractmethod MetaView._set_control_area(layout: QBoxLayout) None¶
Create and set up the control area for user interaction elements.
- Parameters:
layout (QBoxLayout) – The main layout to which the control area will be added. A box layout specifically, since implementations nest a sub-layout with addLayout().
Concrete Methods¶
- MetaView._expand_event_indices(indices_str: str) list[int]¶
Expand ‘1,3-5’ → [1,3,4,5], exclude segments with negatives.
- MetaView._factors(n: int) Tuple[int, int]¶
Find the closest pair of factors for a given number to approximate a square layout.
- MetaView._format_ranges(ranges: Sequence[tuple[float, float]]) str¶
Format list of tuples into ‘8-11,13’
- MetaView._logscale_and_filter_dataframe(df: DataFrame, log_columns: List[str] | None = None) DataFrame¶
Filters a DataFrame for NaN values and applies logarithmic scaling to specified columns, returning a new DataFrame; the input is not modified.
This function:
Removes rows with NaN values in any column.
Applies log10 scaling to specified columns after rectifying based on average sign.
Sequentially removes rows with non-positive values in log columns.
- Args:
df (pd.DataFrame): Input DataFrame with numerical data. Not modified; a copy is filtered and transformed internally. log_columns (list of str, optional): List of column names to apply log scaling. If None, no log scaling is applied.
- Returns:
pd.DataFrame: A new, filtered and transformed DataFrame.
- MetaView._logscale_and_filter_multiple_columns(*data: ndarray[tuple[int, ...], dtype[Any]], log_flags: Sequence[bool] | None = None) Tuple[ndarray[tuple[int, ...], dtype[Any]], ...]¶
Filters multiple data columns for NaN values and applies logarithmic scaling.
This function takes an arbitrary number of 1D NumPy arrays as input. It first removes any data points (rows) where any of the input arrays contain a NaN value. Then, it optionally applies a base-10 logarithmic scale to specified columns. When applying log scale, it handles potentially negative data by ‘rectifying’ it based on its average sign and filters out any non-positive values after rectification. This filtering is applied sequentially, meaning filtering based on one column affects all others.
- Parameters:
*data (npt.NDArray[Any]) – A variable number of 1D NumPy arrays representing the data columns.
log_flags (Optional[Sequence[bool]]) – A sequence of booleans, one for each data array. If True, the corresponding array will be log-scaled. If None, no log scaling is applied. Defaults to None.
- Raises:
ValueError – If log_flags is provided but is not a list or tuple with the same length as the number of data arguments.
- Returns:
A tuple containing the processed 1D NumPy arrays. The number of arrays returned matches the number of input arrays.
- Return type:
Tuple[npt.NDArray[Any], …]
- MetaView._merge_ranges(ranges: Sequence[tuple[float, float]]) list[tuple[float, float]]¶
Merge overlapping or contiguous ranges.
- MetaView._parse_event_indices(indices: str, allow_floats: bool) list[tuple[float, float]]¶
Parse ‘7-10,12’ → [(7,10), (12,12)] If allow_floats=True, accepts ‘1.5-4.5,6’ → [(1.5, 4.5), (6.0, 6.0)]; otherwise every bound is parsed with int().
- MetaView._set_display_area_base(layout: QLayout) None¶
Create and set up the display area for the plot canvas.
- Parameters:
layout (QLayout) – The main layout to which the display area will be added.
- MetaView._set_progress_area(layout: QLayout) None¶
Initialize the area for progress bars within the control area.
- MetaView._setup_canvas(num_channels: int = 1) None¶
Set up the canvas with a given number of subplots corresponding to the number of channels.
- MetaView._setup_ui() None¶
Set up the user interface with a main layout containing a display area for the plot canvas and a control area for user interaction elements.
- MetaView._shift_ranges(ranges: Sequence[tuple[float, float]], direction: str, offset: float) list[tuple[float, float]]¶
Shift each tuple range left or right.
- MetaView._update_cache(*data_label_pairs: Sequence[Any]) None¶
Update the cache with an arbitrary number of (data, label) pairs.
- Parameters:
*data_label_pairs (Sequence[Any]) – Tuple(s) of (data, label)
- Raises:
ValueError – If any argument is not a tuple or list of 1 or 2 elements.