populse_mia.user_interface.data_viewer package

Handle the data viewer tab, for advanced visualisation (in 2D and 3D modes, overlay, etc.) of volumetric medical data.

Contains:
Module:
  • anatomist

  • anatomist_2

  • data_viewer

  • data_viewer_tab

Subpackages

Submodules

populse_mia.user_interface.data_viewer.data_viewer module

This module provides an abstract base class for data viewer implemenataions in populse_mia.

Data viewers are supposed to inherit DataViewer and implement (at least) its methods. A data viewer is given a project and documents list, and is thus allowed to access databasing features and documents attributes.

Coding a data viewer

A data viewer is identified after its module name, and is currently searched for as a submodule of populse_mia.user_interface.data_viewer. The data viewer module may be implemented as a “regular” module (.py file) or a package (directory) and should contain at least a class named MiaViewer which:

  • is a Qt QWidget (inherits QWidget as 1st inheritance as is required by Qt)

  • implements the DataViewer API (normally by inheriting it as second inheritance after QWidget but this is not technically required if the API is implemented)

class populse_mia.user_interface.data_viewer.data_viewer.DataViewer[source]

Bases: ABC, QWidget

An abstract base class for data viewers with a minimal, extensible API.

This class defines a standard interface for data viewers, allowing subclasses to implement custom visualization strategies. The base methods provide a simple contract for managing and displaying documents across different viewer implementations.

The API is intentionally kept simple to provide flexibility for specific use cases while ensuring a consistent basic functionality.

clear()[source]

Remove all currently displayed files.

This method provides a default implementation that removes all files currently being displayed by calling remove_files().

close()[source]

Close the viewer by clearing all displayed files.

This method provides a standard way to clean up and close the viewer, ensuring all resources are released.

abstract display_files(files)[source]

Display the specified document files.

This method must be implemented by subclasses to define how files are visually presented or loaded.

Parameters:

(List) (files) – A list of files to be displayed.

Raises:

NotImplementedError: If not overridden by a subclass.

abstract displayed_files()[source]

Retrieve the list of currently displayed files.

Return (list):

A list of files currently being displayed.

Raises:

NotImplementedError: If not overridden by a subclass.

abstract remove_files(files)[source]

Remove specified files from the display.

Parameters:

(list) (files) – A list of files to be removed from display.

Raises:

NotImplementedError: If not overridden by a subclass.

abstract set_documents(project, documents)[source]

Set the project context and available documents.

Parameters:
  • project – The project associated with the documents.

  • (list) (documents) – The list of available documents.

Raises:

NotImplementedError: If not overridden by a subclass.

class populse_mia.user_interface.data_viewer.data_viewer.MetaDataViewer(name, bases, namespace, /, **kwargs)[source]

Bases: wrappertype, ABCMeta

Custom metaclass that combines ABC and QWidget’s metaclasses.

populse_mia.user_interface.data_viewer.data_viewer_tab module

Populse_mia data viewer GUI interface (in the “Data Viewer” tab).

Contains:
Class:
  • DataViewerTab

class populse_mia.user_interface.data_viewer.data_viewer_tab.DataViewerTab(main_window)[source]

Bases: QWidget

A flexible and extensible widget for managing data viewers in a GUI application.

This widget provides a dynamic interface for loading and switching between different data viewers. Key features include: - Automatic discovery of viewers in the data_viewer directory - Graceful handling of viewer import failures - Ability to dynamically add new viewers - Centralized document and project management across viewers

__init__(main_window)[source]

Initialize the DataViewerTab with a reference to the main window.

Parameters:

(Qt.QMainWindow) (main_window) – The main application window providing context and potential shared resources.

activate_viewer(viewer_name)[source]

Activate a specific viewer by name.

Parameters:

(str) (viewer_name) – Name of the viewer to activate.

change_viewer()[source]

Handle viewer change event triggered by the combobox.

Retrieves the selected viewer, activates it, and ensures that the current project and documents are set.

clear()[source]

Clean up and close all loaded viewers.

Called before closing the application to ensure proper resource management.

closeEvent(event)[source]

Override close event to ensure proper cleanup.

Parameters:

(QCloseEvent) (event) – Close event triggered by the window system.

current_viewer()[source]

Retrieve the name of the currently active viewer.

Return (str):

Name of the current viewer, either from the current viewer tracking or the combobox selection.

load_viewer(viewer_name=None)[source]

Dynamically load viewers from the data_viewer directory.

Attempts to import and initialize viewers, handling import failures gracefully.

Parameters:

(str) (viewer_name) – Specific viewer to load. If None, discovers all viewers.

set_documents(project, documents)[source]

Distribute project and document information to the current viewer.

Parameters:
  • project – The entire project context.

  • (list) (documents) – List of document/image objects in the project.