populse_mia.user_interface.pipeline_manager.pipeline_manager_tab

Module to define pipeline manager tab appearance, settings and methods.

Functions

protected_logging()

Context manager that preserves logging configuration across soma-workflow interference.

Classes

PipelineManagerTab(project, scan_list, ...)

Widget that handles the Pipeline Manager tab.

RunProgress(pipeline_manager[, settings])

A Qt widget for displaying and managing pipeline execution progress.

RunWorker(pipeline_manager)

Worker thread for executing a pipeline in the background.

StatusWidget(pipeline_manager)

A widget that displays the current or last pipeline execution status along with logs and an optional Soma-Workflow monitoring panel.

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

Examples

>>> with protected_logging():
>>>    # Code that might interfere with logging
>>>    some_workflow_operation()
>>>    # Any new handlers/filters added here are preserved
class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.PipelineManagerTab(project, scan_list, main_window)[source]

Bases: QWidget

Widget that handles the Pipeline Manager tab.

Contains:

Methods:

  • _register_node_io_in_database: Register node input and output values in the database.

  • _set_anim_frame: Callback that updates the pipeline status action icon.

  • _should_register_plug: Determine if a plug should be registered.

  • add_plug_value_to_database: Add the plug value to the database.

  • ask_iterated_pipeline_plugs: Display a config dialog for pipeline plug iteration and database connections.

  • build_iterated_pipeline: Build a new pipeline with an iteration node.

  • check_requirements: Return the configuration of a pipeline as required.

  • cleanup_older_init: Remove non-existent entries from the databrowser.

  • complete_pipeline_parameters: Complete pipeline parameters.

  • controller_value_changed: Update history when a pipeline node is changed.

  • displayNodeParameters: Display the node controller when a node is clicked.

  • finish_execution: Handle pipeline execution completion and update UI state.

  • garbage_collect: Clean up obsolete data and maintain database consistency.

  • get_capsul_engine: Retrieve and configure a Capsul engine from the pipeline editor.

  • get_pipeline_or_process: Get the pipeline or its single unconnected process node.

  • get_missing_mandatory_parameters: Check on missing parameters for each job.

  • initialize: Clean previous initialization then initialize the current pipeline.

  • init_pipeline: Initialize the current pipeline of the pipeline editor.

  • layout_view : Initialize layout for the pipeline manager.

  • loadParameters: Load pipeline parameters to the current pipeline of the pipeline editor.

  • loadPipeline: Load a pipeline to the pipeline editor.

  • postprocess_pipeline_execution: Operations to be performed after a run has been completed.

  • redo: Redo the last undone action on the current pipeline editor.

  • register_completion_attributes: Register completion attributes for a given pipeline in the project database.

  • remove_progress: Remove and clean up the progress widget.

  • runPipeline: Run the current pipeline of the pipeline editor.

  • saveParameters: Save the pipeline parameters of the the current pipeline of the pipeline editor.

  • savePipeline: Save the current pipeline of the pipeline editor.

  • save_pipeline_as: Save the current pipeline of the pipeline editor under another name.

  • show_status: Display the execution status window with runtime information.

  • stop_execution: Interrupt pipeline execution gracefully.

  • undo: Undo the last action made on the current pipeline editor.

  • update_inheritance: Update the inheritance dictionary for a process node in a pipeline execution.

  • update_node_list: Update the list of nodes in workflow.

  • updateProcessLibrary: Update the library of processes when a pipeline is saved.

  • update_project: Update the project attribute of several objects.

  • update_scans_list: Update the user-selected list of scans.

  • update_user_buttons_states: Update the visibility of initialize / run / save actions according to the pipeline state.

  • update_user_mode: Update the visibility of widgets / actions depending of the chosen mode.

Signals:

  • item_library_clicked: Emitted when an item is selected in the process library. The signal carries the identifier or name of the selected library item as a string.

__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.

_register_node_io_in_database(job, node, pipeline_name='', history_id='')[source]

