dcp_client.gui package

Submodules

dcp_client.gui.main_window module

class dcp_client.gui.main_window.MainWindow(app: Application)

Bases: MyWidget

Main Window Widget object. Opens the main window of the app where selected images in both directories are listed. User can view the images, train the model to get the labels, and visualise the result.

clear_image_caches() None

Clears the image caches from all file system models. This should be called after new segmentations are created to force the views to reload and overlay the new segmentations.

main_window() None

Sets up the GUI

on_extract_features_clicked() None

Opens the extract features dialog.

on_finished(result: tuple) None

Is called once the worker thread emits the on finished signal.

Parameters:

result (tuple) – The result emitted by the worker thread. See return type of WorkerThread.run

on_item_eval_double_clicked(item: QModelIndex) None

Is called once an image is double-clicked in the ‘uncurated dataset’ folder. Launches the napari viewer immediately.

Parameters:

item (QModelIndex) – The selected item from the ‘uncurated dataset’ folder.

on_item_eval_selected(item: QModelIndex) None

Is called once an image is selected in the ‘uncurated dataset’ folder.

Parameters:

item (QModelIndex) – The selected item from the ‘uncurated dataset’ folder.

on_item_inprogr_double_clicked(item: QModelIndex) None

Is called once an image is double-clicked in the ‘in progress’ folder. Launches the napari viewer immediately.

Parameters:

item (QModelIndex) – The selected item from the ‘in progress’ folder.

on_item_inprogr_selected(item: QModelIndex) None

Is called once an image is selected in the ‘in progress’ folder.

Parameters:

item (QModelIndex) – The selected item from the ‘in progress’ folder.

on_item_train_double_clicked(item: QModelIndex) None

Is called once an image is double-clicked in the ‘curated dataset’ folder. Launches the napari viewer immediately.

Parameters:

item (QModelIndex) – The selected item from the ‘curated dataset’ folder.

on_item_train_selected(item: QModelIndex) None

Is called once an image is selected in the ‘curated dataset’ folder.

Parameters:

item (QModelIndex) – The selected item from the ‘curated dataset’ folder.

on_launch_napari_button_clicked()

Launches the napari window after the image is selected.

on_progress_updated(current: int, total: int) None

Updates the progress bar based on the number of images segmented.

Parameters:
  • current (int) – Number of images processed so far.

  • total (int) – Total number of images to process.

on_run_inference_button_clicked() None

Is called once user clicks the “Generate Labels” button.

class dcp_client.gui.main_window.WorkerThread(app: Application, task: str = None, parent=None, skip_images=None)

Bases: QThread

Worker thread for displaying Pulse ProgressBar during model serving.

on_progress(current: int, total: int) None

Callback to emit progress updates.

Parameters:
  • current (int) – Number of images processed so far.

  • total (int) – Total number of images to process.

progress_updated

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

run() None

Once run_inference or run_train is executed, the tuple of (message_text, message_title) will be returned to on_finished.

task_finished

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

dcp_client.gui.napari_window module

class dcp_client.gui.napari_window.NapariWindow(app: Application)

Bases: MyWidget

Napari Window Widget object. Opens the napari image viewer to view and fix the labeles. :param app: The Application instance. :type app: Application

adjust_window_size()

Resize Napari main window to 80% of available screen, centered.

axis_changed(event) None

Is triggered each time the user switches the viewer between the mask channels. At this point the class mask needs to be updated according to the changes made to the instance segmentation mask.

check_and_update_if_layers_changed(seg, class_mask_with_contour, seg_name_to_save)

Checks to see if changes have been made to the layers right before saving. Updates the masks if so. This function handles the case when e.g. user deletes an object from the instance mask and then directly tries to move the data to in progress. The class label needs to be updated with the change. :param seg: Current seg layers :type seg: List :param class_mask_with_contour: Class mask with contour added :type class_mask_with_contour: np.ndarray :param seg_name_to_save: Name of the segmentation layer user wants to save :type seg_name_to_save: str

closeEvent(event)

Properly close Napari viewer and all child widgets.

