tabs_interfaces#

This module contains the interfaces to the different tabs and dialogs in the ClearMap GUI.

class BatchTab(main_window: QMainWindow, tab_idx: int)[source]#

Bases: GroupTab

create_wizard() SamplePickerDialog[source]#
setup_results_folder() None[source]#
property initialised: bool#
class ExperimentTab(main_window: QMainWindow, ui_file_name: str, tab_idx: int, name: str = '')[source]#

Bases: GenericTab

reconcile_channel_pages(desired_channels: list[str]) None[source]#

Update the configuration for the channels and the associated page widgets

Parameters:

desired_channels (list[str]) – The list of channels that should be present

set_controller(controller: ExperimentController) None[source]#
set_params(sample_params: SampleParameters | None = None) None[source]#

Set the params object which links the UI and the configuration file

setup_sample_manager(sample_manager: SampleManager) None[source]#
property exp_controller: ExperimentController#

The experiment controller for this tab.

Raises:

RuntimeError – If accessed before set_controller() has been called.

property sample_manager: SampleManager#

The sample manager for this tab.

Raises:

RuntimeError – If accessed before setup_sample_manager() has been called.

sample_params: SampleParameters | None#
class GenericDialog(main_window, name: str, file_name: str)[source]#

Bases: GenericUi

Interface to any dialog associated with parameters

set_params(*args) None[source]#

Set the params object which links the UI and the configuration file

class GenericTab(main_window: ClearMapApp, ui_file_name: str, tab_idx: int, name: str = '')[source]#

Bases: GenericUi, BusSubscriberMixin

The interface to all tab managers. A tab manager includes a tab widget, the associated parameters and an optional processor object which handles the computations.

classmethod get_tab_name() str[source]#
classmethod requirements_fulfilled(sample_manager) bool[source]#

Whether this tab may be shown for the current sample_manager state.

static ui_plot(status_msg: str = '') Callable[source]#

Decorator for tab methods that produce plot widgets.

Handles:

  • Status message display.

  • Clearing previous plots.

  • MissingRequirementException / PlotGraphError.

  • (dvs, titles) tuple return pattern.

  • setup_plots() call.

  • Filtering return to DataViewer instances only.

Parameters:

status_msg (str, optional) – Status message to display during plotting (default: '').

Returns

Callable

Decorated function that wraps plot logic with error handling and setup.

Examples

@GenericTab.ui_plot("Plotting p-values…")
def plot_p_vals(self, ...):
    # pure plotting logic
    return [widget1, widget2]
add_channel_tab(channel: str = '') None[source]#

Add a tab for a specific channel. This should then call the connect_channel method to set up the tab bindings.

Hint

This method is meant to be used for tab with channels. To use it ensure that your tab has a channelsParamsTabWidget attribute and set channels_ui_name to the name of the UI file for the channel tabs.

connect_whats_this_btn(info_btn: QToolButton, whats_this_ctrl: QWidget)[source]#

Utility function to bind the info button to the display of the detailed whatsThis message of whats_this_control

Parameters:
  • info_btn (QToolButton) – The button to display the info

  • whats_this_ctrl (QWidget) – The control to display the info for (it should have a whatsThis message)

disable() None[source]#

Disable this tab (UI element)

final finalise_set_params() None[source]#
finalise_workers_setup() None[source]#

Finalise the setup of the workers. Typically called when the tab is selected

get_channel_ui(channel: str) QWidget | None[source]#

Get the UI widget for a specific channel

handle_advanced_checked() None[source]#

Activate the advanced mode which will display more controls

final notify_selected() None[source]#

Notify that the tab has been selected (i.e. clicked on). It will also store that the tab has been selected at least once

on_selected() None[source]#

Called when this tab is selected; override in subclasses if needed.

remove_channel_tab(channel: str) None[source]#

Wrapper so removal always triggers the hook.

set_advanced_controls_visibility(visible: bool) None[source]#

Set the visibility of the advanced controls

Parameters:

visible (bool) – Whether to show the advanced controls

set_params(sample_params: SampleParameters | None = None) None[source]#

Set the params object which links the UI and the configuration file

setup() None[source]#

Setup more advanced features of the UI, notably the callbacks

step_exists(step_name: str, file_list: list[str | Path] | str | Path) bool[source]#

Check that prerequisite step step_name has been run and produced the outputs in file_list

Parameters:
  • step_name (str) – The name of the step

  • file_list (list[str] | list[Path] | str | Path) – The list of files that should have been produced by the step

Returns

bool

Whether the step has been run

wrap_plot(plot_method: Callable[P, Any], *args: P.args, **kwargs: P.kwargs) list[DataViewer][source]#

Wrapper to plot a graph and display it in the main window. It also handles ClearMap exceptions gracefully

Parameters:
  • plot_method (function) – The function (or method) to plot the graph

  • args (list) – The positional arguments to plot_function

  • kwargs (dict) – The keyword arguments to plot_function

Returns

list[DataViewer]

The data viewers returned by plot_function