Register node input and output values in the database.

This method processes the inputs and outputs of a given node, associates them with a job, and updates the database with the appropriate values. It handles leaf processes, user-defined traits, and completion attributes, ensuring that initialization data is recorded correctly.

Parameters:
  • job – Job object containing parameter values and unique identifier (UUID).

  • node – Node instance (Process, Pipeline, or custom node) to register.

  • pipeline_name – (str, optional) Name of the containing pipeline, if any.

  • history_id – (str, optional) Database history entry identifier. Defaults to an empty string.

Note

Pipeline and PipelineNode instances are skipped as only leaf processes produce meaningful output data.

Contains:

Inner functions:

  • _serialize_for_json: Serialize objects to JSON-compatible format.

  • _update_values_from_job: Update values dictionary with job parameters.

  • _serialize_dict_values: Serialize all values in a dictionary for JSON compatibility.

_set_anim_frame()[source]

Update the pipeline status action icon with the current animation frame.

This method serves as a callback that synchronizes the animated movie’s current frame with the status action’s icon, creating a smooth animated icon effect in the UI.

Note

This method is typically connected to QMovie’s frameChanged signal to automatically update the icon as the animation progresses.

_should_register_plug(process, plug_name: str) bool[source]

Determine if a plug should be registered in the database.

Parameters:
  • process – Process instance.

  • plug_name – (str) Name of the plug to check.

Returns:

True if plug should be registered, False otherwise.

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”.

  • brick_id – (str) UUID of the brick in the database.

  • history_id – (str) UUID of the processing history in the database.

  • node_name – (str) Name of the processing node.

  • plug_name – (str) Name of the specific plug/parameter.

  • full_name – (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).

  • inputs – (dict) Input parameter values for the process/node.

  • attributes – (dict) Completion engine attributes to be applied to all outputs.

Note

  • 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.

Contains:

Inner functions:

  • is_database_compatible: Check if a plug can connect to a database filter.

  • on_iteration_toggled: Handle iteration checkbox toggle events.

  • on_database_toggled: Handle database checkbox toggle events.

  • create_dialog_layout: Build the main dialog window and layout.

  • add_parameter_controls: Add iteration and optional database controls for plugs into the grid layout.

  • extract_results: Extract the final plug configuration from 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:

  1. Interactive selection of plugs to iterate over and database connections.

  2. Preprocessing of list-type plugs with ReduceNode to handle nested lists.

  3. Creation of an iterative pipeline using the CAPSUL engine.

  4. Addition of Input_Filter nodes for database-connected plugs.

  5. 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.

Note

  • 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:

environment – (str) The target environment for checking configurations. Defaults to “global”.

Returns:

