populse_mia.user_interface.pipeline_manager package¶
Handle the pipeline manager tab. Allow to create and run pipelines.
- Contains:
- Module:
iteration_table
node_controller
pipeline_editor
pipeline_manager_tab
process_library
process_mia
type_editors
Submodules¶
populse_mia.user_interface.pipeline_manager.iteration_table module¶
Module that handles pipeline iteration.
- Contains:
- Class:
IterationTable
- class populse_mia.user_interface.pipeline_manager.iteration_table.IterationTable(project, scan_list=None, main_window=None)[source]¶
Bases:
QWidgetWidget that handles pipeline iteration.
This widget allows users to select tags for iteration and visualization, filter values, and manage the iteration process for pipeline execution.
- __init__(project, scan_list=None, main_window=None)[source]¶
Initialize the IterationTable widget.
- Parameters:
project – Current project in the software.
scan_list – List of the selected database files. If None, all documents from the current collection will be used.
main_window – Software’s main window reference.
- fill_values(idx)[source]¶
Fill values_list with unique tag values for the specified tag.
- Parameters:
(int) (idx) – Index of the tag in push_buttons list.
- iteration_table_updated¶
pyqtSignal(*types, name: str = …, revision: 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.
- refresh_layout()[source]¶
Update the layout of the widget.
Called in widget’s initialization and when a tag push button is added or removed.
- select_visualized_tag(idx)[source]¶
Open a dialog to select which tag to visualize in the iteration table.
- Parameters:
(int) (idx) – Index of the clicked push button.
- update_iterated_tag(tag_name=None)[source]¶
Update the widget when the iterated tag is modified.
- Parameters:
(str) (tag_name) – Name of the iterated tag.
- update_selected_tag(selected_tag)[source]¶
Update the lists of values corresponding to the selected tag.
Retrieves all unique values of the selected tag from scans in the current collection that also exist in the scan list. Then updates the tag value lists in the current pipeline editor.
- Parameters:
(str) (selected_tag) – The tag whose values should be retrieved and updated.
populse_mia.user_interface.pipeline_manager.node_controller module¶
Pipeline Node Management and Filtering Module
This module provides a collection of Qt-based widgets and controllers for managing pipeline nodes, filtering database entries, and assigning values to node plugs in a data processing workflow. It is designed to integrate with a pipeline editor, enabling users to:
View and edit node parameters, including inputs, outputs, and attributes.
Filter and select database entries (e.g., scans, files) for assignment to pipeline nodes.
Apply advanced search and tag-based filtering to refine selections.
Handle undo/redo operations for parameter changes and node renaming.
Manage subprocesses and context names for hierarchical pipelines.
The module is built on top of Qt and Capsul, leveraging custom widgets like AttributedProcessWidget and TableDataBrowser to provide a user-friendly interface for complex pipeline interactions.
- Contains:
- Class:
PlugFilter (must be declared before AttributesFilter)
AttributesFilter
CapsulNodeController
FilterWidget
NodeController
- class populse_mia.user_interface.pipeline_manager.node_controller.AttributesFilter(project, scans_list, process, node_name, plug_name, node_controller, main_window)[source]¶
Bases:
PlugFilterA specialized widget for filtering database entries and collecting their attributes.
This widget extends PlugFilter to provide a user-friendly interface for filtering files using both rapid and advanced search tools. It allows users to:
Filter database entries based on customizable criteria.
Select specific rows or use the entire filtered dataset.
Collect attributes from the selected or filtered entries.
Emit the collected attributes as a structured dictionary for further processing.
The collected attributes are organized into a dictionary where each key represents an attribute name, and the corresponding value is a list of all values for that attribute across the selected or filtered entries.
- attributes_selected¶
pyqtSignal(*types, name: str = …, revision: 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.
- ok_clicked()[source]¶
Close the widget and emit the collected attributes.
If rows are selected in the table, attributes are collected only from those rows. Otherwise, attributes are collected from all entries matching the current filter. The resulting attributes are grouped by field name and emitted via the
attributes_selectedsignal.
- class populse_mia.user_interface.pipeline_manager.node_controller.CapsulNodeController(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Bases:
QWidgetA PyQt widget for managing and editing pipeline node parameters using Capsul’s AttributedProcessWidget.
This controller provides a user interface for interacting with pipeline nodes, enabling users to:
View and modify node parameters using Capsul’s AttributedProcessWidget.
Rename nodes and update the pipeline accordingly.
Filter and manage node attributes.
Handle undo/redo operations for parameter changes.
Recursively rename subprocesses and adjust context names.
The widget is designed to integrate with a pipeline editor, providing real-time updates and synchronization between the UI and the underlying pipeline state.
- __init__(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Initialize the node controller.
- Parameters:
project – Current project instance.
scan_list – List of available scans.
pipeline_manager_tab – Parent pipeline manager tab.
- Parammain_window:
Main application window.
- display_parameters(node_name, process, pipeline)[source]¶
Display the parameters of the selected node.
Creates and displays widgets for all node parameters, including line edits, labels, and control buttons. Handles special cases for pipeline inputs/outputs nodes.
- Parameters:
(str) (node_name) – Name of the node to display.
process – Process instance associated with the node.
pipeline – Current pipeline containing the node.
- filter_attributes()[source]¶
Display the attributes filter dialog.
Opens a popup widget that allows users to filter and select attributes for the current process node.
- parameters_changed(_, plug_name, old_value, new_value)[source]¶
Handle parameter value changes and emit signal.
- Parameters:
_ – Unused parameter (object instance).
(str) (plug_name) – Name of the changed parameter.
old_value – Previous parameter value.
new_value – New parameter value.
- rename_subprocesses(node, parent_node_name)[source]¶
Recursively rename subprocesses within the pipeline, adjusting the context name.
This method checks if the process is part of a pipeline and modifies its context name accordingly. If the process name contains a hierarchy of at least three levels, the context name is updated with the parent node name and the remaining parts of the context name. If the process is a pipeline node, the method is called recursively for each subprocess.
- Parameters:
node – The current node being processed.
(str) (parent_node_name) – The name of the parent node to be included in the context name.
- static static_release(process, param_changed)[source]¶
Remove trait change notification from process.
- Parameters:
process – Process instance to remove notification from.
param_changed – Callback function to remove.
- update_attributes_from_filter(attributes)[source]¶
Apply selected attributes from the filter widget.
Updates the process completion engine attributes based on user selection from the filter dialog. Shows a warning if no matching attributes are found.
- Parameters:
(dict) (attributes) – Dictionary of attribute names and values to apply.
- update_node_name(new_node_name=None, old_node_name=None, from_undo=False, from_redo=False)[source]¶
Change the name of the selected node and update the pipeline.
Renames the node in the pipeline dictionary and updates all associated links. For iterated processes, ensures the name starts with “iterated_”.
- Parameters:
(str) (old_node_name) – New name for the node. If None (when this method is not called from an undo/redo), reads from the line edit widget.
(str) – Current node name. If None (when this method is not called from an undo/redo), uses self.node_name.
(bool) (from_redo) – True if this action is from an undo operation.
(bool) – True ifthis action is from a redo operation.
- update_parameters(process=None)[source]¶
Update parameter values.
This method is maintained for backward compatibility but does nothing, as the controller widget already reacts to process parameter changes.
- Parameters:
process – Process instance (unused).
- value_changed¶
pyqtSignal(*types, name: str = …, revision: 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.
- class populse_mia.user_interface.pipeline_manager.node_controller.FilterWidget(project, node_name, node, main_window)[source]¶
Bases:
QWidgetA PyQt widget for filtering and selecting files in a pipeline’s Input_Filter process.
This widget provides a user-friendly interface for filtering database files using both rapid and advanced search functionalities. It allows users to:
Browse and select files from the project database.
Perform rapid searches using a text-based search bar.
Apply advanced filters using a customizable search interface.
Visualize and update tags associated with the files.
Save the configured filter to the process for further use in the pipeline.
The widget is designed to integrate seamlessly with the pipeline editor, providing real-time feedback and updates as filters are applied.
- __init__(project, node_name, node, main_window)[source]¶
Initialize the Filter Widget for pipeline node filtering.
- Parameters:
project – Current project instance containing database and configuration.
node_name – Display name of the filter node.
node – Input_Filter node instance containing the filter process.
main_window – Parent main window for UI hierarchy.
- layout_view()[source]¶
Configure and initialize the main widget layout.
- Sets up a vertical layout containing:
Search bar with reset button
Advanced search widget
Data table
Action buttons (visualize tags, filter, OK, Cancel)
The window is sized to 60% width and 80% height of the screen resolution.
- ok_clicked()[source]¶
Apply the configured filter to the process and close the dialog.
Collects filter parameters from the advanced search interface and rapid search text field, creates a Filter object, and applies it to the process if it’s a ProcessMIA instance. The dialog is then closed regardless of process type.
- reset_search_bar()[source]¶
Reset search interface to default state.
Clears the rapid search text field, resets advanced search rows, and restores the table to display all available scans. The table is updated efficiently by tracking the previous visualization state.
- Side effects:
Clears rapid_search text field
Resets advanced_search rows to empty list
Updates advanced_search display
Restores table_data to show all scans from scan_list
- search_str(str_search)[source]¶
Filter and update the displayed scans based on a search string.
Performs a rapid search to filter scans in the browser view. An empty search string displays all available scans. Special handling is provided for undefined values and custom search filters.
- Parameters:
str_search – Search query string. Use empty string to show all scans, or NOT_DEFINED_VALUE constant to filter scans with undefined fields.
- Side Effects:
Updates self.table_data.scans_to_visualize with filtered results
Updates self.advanced_search.scans_list with filtered results
Triggers table row update via self.table_data.update_visualized_rows()
- update_tag_to_filter()[source]¶
Display a tag selection dialog and update the filter button text.
Opens a popup dialog allowing the user to select from visible project tags. If a tag is selected (dialog accepted), updates the filter button’s text to reflect the chosen tag.
- update_tags()[source]¶
Update the list of visualized tags through a user dialog.
Opens a modal dialog that allows users to select which tags should be displayed in the table view. Upon confirmation, the method:
Updates table columns to show only selected tags
Refreshes advanced search field options
Ensures TAG_FILENAME is always included in visible tags
The dialog is automatically cleaned up after use, whether the user confirms or cancels the operation.
- class populse_mia.user_interface.pipeline_manager.node_controller.NodeController(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Bases:
QWidgetA PyQt widget for managing and editing the input/output values and parameters of a pipeline node.
This controller provides a user interface to interact with pipeline nodes, allowing users to:
View and edit node names and parameters
Filter and update plug values
Handle undo/redo operations for parameter changes
Manage subprocesses and context names
The widget is designed to integrate with a pipeline editor, providing real-time updates and synchronization between the UI and the underlying pipeline state.
- __init__(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Initialize the node controller widget.
This controller manages the interaction between the current project, the selected scans, and the active pipeline within the pipeline manager interface.
- Parameters:
project – The current project instance.
scan_list – lThe list of selected database files (scans).
pipeline_manager_tab – The parent pipeline manager tab widget.
main_window – The main application window.
- clearLayout(widget)[source]¶
Remove and delete all items from a widget’s layout.
- This method recursively clears the layout attached to the given widget:
QWidget items are detached from their parent.
Nested layouts are emptied and scheduled for deletion.
The layout itself is deleted once cleared.
- Parameters:
(QtWidgets.QWidget) (widget) – The widget whose layout should be cleared.
- display_filter(node_name, plug_name, parameters, process)[source]¶
Display an interactive filter widget for modifying plug values.
Creates and shows a PlugFilter dialog that allows users to filter and modify the value of a specific plug. The dialog’s value changes are automatically propagated back to update the plug through a signal connection.
- Parameters:
node_name – The name of the pipeline node containing the plug.
plug_name – The name of the plug to filter.
parameters – A tuple containing (plug_index, pipeline_instance, plug_value_type) that provides context for the plug being filtered.
process – The process instance associated with the node.
- Note:
The created PlugFilter is stored in self.pop_up and remains accessible until another filter is displayed or the instance is destroyed.
- display_parameters(node_name, process, pipeline)[source]¶
Display and configure parameters for the selected pipeline node.
Creates an interactive interface showing the node’s input and output parameters with editable fields. For pipeline global inputs (except ‘database_scans’), adds filter buttons for File/List_File/Any trait types.
- Special handling:
- ‘inputs’/’outputs’ nodes: Name field is read-only, displays
“Pipeline inputs/outputs”
Other nodes: Name field is editable and updates on Enter
Parameters with userlevel > 0 are hidden from the interface
- Parameters:
node_name – Identifier for the node being displayed
process – Node’s process object containing traits and their values
pipeline – Parent pipeline instance containing this node
- Side effects:
Clears and rebuilds the widget layout
Updates node_parameters_tmp in the current pipeline editor
Enables the run_pipeline_action
- get_index_from_plug_name(plug_name, in_or_out)[source]¶
Get the index of a plug by its name.
- Parameters:
(str) (in_or_out) – The name of the plug to find.
(str) – Direction of the plug ; “in” for input, “out” for output.
- Returns:
The zero-based index of the plug if found, None otherwise.
- release_process()[source]¶
Release the process from notification tracking.
This method is intended to be overridden by subclasses that need to implement process release logic. The base implementation is a no-op.
- Note:
Currently only implemented in CapsuleNodeController.
- rename_subprocesses(node, parent_node_name)[source]¶
Recursively update context names for a node and its subprocesses.
This method updates the context_name attribute throughout a node hierarchy, ensuring consistent naming based on the parent context. For pipeline processes, it preserves the hierarchical structure while incorporating the parent node name.
The context name follows these rules: - Pipeline processes:”Pipeline.{parent_node_name}.{additional_parts}” - Non-pipeline processes: “{parent_node_name}” - Nested subprocesses are updated recursively
- Parameters:
(Node) (node) – The node whose context name will be updated, along with all its subprocesses.
(str) (parent_node_name) – The parent node’s name to incorporate into the context naming hierarchy.
- update_node_name(new_node_name=None)[source]¶
Update the name of the currently selected node in the pipeline.
Renames a node in the pipeline dictionary, preserving all its properties and connections. If the pipeline contains a ProcessIteration, ensures the name is prefixed with ‘iterated_’.
- Parameters:
new_node_name – The new name for the node. If None, retrieves the name from the UI line edit widget. Is not None only when this method is called from an “undo/redo”)
- Emits:
value_changed: Signal with node rename details for undo/redo tracking.
- Note:
Does nothing if the new name already exists in the pipeline.
- update_parameters(process=None)[source]¶
Update parameter values in the UI from the process traits.
Synchronizes input and output line edit widgets with the current values of the process traits. If no process is provided, uses the current process if available. The ‘nodes_activation’ trait is ignored. Undefined trait values are handled gracefully.
- Parameters:
process – Optional process node whose parameters should be displayed. If None, uses self.current_process.
- update_plug_value(in_or_out, plug_name, pipeline, value_type, new_value=None)[source]¶
Update the value of a node plug and propagate changes through the pipeline.
The new value is either explicitly provided (typically during undo/redo) or read from the corresponding line edit widget and evaluated. If the update fails, the previous value is restored in the UI and a warning dialog is shown.
- Parameters:
(str) (plug_name) – Direction of the plug - “in” for input plugs, “out” for output plugs.
(str) – Name of the plug to update.
pipeline – The current pipeline instance.
(type) (value_type) – Expected type of the plug value.
(optional) (new_value) – New value for the plug. If None, reads from the line edit widget (is None except when this method is called from an undo/redo)
- Side Effects:
Updates the plug value in the pipeline node
Updates the corresponding line edit widget text
Triggers pipeline node and plug activation updates
Emits value_changed signal for undo/redo tracking
Displays status message in the main window
Shows error dialog on TraitError or OSError
- Note:
The method uses eval() to parse string input, which handles lists, dicts, and other Python literals. Special handling is included for ‘<undefined>’ values in dictionaries, which are converted to Undefined objects.
- update_plug_value_from_filter(plug_name, parameters, filter_res_list)[source]¶
Update a plug’s value based on filtered results.
Automatically unwraps single-item lists for convenience, setting the plug value to the item itself rather than a list containing one item.
- Parameters:
plug_name – Name of the plug to update.
parameters – Tuple of (plug_index, pipeline_instance, value_type).
filter_res_list – Filtered file list to set as the plug value.
- Note:
Empty lists are preserved as empty lists
Single-item lists are unwrapped to the item itself
Multi-item lists are kept as lists
- value_changed¶
pyqtSignal(*types, name: str = …, revision: 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.
- class populse_mia.user_interface.pipeline_manager.node_controller.PlugFilter(project, scans_list, process, node_name, plug_name, node_controller, main_window)[source]¶
Bases:
QWidgetA PyQt widget for interactively filtering and selecting database scans to assign to a pipeline node plug.
This widget provides a powerful interface for browsing, searching, and filtering files from the project database. It features:
A customizable data browser with tag columns.
Rapid text search for quick filtering.
Advanced multi-criteria filtering for precise selection.
Tag visibility controls to customize the displayed information.
Automatic exclusion of files that are outputs from existing pipeline bricks to prevent circular dependencies.
The widget is designed to integrate seamlessly with a pipeline editor, allowing users to select and assign files to a specific node plug. When the selection is confirmed, the chosen files are emitted as a list via the plug_value_changed signal.
- __init__(project, scans_list, process, node_name, plug_name, node_controller, main_window)[source]¶
Initialize the PlugFilter widget for filtering database scans.
Creates a filterable data browser interface with search capabilities, tag visualization controls, and scan selection. Automatically excludes scans that are outputs from existing pipeline bricks.
- Parameters:
project – Current project instance containing database and folder paths
scans_list – Initial list of database file paths to filter. If empty, all scans from COLLECTION_CURRENT are included
process – Process instance associated with the selected pipeline node
node_name – Display name of the current pipeline node
plug_name – Name of the selected node plug/connection point
node_controller – Parent controller managing node visibility and tags
main_window – Main application window containing the pipeline manager
- ok_clicked()[source]¶
Handle OK button click by applying changes and closing the dialog.
Commits the current widget value to the associated node plug, then closes the widget dialog.
- plug_value_changed¶
pyqtSignal(*types, name: str = …, revision: 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.
- reset_search_bar()[source]¶
Reset search interface to initial state and restore all scan rows.
Clears the rapid search text field, resets advanced search rows, and restores the full scan list to the table view, updating the display to reflect all available scans.
- search_str(str_search)[source]¶
Filter and update the list of scans displayed in the browser based on search criteria.
This method updates scans_to_visualize by applying either a rapid search filter or showing all available scans when the search is empty. Special handling is provided for the NOT_DEFINED_VALUE constant to filter scans with undefined tag values.
- Parm str_search (str):
The search string entered by the user. An empty string shows all scans, NOT_DEFINED_VALUE filters for scans with undefined tags, and any other value performs a rapid search filter.
- Side Effects:
Updates self.table_data.scans_to_visualize with filtered scan list
Updates self.advanced_search.scans_list with the same filtered list
Triggers UI update via self.table_data.update_visualized_rows()
- set_plug_value()[source]¶
Extract selected or filtered scan values and emit to node plug.
Retrieves values from the database for the currently filtered tag. If items are selected in the table, only those values are extracted. Otherwise, all filtered items are processed. For filename tags, paths are converted to absolute paths within the project folder.
- Emits:
plug_value_changed: Signal with list of extracted values.
- update_tag_to_filter()[source]¶
Open a dialog to select a tag filter and update the button text.
Displays a popup dialog allowing the user to select a tag from the available visible tags. If a tag is selected (dialog accepted), updates the filter button’s text to reflect the chosen tag.
- update_tags()[source]¶
Open a dialog to update the list of visualized tags.
Displays a modal dialog allowing users to select which tags should be visualized in the table. If accepted, updates the visible columns in the data table, refreshes the node controller’s visible tags list, and updates all advanced search field dropdowns with the new tag selection.
The ‘Filename’ tag is always included in the visible tags list.
populse_mia.user_interface.pipeline_manager.pipeline_editor module¶
Module that executes the actions in the pipeline manager menu and allows to graphically modify a pipeline.
Contains:
- Class:
PipelineEditor
PipelineEditorTabs
- Function:
find_filename
get_path
save_pipeline
- class populse_mia.user_interface.pipeline_manager.pipeline_editor.PipelineEditor(project, main_window)[source]¶
Bases:
PipelineDeveloperViewGraphical editor for creating, editing, and managing pipelines.
This view provides interactive tools to build pipeline graphs, connect nodes and plugs, edit node properties, and track modifications. It also handles persistence (save/export) and undo/redo history management.
- __init__(project, main_window)[source]¶
Initialize the PipelineEditor for visual pipeline development.
Sets up the pipeline editor with project context and initializes undo/redo functionality.
- Parameters:
project – The current project instance containing pipeline data and configuration.
- Parm main_window:
The main application window instance for UI integration.
- add_link(source, dest, active, weak, from_undo=False, from_redo=False, allow_export=False)[source]¶
Add a link between two nodes in the pipeline.
Creates a connection between a source node’s output plug and a destination node’s input plug. The link is represented as “node.plug->node.plug” format and added to the pipeline scene.
- Parameters:
source – A tuple of (node_name, plug_name) for the source connection.
dest – A tuple of (node_name, plug_name) for the destination connection.
active – Whether the link is currently active/enabled.
weak – Whether the link is a weak reference that doesn’t enforce strict execution dependencies.
from_undo – Whether this action originates from an undo operation. Defaults to False.
from_redo – Whether this action originates from a redo operation. Defaults to False.
allow_export – Whether to allow this link in exported pipelines. Defaults to False.
- Side Effects:
Adds the link to the pipeline scene
Updates the pipeline visualization
Records the action in history (unless from undo/redo)
Displays a status message in the main window
- add_named_process(class_process, node_name=None, from_undo=False, from_redo=False, links=None)[source]¶
Add a process to the pipeline with optional link restoration.
This method adds a named process to the pipeline and configures it according to project settings. It also handles link restoration when the action is part of an undo/redo operation.
- Parameters:
(str) (node_name) – The name of the process class to instantiate.
(str) – Custom name for the node. If None, the name is derived from the process’s context_name or name attribute. Defaults to None.
(bool) (from_redo) – Whether this action is part of an undo operation. Defaults to False.
(bool) – Whether this action is part of a redo operation. Defaults to False.
(list) (links) – List of link tuples to restore, where each tuple contains (source, dest, active, weak). Used during undo/redo operations. Defaults to None.
- Side Effects:
Adds process to the pipeline
Configures project settings if applicable
Restores links if provided
Updates history for undo/redo
Updates UI status bar and buttons
- check_modifications()[source]¶
Check and update pipeline nodes that have been modified.
This method iterates through all pipeline nodes and detects if the underlying process definition has changed (added/removed inputs/outputs).
- When changes are detected, it:
Recreates the node with the updated process definition
Preserves the node’s position in the scene
Attempts to restore compatible links
Removes incompatible links and notifies the user
- Side Effects:
Modifies self.scene.gnodes, self.scene.glinks, and pipeline.nodes. Displays a warning dialog if any links are removed.
- del_node(node_name=None, from_undo=False, from_redo=False)[source]¶
Deletes a node from the pipeline and updates the GUI and history accordingly.
- Parameters:
(str) (node_name) – The name of the node to delete. If not provided, the currently selected node is used.
(bool) (from_redo) – True if the deletion was triggered by an undo operation.
(bool) – True if the deletion was triggered by a redo operation.
- export_node_plugs(node_name, inputs=True, outputs=True, optional=False, from_undo=False, from_redo=False)[source]¶
Export plugs (parameters) from a pipeline node to make them available externally.
This method identifies and exports node plugs that meet the specified criteria (input/output type, optional status, unlinked status) and are not in the pipeline’s exclusion list.
- Parameters:
node_name – Name of the node whose plugs should be exported.
inputs – Whether to export input plugs. Defaults to True.
outputs – Whether to export output plugs. Defaults to True.
optional – Whether to include optional plugs in the export. Defaults to False.
from_undo – Whether this call originates from an undo operation. Defaults to False.
from_redo – Whether this call originates from a redo operation. Defaults to False.
- Note:
Only unlinked plugs are exported (outputs without links_to, inputs without links_from)
Certain system plugs are automatically excluded (nodes_activation, selection_changed, etc.)
The operation is recorded in the history for undo/redo support
- get_current_filename()[source]¶
Return the relative path to the last saved pipeline file.
Returns the relative path from the current working directory to the file where this pipeline was most recently saved. If the pipeline has never been saved, returns an empty string.
- Return (str):
Relative path to the pipeline file, or empty string if never saved.
- pipeline_modified¶
pyqtSignal(*types, name: str = …, revision: 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.
- pipeline_saved¶
pyqtSignal(*types, name: str = …, revision: 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.
- save_pipeline(filename=None)[source]¶
Save the pipeline to a Python file.
This method saves the current pipeline configuration to a file. If no filename is provided, it prompts the user with a file dialog. The method performs validation to ensure the filename is valid (doesn’t start with a digit, has .py extension) and checks user permissions.
- Parameters:
(str) (filename) – Path where the pipeline should be saved. If None, a file dialog will be shown. Defaults to None.
- Return (str):
- The absolute path of the saved pipeline file,
or None if:
The pipeline is empty (fewer than 2 nodes)
The user cancelled the save dialog
The filename is invalid
The user lacks permission to overwrite an existing file
- Note:
- pipeline_saved: Signal emitted with the filename when save is
successful.
- update_history(history_maker, from_undo, from_redo)[source]¶
Update the undo/redo history after a pipeline action.
Manages the undo and redo stacks based on the action performed. When an action is undone, it’s moved to the redo stack. When a new action is performed (not from undo/redo), it’s added to the undo stack and complementary redo entries are cleaned up to maintain consistency.
- Parameters:
history_maker – A list describing the action, where history_maker[0] is the action type (e.g., ‘add_process’, ‘delete_process’, ‘update_node_name’) and history_maker[1] is typically the affected node identifier.
(bool) (from_redo) – Whether this update stems from an undo operation. Defaults to False.
(bool) – Whether this update stems from a redo operation. Defaults to False.
- Note:
‘update_node_name’ actions are not added to the undo stack
Complementary actions (add/delete for the same process) are removed from the redo stack when a new action occurs
pipeline_modified: Signal emitted indicating the pipeline has been modified.
- update_node_name(old_node, old_node_name, new_node_name, from_undo=False, from_redo=False)[source]¶
Update a node’s name in the pipeline, preserving all connections.
This method renames a node by: 1. Temporarily removing all links connected to the node 2. Renaming the node in the pipeline 3. Restoring all links with the updated node name 4. Recording the action in the history for undo/redo support
- Parameters:
old_node – The node object to rename.
old_node_name – The current name of the node.
new_node_name – The desired new name for the node.
from_undo – Whether this action is being performed as part of an undo operation. Defaults to False.
from_redo – Whether this action is being performed as part of a redo operation. Defaults to False.
- Side Effects:
Updates the pipeline’s node registry
Removes and recreates all links connected to the node
Updates pipeline activation states
Records action in history
Displays status message to user
- update_plug_value(node_name, new_value, plug_name, value_type, from_undo=False, from_redo=False)[source]¶
Update a node’s plug value and record the change in history.
Updates the specified plug on the given node with a new value. The update is recorded in the history for undo/redo operations unless it’s already part of an undo/redo action.
- Parameters:
node_name – The name of the node containing the plug.
new_value – The new value to assign to the plug. Will be cast to value_type unless from_undo or from_redo is True.
plug_name – The name of the plug to update.
value_type – The type constructor to apply to new_value (e.g., int, float, str). Ignored when from_undo or from_redo is True.
from_undo – If True, indicates this update is from an undo operation. Defaults to False.
from_redo – If True, indicates this update is from a redo operation. Defaults to False.
- Side Effects:
Updates the plug value in the pipeline
Records the change in history (unless from undo/redo)
Displays a status message in the main window
Pops from the undo stack if from undo/redo
- class populse_mia.user_interface.pipeline_manager.pipeline_editor.PipelineEditorTabs(project, scan_list, main_window)[source]¶
Bases:
QTabWidgetTab widget for managing multiple pipeline editors.
This widget provides a tabbed interface for creating, editing, and managing multiple pipeline configurations. Each tab contains a PipelineEditor instance with its own undo/redo history.
- __init__(project, scan_list, main_window)[source]¶
Initialize the pipeline editor tabs.
- Parameters:
project – Current project instance in the software.
scan_list – List of selected database files.
main_window – Main application window reference.
- check_modifications(current_index)[source]¶
Check if nodes in the current pipeline have been modified.
Validates modifications when switching between pipeline tabs. Skips validation for the special “add new pipeline” tab (last position).
- Parameters:
current_index – The index of the tab being switched to.
- Note:
The last tab (‘+’ button) may not have a widget, which is handled gracefully by catching AttributeError.
- close_tab(idx)[source]¶
Close a tab and its associated editor, prompting to save if modified.
Removes the specified tab and cleans up its undo/redo history. If the tab contains unsaved changes (indicated by “ *” suffix), prompts the user to save before closing. If all tabs are closed, creates a new default pipeline.
- Parameters:
idx – index of the tab to close
- emit_node_clicked(node_name, process)[source]¶
Emit the appropriate signal when a node is clicked.
Emits either process_clicked or node_clicked signal depending on whether the process parameter is a Process instance.
- Parameters:
node_name – The name of the clicked node.
process – The process associated with the node. If this is a Process instance, emits process_clicked; otherwise emits node_clicked.
- emit_pipeline_saved(filename)[source]¶
Update the current tab title and emit the pipeline_saved signal.
- Parameters:
filename – Path to the saved pipeline file.
- emit_switch_clicked(node_name, switch)[source]¶
Emit a signal when a switch is toggled.
- Parameters:
node_name – The name of the node whose switch was clicked.
switch – The Switch associated with the node.
- Emits:
switch_clicked: Signal containing the node name and the Switch.
- export_to_db_scans(node_name)[source]¶
Export the input of a filter to “database_scans” plug.
If database_scans already exists as a pipeline parameter, creates a link from database_scans to the node’s input. Otherwise, exports the node’s input parameter as database_scans at the pipeline level.
- Parameters:
node_name – Name of the node whose input should be exported.
- Note:
This method automatically updates the editor scene after modification.
- get_capsul_engine()[source]¶
Configure and return a CapsulEngine for the current pipeline.
Retrieves a CapsulEngine instance from the MIA configuration and sets up the study configuration with project-specific directories. If the current pipeline has completion attributes, they are preserved during the engine setup process.
- Returns (CapsulEngine):
Configured engine instance with study directories set to the project’s raw_data and derived_data folders.
- Note:
This method temporarily saves and restores completion engine attributes to prevent loss of configuration when switching between pipelines.
- get_current_editor()[source]¶
Return the editor corresponding to the currently selected tab.
- Returns:
Editor instance for the active tab.
- get_current_filename()[source]¶
Return the relative path of the file last saved in the current editor.
If the pipeline has never been saved, the current tab title is returned.
- Returns:
The filename for the current editor.
- get_current_pipeline()[source]¶
Return the pipeline associated with the current editor.
Returns None if no editor or scene is available.
- Returns:
The pipeline for the current editor
- get_current_tab_name()[source]¶
Return the name of the currently selected tab.
Trailing “*” and “&” characters are stripped.
- Returns:
The current tab name.
- get_editor_by_file_name(file_name)[source]¶
Return the editor associated with the given pipeline filename.
The filename corresponds to the last saved location of the pipeline.
- Parameters:
file_name – Name of the file the pipeline was last saved to.
- Returns:
The editor corresponding to the file name.
- get_editor_by_index(idx)[source]¶
Retrieve an editor widget by its tab index.
- Parameters:
idx – Zero-based index of the editor tab, or None if not found.
- Returns:
The editor widget at the specified index, or None if idx is None or if the index corresponds to the “add tab” button (last tab) or if index out of range.
- Note:
The last tab position is reserved for the “add tab” button and does not contain an editor widget.
- get_editor_by_tab_name(tab_name)[source]¶
Retrieve the editor instance associated with a specific tab name.
- Parameters:
(str) (tab_name) – The name of the tab to search for.
- Returns:
The editor instance corresponding to the specified tab name, or None if the tab is not found.
- Raises:
ValueError: If tab_name is empty or None.
KeyError: If no tab exists with the given name.
- get_filename_by_index(idx)[source]¶
Get the filename for the pipeline at the specified editor index.
Returns the relative path to the file where the pipeline was last saved. If the pipeline has never been saved, returns the tab title instead.
- Parameters:
idx – The zero-based index of the editor tab.
- Returns:
str or None. The filename or tab title if the editor exists, None if no editor exists at the given index.
- get_index_by_editor(editor)[source]¶
Find the tab index for a given editor widget.
- Parameters:
editor – The pipeline editor widget to locate.
- Returns:
The zero-based index of the editor’s tab, or None if not found.
- Note:
Searches all tabs except the last one (count() - 1).
- get_index_by_filename(filename)[source]¶
Get the index of the first tab with the specified filename.
- Parameters:
(str) (filename) – The pipeline filename to search for. Can be an absolute or relative path; will be normalized to relative.
- Return (int):
The zero-based index of the matching tab, or None if no match is found.
- Note:
Filenames are internally stored as relative paths for consistency. Only searches up to count() - 1 to exclude special tabs if any.
- get_index_by_tab_name(tab_name)[source]¶
Find the index of a tab by its name.
Searches through all tabs (excluding the last one) to find a tab matching the given name.
- Parameters:
(str) (tab_name) – The name of the tab to locate.
- Return (int):
The zero-based index of the matching tab, or None if no match is found.
- get_tab_name_by_index(idx)[source]¶
Get the clean tab name at the specified index.
Retrieves the tab text at the given index and removes formatting characters:
Qt keyboard shortcut indicators (ampersands)
Unsaved file indicators (trailing “ *”)
- Parameters:
idx – Zero-based index of the tab.
- Return (str):
The cleaned tab name, or None if the index is invalid or corresponds to the “add tab” button (last position).
- has_pipeline_nodes()[source]¶
Check if any pipeline in the editor tabs contains nodes.
Iterates through all tab widgets and checks if any pipeline editor contains nodes by examining the presence of plugs in the pipeline’s root node.
- Return (bool):
True if at least one pipeline contains nodes, False otherwise.
- load_pipeline(filename=None)[source]¶
Load a pipeline into the editor.
Opens a pipeline file in a new or existing tab. If the pipeline is already open, switches to that tab. If the current tab is not empty, creates a new tab for the pipeline.
- Parameters:
(str) (filename) – Path to the pipeline file to load. If None, prompts the user to select a file. Defaults to None.
- Return (None):
Returns early on success, or cleans up and returns on failure.
- Note:
This method is also called from open_sub_pipeline with a filename.
- load_pipeline_parameters()[source]¶
Load pipeline parameters for the current editor.
Opens a file dialog in the user’s home directory to select a JSON file containing pipeline configuration parameters, then loads those parameters into the currently active editor’s pipeline.
- new_tab()[source]¶
Create and initialize a new pipeline editor tab.
Creates a new PipelineEditor instance, connects all necessary signals, initializes its state, generates a unique tab name, and makes it the current tab. The new tab is inserted at the last tab position.
The tab name follows the pattern “New Pipeline {n}” where n is the first available index from 1 to 49.
- node_clicked¶
pyqtSignal(*types, name: str = …, revision: 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.
- open_filter(node_name)[source]¶
Open a filter widget for the specified pipeline node.
Creates and displays a FilterWidget instance for filtering data associated with the given node in the current pipeline.
- Parameters:
node_name – The name of the node to apply filters to.
- open_sub_pipeline(sub_pipeline)[source]¶
Open a sub-pipeline in a new tab.
- This method locates and loads a sub-pipeline by:
Reading the process configuration to find package paths
Determining the pipeline’s source package (mia_processes or custom)
Resolving the full filesystem path to the pipeline file
Loading the pipeline in a new tab
- Parameters:
sub_pipeline – The pipeline object to open. Must have a ‘name’ attribute and ‘__module__’ attribute for package resolution.
- pipeline_saved¶
pyqtSignal(*types, name: str = …, revision: 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.
- process_clicked¶
pyqtSignal(*types, name: str = …, revision: 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.
- reset_pipeline()[source]¶
Reset and refresh the currently active editor’s pipeline display.
This triggers an asynchronous update of the pipeline view after a short delay (20ms). The update strategy depends on the editor’s view mode:
- Logical view: Displays logical representations of nodes, plugs,
and links
- Normal view: Displays standard representations of nodes, plugs,
and links
- Note:
The update is performed asynchronously via a single-shot timer to allow the UI thread to remain responsive.
- save_pipeline(new_file_name=None)[source]¶
Save the current pipeline to a file.
Performs either a “Save” or “Save As” operation depending on whether a filename is provided. Updates the tab text and emits a signal upon successful save.
- Parameters:
(str) (new_file_name) – Target filename for the pipeline. If None, triggers a “Save As” dialog. Defaults to None.
- Return (str or None):
The basename of the saved file if successful, None otherwise.
- Side Effects:
Updates the current tab text with the new filename
Emits pipeline_saved signal (only for explicit saves)
Modifies the editor’s _pipeline_filename attribute
- save_pipeline_parameters()[source]¶
Save pipeline parameters from the currently active editor.
Delegates the save operation to the current editor’s save method.
- set_current_editor_by_editor(editor)[source]¶
Set the specified editor as the currently active editor.
Activates the tab containing the given editor by switching to its index.
- Parameters:
editor – The editor instance to make active. Must be an editor that exists within one of the managed tabs.
- set_current_editor_by_file_name(file_name)[source]¶
Activate the editor tab containing the specified file.
Sets the active editor tab to the one associated with the given file name, typically used when reopening a previously saved pipeline.
- Parame file_name:
The name of the file whose editor tab should be activated.
- set_current_editor_by_tab_name(tab_name)[source]¶
Activate the editor tab with the specified name.
- Parameters:
tab_name – The display name of the tab to activate.
- set_tab_index(index)[source]¶
Activate the tab at the specified index and update the current node.
Sets the active tab, stores it as the previous index for navigation history, and updates the current node state for the newly active editor.
- Parameters:
index – The zero-based index of the tab to activate.
- switch_clicked¶
pyqtSignal(*types, name: str = …, revision: 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.
- update_current_node()[source]¶
Update the node parameters display for the current pipeline.
Refreshes the UI to display parameters for all nodes in the current pipeline, updates user button states, iteration checkbox, and iterated tag display.
- update_history(editor)[source]¶
Update the undo/redo history for the specified editor.
Saves the editor’s current undo and redo stacks and marks the active tab as modified by appending an asterisk to its title if not already present.
- Parameters:
editor – The editor instance whose history should be saved.
- Note:
This method assumes the editor is in the currently active tab.
- update_iteration_checkbox()[source]¶
Update the iteration checkbox state based on pipeline node names.
Sets the iteration checkbox to checked if any pipeline node has ‘iterated_’ in its key name, otherwise sets it to unchecked. If no valid pipeline exists or the pipeline lacks nodes, the checkbox is unchecked.
- update_pipeline_editors(editor)[source]¶
Update the pipeline editors after changes to the specified editor.
Synchronizes the editor’s undo/redo history and refreshes the scans list to reflect any modifications made in the pipeline editor.
- Parameters:
editor – The editor instance that was modified.
- update_scans_list()[source]¶
Update the list of database scans in every pipeline editor.
Iterates through all editor tabs (excluding the last tab, reserved for the “add tab” button) and updates the database_scans attribute for each pipeline that supports it. Also refreshes the iteration checkbox state after updating.
- Note:
Silently continues if updating a pipeline fails, logging the error without interrupting the update process for remaining pipelines.
- populse_mia.user_interface.pipeline_manager.pipeline_editor.find_filename(paths_list, packages_list, file_name)[source]¶
Locate a pipeline file within configured paths.
Searches for a file with the given name (with .py or .xml extension) by traversing through base paths combined with package subdirectories. Performs case-insensitive matching to handle filesystem sensitivity issues.
- Parameters:
paths_list – Base directory paths from process_config.yml
packages_list – Ordered list of package subdirectories to traverse
file_name – Base name of the sub-pipeline file (without extension)
- Returns:
Absolute path to the matched file, or None if not found
- populse_mia.user_interface.pipeline_manager.pipeline_editor.get_path(name, dictionary, prev_paths=None, pckg=None)[source]¶
Recursively search for a module name inside a nested dictionary structure and return its full path as a list of keys.
- The tree is assumed to be a mapping where:
Intermediate nodes are dictionaries (packages),
Leaf nodes are strings (module names).
- Parameters:
(str) (pckg) – Name of the module to locate in the tree.
(dict) (dictionary) – The nested dictionary representing the tree structure.
(list[str]) (prev_paths) – The accumulated path leading to the current dictionary. If None, a new path list is created.
(str) – If provided, navigation starts inside that package name.
- Return (list[str]):
A list of keys representing the path to the module, or None if the module is not found.
- populse_mia.user_interface.pipeline_manager.pipeline_editor.save_pipeline(pipeline, filename)[source]¶
Save a pipeline to a file in the appropriate format.
Automatically detects the output format based on the file extension. Supported formats are Python source (.py) and XML (.xml). If no recognized extension is provided, defaults to Python format.
- Parameters:
pipeline – The pipeline object to serialize and save.
filename – Path to the output file. The extension determines the output format (.py or .xml).
- Note:
Unrecognized extensions will default to Python source format (.py)
- Examples:
>>> save_pipeline(my_pipeline, "model.py") >>> save_pipeline(my_pipeline, "config.xml") >>> save_pipeline(my_pipeline, "output") # Defaults to .py format
populse_mia.user_interface.pipeline_manager.pipeline_manager_tab module¶
Module to define pipeline manager tab appearance, settings and methods.
- Contains:
- Class:
PipelineManagerTab
RunProgress
RunWorker
StatusWidget
- Function:
protected_logging
- class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.PipelineManagerTab(project, scan_list, main_window)[source]¶
Bases:
QWidgetWidget that handles the Pipeline Manager tab.
- __init__(project, scan_list, main_window)[source]¶
Initialize the Pipeline Manager tab.
The Pipeline Manager provides a comprehensive interface for creating, editing, and executing data processing pipelines. It integrates process libraries, pipeline editors, node controllers, and iteration tables to manage complex data analysis workflows.
- Parameters:
project – The current project instance containing database and configuration
scan_list – List of selected database files to process. If None or empty, defaults to all documents in the current collection
main_window – Main application window instance for UI integration
- add_plug_value_to_database(p_value, brick_id, history_id, node_name, plug_name, full_name, job, trait, inputs, attributes)[source]¶
Add plug value(s) to the database with proper metadata and inheritance.
This method handles adding file-based plug values to a project database, managing inheritance of metadata tags from input files, and resolving ambiguities when multiple parent files exist.
- Parameters:
p_value – The plug value - either a single file path (str) or list of file paths. Can also be special values like “<undefined>” or Undefined.
(str) (full_name) – UUID of the brick in the database.
(str) – UUID of the processing history in the database.
(str) – Name of the processing node.
(str) – Name of the specific plug/parameter.
(str) – Full hierarchical name including parent bricks. Equals node_name if no parent exists.
(Job) (job) – Job object containing the plug, may have inheritance dictionaries.
(Trait) (trait) – Handler for the plug trait or sub-trait for list elements. Used to validate value types (file vs non-file).
(dict) (attributes) – Input parameter values for the process/node.
(dict) – Completion engine attributes to be applied to all outputs.
- Notes:
Recursively processes list values by calling itself on each element
Only processes file-type traits within the project folder
Handles tag inheritance from parent files using inheritance_dict and auto_inheritance_dict from the job
May prompt user to resolve ambiguous inheritance scenarios
Automatically determines file types based on extensions
Updates both CURRENT and INITIAL database collections
- Raises:
May raise database-related exceptions during document operations.
- ask_iterated_pipeline_plugs(pipeline)[source]¶
Display a configuration dialog for pipeline plug iteration and database connections.
This method opens an interactive dialog that allows users to configure how pipeline plugs (inputs and outputs) should be handled during execution. Users can specify:
Which plugs should be iterated over during pipeline execution
Which input plugs should be connected to database filters
Interactive dependency management (database connection requires iteration)
The dialog presents a grid layout with checkboxes for each available plug:
Iteration checkbox: Mark plug for iteration during execution
Database checkbox: Connect input plug to database filter (inputs only)
- Behavioral constraints:
Database connection automatically enables iteration
Disabling iteration automatically disables database connection
Only file-compatible plugs can connect to database filters
Certain system plugs are excluded from configuration
- Parameters:
pipeline – Pipeline object containing plugs to be configured
- Returns:
- Optional[Tuple[List[str], List[str]]]: A tuple containing:
iterated_plugs: List of plug names marked for iteration
database_plugs: List of plug names connected to database
None if the user cancels the dialog.
- build_iterated_pipeline()[source]¶
Build an iteration pipeline wrapper around the current pipeline.
This method creates a new pipeline that iterates over the current pipeline, allowing batch processing of multiple datasets. The process involves:
Interactive selection of plugs to iterate over and database connections
Preprocessing of list-type plugs with ReduceNode to handle nested lists
Creation of an iterative pipeline using the CAPSUL engine
Addition of Input_Filter nodes for database-connected plugs
Proper linking of database_scans parameter across all filters
The method handles both single processes and full pipelines, converting single processes into single-node pipelines when necessary.
- Returns:
Pipeline or None: The new iteration pipeline if successful, None if aborted
- Raises:
ValueError – If Input_Filter process cannot be found in the library.
- Notes:
Modifies pipeline completion settings for database plugs
Sets the editor’s iterated flag to True upon successful completion
Handles context name parsing for proper iteration naming
- check_requirements(environment='global')[source]¶
Check and return the configuration of a pipeline based on its requirements.
This method iterates through the nodes in the pipeline, gathers their requirements, and determines the appropriate configuration for each node in the specified environment. It uses the settings from the study configuration engine to select configurations that match the requirements.
- Parameters:
(str) (environment) – The target environment for checking configurations. Defaults to “global”.
- Return (dict):
A dictionary mapping each pipeline node to its selected configuration.
- cleanup_older_init()[source]¶
Clean up data browser state and remove orphaned files.
- This method performs the following cleanup operations:
Removes non-existent entries from the data browser for each brick
Cleans up orphaned non-existing files from the project
Clears the brick and node lists
Updates the data browser table display
Note: The table update is performed asynchronously using QtThreadCall to ensure UI responsiveness.
- complete_pipeline_parameters(pipeline=None)[source]¶
Complete pipeline parameters using Capsul’s completion engine.
This method utilizes Capsul’s completion engine to automatically populate the parameters of a pipeline based on a set of attributes. These attributes can be retrieved from an associated database. If no pipeline is specified, the current pipeline or process is used.
- Parameters:
(Pipeline) (pipeline) – The pipeline object to be completed. If not provided, the method retrieves the current pipeline or process.
Notes: The completion process relies on Capsul’s ProcessCompletionEngine to automatically determine appropriate parameter values.
- controller_value_changed(signal_list)[source]¶
Update history when a node or plug value changes.
This method processes change signals from the pipeline editor and maintains an undo history for user actions. It handles two types of changes:
- Node name updates: Updates the node name and refreshes the
pipeline view while preserving the current view state.
- Plug value updates: Records parameter changes while filtering
out protected parameters, empty values, and system-generated changes to avoid cluttering the undo history.
- Parameters:
signal_list –
- A list containing change information with the
first element being the change type (“node_name” or “plug_value”), followed by context-specific data:
- For “node_name”: [“node_name”, ProcessNode_object,
new_node_name, old_node_name]
- For “plug_value”: [“plug_value”, node_name, old_value,
plug_name, plug_type, new_value]]
- displayNodeParameters(node_name, process)[source]¶
Display the node controller interface for the specified node.
This method configures and shows the node parameter interface when a user clicks on a node in the pipeline editor. It updates the scroll area widget to display the node controller with the current pipeline context.
- Parameters:
node_name – The name/identifier of the selected node.
process – The process instance associated with the selected node.
- finish_execution()[source]¶
Handle pipeline execution completion and update UI state.
This callback is invoked after a pipeline execution completes, whether successfully or with errors. The method performs comprehensive cleanup and user feedback operations:
Disables pipeline control actions during cleanup
Disconnects progress worker signals to prevent memory leaks
Checks execution status and handles WorkflowExecutionError/RuntimeError
Updates status bar with clear success/failure messages
Sets appropriate visual status icon (green checkmark or red cross)
Cleans up progress indicators and re-enables pipeline actions
Updates node controller parameters for next execution
The method ensures proper cleanup regardless of execution outcome and provides comprehensive user feedback through status messages and visual indicators.
- Raises:
WorkflowExecutionError: When pipeline execution fails RuntimeError: When execution is aborted before running
- garbage_collect()[source]¶
Clean up obsolete data and maintain database consistency.
- This method performs comprehensive cleanup operations including:
Processing finished pipeline executions with error protection
Removing orphaned files and historical data entries
Refreshing the data browser table display
Resetting pipeline editor initialization state if applicable
Updating UI button states to reflect current system status
The cleanup operations ensure the application remains performant and maintains data integrity across user sessions.
- get_capsul_engine()[source]¶
Retrieve and configure a Capsul engine from the pipeline editor.
This method obtains a CapsulEngine object from the current pipeline editor tabs and configures it using the Mia configuration settings.
- Return (CapsulEngine):
A configured Capsul engine instance ready for pipeline execution, with settings applied from the Mia config object.
- get_missing_mandatory_parameters()[source]¶
Find missing mandatory parameters across all pipeline nodes.
Checks each node in the pipeline for missing mandatory parameters, accounting for workflow job parameter overrides and temporary values.
- Return (list[str]):
Parameter names that are missing, formatted as either ‘parameter_name’ for pipeline root or ‘node.parameter_name’ for other nodes.
- Note:
Parameters with non-null values in the workflow job dictionary are not considered missing, even if undefined at the node level.
- get_pipeline_or_process(pipeline=None)[source]¶
Get the pipeline or its single unconnected process node.
When a pipeline contains only one process node with no connections, this method returns the process directly instead of the pipeline wrapper. This simplifies GUI workflows where single processes can act as pipelines.
- Parameters:
(Pipeline) (pipeline) – Optional pipeline to evaluate. If None, uses the currently selected pipeline from the editor GUI.
- Return (Pipeline | Process):
The process node if pipeline contains a single unconnected process, otherwise the pipeline itself.
- init_pipeline(pipeline=None, pipeline_name='')[source]¶
Initialize the current pipeline in the pipeline editor.
- This method:
Retrieves and configures the pipeline or sub-pipeline.
Generates and validates the workflow.
Checks requirements (FSL, AFNI, ANTS, Matlab, MRtrix, SPM).
Verifies that mandatory inputs/outputs are properly set.
Records initialization results in the project database.
Updates the status bar and displays warnings when needed.
- Parameters:
Process) (pipeline (Pipeline,) – The pipeline or process instance to initialize. If None, the main pipeline is retrieved.
(str) (pipeline_name) – The name of the parent pipeline, if applicable.
- Return (bool):
True if the pipeline was successfully initialized, False otherwise.
- initialize()[source]¶
Initialize the pipeline after cleaning up any previous initialization.
- This method performs the following operations:
Sets a wait cursor to indicate processing
Cleans up any previous initialization if needed
Resets internal state variables
Attempts to initialize the pipeline
Updates the UI with the results
Restores the normal cursor
The method handles initialization errors gracefully by logging warnings and updating the status bar with error messages.
- Side Effects:
Modifies cursor appearance during execution
Updates pipeline editor tabs and node parameters
May display error messages in the status bar
Sets self.init_clicked to True upon completion
- item_library_clicked¶
pyqtSignal(*types, name: str = …, revision: 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.
- layout_view()[source]¶
Initialize the layout and toolbar for the pipeline manager tab.
This method sets up the main diagram editor window, configures the scroll area, builds the toolbar with pipeline actions, and arranges widgets in splitters and layouts for the pipeline editor interface.
- loadParameters()[source]¶
Load pipeline parameters into the current pipeline of the editor.
This method refreshes the pipeline editor by loading the stored parameters and then updates the node controller accordingly.
- loadPipeline()[source]¶
Load a pipeline into the pipeline editor.
This method initializes the pipeline editor with the selected pipeline.
- postprocess_pipeline_execution(pipeline=None)[source]¶
Operations to be performed after a run has been completed.
It can be called either within the run procedure (the user clicks on the “run” button and waits for the results), or after a disconnetion / reconnection of the client app: the user clicks on “run” with distributed/remote execution activated, then closes the client Mia. Processing takes place (possibly remotely) within a soma-workflow server. Then the user runs Mia again, and we have to collect the outputs of runs which happened (finished) while we were disconnected.
Such post-processing includes database indexing of output data, and should take into account not only the current pipeline, but all past runs which have not been postprocessed yet.
When called with a pipeline argument, it only deals with this one.
The method can be called from within a worker run thread, thus has to be thread-safe.
- Parameters:
(Pipeline) (pipeline) – The pipeline to postprocess. If not provided, the method will use self.last_run_pipeline or fetch the currently selected pipeline from the pipeline editor.
- redo()[source]¶
Redo the last undone action on the current pipeline editor
- Supported redoable actions:
add_process
delete_process
export_plug
export_plugs
remove_plug
update_node_name
update_plug_value
add_link
delete_link
- register_completion_attributes(pipeline)[source]¶
Register completion attributes for a given pipeline in the project database.
This method retrieves attribute values from the pipeline’s completion engine and records them in the project database. Only attributes corresponding to existing fields (tags) in the database schema are stored. For each pipeline parameter that resolves to a file path within the project directory, the attributes are associated with both the current and initial collections.
- Parameters:
(Pipeline) (pipeline) – The pipeline whose completion attributes should be registered. The pipeline must provide a completion engin capable of exporting its attributes
- remove_progress()[source]¶
Remove and clean up the progress widget.
Safely removes the progress widget from the UI and frees associated resources. This method handles the complete lifecycle cleanup of the progress widget, nsuring proper Qt object disposal and memory management.
- Note:
This method is idempotent - it can be safely called multiple times without side effects if the progress widget has already been removed.
- runPipeline()[source]¶
Execute the current pipeline in the pipeline editor.
This method initializes and runs the active pipeline with the following steps:
Initializes the pipeline and validates prerequisites
Sets up pipeline metadata and UI state
Configures soma-workflow connection (if enabled)
Starts pipeline execution with progress tracking
The method handles both local and remote execution via soma-workflow, displays progress animation, and manages UI state during execution.
- saveParameters()[source]¶
Saves the parameters of the currently active pipeline in the pipeline editor.
- savePipeline(skip_overwrite_warning: bool = False)[source]¶
Save the current pipeline in the pipeline editor.
- This method handles three scenarios:
Save to existing file with overwrite confirmation (unless skipped)
Save to existing file without confirmation when warning is skipped
Save as new file when no filename exists or file is in protected directory
- Parameters:
(bool) (skip_overwrite_warning) – If True, skip the overwrite confirmation dialog when saving to an existing file. Defaults to False.
- Side Effects:
Updates the main window status bar with save operation messages
May display a confirmation dialog for file overwriting
Saves the pipeline to disk via pipelineEditorTabs.save_pipeline()
- Note:
Files in “mia_processes/mia_processes” directory are treated as protected and will trigger a “save as” operation regardless of other conditions.
- save_pipeline_as()[source]¶
Save the current pipeline under a new name via ‘Save As’ dialog.
This method displays a status message during the save operation and provides user feedback based on the save result. The pipeline name in the success message is capitalized and stripped of its file extension for display.
- show_status()[source]¶
Display the execution status window with runtime information.
Opens a new status widget window that shows the last execution run details, including runtime statistics, error messages, and other diagnostic information. The widget is stored as an instance attribute for potential future reference.
- stop_execution()[source]¶
Interrupt pipeline execution gracefully.
This method signals the pipeline to stop its current execution flow. The interruption is handled asynchronously through the progress tracker, allowing any in-flight operations to complete safely before termination.
- undo()[source]¶
Undo the last action performed on the current pipeline editor.
This method reverts the most recent undoable action by popping it from the undo stack and performing the inverse operation. The method handles all reversible operations in the pipeline editor interface.
- Supported undoable actions:
add_process: Remove the added process node
delete_process: Restore the deleted process node with its links
export_plug/export_plugs: Remove the exported pipeline plug(s)
remove_plug: Restore the removed plug(s) and reconnect links
update_node_name: Revert node name change
update_plug_value: Restore previous plug value
add_link: Remove the added connection
delete_link: Restore the deleted connection
The method automatically updates the pipeline state and node parameters after performing the undo operation.
- Note:
Does nothing if no undoable actions are available in the stack.
- updateProcessLibrary(filename)[source]¶
Update the library of processes when a pipeline is saved.
- This method performs the following operations:
Renames the Pipeline class in the saved file to match the filename
Updates the __init__.py file to include the new import
Refreshes the module in sys.modules if it already exists
Adds the module to the process library
- Parameters:
filename – Path to the pipeline file that has been saved
- Note:
Only processes saved in the User_processes directory are added to the library.
- static update_auto_inheritance(node, job=None)[source]¶
Automatically infer database tags for output parameters from input parameters.
Single input case: When only one input parameter has a database value, all outputs inherit from this input.
- Multiple inputs with same value: When multiple inputs exist but
have identical database values, fallback to single input behavior.
Ambiguous case: When multiple inputs have different database values, track all possible inheritance sources for user resolution.
The process attribute auto_inheritance_dict is filled with these values. It’s a dict with the shape:
{output_filename: <input_spec>}
output_filename is the relative filename in the database
<input_spec> can be:
a string: filename
a dict:
{input_param: input_filename}
auto_inheritance_dict is built automatically, and is used as a fallback to
ProcessMIAinheritance_dict, built “manually” (specialized for each process) in theProcessMIA.list_outputs()when the latter does not exist, or does not specify what an output inherits from.If ambiguities still subsist, the Mia infrastructure will ask the user how to solve them, which is not very convenient, and error-prone, thus should be avoided.
- Parameters:
node – The node (typically a process or process node) whose inputs and outputs are analyzed for tag inheritance.
job – An optional job object containing parameter values to override or populate the node’s inputs and outputs. Defaults to None.
- Return (dict or None):
Auto-inheritance mapping if successful and no job provided, None if no inheritance can be determined or job is provided (in which case the job object is updated in-place).
- update_inheritance(job, node)[source]¶
Update the inheritance dictionary for a process node in a pipeline execution.
This method manages metadata inheritance by updating a job’s inheritance_dict based on the node’s execution context and the project’s inheritance history. The inheritance dictionary defines relationships between input and output parameters, enabling propagation of database tags and other metadata properties through the pipeline.
- The method follows this precedence order:
Project-specific inheritance history (if matching parameters are found)
Process-level inheritance dictionary (fallback)
- Parameters:
job – Job execution object containing param_dict (parameter name->value mapping) and inheritance_dict (will be updated by this method)
node – Process node being evaluated (ProcessNode or Process object). Used to determine inheritance rules via context_name or name attribute.
- Note: For Pipeline nodes, the method strips the “Pipeline.” prefix
from the context_name to match against inheritance history keys.
- update_node_list(brick=None)[source]¶
Update the node list with unique nodes from workflow jobs.
Iterates through all jobs in the current workflow and adds their associated process nodes to the node list, ensuring no duplicates. Only jobs with a ‘process’ attribute are considered.
- Parameters:
brick – Reserved for future use. Currently unused parameter that could be used for filtering or extending functionality.
- Note:
This method modifies self.node_list in-place by extending it with new unique nodes. Jobs without a ‘process’ attribute are silently skipped.
- update_project(project)[source]¶
Update the project reference across all relevant components.
This method propagates the project instance to all components that require access to project data, ensuring consistency across the application state. It also updates the node controller’s visible tags from the project database.
- Parameters:
project – The current project instance containing application data and database connections.
- Note:
This method has the side effect of setting ProcessMIA.project as a class attribute, which is required for Mia brick functionality.
- update_scans_list(iteration_list, all_iterations_list)[source]¶
Update the user-selected list of scans based on iteration settings.
This method handles the transition between regular and iterated pipeline modes, updating the scan list accordingly. When iteration mode is enabled, it builds an iterated pipeline and uses the full iterations list. When disabled, it extracts the pipeline from the iteration node and reverts to the original scan list.
- Parameters:
iteration_list – Current list of scans in the iteration table (unused in current implementation)
all_iterations_list – Complete list of all iteration scan lists
- Side Effects:
Updates UI button states
May modify the current pipeline (switch between regular/iterated)
Updates scan lists for both iteration table and pipeline editor
May update node parameters display
Falls back to database scan list if pipeline scan list is empty
- update_user_buttons_states(index=-1)[source]¶
Update the visibility and state of pipeline-related UI actions.
Updates the enabled/disabled state of pipeline actions (Run, Save, Save As) based on the current pipeline state. The method evaluates the pipeline associated with either the specified editor or the current active editor.
- Button states updated:
Run Pipeline: Disabled when pipeline is empty or None
Save Pipeline & Save As: Enabled only when pipeline is not iterated
- Parameters:
(int) (index) – Index of the specific editor to check. If -1 (default), uses the currently active editor.
- Note:
If the specified editor doesn’t exist or has no scene, the pipeline is treated as None and buttons are disabled accordingly.
- update_user_mode()[source]¶
Update widget/action visibility and functionality based on user mode configuration.
- In user mode:
Disables pipeline saving (process library unavailable)
Disables pipeline overwriting
Disables project deletion
Also synchronizes user level across pipeline editor and node controller components.
- class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.RunProgress(pipeline_manager, settings=None)[source]¶
Bases:
QWidgetA Qt widget for displaying and managing pipeline execution progress.
This widget provides a visual progress indicator and manages the lifecycle of pipeline execution through a worker thread. It handles user feedback, error reporting, and resource cleanup.
The widget integrates with a PipelineManagerTab to control pipeline execution, providing real-time feedback and graceful error handling.
- Notes:
- pipeline_manager (PipelineManagerTab):
The pipeline manager instance that handles the pipeline operations.
- progressbar (QProgressBar):
The progress bar widget to show execution progress.
- worker (RunWorker):
The worker thread that runs the pipeline.
- AUTO_CLOSE_DELAY_MS = 2000¶
- MIN_PROGRESS_WIDTH = 350¶
- __init__(pipeline_manager, settings=None)[source]¶
Initialize the RunProgress widget with a progress bar and worker thread.
- Parameters:
(PipelineManagerTab) (pipeline_manager) – A PipelineManagerTab instance responsible for managing the pipeline.
(dict) (settings) – A dictionary of settings to customize pipeline iteration, default is None.
- cleanup()[source]¶
Clean up resources and prepare for widget destruction.
Ensures the worker thread completes, disconnects signals, and releases resources. Should be called before widget destruction.
- Note:
This method blocks until the worker thread finishes.
- end_progress()[source]¶
Handle completion of pipeline execution and show results.
Called automatically when the worker thread finishes. Restores the application cursor, evaluates execution status, and displays an appropriate message to the user.
The message dialog automatically closes after a brief delay.
- start()[source]¶
Starts the worker thread to begin the pipeline execution process.
This method initiates the worker thread by calling its start method, which in turn triggers the execution of the pipeline.
- stop_execution()[source]¶
Stops the execution of the pipeline by signaling the worker to interrupt.
This method sets the interrupt_request flag to True within the worker thread’s lock, which tells the worker to stop its execution. The method can be used to cancel the pipeline execution at any point during its run.
- class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.RunWorker(pipeline_manager)[source]¶
Bases:
QThreadWorker thread for executing a pipeline in the background.
This class runs a pipeline or process using a separate thread to avoid blocking the GUI. Execution can be interrupted at any time by setting the
interrupt_requestflag while holdinglock.- __init__(pipeline_manager)[source]¶
Initialize the worker thread for pipeline execution.
- Parameters:
(PipelineManager) (pipeline_manager) – The manager responsible for configuring, running, and monitoring the pipeline execution.
- run()[source]¶
Run the pipeline in a background thread.
The method prepares the pipeline, disables unnecessary copy flags for Nipype processes, rebuilds workflows when file transfer or path translation is required, and starts execution using the Capsul engine. The status is monitored until the workflow completes or an interrupt is requested.
- class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.StatusWidget(pipeline_manager)[source]¶
Bases:
QWidgetA widget that displays the current or last pipeline execution status
along with logs and an optional Soma-Workflow monitoring panel.
- Features:
Shows the last known pipeline status (or a default message if unavailable).
Displays the execution log of the most recent run.
Provides a toggleable Soma-Workflow monitoring section.
- __init__(pipeline_manager)[source]¶
Initializes the execution status window for monitoring pipeline runs.
This window displays the latest pipeline execution status, the execution log, and provides an optional section for Soma-Workflow monitoring. The log is automatically populated from the pipeline manager’s last recorded run.
- Parameters:
pipeline_manager – The pipeline manager instance containing
- populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.protected_logging()[source]¶
Context manager that preserves logging configuration across soma-workflow interference.
This context manager creates a snapshot of all logger configurations before execution and intelligently restores them afterwards. It preserves any new handlers or filters that were added during execution while ensuring original configurations are restored.
- The protection covers:
All named loggers in the logger hierarchy
The root logger
Handler and filter lists (with intelligent merging)
Logger levels, disabled state, and propagation settings
- Usage:
- with protected_logging():
# Code that might interfere with logging some_workflow_operation() # Any new handlers/filters added here are preserved
populse_mia.user_interface.pipeline_manager.process_library module¶
Module that contains class and methods to process the different libraries of the project.
- Contains:
- Class:
DictionaryTreeModel
InstallProcesses
Node
PackageLibrary
PackageLibraryDialog
ProcessHelp
ProcessLibrary
ProcessLibraryWidget
- Functions:
import_file
node_structure_from_dict
- class populse_mia.user_interface.pipeline_manager.process_library.DictionaryTreeModel(root, parent=None)[source]¶
Bases:
QAbstractItemModelData model providing a tree structure for an arbitrary dictionary.
This model is designed to represent a dictionary as a tree structure, enabling interaction with the data through a tree view.
- __init__(root, parent=None)[source]¶
Initializes the DictionaryTreeModel with a root node.
- Parameters:
root – The root node of the tree.
“param parent (QObject): The parent object.
- columnCount(parent=None)[source]¶
Returns the number of columns, which is always 1.
- Parameters:
(QModelIndex) (parent) – The parent index (unused in this implementation).
- Return (int):
The number of columns.
- data(index, role)[source]¶
Returns the data stored under the given role for the item at the given index.
- Parameters:
(QModelIndex) (index) – The index of the item.
(Qt.ItemDataRole) (role) – The role of the data to retrieve.
- Returns:
The data stored under the given role, or None if not available.
- flags(index)[source]¶
Get the item flags for the specified index.
- Parameters:
(QModelIndex) (index) – The model index to retrieve flags for.
- Return (Qt.ItemFlags):
The corresponding item flags.
- getNode(index)[source]¶
Retrieves the Node object from the given index.
- Parameters:
(QModelIndex) (index) – The index of the node.
- Returns:
The Node object.
- headerData(section, orientation, role)[source]¶
Returns the data for the given role and section in the header.
- Parameters:
(int) (section) – The section number.
(Qt.Orientation) (orientation) – The orientation of the header (unused in this implementation).
(Qt.ItemDataRole) (role) – The role of the data to retrieve.
- Return (str):
The header data, or None if not available.
- index(row, column, parent)[source]¶
Creates an index for the given row, column, and parent.
- Parameters:
(int) (column) – The row number.
(int) – The column number.
(QModelIndex) (parent) – The parent index.
- Return (QModelIndex):
The created index, or an invalid index if not available.
- insertRows(position, rows, parent=<PyQt5.QtCore.QModelIndex object>)[source]¶
Inserts rows starting from the specified position.
- Parameters:
(int) (rows) – The starting position to insert rows.
(int) – The number of rows to insert.
(QModelIndex) (parent) – The parent index.
- Return (bool):
True if the rows were successfully inserted, False otherwise.
- mimeData(indexes)[source]¶
Generate MIME data for a drag-and-drop operation.
- Parameters:
QModelIndex) (indexes (list of) – The list of model indexes being dragged.
- Return (QMimeData):
A QMimeData object containing serialized node information.
- mimeTypes()[source]¶
Returns the supported MIME types.
- Return (list of str):
A list of supported MIME types.
- parent(index)[source]¶
Returns the parent index for the given index.
- Parameters:
(QModelIndex) (index) – The index of the item.
- Return (QModelIndex):
The parent index, or an invalid index if not available.
- removeRows(position, rows, parent=<PyQt5.QtCore.QModelIndex object>)[source]¶
Removes rows starting from the specified position to position+rows.
- Parameters:
(int) (rows) – The starting position to remove rows.
(int) – The number of rows to remove.
(QModelIndex) (parent) – The parent index.
- Return (bool):
True if all rows were successfully removed, False otherwise.
- rowCount(parent)[source]¶
Returns the number of rows, which corresponds to the number of children.
- Parameters:
(QModelIndex) (parent) – The parent index.
- Return (int):
The number of rows.
- setData(index, value, role=2)[source]¶
Updates the data when the user makes changes.
- Parameters:
(QModelIndex) (index) – The index of the item.
value – The new value to set.
(Qt.ItemDataRole) (role) – The role of the data to set.
- Return (bool):
True if the data was successfully set, False otherwise.
- class populse_mia.user_interface.pipeline_manager.process_library.InstallProcesses(main_window, folder)[source]¶
Bases:
QDialogDialog for installing Python packages from a folder or zip file.
This widget allows users to browse and select a Python package or zip file containing packages, then install them into Populse_MIA.
- __init__(main_window, folder)[source]¶
Initialize the installation dialog.
- Parameters:
main_window – The main application window
(bool) (folder) – If True, install from folder; if False, install from zip file
- get_filename(folder)[source]¶
Open a file dialog to select the package source.
- Parameters:
(bool) (folder) – If True, opens a directory selection dialog; If False, opens a zip file selection dialog
- install()[source]¶
Install a package from a zip file or a folder.
This method handles the complete installation process: 1. Extracts or copies the package to the processes directory 2. Updates the process dictionary 3. Registers the new package in the configuration
Any exceptions during installation are caught and reported to the user, with automatic rollback of any changes made.
- process_installed¶
pyqtSignal(*types, name: str = …, revision: 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.
- class populse_mia.user_interface.pipeline_manager.process_library.Node(name, parent=None)[source]¶
Bases:
objectA tree-like structure to manage hierarchical data with parent-child relationships.
This class provides functionality to create and manipulate tree nodes, where each node can have a name, value, parent, and multiple children.
- __init__(name, parent=None)[source]¶
Initialize a new Node instance.
- Parameters:
(str) (name) – The name of the node.
parent – The parent node. If provided, this node is automatically added as a child to the parent. Defaults to None.
- attrs()[source]¶
Get attributes of this node as a dictionary.
- Return (dict):
A dictionary of property names and their values.
- child(row)[source]¶
Get a child node by its index.
- Parameters:
(int) (row) – The index of the child node in the children list.
- Returns:
The child node at the specified index.
- childCount()[source]¶
Get the number of children of this node.
- Return (int):
The number of child nodes.
- data(column)[source]¶
Get data about this node based on the column parameter.
- Parameters:
(int) (column) – 0 for the fully qualified name (including parent names), 1 for the value of this node.
- Return (str):
The requested data (either string path or node value).
- insertChild(position, child)[source]¶
Insert a child node at a specific position.
- Parameters:
(int) (position) – The position at which to insert the child.
child – The child node to insert.
- Return (bool):
True if insertion was successful, False otherwise.
- log(tabLevel=-1)[source]¶
Generate a formatted string representation of the node hierarchy.
- Parameters:
(int) (tabLevel) – The current indentation level. Defaults to -1.
- Retur (str):
A formatted string showing the node hierarchy.
- property name¶
Get the name of this node.
- Return (str):
The name of the node.
- parent()[source]¶
Get the parent of this node.
- Returns:
The parent node or None if this is a root node.
- removeChild(position, child)[source]¶
Remove a child node at the specified position.
- Parameters:
(int) (position) – The position of the child to remove.
child – The child node to remove.
- Return (bool):
True if removal was successful, False otherwise.
- resource()[source]¶
Get resource information for this node.
This method is a placeholder that always returns None.
- Returns:
None
- row()[source]¶
Get the index of this node in its parent’s children list.
- Return (int):
The index of this node in its parent’s children list, or None if this node has no parent.
- setData(column, value)[source]¶
Set the name or value of this node based on the column parameter.
- Parameters:
(int) (column) – 0 to set the name, 1 to set the value.
value – The new name or value to set.
- to_dict(d=None)[source]¶
Convert the node hierarchy to a dictionary.
- Parameters:
(dict) (d) – A dictionary to populate. Defaults to empty dict.
- Return (dict):
A dictionary representation of the node hierarchy.
- to_list()[source]¶
Convert the node hierarchy to a list.
- Return (list):
A list representation of the node hierarchy.
- property value¶
Get the value of this node.
- Returns:
The value of the node.
- class populse_mia.user_interface.pipeline_manager.process_library.PackageLibrary(package_tree, paths)[source]¶
Bases:
QTreeWidgetA tree widget that displays user-added packages and their modules.
This widget allows users to enable or disable packages and modules by checking or unchecking them in the tree view. The tree structure reflects the hierarchical organization of packages and their modules.
- __init__(package_tree, paths)[source]¶
Initialize the PackageLibrary widget.
- Parameters:
(dict) (package_tree) – Hierarchical representation of packages.
(list) (paths) – System paths for importing the packages.
- fill_item(item, value)[source]¶
Recursively populate the tree items.
Traverses the package tree and creates corresponding QTreeWidgetItems with appropriate check states.
- generate_tree()[source]¶
Generate the package tree structure.
Clears the current tree and populates it with items from package_tree. Temporarily disconnects the itemChanged signal to prevent unwanted updates.
- recursive_checks(parent)[source]¶
Propagate check state down to all child items.
When a parent item is checked/unchecked, all its children inherit the same check state.
- Parameters:
(QTreeWidgetItem) (parent) – Parent item whose check state is propagated.
- recursive_checks_from_child(child)[source]¶
Propagate check state up to parent items.
When a child item is checked, its parents are also checked. When a child item is unchecked, its parent is unchecked only if all siblings are also unchecked.
- Parameters:
(QTreeWidgetItem) (child) – Child item whose check state affects parents.
- set_module_view(item, state)[source]¶
Update the module’s enabled/disabled status in the package tree.
Updates the underlying package_tree data structure when an item’s check state changes in the UI.
- Parameters:
(QTreeWidgetItem) (item) – Tree item corresponding to a module.
(Qt.CheckState) (state) – New check state, Qt.Checked or Qt.Unchecked. (Qt.Checked == 2. So if val == 2 -> checkbox is checked, and if val == 0 -> checkbox is not checked)
- update_checks(item, column)[source]¶
“Handle check state changes and propagate them.
When an item’s check state changes, this method ensures the change is properly propagated to children and parent items.
- Parameters:
(QTreeWidgetItem) (item) – Item whose check state changed.
(int) (column) – Column index of the change (should be 0).
- class populse_mia.user_interface.pipeline_manager.process_library.PackageLibraryDialog(mia_main_window=None, parent=None)[source]¶
Bases:
QDialogDialog for managing package library configurations.
This dialog allows users to add, remove, and delete packages from the process library. It provides interfaces for installing packages, updating the package tree, and saving configurations.
- __init__(mia_main_window=None, parent=None)[source]¶
Initialize the PackageLibraryDialog.
- Parameters:
mia_main_window – Reference to the main application window.
(QWidget) (parent) – Parent widget for the dialog.
- add_package(module_name, class_name=None, show_error=False, init_package_tree=False)[source]¶
Add a package and its modules to the package tree with comprehensive module and class discovery.
This method recursively discovers and adds packages, subpackages, and their classes to the package tree. It provides flexible options for package initialization and error handling.
- Parameters:
(str) (class_name) – Fully qualified name of the module to add. Example: ‘myproject.processors’
(str) – Specific class name to focus on during package addition. If provided, only this class or its parent packages will be processed.
(bool) (init_package_tree) – Controls error reporting behavior. If True, displays error messages in a QMessageBox. If False, collects errors silently. Defaults to False.
(bool) – If True, reinitializes the entire package tree before adding the module. Defaults to False.
- Return (List[str] | str):
A list of error messages encountered during package addition, or “No package selected!” if no module name is provided.
- add_package_with_text(package_name=False, update_view=True)[source]¶
Add a package to the Package Library.
This method attempts to add a package or module to the library based on the provided package name. It supports adding packages with or without file extensions, and handles various import scenarios.
- Parameters:
False) (package_name (str |) – Name of the package to add. If False (default), uses the text from the line edit widget.
(bool) (update_view) – Whether to update the package list view. Defaults to True.
- delete_package(index=1, to_delete=None, remove=True, loop=False, from_pipeline_manager=False)[source]¶
Delete a package from the library (admin-only functionality).
This method removes the package from the package library tree, updates the __init__.py file, and deletes the package directory and files if they are empty.
- Parameters:
(int) (index) – Recursive index for navigating modules. Defaults to 1.
(str) (to_delete) – The package/brick to delete (e.g., ‘test.Test’). Defaults to None.
(bool) (from_pipeline_manager) – Whether to remove the brick from the package tree. Defaults to True.
(bool) – Whether to delete silently without confirmation. Defaults to False.
(bool) – Whether deletion is initiated from pipeline manager. Defaults to False.
- Return (list[str]):
A list of deleted packages/bricks.(classes).
- delete_package_with_text(package_name='', update_view=True)[source]¶
Delete a package from the line edit’s text.
- Parameters:
(str) (package_name) – The name of the package to delete. Defaults to the text in the line edit.
(bool) (update_view) – Whether to update the QListWidget after deletion. Defaults to True.
- install_processes_pop_up(from_folder=False)[source]¶
Display the install processes pop-up.
- Parameters:
(bool) (from_folder) – Whether the installation is from a folder. Defaults to False.
- static load_config()[source]¶
Loads and returns the configuration from ‘process_config.yml’.
- Return (dict | {}):
The configuration dictionary if successfully loaded, otherwise None in case of an error.
- remove_package(package)[source]¶
Removes a package from the package tree.
This method attempts to remove the specified package from the package library. If the package is not found, a warning message is displayed. The package tree is updated after a successful removal.
- Parameters:
(str) (package) – The fully qualified module name (e.g., ‘nipype.interfaces.spm’).
- Returns (bool):
True if the package was successfully removed, False if the package was not found or no package was provided.
- remove_package_with_text(package_name='', update_view=True, tree_remove=True)[source]¶
Removes the specified package from the package tree and updates the view accordingly.
- Parameters:
(str) (package_name) – The name of the package to remove. If not provided, the package name is taken from the line edit.
(bool) (tree_remove) – Whether to update the QListWidget view after removal. Defaults to True.
(bool) – Whether to remove the package from the tree. Defaults to True.
- reset_action(itemlist, add)[source]¶
Resets a previous package addition or removal action.
- Parameters:
(QListWidget) (itemlist) – The list widget containing items to reset.
(bool) (add) – If True, resets an addition by removing the package if it exists in the configuration. If False, re-adds the package.
- save(close=True)[source]¶
Saves the package library configuration to process_config.yml.
This method updates the package information from the package library tree and writes it to the configuration file. Optionally, it can close the dialog after saving.
- Parameters:
(bool) (close) – If True, closes the dialog after saving. Defaults to True.
- signal_save¶
pyqtSignal(*types, name: str = …, revision: 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.
- class populse_mia.user_interface.pipeline_manager.process_library.ProcessLibrary(d, pkg_lib)[source]¶
Bases:
QTreeViewA tree view to display available Capsul’s processes.
- Parameters:
d – dictionary corresponding to the tree (dict)
- __init__(d, pkg_lib)[source]¶
Initialize the ProcessLibrary class.
- Parameters:
(dict) (d) – Dictionary corresponding to the tree.
pkg_lib – An instance of the PackageLibraryDialog class.
- item_library_clicked¶
pyqtSignal(*types, name: str = …, revision: 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.
- keyPressEvent(event)[source]¶
Handles key press events, specifically the Delete key.
If the Delete key is pressed and the user is not in user mode, the selected package(s) will be deleted from the package library.
- Parameters:
(QKeyEvent) (event) – The key event triggering this handler.
- load_dictionary(d)[source]¶
Load a dictionary into the tree.
- Parameters:
(dict) (d) – Dictionary to load. See the packages attribute in the ProcessLibraryWidget class.
- mousePressEvent(event)[source]¶
Handles mouse press events on the tree view.
If a valid item is clicked, it sets the current index and emits a signal with the selected item’s text. If the right mouse button is pressed, a context menu is displayed, allowing the user to remove or delete a package.
- Parameters:
(QMouseEvent) (event) – The mouse event triggering this handler.
- class populse_mia.user_interface.pipeline_manager.process_library.ProcessLibraryWidget(main_window=None)[source]¶
Bases:
QWidgetWidget that manages the available Capsul’s processes in the software.
- __init__(main_window=None)[source]¶
Initialize the ProcessLibraryWidget.
- Parameters:
main_window – The current main window.
- populse_mia.user_interface.pipeline_manager.process_library.import_file(full_name, path)[source]¶
Import a Python module from a specified file path.
This function dynamically imports a module from a given file path and returns the module object. It does not modify sys.modules.
- Parameters:
(str) (path) – The name of the module to import.
(str) – The file path of the module.
- Returns:
The imported module.
- populse_mia.user_interface.pipeline_manager.process_library.node_structure_from_dict(datadict, parent=None, root_node=None)[source]¶
Construct a hierarchical node structure from a dictionary.
This function converts a nested dictionary into a tree structure suitable for a TreeModel. It processes nodes based on specific conditions and recursively builds the tree.
- Parameters:
(dict) (datadict) – The dictionary to convert into a node structure.
parent – The parent node of the current node. Defaults to None.
root_node – The root node of the tree. Defaults to None.
- Returns:
The root node of the constructed tree.
populse_mia.user_interface.pipeline_manager.process_mia module¶
Module for managing and running processes within the Populse_mia framework.
This module provides specialized classes and methods to handle the execution and completion of processes within the Populse_mia framework. It includes functionalities for managing process attributes, handling database interactions, and ensuring proper inheritance of metadata tags. The module supports various process types, including those from mia_processes, Nipype, and Capsul.
- Contains:
- Class:
MIAProcessCompletionEngine
MIAProcessCompletionEngineFactory
ProcessMIA
- class populse_mia.user_interface.pipeline_manager.process_mia.MIAProcessCompletionEngine(process, name, fallback_engine)[source]¶
Bases:
ProcessCompletionEngineA specialized completion engine for all processes within the Populse_mia context.
This engine handles both PopulseMIA processes and NipypeProcess instances with special consideration for their unique requirements:
PopulseMIA processes use their list_outputs method to generate outputs based on input parameters, primarily using filename patterns rather than attributes.
NipypeProcess instances have their MATLAB/SPM settings configured from the application configuration.
The engine also manages project-specific parameters including “project” and “output_directory” when available in the study configuration.
The completion system is augmented with Mia database integration, where attributes from input parameters (called “tags” in Mia) are added to the completion attributes.
This engine tracks completed processes in the correct order, enabling other operations to be performed in the same sequence later.
- Contains:
- Method:
- _complete_mia_process: Complete parameters for Mia-specific
processes.
- _complete_standard_process: Complete parameters for standard
(non-Mia) processes.
- complete_attributes_with_database: Augments the Capsul
completion system attributes associated with a process.
complete_nipype_common: Set Nipype parameters for SPM.
- complete_parameters: Completes file parameters from
given inputs parameters.
- complete_parameters_mia: Completion for
ProcessMIA instances.
- complete_parameters_mia: Completion for
- get_attribute_values: Get attribute values from the fallback
engine.
- get_path_completion_engine: Get the path completion engine from
the fallback engine.
get_project: Get the project associated with the process
path_attributes: Get path attributes from the fallback engine.
- remove_switch_observe: Reimplemented since it is expects
in switches completion engine.
- __init__(process, name, fallback_engine)[source]¶
Initialize the Mia process completion engine.
- Parameters:
process – The process instance to be completed.
(str) (name) – The name of the process.
fallback_engine – The fallback engine to use when MIA-specific completion is not applicable.
- complete_attributes_with_database(process_inputs=None)[source]¶
Augment the completion attributes with values from the Mia database.
Queries the database for attributes associated with input parameters and adds them to the completion attributes if matches are found.
- Parameters:
(dict) (process_inputs) – Parameters to be set on the process.
- Returns:
The augmented attributes collection.
- static complete_nipype_common(process, output_dir=True)[source]¶
Configure Nipype/SPM parameters for a process.
Sets MATLAB/SPM paths, commands, and project-specific parameters based on the configuration.
- Parameters:
process – The process to configure.
(bool) (output_dir) – If False, the output_directory attribute value is not initialised.
- complete_parameters(process_inputs=None, complete_iterations=True)[source]¶
Complete process parameters based on input values.
This method handles both standard Capsul processes and Mia-specific processes, applying the appropriate completion strategy for each.
- Parameters:
(dict) (process_inputs) – Parameters to be set on the process. May include regular parameters and completion attributes (under ‘capsul_attributes’ key).
(bool) (complete_iterations) – If False, iteration nodes in pipelines will not complete their parameters. This prevents modification of the input pipeline and avoids redundant iterations completion that will be done again during workflow building.
- complete_parameters_mia(process_inputs=None, iteration=False, verbose=False)[source]¶
Complete parameters for ProcessMIA instances.
Uses the ProcessMIA.list_outputs method to generate output parameters based on input values and sets the inheritance_dict for data indexation.
- Parameters:
(dict) (process_inputs) – Parameters to set on the process.
(bool) (verbose) – Whether this completion is for an iteration node.
(bool) – If true, makes the method verbose
- get_attribute_values()[source]¶
Get attribute values from the fallback engine.
- Returns:
The attribute values collection.
- get_path_completion_engine()[source]¶
Get the path completion engine from the fallback engine.
- Returns:
The path completion engine.
- static get_project(process)[source]¶
Get the project associated with a process.
- Parameters:
process – The process to get the project for.
- Returns:
The associated project or None if not found.
- class populse_mia.user_interface.pipeline_manager.process_mia.MIAProcessCompletionEngineFactory[source]¶
Bases:
ProcessCompletionEngineFactorySpecialization of the ProcessCompletionEngineFactory for the Populse Mia context.
This factory is identified by
factory_id = "mia_completion"and is activated in aStudyConfiginstance by setting the following 2 parameters:- study_config.attributes_schema_paths += [
‘populse_mia.user_interface.pipeline_manager.process_mia’
] study_config.process_completion = ‘mia_completion’
Once activated, the completion system is applied to all processes, distinguishing between MIA and Nipype processes. For standard processes, additional database operations are performed before invoking the underlying completion system (such as FOM or others).
- Contains:
- Method:
get_completion_engine: get a ProcessCompletionEngine instance for a given process/node
- factory_id = 'mia_completion'¶
- get_completion_engine(process, name=None)[source]¶
Retrieves a ProcessCompletionEngine instance for the given process or node.
- Parameters:
Node) (process (Process or) – The process or node for which to get the completion engine.
optional) (name (str,) – An optional name for the completion engine.
- Return (ProcessCompletionEngine):
A completion engine instance associated with the process.
- class populse_mia.user_interface.pipeline_manager.process_mia.ProcessMIA(*args, **kwargs)[source]¶
Bases:
ProcessExtends the Capsul Process class to customize execution for Mia bricks.
This class provides specialized methods for Mia bricks, including process initialization, output handling, and trait management.
Note
Type ‘ProcessMIA.help()’ for a full description of this process parameters.
Type ‘<ProcessMIA>.get_input_spec()’ for a full description of this process input trait types.
Type ‘<ProcessMIA>.get_output_spec()’ for a full description of this process output trait types.
- __init__(*args, **kwargs)[source]¶
Initializes the process instance with default attributes.
- Parameters:
(tuple) (args) – Positional arguments passed to the parent class.
(dict) (kwargs) – Keyword arguments passed to the parent class
- ignore = {}¶
- ignore_node = False¶
- init_process(int_name)[source]¶
Instantiate the process attribute given a process identifier.
- Parameters:
(str) (int_name) – A process identifier used to fetch the process instance.
- key = {}¶
- load_nii(file_path, scaled=True, matlab_like=False)[source]¶
Load a NIfTI image and return its header and data, optionally adjusting for MATLAB conventions.
MATLAB and Python (in particular NumPy) treat the order of dimensions and the origin of the coordinate system differently. MATLAB uses main column order (also known as Fortran order). NumPy (and Python in general) uses the order of the main rows (C order). For a 3D array data(x, y, z) in MATLAB, the equivalent in NumPy is data[y, x, z]. MATLAB and NumPy also handle the origin of the coordinate system differently: MATLAB’s coordinate system starts with the origin in the lower left-hand corner (as in traditional matrix mathematics). NumPy’s coordinate system starts with the origin in the top left-hand corner. When taking matlab_like=True as argument, the numpy matrix is rearranged to follow MATLAB conventions. Using scaled=False generates a raw unscaled data matrix (as in MATLAB with header = loadnifti(fnii) and header.reco.data).
- Parameters:
(str) (file_path) – The path to a NIfTI file.
(bool) (matlab_like) – If True the data is scaled.
(bool) – If True the data is rearranged to match the order of the dimensions and the origin of the coordinate system in Matlab.
- relax_nipype_exists_constraints()[source]¶
Relax the ‘exists’ constraint of the process.inputs traits.
- tags_inheritance(in_file, out_file, node_name=None, own_tags=None, tags2del=None)[source]¶
Inherit and manage data tags from input file(s) to an output file.
This method handles the inheritance of metadata tags from one or more input files to an output file. It also allows adding new tags, modifying existing ones, or deleting unwanted tags in the process.
Notes: This method performs inheritance in two ways: 1. Immediate inheritance during process execution 2. Deferred inheritance by storing inheritance information for later
use during workflow generation (addresses issue #290, #310)
In ambiguous cases (multiple input files), the method will either: - Use previously stored inheritance rules - Prompt the user for a decision if no rule exists - Auto-resolve if all inputs have identical tag values
- Parameters:
dict) (own_tags (list of) –
Source of tag inheritance. Either: - A string representing a single input
file path (unambiguous case)
A dictionary mapping plug names to corresponding input file paths (ambiguous case)
(str) (node_name) – Path of the output file that will inherit the tags.
(str) – Name of the processing node in the workflow.
dict) –
Tags to be added or modified. Each dictionary must contain: - “name”: Tag identifier - “field_type”: Data type of the tag - “description”: Human-readable
description
- ”visibility”: Boolean or visibility
level
”origin”: Source of the tag
- ”unit”: Unit of measurement
(if applicable)
”default_value”: Default value
”value”: Current value to set
str) (tags2del (list of) – Tags to be deleted from the output file.
populse_mia.user_interface.pipeline_manager.type_editors module¶
Define the Mia logger.
The soma control classes are overloaded for the needs of Mia.
- Contains:
- Class:
PopulseFileControlWidget
PopulseDirectoryControlWidget
PopulseOffscreenListFileControlWidget
PopulseUndefinedControlWidget
- class populse_mia.user_interface.pipeline_manager.type_editors.PopulseDirectoryControlWidget[source]¶
Bases:
DirectoryControlWidgetWidget for selecting a directory.
- Contains:
- Method:
create_widget: Creates the directory selection widget.
filter_clicked: Displays a filtering widget.
- update_plug_value_from_filter: Updates the plug value based on
the filter result.
- static create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None)[source]¶
Creates and returns a directory selection widget.
- Parameters:
(QWidget) (parent) – The parent widget.
(str) (control_name) – The name of the control.
(Any) (trait) – The initial value of the control.
(Any) – The trait associated with the control.
(Optional[Any]) (label_class) – The label class (optional).
(Optional[dict]) (user_data) – User data associated with the widget.
- Return (QWidget):
The directory selection widget.
- static filter_clicked(widget, node_name, plug_name)[source]¶
Displays a filter widget for selecting a directory.
- Parameters:
(QWidget) (widget) – The calling widget.
(str) (plug_name) – The name of the node.
(str) – The name of the associated plug.
- static update_plug_value_from_filter(widget, plug_name, filter_res_list)[source]¶
Updates the plug value based on the filter result.
If multiple elements are returned, the first one is selected. If the selected element is not a directory, its parent directory is used.
- Parameters:
(QWidget) (widget) – The widget being updated.
(str) (plug_name) – The name of the associated plug.
(list[str]) (filter_res_list) – The list of filtered files.
- class populse_mia.user_interface.pipeline_manager.type_editors.PopulseFileControlWidget[source]¶
Bases:
FileControlWidgetWidget control for selecting a file.
Provides methods to create a file selection widget, display a filter dialog, and update plug values based on filter results.
- Contains:
- Method:
create_widget: Method to create the file widget.
filter_clicked: Display a filter widget.
- update_plug_value_from_filter: Update the plug value from
a filter result.
- static create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None)[source]¶
Creates a file selection widget.
- Parameters:
(QWidget) (parent) – The parent widget.
(str) (control_value) – The name of the control to create.
(str) – The default control value.
(Trait) (trait) – The trait associated with the control.
(Optional[Type[QWidget]]) (label_class) – Custom label widget class.
(Optional[dict]) (user_data) – Additional user data.
- Return (Tuple[QWidget, QLabel]):
A tuple containing the created widget and its associated label. The widget includes a QLineEdit (‘path’) and a browse button (‘browse’).
- class populse_mia.user_interface.pipeline_manager.type_editors.PopulseOffscreenListFileControlWidget[source]¶
Bases:
OffscreenListFileControlWidgetA control widget for entering a list of files.
- Contains:
- Method:
create_widget: Creates the list of files widget.
filter_clicked: Displays a filter widget.
- update_plug_value_from_filter: Updates the plug value based on
the filter result.
- static create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None)[source]¶
Creates and returns a file list control widget with an optional filter button.
- Parameters:
(QWidget) (parent) – The parent widget.
(str) (control_name) – The name of the control.
(list) (control_value) – The default control value.
(Trait) (trait) – The trait associated with the control.
(type) (label_class) – A Qt widget class for the label.
(dict) (user_data) – Additional data, including project, scan list, and connected inputs.
- Return (tuple):
A tuple (control widget, (QLabel, QWidget)).
- class populse_mia.user_interface.pipeline_manager.type_editors.PopulseUndefinedControlWidget[source]¶
Bases:
objectWidget control for handling Undefined trait values in a Qt interface.
This class provides methods to create, validate, and update Qt widgets that represent undefined values in a controller-based UI framework.
- Contains:
- Method:
check: Check if a controller widget control is filled correctly.
- connect: Connect a ‘Str’ or ‘String’ controller trait and a
‘StrControlWidget’ controller widget control.
create_widget: Method to create the Undefined widget.
- disconnect: Disconnect a ‘Str’ or ‘String’ controller trait and
a ‘StrControlWidget’ controller widget control.
is_valid: Method to check if the new control value is correct.
update_controller: Update one element of the controller.
- update_controller_widget: Update one element of the controller
widget.
- STYLED_UNDEFINED_TEXT = '<style>background-color: gray; text-color: red;</style><undefined>'¶
- UNDEFINED_TEXT = '<undefined>'¶
- VALID_REPRESENTATIONS = ['<undefined>', '<style>background-color: gray; text-color: red;</style><undefined>']¶
- classmethod check(control_instance)[source]¶
Check if a controller widget control is filled correctly.
This method is a placeholder in this implementation.
- Parameters:
(StrControlWidget) (cls) – A StrControlWidget control.
(QLineEdit) (control_instance) – The control widget to check.
- classmethod connect(controller_widget, control_name, control_instance)[source]¶
Connect a ‘Str’ or ‘String’ controller trait and a ‘StrControlWidget’ controller widget control.
This method is a placeholder in this implementation.
- Parameters:
(StrControlWidget) (cls) – A StrControlWidget control.
(ControllerWidget) (controller_widget) – The controller widget containing the controller.
(str) (control_name) – The name of the control to connect.
(QWidget) (control_instance) – The widget instance to connect
- static create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None)[source]¶
Create a widget for displaying Undefined values in the UI.
This method creates a read-only QLabel widget that displays a styled representation of undefined/null values, along with an optional label.
- Parameters:
(QWidget) (parent) – The parent widget that will contain the created widgets.
(str) (control_name) – The name/text for the label widget. If None, no label is created.
control_value – The undefined value to display (currently unused in implementation).
trait – trait: The trait object associated with this control (currently unused in implementation).
label_class – The Qt widget class to use for creating the label. Defaults to QtGui.QLabel if None.
user_data – Additional user-defined data (currently unused in implementation).
- Return (tuple):
A tuple containing: - control_widget: A QLabel displaying the styled undefined value
text
- label_widget: The associated label widget, or None if
control_name is None
- static disconnect(controller_widget, control_name, control_instance)[source]¶
Disconnect a ‘Str’ or ‘String’ controller trait and a ‘StrControlWidget’ controller widget control.
This method is a placeholder in this implementation.
- Parameters:
(ControllerWidget) (controller_widget) – The controller widget containing the controller.
(str) (control_name) – The name of the control to disconnect
(QWidget) (control_instance) – The widget instance to disconnect
- static is_valid(control_instance, *args, **kwargs)[source]¶
Validate if the control contains an Undefined value representation.
- Parameters:
(QWidget) (control_instance) – The control widget to validate.
- Return (bool):
True if the control value is Undefined, False otherwise
- static update_controller(controller_widget, control_name, control_instance, reset_invalid_value, *args, **kwargs)[source]¶
Update the controller with the widget’s value if valid.
At the end the controller trait value with the name ‘control_name’ will match the controller widget user parameters defined in ‘control_instance’.
- Parameters:
(ControllerWidget) (controller_widget) – The controller widget containing the controller to update
(str) (control_name) – The name of the control to synchronize with the controller
(QWidget) (control_instance) – The widget instance to synchronize with the controller
(bool) (reset_invalid_value) – If True and the value is invalid, reset the widget to the controller’s value
- static update_controller_widget(controller_widget, control_name, control_instance)[source]¶
Update the widget to reflect the controller’s value.
At the end the controller widget user editable parameter with the name ‘control_name’ will match the controller trait value with the same name.
- Parameters:
(ControllerWidget) (controller_widget) – The controller widget containing the controller.
(str) (control_name) – The name of the control to synchronize.
(QWidget) (control_instance) – The widget instance to update.