on_add_to_curated_button_clicked() None

Defines what happens when the “Move to curated dataset folder” button is clicked.

on_add_to_inprogress_button_clicked() None

Defines what happens when the “Move to curation in progress folder” button is clicked.

on_assisted_labelling(checked: bool) None

Triggered when the user toggles the Assisted labelling mode ON or OFF.

on_prompting_mode_changed(_id: int) None

Triggered when the user switches between ‘Boxes’ and ‘Points’.

on_remove_from_dataset_button_clicked() None

Defines what happens when the “Remove from dataset” button is clicked.

on_save_to_folder_clicked(save_folder, move_segs=False) None

Is called when either of the two buttons are clicked to save data to new folder :param save_folder: Indicates the directory where we wish to save the data :type save_folder: str :param move_segs: Indicates whether all labels layers found in same directory with the image should be moved too.

If we are moving to in_progress directory all segs are moved, otherwise only the one selected by the user.

on_seg_channel_changed(event) None

Is triggered each time the user selects a different layer in the viewer.

set_editable_mask() None

This function is not implemented. In theory the use can choose between which mask to edit. Currently painting and erasing is only possible on instance mask and in the class mask only the class labels can be changed.

switch_controls(target_widget: str, status: bool, info_message: str | None = None) None

Enables or disables a specific widget.

Parameters:
  • target_widget (str) – The name of the widget to be controlled within the QCtrl object.

  • status (bool) – If True, the widget will be enabled; if False, it will be disabled.

  • info_message (str or None) – Optionally add an info message when hovering over some widget. Default is None.

switch_to_instance_mask() None

Switch the application to the active mask mode by enabling ‘paint_button’, ‘erase_button’ and ‘fill_button’.

switch_to_labels_mask() None

Switch the application to non-active mask mode by enabling ‘fill_button’ and disabling ‘paint_button’ and ‘erase_button’.

update_instance_mask(instance_mask: ndarray, labels_mask: ndarray) None

Updates the instance mask based on changes in the labels mask.

If the labels mask has changed, but only if an object has been removed, the instance mask is updated accordingly.

Parameters:
  • instance_mask (numpy.ndarray) – The existing instance mask, which needs to be updated.

  • labels_mask (numpy.ndarray) – The updated labels mask, changed by the user.

update_labels_mask(instance_mask: ndarray) None

Updates the class mask based on changes in the instance mask.

If the instance mask has changed since the last switch between channels, the class mask needs to be updated accordingly.

Parameters:

instance_mask (numpy.ndarray) – The updated instance mask, changed by the user.

Returns:

None

dcp_client.gui.welcome_window module

class dcp_client.gui.welcome_window.WelcomeWindow(app: Application)

Bases: MyWidget

Welcome Window Widget object. The first window of the application providing a dialog that allows users to select directories. Currently supported image file types that can be selected for segmentation are: .jpg, .jpeg, .png, .tiff, .tif. By clicking ‘start’ the MainWindow is called.

browse_eval_clicked() None

Activates when the user clicks the button to choose the evaluation directory (QFileDialog) and displays the name of the evaluation directory chosen in the validation textbox line (QLineEdit).

browse_inprogr_clicked()

Activates when the user clicks the button to choose the curation in progress directory (QFileDialog) and displays the name of the evaluation directory chosen in the validation textbox line (QLineEdit).

browse_train_clicked() None

Activates when the user clicks the button to choose the train directory (QFileDialog) and displays the name of the train directory chosen in the train textbox line (QLineEdit).

eventFilter(obj, event)

Event filter to capture double-click events on QLineEdit widgets

on_text_changed(field_obj: QLineEdit, field_name: str, text: str) None

Update data paths based on text changes in input fields. Used for copying paths in the welcome window.

Parameters:
  • field_obj (QLineEdit) – The QLineEdit object.

  • field_name (str) – The name of the data field being updated.

  • text (str) – The updated text.

start_main() None

Starts the main window after the user clicks ‘Start’ and only if both evaluation and train directories are chosen and all unique.