(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:
  1. Removes non-existent entries from the data browser for each brick.

  2. Cleans up orphaned non-existing files from the project.

  3. Clears the brick and node lists.

  4. 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.

Note

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.

Returns:

(CapsulEngine) A configured Capsul engine instance ready for pipeline execution, with settings applied from the Mia config object.

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.

Returns:

(Pipeline | Process) The process node if pipeline contains a single unconnected process, otherwise the pipeline itself.

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.

Returns:

(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.

initialize()[source]

Initialize the pipeline after cleaning up any previous initialization.

This method performs the following operations:
  1. Sets a wait cursor to indicate processing.

  2. Cleans up any previous initialization if needed.

  3. Resets internal state variables.

  4. Attempts to initialize the pipeline.

  5. Updates the UI with the results.

  6. 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.

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:
  • pipeline – (Pipeline, Process) The pipeline or process instance to initialize. If None, the main pipeline is retrieved.

  • pipeline_name – (str) The name of the parent pipeline, if applicable.

Returns:

(bool) True if the pipeline was successfully initialized, False otherwise.

Contains:

Inner functions:

  • _calculate_duration: Calculate the elapsed time since t0, rounded to the nearest significant digit.

  • _get_node_name: Extracts a node’s name, preferring context_name if available.

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 engine 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:

  1. Initializes the pipeline and validates prerequisites.

  2. Sets up pipeline metadata and UI state.

  3. Configures soma-workflow connection (if enabled).

  4. 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:
  1. Save to existing file with overwrite confirmation (unless skipped).

  2. Save to existing file without confirmation when warning is skipped.

  3. Save as new file when no filename exists or file is in protected directory.

Parameters:

skip_overwrite_warning – (bool) 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.

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:
  1. Project-specific inheritance history (if matching parameters are found).

  2. 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.

updateProcessLibrary(filename)[source]

Update the library of processes when a pipeline is saved.

This method performs the following operations:
  1. Renames the Pipeline class in the saved file to match the filename.

  2. Updates the __init__.py file to include the new import.

  3. Refreshes the module in sys.modules if it already exists.

  4. 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.

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:

index – (int) 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: QWidget

A 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.

Contains:

Methods:

  • _determine_completion_message: Analyze execution results and determine appropriate user message.

  • _setup_ui: Set up the user interface for the widget.

  • _show_completion_message: Display execution completion message.

  • cleanup: Clean up resources and prepare for widget destruction.

  • end_progress: Handle completion of pipeline execution and show results.

  • start: Starts the worker thread to begin the pipeline execution process.

  • stop_execution: Stops the execution of the pipeline by signaling the worker to interrupt.

Note

  • 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.

MIN_PROGRESS_WIDTH = 350
AUTO_CLOSE_DELAY_MS = 2000
__init__(pipeline_manager, settings=None)[source]

Initialize the RunProgress widget with a progress bar and worker thread.

Parameters:
  • pipeline_manager – (PipelineManagerTab) A PipelineManagerTab instance responsible for managing the pipeline.

  • settings – (dict) A dictionary of settings to customize pipeline iteration, default is None.

_determine_completion_message()[source]

Analyze execution results and determine appropriate user message.

Returns:

Dictionary containing message box configuration with keys: ‘icon’, ‘title’, and ‘text’.

_setup_ui() None[source]

Set up the user interface for the widget.

This method initializes an indeterminate progress bar with a predefined minimum width and places it inside a horizontal box layout, which is then assigned to the widget.

_show_completion_message(icon, title, text)[source]

Display execution completion message with auto-close timer.

Parameters:
  • icon – (QMessageBox.Icon) Message box icon type.

  • title – (str) Dialog window title.

  • text – (str) Message content to display.

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: QThread

Worker 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_request flag while holding lock.

Contains:

Methods:

  • _check_interrupt: Check whether an interrupt has been requested.

  • _disable_nipype_copy: Recursively check and disable the copy flag for Nipype processes in the pipeline.

  • run: Run the pipeline in a background thread.

__init__(pipeline_manager)[source]

Initialize the worker thread for pipeline execution.

Parameters:

pipeline_manager – (PipelineManager) The manager responsible for configuring, running, and monitoring the pipeline execution.

_check_interrupt(engine=None) bool[source]

Check whether an interrupt has been requested.

If an interrupt is detected, log the event and optionally stop the execution engine.

Parameters:

engine – (CapsulEngine) Execution engine to interrupt if running.

Returns:

(bool) True if an interrupt was requested, False otherwise.

_disable_nipype_copy(proc)[source]

Recursively check and disable the copy flag for Nipype processes in the pipeline.

This function traverses the pipeline’s nodes and checks if the nodes contain a NipypeProcess. If it does, it sets the activate_copy flag to False. The recursion handles nested pipelines.

Parameters:

proc – A Pipeline or NipypeProcess instance.

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: QWidget

A 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.

Contains:

Methods:

  • toggle_soma_workflow: Show or hide the Soma-Workflow monitoring widget.

__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.

toggle_soma_workflow(checked)[source]

Show or hide the Soma-Workflow monitoring widget.

If enabled and the widget does not yet exist, it is created and added below the status section.

Parameters:

checked – (bool) Whether the monitoring panel is enabled.