widgets#

A set of custom widgets for the ClearMap GUI

class DataFrameWidget(df, n_digits=2, parent=None)[source]#

Bases: QWidget

A simple widget to display a pandas DataFrame

class LandmarksSelectorDialog(app=None)[source]#

Bases: WizardDialog

A 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

add_marker()[source]#
connect_buttons()[source]#

Connect the buttons to their slots. This method is called automatically in the constructor

get_new_color()[source]#
remove_marker()[source]#
set_fixed_coords(x, y, z)[source]#
set_moving_coords(x, y, z)[source]#
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

property fixed_coords#
property moving_coords#
class OrthoViewer(img=None, parent=None)[source]#

Bases: object

Orthogonal viewer for 3D images

This is a class that allows to visualize 3D images in 3 orthogonal views.

add_regions()[source]#

Add the regions to the viewer

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(DataViewer)

setup(img, params, parent=None)[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

Returns

update_ranges(ranges)[source]#

Update the ranges (min, max) for each axis of the viewer

Parameters:

ranges (list(tuple(float, 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(int, int, 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: WizardDialog

A 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()[source]#

Scan the current source folder to get the pattern finders for the image files

Returns

list(PatternFinder)

The pattern finders for the source folder

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)

save_results()[source]#

Save the file patterns to the sample configuration file and close the dialog

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

class PerfMonitor(parent, fast_period, slow_period, *args, **kwargs)[source]#

Bases: QWidget

get_cpu_percent()[source]#
get_ram_percent()[source]#
get_thread_percent()[source]#
handle_gpu_vals_updated()[source]#
handle_proc_changed(file_path)[source]#
start()[source]#
stop()[source]#
update_cpu_values()[source]#
update_gpu_values()[source]#
cpu_vals_changed#
gpu_vals_changed#
percent_thread#

The percentage of the CPU used by the most active process of ClearMap

class ProgressWatcher(max_progress=100, main_max_progress=1, parent=None)[source]#

Bases: QWidget

A 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 and prepare_for_substep It is meant to be used in conjunction with a ProgressWatcherDialog to which it is connected through its signals

count_dones()[source]#

Parse the logs to extract the number of done operations (based on self.pattern) For each done operation, the progress is incremented by 1 For efficiency, the logs are read from the last read position

Returns

int

The number of done operations found

finish()[source]#

Trigger the finish signal

get_progress()[source]#

Get the current progress

Returns

int

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 percentage 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_name – str

  • step_length – int The number of steps in the operation

  • pattern – str or re.Pattern or (str, re.Pattern) the text to look for in the logs to check for progress

reset()[source]#

Reset all the values to their initial state

Returns

reset_log_length()[source]#

Resets dones to 0 and seeks to the end of the log file

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 of the

Parameters:
  • main_step_name

  • main_step_length

  • sub_step_length

  • pattern

Returns

aborted#
finished#
main_max_changed#
property main_max_progress#
main_progress_changed#
property main_step_name#
main_step_name_changed#
max_changed#
property max_progress#
progress_changed#
property sub_step_name#
sub_step_name_changed#
class SamplePickerDialog(src_folder, params, app=None)[source]#

Bases: WizardDialog

A 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

parse_sample_folders()[source]#

Scan the source folder to find the sample folders based on the presence of a sample_params.cfg file (skip config_snapshots folders)

Returns

list(str)

The list of sample folders

setup()[source]#

Setup the dialog after creation from the ui file. This method is called automatically in the constructor

class StructurePickerWidget(parent=None)[source]#

Bases: QTreeWidget

static build_tree(tree=None, parent=None)[source]#
static parse_json()[source]#
print_id(itm, col)[source]#
DARK_COLOR = '#2E3436'#
LIGHT_COLOR = 'white'#
class StructureSelector(app=None)[source]#

Bases: WizardDialog

close()[source]#
connect_buttons()[source]#

Connect the buttons to their slots. This method is called automatically in the constructor but should be implemented in the subclass

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

show()[source]#
class TwoListSelection(parent=None)[source]#

Bases: QWidget

A 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(str)) – The list of items to add

get_left_elements()[source]#

Get the list of items in the left list (available items)

Returns

list(str)

get_right_elements()[source]#

Get the list of items in the right list (selected items)

Returns

list(str)

setSelectedItems(items)[source]#

Add the list of selected items to the right list :param items: The list of items to add :type items: list(str)

update_buttons_status()[source]#
class WizardDialog(ui_name, ui_title, src_folder='', params=None, app=None, size=None)[source]#

Bases: object

A 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

connect_buttons()[source]#

Connect the buttons to their slots. This method is called automatically in the constructor but should be implemented in the subclass

static enable_widgets(widgets)[source]#

Helper method to enable a list of widgets

Parameters:

widgets (list(QWidget)) – The list of widgets to enable

exec()[source]#

Execute the dialog

static hide_widgets(widgets)[source]#

Helper method to hide a list of widgets

Parameters:

widgets (list(QWidget)) – The list of widgets to hide

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

setup_mini_brain(mini_brain_scaling=(5, 5, 5))[source]#

Create a downsampled version of the Allen Brain Atlas for the mini brain widget

Parameters:

mini_brain_scaling (tuple(int, int, int)) – The scaling factors for the mini brain. Default is (5, 5, 5)

Returns

tuple(scale, downsampled_array)