widgets#
Custom widgets for the ClearMap GUI.
This module provides reusable Qt widgets and compound controls used throughout the ClearMap graphical interface, including:
OrthoViewer— orthogonal slice viewer for 3-D images.ProgressWatcher— progress monitoring with log-file polling.TwoListSelection— dual-list item picker (available ↔ selected).CheckableListWidget— list with per-item checkboxes.DataFrameWidget— simple table display for pandas DataFrames.WizardWidget— base class for multi-step dialogs built from.uifiles.PatternDialog— file-pattern wizard for tiled acquisitions.SamplePickerDialog— experiment-folder picker with group support.LandmarksSelectorDialog— 3-D landmark selection for registration.StructurePickerWidget/StructureSelector— atlas region tree browser.PerfMonitor— CPU / RAM / GPU usage bars.ExtendableTabWidget— tab widget with an optional(+)button.FileDropListWidget— list that accepts file drag-and-drop.LandmarksWeightsPanel— slider panel for landmark weight tuning.GraphFilterList— AND/OR filter chain for graph properties.ComparisonsWidgetAdapter— group-comparison checkbox builder.GroupsWidgetAdapter— toolbox-based sample-group editor.NProcessesWidget— label + spin box forn_processes.BlockProcessingWidget— grouped controls for block-processing parameters.ClickableFrame— QFrame that emits aclickedsignal.
- class BlockProcessingWidget(parent=None, title: str = 'Block processing', with_overlap: bool = True, default_min: int = 1000000, default_max: int = 10000000)[source]#
Bases:
QGroupBox- Reusable UI for block_processing parameters:
size_min
size_max
overlap
n_processes
The internal controls are spinboxes. We expose properties with value()/setValue() style methods to play nice with ParamLink.
- property n_processes: int#
- property overlap: int | None#
- property size_max: int#
- property size_min: int#
- class CheckableListWidget(parent=None)[source]#
Bases:
QWidgetA list widget where each item has a checkbox.
- check_state_changed#
(index, checked, item_text).- Type:
Emitted when an item’s check state changes. Arguments
- class ClickableFrame[source]#
Bases:
QFrameA QFrame that emits a
clickedsignal on mouse press.- clicked#
Emitted on mouse press.
- class ComparisonsModel(group_names: List[str] = <factory>, selected: List[Tuple[str, str]]=<factory>, sep: str = ' vs ')[source]#
Bases:
object- group_names: List[str]#
- selected: List[Tuple[str, str]]#
- sep: str = ' vs '#
- class ComparisonsWidgetAdapter(layout, groups_sep: str = ' vs ')[source]#
Bases:
objectOwns and (re)builds the comparisons area. Exposes only high-level ops so GroupAnalysisParams doesn’t touch low-level widgetry.
- rebuild(model: ComparisonsModel, *, on_plot_group: Callable[[str], None], channels: List[str], on_channel_changed: Callable[[str], None], suffixes: List[str] = None, preselected_comparisons: List[Tuple[str, str]] | None = None) None[source]#
- selected_pairs(model: ComparisonsModel) List[Tuple[str, str]][source]#
- class DataFrameWidget(df, n_digits=2, parent=None)[source]#
Bases:
QWidgetA simple widget to display a pandas DataFrame
- class ExtendableTabWidget(parent=None, with_add_tab=True)[source]#
Bases:
QTabWidget- addTabClicked#
Emitted when the
(+)tab is clicked.
- channelChanged#
channel name.
- Type:
Emitted when a channel tab is clicked. Argument
- channelRenamed#
(old_name, new_name).- Type:
Emitted when a channel tab is renamed. Arguments
- property last_real_tab_idx#
- class FileDropListWidget(parent=None, plus_btn=None, minus_btn=None)[source]#
Bases:
QListWidget- itemsChanged#
Emitted when items are added or removed.
- class GraphFilterList(layout: QVBoxLayout, parent: QWidget | None = None)[source]#
Bases:
QWidgetA vertical list of graph-filter rows with AND/OR combiners between them.
Compatibility guarantees for
GraphFilterParams:The container layout is a
QVBoxLayoutnamed'filterParamsVerticalLayout'.Each filter row widget is named
'filter_{idx}'.Between row i and i+1 a
QFrameis inserted that contains twoQRadioButtoninstances named'filter_{i}_and_btn'(checked by default) and'filter_{i}_or_btn'.
- add_filter_row(*, title: str | None = None) QWidget[source]#
Add a new filter row. Returns the filter QWidget to pass to GraphFilterParams.
- filtersChanged#
Emitted when filters are added or modified.
- class GroupPage(*, ui_name: str = 'sample_group_controls.ui', start_folder_getter=<function GroupPage.<lambda>>)[source]#
Bases:
objectWrapper around one sample_group_controls.ui page.
- property name: str#
- property paths: List[str]#
- property widget: QWidget#
- class GroupsWidgetAdapter(*, toolbox: QToolBox, container_layout: QLayout, add_btn: QPushButton, remove_btn: QPushButton, start_folder_getter=<function GroupsWidgetAdapter.<lambda>>, groups_ui_file='sample_group_controls.ui')[source]#
Bases:
QWidget- ParamLink-compatible adapter:
owns a list[GroupPage] kept in the same order as the toolbox pages.
add/remove uses the provided buttons and QToolBox currentIndex.
set_value/get_value talk only dict[str, list[str]].
- add_group(name: str | None = None, paths: List[str] | None = None) int[source]#
Add a new (possibly empty) group and return its index.
- property group_names: list[str]#
- class LandmarksSelectorDialog(fixed_image_path, moving_image_path, fixed_image_landmarks_path, moving_image_landmarks_path, app=None)[source]#
Bases:
WizardWidgetA dialog to select landmarks in 3D space for registration The dialog allows to select landmarks in two views (fixed and moving) The landmarks are displayed in two 3D viewers with matching colors The dialog saves the landmarks to files for the fixed and moving images
- connect_buttons()[source]#
Connect the buttons to their slots. This method is called automatically in the constructor
- get_coords(img_type)[source]#
Get the coordinates of all the markers for the specified image type.
- Parameters:
img_type (str) – The type of the image (‘fixed_image’ or ‘moving_image’).
Returns
- np.ndarray
The array of marker coordinates.
- get_new_color()[source]#
Get a new color for a marker (not already used) .. rubric:: Returns
- str
The new color name
- plot(lut=None, parent=None)[source]#
Plot the 3D landmarks onto the fixed and moving images using data viewers.
- Parameters:
lut (str) – Lookup table for coloring the 3D plot.
parent (QWidget) – The parent widget for the plot.
- set_current_coords(x, y, z, img_type)[source]#
Set the coordinates for the specified image type.
- Parameters:
img_type (str) – The type of the image (‘fixed_image’ or ‘moving_image’).
x (float) – The x-coordinate.
y (float) – The y-coordinate.
z (float) – The z-coordinate.
- setup()[source]#
Setup the dialog after creation from the ui file. This method is called automatically in the constructor
- property colors#
Get the ordered list of colors of the markers
Returns
- list(str)
The markers colors
- property current_color#
Get the color of the currently selected marker
Returns
- str
The color of the currently selected marker
- property current_marker#
Get the index of the currently selected marker .. rubric:: Returns
int : the index of the currently selected marker
- class LandmarksWeightsPanel(parent: QWidget = None, value_to_model=None, model_to_value=None)[source]#
Bases:
QFrameCompact panel that renders one row per landmark-params file.
Each row contains a label, a 0–100 slider, and a value display.
Public API:
set_items()— rebuild rows from names and optional initial weights.get_weights()— return current slider values (0–100) as integers.set_weights()— set slider values without rebuilding rows.valueChangedConnect()— Qt-like hook for external binding.
Optional transforms can be supplied to map between slider value (0–100) and model value (float). Defaults are identity; keep scaling (e.g. exp) in the controller.
- get_params_and_weights() dict[str, int][source]#
Return current mapping of param file name to raw slider value (0..100).
- set_items(names: list[str], weights: list[int] | None = None) None[source]#
Rebuild rows for the given names; optionally seed slider positions.
- set_weights(weights: list[int]) None[source]#
Set weights without rebuilding rows (length must match).
- weightAtChanged#
(index, value).- Type:
Emitted when a single slider changes. Arguments
- weightsChanged#
full list of weights (0–100).
- Type:
Emitted when any slider changes. Argument
- class ManageAssetsWidget(src_folder, params, sample_manager, app=None)[source]#
Bases:
WizardWidget- action(action_name)[source]#
Perform the specified action on the selected assets. This will broadcast the action to the appropriate method of the sample manager
- Parameters:
action_name (str) – The name of the action to perform
- connect_buttons()[source]#
Connect the buttons to their slots. This method is called automatically in the constructor but should be implemented in the subclass
- handle_selection_changed(itm_text)[source]#
Handle the selection change in the list_selection widget. This will update the asset info text browser with the information of the selected asset
- Parameters:
itm_text (str) – The text of the selected item in the list_selection widget. This is a string representation of the asset type and channel, e.g. “(channel, asset_type)”
- prompt_params(action_name)[source]#
Create a new dialog to prompt the user for the additional parameters of the specified action
- Parameters:
action_name (str) – The name of the action to perform
Returns
- dict
The parameters to use for the action
- setup()[source]#
Setup the dialog after creation from the ui file. This method is called automatically in the constructor but should be implemented in the subclass
- property channel#
- property selected_asset_types#
- property selected_assets#
- class NProcessesWidget(parent: QWidget | None = None, label: str = 'n_processes')[source]#
Bases:
QWidgetSimple
n_processeswidget: label + spinbox.Exposes
value()/setValue()and avalueChangedsignal so it can be used transparently byParamLink.- valueChanged#
new value.
- Type:
Emitted when the spin box value changes. Argument
- class OrthoViewer(img=None, parent=None)[source]#
Bases:
objectOrthogonal viewer for 3D images.
This is a class that allows to visualize 3D images in 3 orthogonal views.
- plot_orthogonal_views(img=None, parent=None)[source]#
Plot the orthogonal views of the image.
- Parameters:
img (np.ndarray) – The image to plot. If None, the image set at initialization will be used.
parent (QWidget) – The parent widget to plot into. If None, the parent set at initialization will be used.
Returns
list of DataViewer
- setup(img, params, parent=None, no_scale=False)[source]#
Initialize the viewer after the object has been created.
- Parameters:
img (np.ndarray) – The 3D image to visualize.
params (UiParameter) – The parameters object.
parent (QWidget) – The parent widget.
no_scale (bool) – If True, disable coordinate scaling.
- update_ranges(ranges)[source]#
Update the ranges (min, max) for each axis of the viewer.
- Parameters:
ranges (list of tuple of float)
- property depth#
Get the depth of the image.
Returns
int
- property height#
Get the height of the image.
Returns
int
- property shape#
Get the shape of the image.
Returns
tuple of int
- property width#
Get the width of the image.
Returns
int
- class PatternDialog(src_folder, params, app=None, min_file_number=10, tile_extension='.ome.tif')[source]#
Bases:
WizardWidgetA wizard dialog to help the user define file patterns for a set of image file paths The dialog scans the source folder to find patterns in the file names and suggests them to the user there must be at least min_file_number files in the folder with the extension tile_extension to trigger the pattern search
- add_group()[source]#
Add a new group of widgets to the dialog This is a group of widgets to define a pattern for a set of image files (typically a channel)
- connect_buttons()[source]#
Connect the buttons to their slots. This method is called automatically in the constructor
- get_patterns() List[PatternFinder][source]#
Scan the current source folder to get the pattern finders for the image files
Non blocking to keep the UI responsive
Returns
- list(PatternFinder)
The pattern finders for the source folder
- get_results() List[ChannelPatternSpec][source]#
- get_widgets(image_group_id, axis)[source]#
Get the widgets (label, pattern and combo) for a given image group and axis
- Parameters:
image_group_id (int) – The index of the image group
axis (int) – The index of the axis
Returns
- tuple(QLabel, QLabel, QComboBox)
The label of the axis, pattern for the axis pattern and combobox containing the axis name (as a letter)
- setup()[source]#
Setup the dialog after creation from the ui file. This method is called automatically in the constructor
- validate_pattern()[source]#
Validate the pattern defined by the user and update the result widget The result is saved in the pattern_strings attribute for the current channel name
- min_file_number: int#
- n_image_groups: int#
- patterns_finders: List[PatternFinder]#
- tile_extension: str#
- class PerfMonitor(parent, fast_period, slow_period, *args, **kwargs)[source]#
Bases:
QWidget- cpu_vals_changed#
(cpu_percent, thread_percent, ram_percent).- Type:
Emitted when CPU values update. Arguments
- gpu_vals_changed#
(gpu_percent, vram_percent).- Type:
Emitted when GPU values update. Arguments
- percent_thread#
The percentage of the CPU used by the most active process of ClearMap
- class ProgressWatcher(max_progress=100, main_max_progress=1, timer_interval_ms=250, parent=None)[source]#
Bases:
QWidgetA QWidget that watches the progress of a process.
It uses signals to update the progress bar and the text. The main setup methods are
setup()andprepare_for_substep(). It is meant to be used in conjunction with a progress dialog to which it is connected through its signals.- count_dones()[source]#
Parse the logs to extract the number of completed operations (based on
self.pattern). For each match, the progress is incremented by 1. For efficiency, the logs are read from the last read position.Returns
- int
The cumulative number of matched operations.
- increment(increment)[source]#
Increment the progress value of the current main or sub step.
- Parameters:
increment (int or float) – The increment value. If float, it is considered as a fraction of the maximum progress value.
- increment_main_progress(increment=1)[source]#
Integer increment of the main progress.
- Parameters:
increment (int) – The increment value (default is 1).
- prepare_for_substep(step_length, pattern, step_name)[source]#
Setup the watcher for a new substep.
- Parameters:
step_length (int) – The number of steps in the operation.
pattern (str or re.Pattern or tuple or None) – The text to look for in the logs to check for progress.
step_name (str) – Name (title) of the substep.
- set_main_progress(value)[source]#
Set the progress value for the main step.
- Parameters:
value (int) – The progress value.
- set_progress(value)[source]#
Set the progress value of the current main or sub step.
- Parameters:
value (int) – The progress value.
- setup(main_step_name, main_step_length, sub_step_length=0, pattern=None)[source]#
Post-initialisation setup.
- Parameters:
main_step_name (str) – Title of the main processing step.
main_step_length (int) – Total number of main steps.
sub_step_length (int) – Total number of sub-steps within the current main step.
pattern (str or re.Pattern or tuple or None) – Text pattern to search for in logs to detect progress increments.
- aborted#
whether abort was confirmed.
- Type:
Emitted when processing is aborted. Argument
- finished#
main step name.
- Type:
Emitted when all processing has finished. Argument
- main_max_changed#
new maximum.
- Type:
Emitted when the main progress maximum changes. Argument
- property main_max_progress#
Current main-step maximum.
- main_progress_changed#
current value.
- Type:
Emitted when the main progress value changes. Argument
- property main_step_name#
Current main step name.
- main_step_name_changed#
step name.
- Type:
Emitted when the main step name changes. Argument
- max_changed#
new maximum.
- Type:
Emitted when the sub-step progress maximum changes. Argument
- property max_progress#
Current sub-step maximum.
- progress_changed#
current value.
- Type:
Emitted when the sub-step progress value changes. Argument
- property sub_step_name#
Current sub-step name.
- sub_step_name_changed#
step name.
- Type:
Emitted when the sub-step name changes. Argument
- class SamplePickerDialog(src_folder, params, app=None)[source]#
Bases:
WizardWidgetA dialog to help the user pick the sample folders from a source folder. The dialog scans the source folder to find the sample folders based on the presence of a sample_params.cfg file The results are displayed in two lists. The user can move the sample folders from the left (available items) list to the right (selected items) list. The samples can be split into groups to allow for different processing of the groups.
- connect_buttons()[source]#
Connect the buttons to their slots. This method is called automatically in the constructor
- class StructurePickerWidget(parent=None, json_base_name='ABA json 2022')[source]#
Bases:
QTreeWidget- DARK_COLOR = '#2E3436'#
- LIGHT_COLOR = 'white'#
- class StructureSelector(app=None)[source]#
Bases:
WizardWidget- connect_buttons()[source]#
Connect the buttons to their slots. This method is called automatically in the constructor but should be implemented in the subclass
- class TwoListSelection(parent=None, input_title=None, output_title=None)[source]#
Bases:
QWidgetA widget that allows to select items from a list and move them to another list.
This is useful for selecting items from a list of available items and moving them to a list of selected items.
- addAvailableItems(items)[source]#
Add the list of available items to the left list.
- Parameters:
items (list) – The list of items to add. Each element can be a string or a
(text, user_data)tuple.
- get_left_elements(with_data=False)[source]#
Get the list of items in the left list (available items).
Returns
list of str
- get_right_elements(with_data=False)[source]#
Get the list of items in the right list (selected items).
Returns
list of str
- setSelectedItems(items)[source]#
Add the list of selected items to the right list.
- Parameters:
items (list) – The list of items to add.
- itemSelectionChanged#
item text.
- Type:
Emitted when a single item is selected in either list. Argument
- class WizardWidget(ui_name, ui_title, src_folder='', params=None, app=None, size=None, patch_parent_class='QDialog')[source]#
Bases:
objectA base class for a complex dialogs designed with QT creator and exported as ui files. It is meant to be subclassed. The subclass should implement the setup and connect_buttons methods This class needs a src_folder, a ui_name, a ui_title. The ui names and titles are used to build a dialog from the ui file of the same name and parametrise the dialog
- static enable_widgets(widgets)[source]#
Helper method to enable a list of widgets
- Parameters:
widgets (list(QWidget)) – The list of widgets to enable
- static hide_widgets(widgets)[source]#
Helper method to hide a list of widgets
- Parameters:
widgets (list(QWidget)) – The list of widgets to hide