wrap_step(task_name: str, func: Callable, step_args: list[Any] | None = None, step_kw_args: dict[str, Any] | None = None, n_steps: int = 1, abort_func: Callable | None = None, bypass_exceptions: Tuple[Exception] | None = None, save_cfg: bool = True, nested: bool = True, close_when_done: bool = True, main_thread: bool = False) None[source]#

Start a new thread (unless main_thread = True) for func and show a progress dialog. Ensures that the UI remains responsive.

Parameters:
  • task_name (str) – The name of the task to be displayed

  • func (Callable) – The function to run

  • step_args (list[Any] | None) – The positional arguments to func

  • step_kw_args (dict[str, Any] | None) – The keyword arguments to func

  • n_steps (int) – The number of top level steps in the computation. This will be disabled if nested is False.

  • abort_func (Callable | None) – The function to trigger to abort the execution of the computation (bound to the abort button)

  • bypass_exceptions (Tuple[Exception] | None) – A tuple of exception types to bypass the GUI exception handling for. Defaults to empty.

  • save_cfg (bool) – Whether to save the configuration to disk before running the computation. This is usually the right choice to ensure that the config reloaded by func is up to date.

  • nested (bool) – Whether the computation has 2 levels of progress

  • close_when_done (bool) – Close the progress dialog when func has finished executing

  • main_thread (bool) – Whether to run in the main thread. Default is False to ensure that the UI thread remains responsive, a new thread will be spawned.

advanced_controls_names: list[str]#
channels_ui_name: str = ''#
inited: bool#
minimum_width: int#
params_set: bool#
processing_type: str | None = None#
requirements = TabRequirements(needs_workspace=False, needs_channels=False)#
setup_complete: bool#
tab_idx: int#
with_add_btn: bool = False#
class GenericUi(main_window: QMainWindow, ui_file_name: str, name: str, widget_class_name: str)[source]#

Bases: object

The first layer of interface. This is not implemented directly but is the base class of GenericTab and GenericDialog, themselves interfaces

set_params(*args) None[source]#

Set the params object which links the UI and the configuration file

setup() None[source]#

Setup more advanced features of the UI, notably the callbacks

main_window: QMainWindow#
name: str#
params: UiParameter | UiParameterCollection | None#
ui: QWidget | None#
ui_file_name: str#
widget_class_name: str#
class GroupTab(main_window: QMainWindow, ui_file_name: str, tab_idx: int, name: str = '')[source]#

Bases: GenericTab

set_controller(controller: AnalysisGroupController) None[source]#
config_handler: ConfigHandler | None#
group_controller: AnalysisGroupController | None#
processing_type = 'group'#
class PipelineTab(main_window: QMainWindow, ui_file_name: str, tab_idx: int, name: str = '')[source]#

Bases: ExperimentTab, Generic[TWorker]

Introduces the TWorker TypeVar into the hierarchy. Concrete subclasses bind it:

class CellCounterTab(PostProcessingTab[CellDetector]): ...
classmethod requirements_fulfilled(sample_manager) bool[source]#

Whether this tab may be shown for the current sample_manager state.

setup_sample_manager(sample_manager: SampleManager) None[source]#

Associate the sample_manager to the current tab

Parameters:

sample_manager (SampleManager) – The object that handles the sample data

pipeline_name: str = ''#
processing_type = ''#
requirements = TabRequirements(needs_workspace=True, needs_channels=True)#
workers_are_global: bool = False#
class PostProcessingTab(main_window: QMainWindow, ui_file_name: str, tab_idx: int, name: str = '')[source]#

Bases: PipelineTab[TWorker]

Interface to all the tab managers in charge of post-processing the data. One particularity of a post-processing tab manager is that it includes the corresponding pre-processor. A tab manager includes a tab widget, the associated parameters and potentially a processor object which handles the computations.

create_tuning_sample(channel: str) None[source]#

Create an array from a subset of the sample to perform tests on

debug_mode(channel: str, debug_status: str | bool)[source]#
get_worker(channel: str | tuple[str, str] | None = None, substep: str | None = None) TWorker[source]#

Retrieve the worker for the given channel / substep combination.

Raises:
  • ValueError – If substep is inconsistent with _workers_sub_steps.

  • RuntimeError – If no worker is found (setup not complete).

plot_slicer(slicer_prefix: str, tab: QWidget, params: OrthoviewerSlicingMixin, channel: str | list[str]) None[source]#

Display the ortho-slicer to pick a subset of 3D data. This is typically used to create a small dataset to evaluate parameters for long-running operations before analysing the whole sample

Parameters:
  • slicer_prefix

  • tab

  • params

processing_type = 'post'#
class PreProcessingTab(main_window: QMainWindow, ui_file_name: str, tab_idx: int, name: str = '')[source]#

Bases: PipelineTab[TWorker]

processing_type = 'pre'#
property worker: TWorker#

The single global worker for this pipeline step.

Raises:

RuntimeError – If the worker has not yet been created (call _setup_workers first).

workers_are_global = True#
class TabRequirements(needs_workspace: 'bool' = False, needs_channels: 'bool' = False)[source]#

Bases: object

needs_channels: bool = False#
needs_workspace: bool = False#
channel_is_compound(channel) bool[source]#