populse_mia.data_manager.project¶
Module that handle the projects and their database.
- Contains:
- Class:
Project
Classes
|
Class that handles projects and their associated database. |
- class populse_mia.data_manager.project.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])¶
Bases:
dateThe year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.
- astimezone()¶
tz -> convert to local time in new timezone tz
- combine()¶
date, time -> datetime with same date and time fields
- ctime()¶
Return ctime() style string.
- date()¶
Return date object with same year, month and day.
- dst()¶
Return self.tzinfo.dst(self).
- fold¶
- fromisoformat()¶
string -> datetime from a string in most ISO 8601 formats
- fromtimestamp()¶
timestamp[, tz] -> tz’s local time from POSIX timestamp.
- hour¶
- isoformat()¶
[sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. sep is used to separate the year from the time, and defaults to ‘T’. The optional argument timespec specifies the number of additional terms of the time to include. Valid options are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’ and ‘microseconds’.
- max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)¶
- microsecond¶
- min = datetime.datetime(1, 1, 1, 0, 0)¶
- minute¶
- now()¶
Returns new datetime object representing current time local to tz.
- tz
Timezone object.
If no tz is specified, uses local timezone.
- replace()¶
Return datetime with new specified fields.
- resolution = datetime.timedelta(microseconds=1)¶
- second¶
- strptime()¶
string, format -> new datetime parsed from a string (like time.strptime()).
- time()¶
Return time object with same time but with tzinfo=None.
- timestamp()¶
Return POSIX timestamp as float.
- timetuple()¶
Return time tuple, compatible with time.localtime().
- timetz()¶
Return time object with same time and tzinfo.
- tzinfo¶
- tzname()¶
Return self.tzinfo.tzname(self).
- utcfromtimestamp()¶
Construct a naive UTC datetime from a POSIX timestamp.
- utcnow()¶
Return a new datetime representing UTC day and time.
- utcoffset()¶
Return self.tzinfo.utcoffset(self).
- utctimetuple()¶
Return UTC time tuple, compatible with time.localtime().
- class populse_mia.data_manager.project.Path(*args, **kwargs)[source]¶
Bases:
PurePathPurePath subclass that can make system calls.
Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.
- stat(*, follow_symlinks=True)[source]¶
Return the result of the stat() system call on this path, like os.stat() does.
- lstat()[source]¶
Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.
- exists(*, follow_symlinks=True)[source]¶
Whether this path exists.
This method normally follows symlinks; to check whether a symlink exists, add the argument follow_symlinks=False.
- is_file()[source]¶
Whether this path is a regular file (also True for symlinks pointing to regular files).
- samefile(other_path)[source]¶
Return whether other_path is the same or not as this file (as returned by os.path.samefile()).
- open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)[source]¶
Open the file pointed to by this path and return a file object, as the built-in open() function does.
- read_text(encoding=None, errors=None)[source]¶
Open the file in text mode, read it, and close the file.
- write_text(data, encoding=None, errors=None, newline=None)[source]¶
Open the file in text mode, write to it, and close the file.
- iterdir()[source]¶
Yield path objects of the directory contents.
The children are yielded in arbitrary order, and the special entries ‘.’ and ‘..’ are not included.
- glob(pattern, *, case_sensitive=None)[source]¶
Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
- rglob(pattern, *, case_sensitive=None)[source]¶
Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.
- walk(top_down=True, on_error=None, follow_symlinks=False)[source]¶
Walk the directory tree from this directory, similar to os.walk().
- classmethod home()[source]¶
Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).
- absolute()[source]¶
Return an absolute version of this path by prepending the current working directory. No normalization or symlink resolution is performed.
Use resolve() to get the canonical path to a file.
- resolve(strict=False)[source]¶
Make the path absolute, resolving all symlinks on the way and also normalizing it.
- touch(mode=438, exist_ok=True)[source]¶
Create this file with the given access mode, if it doesn’t exist.
- lchmod(mode)[source]¶
Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.
- unlink(missing_ok=False)[source]¶
Remove this file or link. If the path is a directory, use rmdir() instead.
- rename(target)[source]¶
Rename this path to the target path.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- replace(target)[source]¶
Rename this path to the target path, overwriting if that path exists.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- symlink_to(target, target_is_directory=False)[source]¶
Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.
- class populse_mia.data_manager.project.Pipeline(autoexport_nodes_parameters=None, **kwargs)[source]¶
Bases:
ProcessPipeline containing Process nodes, and links between node parameters.
A Pipeline is normally subclassed, and its
pipeline_definition()method is overloaded to define its nodes and links.pipeline_definition()will be called by the pipeline constructor.from capsul.pipeline import Pipeline class MyPipeline(Pipeline): def pipeline_definition(self): self.add_process('proc1', 'my_toolbox.my_process1') self.add_process('proc2', 'my_toolbox.my_process2') self.add_switch('main_switch', ['in1', 'in2'], ['out1', 'out2']) self.add_link('proc1.out1->main_switch.in1_switch_out1') self.add_link('proc1.out2->main_switch.in1_switch_out2') self.add_link('proc2.out1->main_switch.in2_switch_out1') self.add_link('proc2.out1->main_switch.in2_switch_out2')
After execution of
pipeline_definition(), the inner nodes parameters which are not connected will be automatically exported to the parent pipeline, with names prefixed with their process name, unless they are listed in a special “do_not_export” list (passed toadd_process()or stored in the pipeline instance).>>> pipeline = MyPipeline() >>> print(pipeline.proc1_input) <undefined>
Nodes
A pipeline is made of nodes, and links between their parameters. Several types of nodes may be part of a pipeline:
process nodes (
pipeline_nodes.ProcessNode) are the leaf nodes which represent actual processing bricks.pipeline nodes (
pipeline_nodes.PipelineNode) are sub-pipelines which allow to reuse an existing pipeline within another oneswitch nodes (
pipeline_nodes.Switch) allows to select values between several possible inputs. The switch mechanism also allows to select between several alternative processes or processing branches.iterative process (:py:class:process_iteration.ProcessIteration`) represent parallel processing of the same pipeline on a set of parameters.
Note that you normally do not instantiate these nodes explicitly when building a pipeline. Rather programmers may call the
add_process(),add_switch(),add_iterative_process()methods.Nodes activation
Pipeline nodes may be enabled or disabled. Disabling a node will trigger a global pipeline nodes activation step, where all nodes which do not form a complete chain will be inactive. This way a branch may be disabled by disabling one of its nodes. This process is used by the switch system, which allows to select one processing branch between several, and disables the unselected ones.
Pipeline steps
Pipelines may define execution steps: they are user-oriented groups of nodes that are to be run together, or disabled together for runtime execution. They are intended to allow partial, or step-by-step execution. They do not work like the nodes enabling mechanism described above.
Steps may be defined within the
pipeline_definition()method. Seeadd_pipeline_step().Note also that pipeline steps only act at the highest level: if a sub-pipeline has disabled steps, they will not be taken into account in the higher level pipeline execution, because executing by steps a part of a sub-pipeline within the context of a higher one does generally not make sense.
Main methods
pipeline_definition()add_process()add_switch()add_custom_node()add_iterative_process()add_optional_output_switch()add_processes_selection()add_link()remove_link()export_parameter()autoexport_nodes_parameters()add_pipeline_step()define_pipeline_steps()define_groups_as_steps()remove_pipeline_step()enable_all_pipeline_steps()disabled_pipeline_steps_nodes()get_pipeline_step_nodes()find_empty_parameters()count_items()
- nodes¶
a dictionary containing the pipeline nodes and where the pipeline node name is ‘’
- Type:
dict {node_name: node}
Note
Type ‘Pipeline.help()’ for a full description of this process parameters.
Type ‘<Pipeline>.get_input_spec()’ for a full description of this process input trait types.
Type ‘<Pipeline>.get_output_spec()’ for a full description of this process output trait types.
- _doc_path = 'api/pipeline.html#pipeline'¶
- do_autoexport_nodes_parameters = True¶
- hide_nodes_activation = True¶
- __init__(autoexport_nodes_parameters=None, **kwargs)[source]¶
Initialize the Pipeline class
- Parameters:
autoexport_nodes_parameters (bool) – if True (default) nodes containing pipeline plugs are automatically exported.
- pipeline_definition()[source]¶
Define pipeline structure, nodes, sub-pipelines, switches, and links.
This method should be overloaded in subclasses, it does nothing in the base Pipeline class.
- autoexport_nodes_parameters(include_optional=False)[source]¶
Automatically export nodes plugs to the pipeline.
Some parameters can be explicitly preserved from exportation if they are listed in the pipeline “do_not_export” variable (list or set).
- Parameters:
include_optional (bool (optional)) – If True (the default), optional plugs are not exported Exception: optional output plugs of switches are exported (otherwise they are useless). It should probably be any single output plug of a node.
- add_trait(name, trait)[source]¶
Add a trait to the pipeline
- Parameters:
name (str (mandatory)) – the trait name
trait (trait instance (mandatory)) – the trait we want to add
- remove_trait(name)[source]¶
Remove a trait to the pipeline
- Parameters:
name (str (mandatory)) – the trait name
- reorder_traits(names)[source]¶
Reimplementation of
Controllermethodreorder_traits()so that we also reorder the pipeline node plugs.
- add_process(name, process, do_not_export=None, make_optional=None, inputs_to_copy=None, inputs_to_clean=None, skip_invalid=False, **kwargs)[source]¶
Add a new node in the pipeline
Note about invalid nodes:
A pipeline can typically offer alternatives (through a switch) to different algorithmic nodes, which may have different dependencies, or may be provided through external modules, thus can be missing. To handle this, Capsul can be telled that a process node can be invalid (or missing) without otherwise interfering the rest of the pipeline. This is done using the “skip_invalid” option. When used, the process to be added is tested, and if its instantiation fails, it will not be added in the pipeline, but will not trigger an error. Instead the missing node will be marked as “allowed invalid”, and links and exports built using this node will silently do nothing. thus the pipeline will work normally, without the invalid node.
Such nodes are generally gathered through a switch mechanism. However the switch inputs should be restricted to actually available nodes. The recommended method is to check that nodes have actually been added in the pipeline. Then links can be made normally as if the nodes were all present:
self.add_process('method1', 'module1.Module1', skip_invalid=True) self.add_process('method2', 'module2.Module2', skip_invalid=True) self.add_process('method3', 'module3.Module3', skip_invalid=True) input_params = [n for n in ['method1', 'method2', 'method3'] if n in self.nodes] self.add_switch('select_method', input_params, 'output') self.add_link('method1.input->select_method.method1_switch_output') self.add_link('method2.input->select_method.method2_switch_output') self.add_link('method3.input->select_method.method3_switch_output')
A last note about invalid nodes:
When saving a pipeline (through the
graphical editortypically), missing nodes will not be saved because they are not actually in the pipeline. So be careful to save only pipelines with full features.- Parameters:
name (str (mandatory)) – the node name (has to be unique).
process (Process (mandatory)) – the process we want to add. May be a string (‘module.process’), a process instance or a class.
do_not_export (list of str (optional)) – a list of plug names that we do not want to export.
make_optional (list of str (optional)) – a list of plug names that we do not want to export.
inputs_to_copy (list of str (optional)) – a list of item to copy.
inputs_to_clean (list of str (optional)) – a list of temporary items.
skip_invalid (bool) – if True, if the process is failing (cannot be instantiated), don’t throw an exception but instead don’t insert the node, and mark it as such in order to make add_link() to also silently do nothing. This option is useful for optional process nodes which may or may not be available depending on their dependencies, typically in a switch offering several alternative methods.
- add_iterative_process(name, process, iterative_plugs=None, do_not_export=None, make_optional=None, inputs_to_copy=None, inputs_to_clean=None, **kwargs)[source]¶
Add a new iterative node in the pipeline.
- Parameters:
name (str (mandatory)) – the node name (has to be unique).
process (Process or str (mandatory)) – the process we want to add.
iterative_plugs (list of str (optional)) – a list of plug names on which we want to iterate. If None, all plugs of the process will be iterated.
do_not_export (list of str (optional)) – a list of plug names that we do not want to export.
make_optional (list of str (optional)) – a list of plug names that we do not want to export.
inputs_to_copy (list of str (optional)) – a list of item to copy.
inputs_to_clean (list of str (optional)) – a list of temporary items.
- call_process_method(process_name, method, *args, **kwargs)[source]¶
Call a method of a process previously added with add_process or add_iterative_process.
- add_switch(name, inputs, outputs, export_switch=True, make_optional=(), output_types=None, switch_value=None, opt_nodes=None)[source]¶
Add a switch node in the pipeline
- Parameters:
name (str (mandatory)) – name for the switch node (has to be unique)
inputs (list of str (mandatory)) – names for switch inputs. Switch activation will select amongst them. Inputs names will actually be a combination of input and output, in the shape “input_switch_output”. This behaviour is needed when there are several outputs, and thus several input groups.
export_switch (bool (optional)) – if True, export the switch trigger to the parent pipeline with
nameas parameter namemake_optional (sequence (optional)) – list of optional outputs. These outputs will be made optional in the switch output. By default they are mandatory.
output_types (sequence of traits (optional)) – If given, this sequence should have the same size as outputs. It will specify each switch output parameter type (as a standard trait). Input parameters for each input block will also have this type.
switch_value (str (optional)) – Initial value of the switch parameter (one of the inputs names). Defaults to 1st input.
opt_nodes (bool or list) – tells that switch values are node names, and some of them may be optional and missing. In such a case, missing nodes are not added as inputs. If a list is passed, then it is a list of node names which length should match the number of inputs, and which order tells nodes related to inputs (in case inputs names are not directly node names).
Examples
>>> pipeline.add_switch('group_switch', ['in1', 'in2'], ['out1', 'out2'])
will create a switch with 4 inputs and 2 outputs: inputs: “in1_switch_out1”, “in2_switch_out1”, “in1_switch_out2”, “in2_switch_out2” outputs: “out1”, “out2”
- add_optional_output_switch(name, input, output=None)[source]¶
Add an optional output switch node in the pipeline
An optional switch activates or disables its input/output link according to the output value. If the output value is not None or Undefined, the link is active, otherwise it is inactive.
This kind of switch is meant to make a pipeline output optional, but still available for temporary files values inside the pipeline.
Ex:
A.output -> B.input
B.input is mandatory, but we want to make A.output available and optional in the pipeline outputs. If we directlty export A.output, then if the pipeline does not set a value, B.input will be empty and the pipeline run will fail.
Instead we can add an OptionalOutputSwitch between A.output and pipeline.output. If pipeline.output is set a valid value, then A.output and B.input will have the same valid value. If pipeline.output is left Undefined, then A.output and B.input will get a temporary value during the run.
Add an optional output switch node in the pipeline
- Parameters:
name (str (mandatory)) – name for the switch node (has to be unique)
input (str (mandatory)) – name for switch input. Switch activation will select between it and a hidden input, “_none”. Inputs names will actually be a combination of input and output, in the shape “input_switch_output”.
output (str (optional)) – name for output. Default is the switch name
Examples
>>> pipeline.add_optional_output_switch('out1', 'in1') >>> pipeline.add_link('node1.output->out1.in1_switch_out1')
See also
capsul.pipeline.pipeline_nodes.OptionalOutputSwitch
- add_custom_node(name, node_type, parameters=None, make_optional=(), do_not_export=None, **kwargs)[source]¶
Inserts a custom node (Node subclass instance which is not a Process) in the pipeline.
- Parameters:
node_type (str or Node subclass or Node instance) – node type to be built. Either a class (Node subclass) or a Node instance (the node will be re-instantiated), or a string describing a module and class.
parameters (dict or Controller or None) – configuration dict or Controller defining parameters needed to build the node. The controller should be obtained using the node class’s configure_node() static method, then filled with the desired values. If not given the node is supposed to be built with no parameters, which will not work for every node type.
make_optional (list or tuple) – parameters names to be made optional
do_not_export (list of str (optional)) – a list of plug names that we do not want to export.
kwargs (default values of node parameters)
- parse_link(link, check=True)[source]¶
Parse a link coming from export_parameter method.
- Parameters:
- Returns:
output – tuple containing the link description and instances
- Return type:
Examples
>>> Pipeline.parse_link("node1.plug1->node2.plug2") "node1", "plug1", <instance node1>, <instance plug1>, "node2", "plug2", <instance node2>, <instance plug2>
For a pipeline node:
>>> Pipeline.parse_link("plug1->node2.plug2") "", "plug1", <instance pipeline>, <instance plug1>, "node2", "plug2", <instance node2>, <instance plug2>
- add_link(link, weak_link=False, allow_export=False, value=None)[source]¶
Add a link between pipeline nodes.
If the destination node is a switch, force the source plug to be not optional.
- Parameters:
link (str or list/tuple) – link description. Its shape should be: “node.output->other_node.input”. If no node is specified, the pipeline itself is assumed. Alternatively the link can be (source_node, source_plug_name, dest_node, dest_plug_name)
weak_link (bool) – this property is used when nodes are optional, the plug information may not be generated.
allow_export (bool) – if True, if the link links from/to the pipeline node with a plug name which doesn’t exist, the plug will be created, and the function will act exactly like export_parameter. This may be a more convenient way of exporting/connecting pipeline plugs to several nodes without having to export the first one, then link the others.
value (any) – if given, set this value instead of the source plug value
- remove_link(link)[source]¶
Remove a link between pipeline nodes
- Parameters:
link (str or list/tuple) – link description. Its shape should be: “node.output->other_node.input”. If no node is specified, the pipeline itself is assumed. Alternatively the link can be (source_node, source_plug_name, dest_node, dest_plug_name)
- export_parameter(node_name, plug_name, pipeline_parameter=None, weak_link=False, is_enabled=None, is_optional=None, allow_existing_plug=None)[source]¶
Export a node plug at the pipeline level.
- Parameters:
node_name (str (mandatory)) – the name of node containing the plug we want to export
plug_name (str (mandatory)) – the node plug name we want to export
pipeline_parameter (str (optional)) – the name to access this parameter at the pipeline level. Default None, the plug name is used
weak_link (bool (optional)) – this property is used when nodes are weak, FIXME: what does it exactly mean ? the plug information may not be generated.
is_enabled (bool (optional)) – a property to specify that it is not a user-parameter automatic generation)
is_optional (bool (optional)) – sets the exported parameter to be optional
allow_existing_plug (bool (optional)) – the same pipeline plug may be connected to several process plugs
- propagate_metadata(node, param, metadata)[source]¶
Set metadata on a node parameter, and propagate these values to the connected plugs.
Typically needed to propagate the “forbid_completion” metadata to avoid manuyally set values to be overridden by completion.
node may be a Node instance or a node name
- all_nodes()[source]¶
Iterate over all pipeline nodes including sub-pipeline nodes.
- Returns:
nodes – Iterates over all nodes
- Return type:
Generator of Node
- _check_local_node_activation(node)[source]¶
Try to activate a node and its plugs according to its state and the state of its direct neighbouring nodes.
- _check_local_node_deactivation(node)[source]¶
Check plugs that have to be deactivated according to node activation state and to the state of its direct neighbouring nodes.
- update_nodes_and_plugs_activation()[source]¶
Reset all nodes and plugs activations according to the current state of the pipeline (i.e. switch selection, nodes disabled, etc.). Activations are set according to the following rules.
- workflow_graph(remove_disabled_steps=True, remove_disabled_nodes=True)[source]¶
Generate a workflow graph
- Returns:
graph (topological_sort.Graph) – graph representation of the workflow from the current state of the pipeline
remove_disabled_steps (bool (optional)) – When set, disabled steps (and their children) will not be included in the workflow graph. Default: True
remove_disabled_nodes (bool (optional)) – When set, disabled nodes will not be included in the workflow graph. Default: True
- workflow_ordered_nodes(remove_disabled_steps=True)[source]¶
Generate a workflow: list of process node to execute
- Returns:
workflow_list (list of Process) – an ordered list of Processes to execute
remove_disabled_steps (bool (optional)) – When set, disabled steps (and their children) will not be included in the workflow graph. Default: True
- _check_temporary_files_for_node(node, temp_files)[source]¶
Check temporary outputs and allocate files for them.
Temporary files or directories will be appended to the temp_files list, and the node parameters will be set to temp file names.
This internal function is called by the sequential execution, _run_process() (also used through __call__()). The pipeline state will be restored at the end of execution using _free_temporary_files().
- _free_temporary_files(temp_files)[source]¶
Delete and reset temp files after the pipeline execution.
This internal function is called at the end of _run_process() (sequential execution)
- _run_process()[source]¶
Pipeline execution is managed by StudyConfig class. This method must not be called.
- find_empty_parameters()[source]¶
Find internal File/Directory parameters not exported to the main input/output parameters of the pipeline with empty values. This is meant to track parameters which should be associated with temporary files internally.
- Returns:
Each element is a list with 3 values: node, parameter_name, optional
- Return type:
- count_items()[source]¶
Count pipeline items to get its size.
- Returns:
items – (nodes_count, processes_count, plugs_count, params_count, links_count, enabled_nodes_count, enabled_procs_count, enabled_links_count)
- Return type:
- pipeline_state()[source]¶
Return an object composed of basic Python objects that contains the whole structure and state of the pipeline. This object can be given to compare_to_state method in order to get the differences with a previously stored state. This is typically used in tests scripts.
- Returns:
pipeline_state – todo
- Return type:
dictionary
- compare_to_state(pipeline_state)[source]¶
Returns the differences between this pipeline and a previously recorded state.
- Returns:
differences – each element is a human readable string explaining one difference (e.g. ‘node “my_process” is missing’)
- Return type:
- install_links_debug_handler(log_file=None, handler=None, prefix='')[source]¶
Set callbacks when traits value change, and follow plugs links to debug links propagation and problems in it.
- Parameters:
log_file (str (optional)) – file-like object to write links propagation in. If none is specified, a temporary file will be created for it.
handler (function (optional)) – Callback to be processed for debugging. If none is specified, the default pipeline debugging function will be used. This default handler prints traits changes and links to be processed in the log_file. The handler function will receive a prefix string, a node, and traits parameters, namely the object (process) owning the changed value, the trait name and value in this object.
prefix (str (optional)) – prefix to be prepended to traits names, typically the parent pipeline full name
- Returns:
log_file
- Return type:
the file object where events will be written in
- uninstall_links_debug_handler()[source]¶
Remove links debugging callbacks set by install_links_debug_handler
- define_pipeline_steps(steps)[source]¶
Define steps in the pipeline. Steps are pipeline portions that form groups, and which can be enabled or disabled on a runtime basis (when building workflows).
Once steps are defined, their activation may be accessed through the “step” trait, which has one boolean property for each step:
Ex:
steps = OrderedDict() steps['preprocessings'] = [ 'normalization', 'bias_correction', 'histo_analysis'] steps['brain_extraction'] = [ 'brain_segmentation', 'hemispheres_split'] pipeline.define_pipeline_steps(steps)
>>> print(pipeline.pipeline_steps.preprocessings) True
>>> pipeline.pipeline_steps.brain_extraction = False
See also add_pipeline_step()
- Parameters:
steps (dict or preferably OrderedDict or SortedDictionary (mandatory)) – The steps dict keys are steps names, the values are lists of nodes names forming the step.
- add_pipeline_step(step_name, nodes, enabled=True)[source]¶
Add a step definition to the pipeline (see also define_steps).
Steps are groups of pipeline nodes, which may be disabled at runtime. They are normally defined in a logical order regarding the workflow streams. They are different from pipelines in that steps are purely virtual groups, they do not have parameters.
Disabling a step acts differently as the pipeline node activation: other nodes are not inactivated according to their dependencies. Instead, those steps are not run.
- disabled_pipeline_steps_nodes()[source]¶
List nodes disabled for runtime execution
- Returns:
disabled_nodes – list of pipeline nodes (Node instances) which will not run in a workflow created from this pipeline state.
- Return type:
- enable_all_pipeline_steps()[source]¶
Set all defined steps (using add_step() or define_steps()) to be enabled. Useful to reset the pipeline state after it has been changed.
- add_processes_selection(selection_parameter, selection_groups, value=None)[source]¶
Add a processes selection switch definition to the pipeline.
Selectors are a “different” kind of switch: one pipeline node set in a group is enabled, the others are disabled.
The selector has 2 levels:
selection_parameter selects a group.
A group contains a set of nodes which will be activated together. Groups are mutually exclusive.
- Parameters:
selection_parameter (string (mandatory)) – name of the selector parameter: the parameter is added in the pipeline, and its value is the name of the selected group.
selection_groups (dict or OrderedDict) – nodes groups contained in the selector : {group_name: [Node names]}
value (str (optional)) – initial state of the selector (default: 1st group)
- get_processes_selections()[source]¶
Get process_selection groups names (corresponding to selection parameters on the pipeline)
- get_processes_selection_groups(selection_parameter)[source]¶
Get groups names involved in a processes selection switch
- get_processes_selection_nodes(selection_parameter, group)[source]¶
Get nodes names involved in a processes selection switch with value group
- set_study_config(study_config)[source]¶
Set a StudyConfig for the process. Note that it can only be done once: once a non-null StudyConfig has been assigned to the process, it should not change.
- define_groups_as_steps(exclusive=True)[source]¶
Define parameters groups according to which steps they are connected to.
- Parameters:
exclusive (bool (optional)) – if True, a parameter is assigned to a single group, the first step it is connected to. If False, a parameter is assigned all steps groups it is connected to.
- class populse_mia.data_manager.project.PipelineNode(pipeline, name, process, **kwargs)[source]¶
Bases:
ProcessNodeA special node to store the pipeline user-parameters
- get_connections_through(plug_name, single=False)[source]¶
If the node has internal links (inside a pipeline, or in a switch or other custom connection node), return the “other side” of the internal connection to the selected plug. The returned plug may be in an internal node (in a pipeline), or in an external node connected to the node. When the node is “opaque” (no internal connections), it returns the input plug. When the node is inactive / disabled, it returns [].
- Parameters:
- Returns:
[(node, plug_name, plug), …] Returns [(self, plug_name, plug)] when the plug has no internal connection.
- Return type:
connected_plug; list of tuples
- class populse_mia.data_manager.project.ProcessNode(pipeline, name, process, **kwargs)[source]¶
Bases:
NodeProcess node.
- process¶
the process instance stored in the pipeline node
- Type:
process instance
- set_callback_on_plug(plug_name, callback)[source]¶
Add an event when a plug change
- Parameters:
plug_name (str (mandatory)) – a plug name
callback (@f (mandatory)) – a callback function
- remove_callback_from_plug(plug_name, callback)[source]¶
Remove an event when a plug change
- Parameters:
plug_name (str (mandatory)) – a plug name
callback (@f (mandatory)) – a callback function
- protect_parameter(plug_name, state=True)[source]¶
Protect the named parameter.
Protecting is not a real lock, it just marks the parameter a list of “protected” parameters. This is typically used to mark values that have been set manually by the user (using the ControllerWidget for instance) and that should not be later modified by automatic parameters tweaking (such as completion systems).
Protected parameters are listed in an additional trait, “protected_parameters”.
If the “state” parameter is False, then we will unprotect it (calling unprotect_parameter())
- get_trait(trait_name)[source]¶
Return the desired trait
- Parameters:
trait_name (str (mandatory)) – a trait name
- Returns:
output – the trait named trait_name
- Return type:
trait
- is_job()[source]¶
if True, the node will be represented as a Job in Soma-Workflow. Otherwise the node is static and does not run.
- requirements()[source]¶
Requirements reimplementation for a process node. This node delegates to its underlying process. see
capsul.process.process.requirements()
- check_requirements(environment='global', message_list=None)[source]¶
Reimplementation of
capsul.pipeline.pipeline_nodes.Node.requirements()for a ProcessNode. This one delegates to its underlying process (or pipeline).
- property study_config¶
- property completion_engine¶
- class populse_mia.data_manager.project.QCoreApplication(argv: List[str])¶
Bases:
QObject- aboutToQuit¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- flush()¶
- instance() QCoreApplication | None¶
- postEvent(receiver: QObject | None, event: QEvent | None, priority: int = Qt.EventPriority.NormalEventPriority)¶
- processEvents(flags: QEventLoop.ProcessEventsFlags | QEventLoop.ProcessEventsFlag = QEventLoop.ProcessEventsFlag.AllEvents)¶
- processEvents(flags: QEventLoop.ProcessEventsFlags | QEventLoop.ProcessEventsFlag, maxtime: int) None
- quit()¶
- setAttribute(attribute: Qt.ApplicationAttribute, on: bool = True)¶
- testAttribute(attribute: Qt.ApplicationAttribute) bool¶
- class populse_mia.data_manager.project.QInputDialog(parent: QWidget | None = None, flags: Qt.WindowFlags | Qt.WindowType = Qt.WindowFlags())¶
Bases:
QDialog- DoubleInput = 2¶
- class InputDialogOptions¶
- class InputDialogOptions(f: QInputDialog.InputDialogOptions | QInputDialog.InputDialogOption)
- class InputDialogOptions(a0: QInputDialog.InputDialogOptions)
Bases:
simplewrapper
- IntInput = 1¶
- NoButtons = 1¶
- TextInput = 0¶
- UseListViewForComboBoxItems = 2¶
- UsePlainTextEditForTextInput = 4¶
- doubleValueChanged¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- doubleValueSelected¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- getDouble(parent: QWidget | None, title: str | None, label: str | None, value: float = 0, min: float = -2147483647, max: float = 2147483647, decimals: int = 1, flags: Qt.WindowFlags | Qt.WindowType = Qt.WindowFlags())¶
- getDouble(parent: QWidget | None, title: str | None, label: str | None, value: float, minValue: float, maxValue: float, decimals: int, flags: Qt.WindowFlags | Qt.WindowType, step: float) None
- getInt(parent: QWidget | None, title: str | None, label: str | None, value: int = 0, min: int = -2147483647, max: int = 2147483647, step: int = 1, flags: Qt.WindowFlags | Qt.WindowType = Qt.WindowFlags())¶
- getItem(parent: QWidget | None, title: str | None, label: str | None, items: Iterable[str | None], current: int = 0, editable: bool = True, flags: Qt.WindowFlags | Qt.WindowType = Qt.WindowFlags(), inputMethodHints: Qt.InputMethodHints | Qt.InputMethodHint = Qt.ImhNone)¶
- getMultiLineText(parent: QWidget | None, title: str | None, label: str | None, text: str | None = '', flags: Qt.WindowFlags | Qt.WindowType = Qt.WindowFlags(), inputMethodHints: Qt.InputMethodHints | Qt.InputMethodHint = Qt.ImhNone)¶
- getText(parent: QWidget | None, title: str | None, label: str | None, echo: QLineEdit.EchoMode = QLineEdit.Normal, text: str | None = '', flags: Qt.WindowFlags | Qt.WindowType = Qt.WindowFlags(), inputMethodHints: Qt.InputMethodHints | Qt.InputMethodHint = Qt.ImhNone)¶
- inputMode(self) QInputDialog.InputMode¶
- intValueChanged¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- intValueSelected¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- minimumSizeHint(self) QSize¶
- options(self) QInputDialog.InputDialogOptions¶
- setInputMode(self, mode: QInputDialog.InputMode)¶
- setOption(self, option: QInputDialog.InputDialogOption, on: bool = True)¶
- setOptions(self, options: QInputDialog.InputDialogOptions | QInputDialog.InputDialogOption)¶
- setTextEchoMode(self, mode: QLineEdit.EchoMode)¶
- sizeHint(self) QSize¶
- testOption(self, option: QInputDialog.InputDialogOption) bool¶
- textEchoMode(self) QLineEdit.EchoMode¶
- textValueChanged¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- textValueSelected¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- class populse_mia.data_manager.project.QLineEdit(parent: QWidget | None = None)¶
- class populse_mia.data_manager.project.QLineEdit(contents: str | None, parent: QWidget | None = None)
Bases:
QWidget- LeadingPosition = 0¶
- NoEcho = 1¶
- Normal = 0¶
- Password = 2¶
- PasswordEchoOnEdit = 3¶
- TrailingPosition = 1¶
- addAction(self, action: QAction | None)¶
- addAction(self, action: QAction | None, position: QLineEdit.ActionPosition) None
- addAction(self, icon: QIcon, position: QLineEdit.ActionPosition) QAction | None
- alignment(self) Qt.Alignment¶
- backspace(self)¶
- clear(self)¶
- copy(self)¶
- cursorMoveStyle(self) Qt.CursorMoveStyle¶
- cursorPositionChanged¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- cursorRect(self) QRect¶
- cut(self)¶
- del_(self)¶
- deselect(self)¶
- echoMode(self) QLineEdit.EchoMode¶
- editingFinished¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- getTextMargins(self)¶
- inputMethodQuery(self, a0: Qt.InputMethodQuery) Any¶
- inputMethodQuery(self, property: Qt.InputMethodQuery, argument: Any) Any
- inputRejected¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- minimumSizeHint(self) QSize¶
- paste(self)¶
- redo(self)¶
- returnPressed¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- selectAll(self)¶
- selectionChanged¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- setAlignment(self, flag: Qt.Alignment | Qt.AlignmentFlag)¶
- setCursorMoveStyle(self, style: Qt.CursorMoveStyle)¶
- setEchoMode(self, a0: QLineEdit.EchoMode)¶
- setTextMargins(self, left: int, top: int, right: int, bottom: int)¶
- setTextMargins(self, margins: QMargins) None
- sizeHint(self) QSize¶
- textChanged¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- textEdited¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- textMargins(self) QMargins¶
- undo(self)¶
- class populse_mia.data_manager.project.QMessageBox(parent: QWidget | None = None)¶
- class populse_mia.data_manager.project.QMessageBox(icon: QMessageBox.Icon, title: str | None, text: str | None, buttons: QMessageBox.StandardButtons | QMessageBox.StandardButton = QMessageBox.NoButton, parent: QWidget | None = None, flags: Qt.WindowFlags | Qt.WindowType = Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint)
Bases:
QDialog- Abort = 262144¶
- AcceptRole = 0¶
- ActionRole = 3¶
- Apply = 33554432¶
- ApplyRole = 8¶
- ButtonMask = -769¶
- Cancel = 4194304¶
- Close = 2097152¶
- Critical = 3¶
- Default = 256¶
- DestructiveRole = 2¶
- Discard = 8388608¶
- Escape = 512¶
- FirstButton = 1024¶
- FlagMask = 768¶
- Help = 16777216¶
- HelpRole = 4¶
- Ignore = 1048576¶
- Information = 1¶
- InvalidRole = -1¶
- LastButton = 134217728¶
- No = 65536¶
- NoAll = 131072¶
- NoButton = 0¶
- NoIcon = 0¶
- NoRole = 6¶
- NoToAll = 131072¶
- Ok = 1024¶
- Open = 8192¶
- Question = 4¶
- RejectRole = 1¶
- Reset = 67108864¶
- ResetRole = 7¶
- RestoreDefaults = 134217728¶
- Retry = 524288¶
- Save = 2048¶
- SaveAll = 4096¶
- class StandardButtons¶
- class StandardButtons(f: QMessageBox.StandardButtons | QMessageBox.StandardButton)
- class StandardButtons(a0: QMessageBox.StandardButtons)
Bases:
simplewrapper
- Warning = 2¶
- Yes = 16384¶
- YesAll = 32768¶
- YesRole = 5¶
- YesToAll = 32768¶
- addButton(self, button: QAbstractButton | None, role: QMessageBox.ButtonRole)¶
- addButton(self, text: str | None, role: QMessageBox.ButtonRole) QPushButton | None
- addButton(self, button: QMessageBox.StandardButton) QPushButton | None
- button(self, which: QMessageBox.StandardButton) QAbstractButton | None¶
- buttonClicked¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- buttonRole(self, button: QAbstractButton | None) QMessageBox.ButtonRole¶
- critical(parent: QWidget | None, title: str | None, text: str | None, buttons: QMessageBox.StandardButtons | QMessageBox.StandardButton = QMessageBox.Ok, defaultButton: QMessageBox.StandardButton = QMessageBox.NoButton) QMessageBox.StandardButton¶
- defaultButton(self) QPushButton | None¶
- icon(self) QMessageBox.Icon¶
- information(parent: QWidget | None, title: str | None, text: str | None, buttons: QMessageBox.StandardButtons | QMessageBox.StandardButton = QMessageBox.Ok, defaultButton: QMessageBox.StandardButton = QMessageBox.NoButton) QMessageBox.StandardButton¶
- question(parent: QWidget | None, title: str | None, text: str | None, buttons: QMessageBox.StandardButtons | QMessageBox.StandardButton = QMessageBox.StandardButtons(QMessageBox.Yes | QMessageBox.No), defaultButton: QMessageBox.StandardButton = QMessageBox.NoButton) QMessageBox.StandardButton¶
- setDefaultButton(self, button: QPushButton | None)¶
- setDefaultButton(self, button: QMessageBox.StandardButton) None
- setEscapeButton(self, button: QAbstractButton | None)¶
- setEscapeButton(self, button: QMessageBox.StandardButton) None
- setIcon(self, a0: QMessageBox.Icon)¶
- setStandardButtons(self, buttons: QMessageBox.StandardButtons | QMessageBox.StandardButton)¶
- setTextFormat(self, a0: Qt.TextFormat)¶
- setTextInteractionFlags(self, flags: Qt.TextInteractionFlags | Qt.TextInteractionFlag)¶
- setWindowModality(self, windowModality: Qt.WindowModality)¶
- standardButton(self, button: QAbstractButton | None) QMessageBox.StandardButton¶
- standardButtons(self) QMessageBox.StandardButtons¶
- standardIcon(icon: QMessageBox.Icon) QPixmap¶
- textFormat(self) Qt.TextFormat¶
- textInteractionFlags(self) Qt.TextInteractionFlags¶
- warning(parent: QWidget | None, title: str | None, text: str | None, buttons: QMessageBox.StandardButtons | QMessageBox.StandardButton = QMessageBox.Ok, defaultButton: QMessageBox.StandardButton = QMessageBox.NoButton) QMessageBox.StandardButton¶
- class populse_mia.data_manager.project.DatabaseMIA(database_engine)[source]¶
Bases:
objectClass providing tools for interacting with a database, under the supervision of populse_db.
- __init__(database_engine)[source]¶
Initializes a DatabaseMIA instance with the given database file.
- Parameters:
(str) (database_engine) – Path to the database file (e.g., ‘/a/folder/path/file.db’).
- close()[source]¶
Closes any open resources or connections held by the instance.
This method sets the storage attribute to None, effectively releasing any held references and cleaning up the object’s state.
- data(write=None, create=None)[source]¶
Provides a context manager for accessing the database data layer.
This method allows safe read and write access to the database data, ensuring proper resource management.
- Parameters:
(bool) (create) – If True, enables write mode.
(bool) – If True, allows creating new records.
- Yields (DatabaseMiaData):
The data interface for the database.
- class populse_mia.data_manager.project.Filter(name, nots, values, fields, links, conditions, search_bar)[source]¶
Bases:
objectClass that represent a Filter, containing the results of both rapid and advanced search.
The advanced search creates a complex query to the database and is a combination of several “query lines” which are linked with AND or OR and all composed of: - A negation or not - A tag name or all visible tags - A condition (==, !=, >, <, >=, <=, CONTAINS, IN, BETWEEN) - A value
- Parameters:
name – filter’s name
nots – list of negations (”” or NOT)
values – list of values
fields – list of list of fields
links – list of links (AND/OR)
conditions – list of conditions (==, !=, <, >, <=, >=, IN, BETWEEN, CONTAINS, HAS VALUE, HAS NO VALUE)
search_bar – value in the rapid search bar
- __init__(name, nots, values, fields, links, conditions, search_bar)[source]¶
Initialization of the Filter class.
- Parameters:
name – filter’s name
nots – list of negations (”” or NOT)
values – list of values
fields – list of list of fields
links – list of links (AND/OR)
conditions – list of conditions (==, !=, <, >, <=, >=, IN, BETWEEN, CONTAINS, HAS VALUE, HAS NO VALUE)
search_bar – value in the rapid search bar
- class populse_mia.data_manager.project.Config(properties_path=None)[source]¶
Bases:
objectObject that handles the configuration of the software
Contains:
Methods:
_configure_matlab_only: Configures MATLAB without SPM
_configure_matlab_spm: Configures SPM and MATLAB
_configure_mcr_only: Configures MCR without SPM
_configure_standalone_spm: Configures standalone SPM and MCR
_disable_matlab_spm: Disables all MATLAB and SPM configurations
get_admin_hash: Get the value of the hash of the admin password
get_afni_path: Returns the path of AFNI
get_ants_path: Returns the path of ANTS
getBackgroundColor: Get background color
get_capsul_config: Get CAPSUL config dictionary
get_capsul_engine: Get a global CapsulEngine object used for all operations in MIA application
getChainCursors: Returns if the “chain cursors” checkbox of the mini-viewer is activated
get_freesurfer_setup: Get freesurfer path
get_fsl_config: Returns the path of the FSL config file
get_mainwindow_maximized: Get the maximized (full-screen) flag
get_mainwindow_size: Get the main window size
get_matlab_command: Returns Matlab command
get_matlab_path: Returns the path of Matlab’s executable
get_matlab_standalone_path: Returns the path of Matlab Compiler Runtime
get_max_projects: Returns the maximum number of projects displayed in the “Saved projects” menu
get_max_thumbnails: Get max thumbnails number at the data browser bottom
get_mri_conv_path: Returns the MRIManager.jar path
get_mrtrix_path: Returns mrtrix path
getNbAllSlicesMax: Returns the maximum number of slices to display in the mini viewer
get_opened_projects: Returns the opened projects
get_projects_save_path: Returns the folder where the projects are saved
get_properties_path: Returns the software’s properties path
get_referential: Returns boolean to indicate DataViewer referential
get_resources_path: Get the resources path
getShowAllSlices: Returns if the “show all slices” checkbox of the mini viewer is activated
getSourceImageDir: Get the source directory for project images
get_spm_path: Returns the path of SPM12 (license version)
get_spm_standalone_path: Returns the path of SPM12 (standalone version)
getTextColor: Return the text color
getThumbnailTag: Returns the tag that is displayed in the mini viewer
get_use_afni: Returns the value of “use afni” checkbox in the preferences
get_use_ants: Returns the value of “use ants” checkbox in the preferences
get_use_clinical: Returns the value of “clinical mode” checkbox in the preferences
get_use_freesurfer: Returns the value of “use freesurfer” checkbox in the preferences
get_use_fsl: Returns the value of “use fsl” checkbox in the preferences
get_use_matlab: Returns the value of “use matlab” checkbox in the preferences
get_use_matlab_standalone: Returns the value of “use matlab standalone” checkbox in the preferences
get_use_mrtrix: Returns the value of “use mrtrix” checkbox in the preferences
get_user_level: Get the user level in the Capsul config
get_user_mode: Returns the value of “user mode” checkbox in the preferences
get_use_spm: Returns the value of “use spm” checkbox in the preferences
get_use_spm_standalone: Returns the value of “use spm standalone” checkbox in the preferences
getViewerConfig: Returns the DataViewer configuration (neuro or radio), by default neuro
getViewerFramerate: Returns the DataViewer framerate for automatic time running images
isAutoSave: Checks if auto-save mode is activated
isControlV1: Checks if the selected display of the controller is of V1 type
isRadioView: Checks if miniviewer in radiological orientation (if not, then it is in neurological orientation)
loadConfig: Reads the config in the config.yml file
saveConfig: Saves the config to the config.yml file
set_admin_hash: Set the password hash
set_afni_path: Set the path of the AFNI
set_ants_path: Set the path of the ANTS
setAutoSave: Sets the auto-save mode
setBackgroundColor: Sets the background color
set_capsul_config: Set CAPSUL configuration dict into MIA config
setChainCursors: Set the “chain cursors” checkbox of the mini viewer
set_clinical_mode: Set the value of “clinical mode” in the preferences
setControlV1: Set controller display mode (True if V1)
set_freesurfer_setup: Set freesurfer path
set_fsl_config: Set the path of the FSL config file
set_mainwindow_maximized: Set the maximized (fullscreen) flag
set_mainwindow_size: Set main window size
set_matlab_path: Set the path of Matlab’s executable
set_matlab_standalone_path: Set the path of Matlab Compiler Runtime
set_max_projects: Set the maximum number of projects displayed in the “Saved projects” menu
set_max_thumbnails: Set max thumbnails number at the data browser bottom
set_mri_conv_path: Set the MRIManager.jar path
set_mrtrix_path: Set the path of mrtrix
setNbAllSlicesMax: Set the maximum number of slices to display in the mini viewer
set_opened_projects: Set the opened projects
set_projects_save_path: Set the folder where the projects are saved
set_radioView: Set the orientation in miniviewer (True for radiological, False for neurological orientation)
set_referential: Set the DataViewer referential
set_resources_path: Set the resources path
setShowAllSlices: Set the “show all slices” checkbox of the mini viewer
setSourceImageDir: Set the source directory for project images
set_spm_path: Set the path of SPM12 (license version)
set_spm_standalone_path: Set the path of SPM12 (standalone version)
setTextColor: Set the text color
setThumbnailTag: Set the tag that is displayed in the mini viewer
set_use_afni: Set the value of “use afni” checkbox in the preferences
set_use_ants: Set the value of “use ants” checkbox in the preferences
set_use_freesurfer: Set the value of “use freesurfer” checkbox in the preferences
set_use_fsl: Set the value of “use fsl” checkbox in the preferences
set_use_matlab: Set the value of “use matlab” checkbox in the preferences
set_use_matlab_standalone: Set the value of “use matlab standalone” checkbox in the preferences
set_use_mrtrix: Set the value of “use mrtrix” checkbox in the preferences
set_user_mode: Set the value of “user mode” checkbox in the preferences
set_use_spm: Set the value of “use spm” checkbox in the preferences
set_use_spm_standalone: Set the value of “use spm standalone” checkbox in the preferences
setViewerConfig: Set the Viewer configuration neuro or radio
setViewerFramerate: Set the Viewer frame rate for automatic running time images
update_capsul_config: Update a global CapsulEngine object used for all operations in MIA application
- capsul_engine = None¶
- __init__(properties_path=None)[source]¶
Initialization of the Config class
- Parameters:
properties_path – (str) If provided, the configuration file will be loaded / saved from the given directory. Otherwise, the regular heuristics will be used to determine the config path. This option allows to use an alternative config directory (for tests for instance).
- _configure_matlab_only(matlab_path: str) None[source]¶
Configures MATLAB without SPM, ensuring that only MATLAB is used.
- Parameters:
matlab_path – (str) The directory path of the MATLAB installation.
- _configure_matlab_spm(spm_dir, matlab_path)[source]¶
Configures SPM to use the specified SPM directory with a MATLAB installation.
- Parameters:
spm_dir – (str) The directory path of the SPM installation.
matlab_path – (str) The directory path of the MATLAB installation.
- _configure_mcr_only(mcr_dir: str) None[source]¶
Configures MATLAB Compiler Runtime (MCR) without SPM, ensuring that only MCR is used.
- Parameters:
mcr_dir – (str) The directory path of the MATLAB Compiler Runtime (MCR).
- _configure_standalone_spm(spm_dir, mcr_dir)[source]¶
Configures standalone SPM to use the specified SPM and MATLAB Compiler Runtime (MCR) directories.
- Parameters:
spm_dir – (str) The directory path of the standalone SPM installation.
mcr_dir – (str) The directory path of the MATLAB Compiler Runtime (MCR).
- _disable_matlab_spm() None[source]¶
Disables all MATLAB and SPM configurations, ensuring that neither MATLAB nor SPM is used.
- get_admin_hash()[source]¶
Retrieves the hashed admin password from the configuration.
- Returns:
The hashed admin password if found in config, False if not present in config.
- getBackgroundColor()[source]¶
Get background color.
- Returns:
(str) Background color, or “” if unknown.
- get_capsul_config(sync_from_engine=True)[source]¶
Retrieve and construct the Capsul configuration dictionary.
This function builds a configuration dictionary for Capsul, incorporating settings for various neuroimaging tools and processing engines. It manages configurations for tools like SPM, FSL, FreeSurfer, MATLAB, AFNI, ANTs, and MRTrix.
The function first retrieves local settings for each tool from the Mia preferences, then constructs the appropriate configuration structure. If requested, it can synchronize the configuration with the current Capsul engine state.
- Parameters:
sync_from_engine – (bool) If True, synchronizes the configuration with the current Capsul engine settings after building the base configuration.
- Returns:
(dict) A nested dictionary containing the complete Capsul configuration, structured with the following main sections:
engine_modules: List of available processing modulesengine: Contains global and environment-specific settings, as well as configurations specific to certain tools (SPM, FSL, etc.)
- Private functions:
_configure_spm: Configure SPM settings.
_configure_tool: Configure various neuroimaging settings (e.g. ‘fsl’, ‘afni’, etc.)
- static get_capsul_engine()[source]¶
Get or create a global CapsulEngine singleton for Mia application operations.
The engine is created only once when first needed (lazy initialization). Subsequent calls return the same instance.
- Returns:
(CapsulEngine) The global CapsulEngine instance.
- getChainCursors()[source]¶
Get the value of the checkbox ‘chain cursor’ in miniviewer.
- Returns:
(bool) Value of the checkbox.
- get_freesurfer_setup()[source]¶
Get the freesurfer path.
- Returns:
(str) Path to freesurfer, or “” if unknown.
- get_fsl_config()[source]¶
Get the FSL config file path.
- Returns:
(str) Path to the fsl/etc/fslconf/fsl.sh file.
- get_mainwindow_maximized()[source]¶
Get the maximized (fullscreen) flag.
- Returns:
(bool) Maximized (fullscreen) flag.
- get_matlab_command()[source]¶
Retrieves the appropriate Matlab command based on the configuration.
- Returns:
(str) The Matlab executable path or None if no path is specified.
- get_matlab_standalone_path()[source]¶
Get the path to matlab compiler runtime.
- Returns:
(str) A path.
- get_max_projects()[source]¶
Retrieves the maximum number of projects displayed in the “Saved projects” menu.
- Returns:
(int) The maximum number of projects. Defaults to 5 if not specified.
- get_max_thumbnails()[source]¶
Retrieves the maximum number of thumbnails displayed in the mini-viewer at the bottom of the data browser.
- Returns:
(int) The maximum number of thumbnails. Defaults to 5 if not specified.
- getNbAllSlicesMax()[source]¶
Get number the maximum number of slices to display in the miniviewer.
- Returns:
(int) Maximum number of slices to display in miniviewer.
- get_properties_path()[source]¶
Retrieves the path to the folder containing the “processes” and “properties” directories of Mia.
The properties path is defined in the configuration_path.yml file, located in ~/.populse_mia.
In user mode, the path is retrieved from the properties_user_path parameter.
In developer mode, the path is retrieved from the properties_dev_path parameter.
If outdated parameters (mia_path, mia_user_path) are found, they are automatically updated in the configuration file.
- Returns:
(str) The absolute path to the properties folder.
- get_referential()[source]¶
Retrieves the chosen referential from the anatomist_2 data viewer.
- Returns:
(str) “0” for World Coordinates, “1” for Image ref.
- getShowAllSlices()[source]¶
Get whether the show_all_slices parameters was enabled or not in the miniviewer.
- Returns:
(bool) True if the show_all_slices parameters was enabled.
- get_spm_standalone_path()[source]¶
Get the path to the SPM12 standalone version.
- Returns:
(str) A path.
- getThumbnailTag()[source]¶
Get the tag of the thumbnail displayed in the miniviewer.
- Returns:
(str) The tag of the thumbnail displayed in miniviewer.
- get_use_afni()[source]¶
Get the value of “use afni” checkbox in the preferences.
- Returns:
(bool) The value of “use afni” checkbox.
- get_use_ants()[source]¶
Get the value of “use ants” checkbox in the preferences.
- Returns:
(bool) The value of “use ants” checkbox.
- get_use_clinical()[source]¶
Get the clinical mode in the preferences.
- Returns:
(bool) The clinical mode.
- get_use_freesurfer()[source]¶
Get the value of “use freesurfer” checkbox in the preferences.
- Returns:
(bool) The value of “use freesurfer” checkbox.
- get_use_fsl()[source]¶
Get the value of “use fsl” checkbox in the preferences.
- Returns:
(bool) The value of “use fsl” checkbox.
- get_use_matlab()[source]¶
Get the value of “use matlab” checkbox in the preferences.
- Returns:
(bool) The value of “use matlab” checkbox.
- get_use_matlab_standalone()[source]¶
Get the value of “use matlab standalone” checkbox in the preferences.
- Returns:
(bool) The value of “use matlab standalone” checkbox.
- get_use_mrtrix()[source]¶
Get the value of “use mrtrix” checkbox in the preferences.
- Returns:
(bool) The value of “use mrtrix” checkbox.
- get_user_level()[source]¶
Get the user level in the Capsul config.
- Returns:
(int) The user level in the Capsul config.
- get_user_mode()[source]¶
Get if user mode is disabled or enabled in the preferences.
- Returns:
(bool) If True, the user mode is enabled.
- get_use_spm()[source]¶
Get the value of “use spm” checkbox in the preferences.
- Returns:
(bool) The value of “use spm” checkbox.
- get_use_spm_standalone()[source]¶
Get the value of “use spm standalone” checkbox in the preferences.
- Returns:
(bool) The value of “use spm standalone” checkbox.
- getViewerConfig()[source]¶
Get the viewer config “neuro” or “radio”, “neuro” by default.
- Returns:
(str) The viewer config (“neuro” or “radio”).
- getViewerFramerate()[source]¶
Get the Viewer framerate.
- Returns:
(str) The Viewer framerat (ex. “5”).
- isAutoSave()[source]¶
Get if the auto-save mode is enabled or not.
- Returns:
(bool) If True, auto-save mode is enabled.
- isControlV1()[source]¶
Gets whether the controller display is of type V1.
- Returns:
(bool) If True, V1 controller display.
- isRadioView()[source]¶
Get if the display in miniviewer is in radiological orientation.
- Returns:
(bool) If True, radiological orientation, otherwise neurological orientation.
- loadConfig()[source]¶
Read the config from config.yml file.
Attempts to read an encrypted YAML configuration file from the properties directory, decrypt it using Fernet encryption, and parse it as YAML.
- Returns:
(dict) Parsed configuration from the YAML file. Returns empty dict if parsing fails.
- saveConfig()[source]¶
Save the current parameters in the config.yml file.
Encrypts and writes the current configuration (self.config) to config.yml using Fernet encryption. Creates the necessary directory structure if it doesn’t exist. After saving, updates the capsul configuration.
- setBackgroundColor(color)[source]¶
Set background color and save configuration.
- Parameters:
color – Color string (‘Black’, ‘Blue’, ‘Green’, ‘Grey’, ‘Orange’, ‘Red’, ‘Yellow’, ‘White’)
- set_capsul_config(capsul_config_dict)[source]¶
Update Mia configuration with Capsul settings and synchronize tools configuration.
Called after editing Capsul config (via File > Mia preferences > Pipeline tab > Edit CAPSUL config) to synchronize Capsul settings with Mia preferences. Configures various neuroimaging tools (AFNI, ANTs, FSL, etc.) based on the Capsul engine configuration.
- Parameters:
capsul_config_dict – Dictionary containing Capsul configuration.
Structure of capsul_config_dict:
{ 'engine': { 'environment_name': {...configuration...} }, 'engine_modules': [...] }
- Private function:
_get_module_config: Extracts module configuration from the global Capsul configuration.
- setChainCursors(chain_cursors)[source]¶
Set the value of the checkbox ‘chain cursor’ in the mini viewer.
- Parameters:
chain_cursors – A boolean.
- set_clinical_mode(clinical_mode)[source]¶
Enable or disable clinical mode.
- Parameters:
clinical_mode – A boolean.
- setControlV1(controlV1)[source]¶
Set controller display mode (True if V1).
- Parameters:
controlV1 – A boolean.
- set_freesurfer_setup(path)[source]¶
Set the freesurfer config file.
- Parameters:
path – (str) Path to freesurfer/FreeSurferEnv.sh.
- set_fsl_config(path)[source]¶
Set the FSL config file.
- Parameters:
path – (str) Path to fsl/etc/fslconf/fsl.sh.
- set_mainwindow_maximized(enabled)[source]¶
Set the maximized (full-screen) flag.
- Parameters:
enabled – A boolean.
- set_matlab_path(path)[source]¶
Set the path of Matlab’s executable.
- Parameters:
path – (str) A path.
- set_matlab_standalone_path(path)[source]¶
Set the path of Matlab Compiler Runtime.
- Parameters:
path – (str) A path.
- set_max_projects(nb_max_projects)[source]¶
Set the maximum number of projects displayed in the “Saved projects” menu.
- Parameters:
nb_max_projects – An integer.
- set_max_thumbnails(nb_max_thumbnails)[source]¶
Set max thumbnails number at the data browser bottom.
- Parameters:
nb_max_thumbnails – An integer.
- setNbAllSlicesMax(nb_slices_max)[source]¶
Set the number of slices to display in the mini-viewer.
- Parameters:
nb_slices_max – (int) Maximum number of slices to display.
- set_opened_projects(new_projects)[source]¶
Set the list of opened projects and saves the modification.
- Parameters:
new_projects – (list[str]) A list of paths.
- set_projects_save_path(path)[source]¶
Set the folder where the projects are saved.
- Parameters:
path – (str) A path.
- set_radioView(radio_view)[source]¶
Set the radiological / neurological orientation in mini viewer.
True for radiological
False for neurological
- Parameters:
radio_view – A boolean.
- set_referential(ref)[source]¶
Set the referential to “image Ref” or “World Coordinates” in anatomist_2 data viewer.
- Parameters:
ref – (str) “0” for World Coordinates, “1” for Image Ref.
- setShowAllSlices(show_all_slices)[source]¶
Set the show_all_slides setting in miniviewer.
- Parameters:
show_all_slices – A boolean.
- setSourceImageDir(source_image_dir)[source]¶
Set the source directory for project images.
- Parameters:
source_image_dir – (str) A path.
- set_spm_standalone_path(path)[source]¶
Set the path of SPM (standalone version).
- Parameters:
path – (str) A path.
- setTextColor(color)[source]¶
Set text color and save configuration.
- Parameters:
color – Color string (‘Black’, ‘Blue’, ‘Green’, ‘Grey’, ‘Orange’, ‘Red’, ‘Yellow’, ‘White’)
- setThumbnailTag(thumbnail_tag)[source]¶
Set the tag that is displayed in the mini-viewer.
- Parameters:
thumbnail_tag – A string.
- set_use_afni(use_afni)[source]¶
Set the value of “use_afni” checkbox in the preferences.
- Parameters:
use_afni – A boolean.
- set_use_ants(use_ants)[source]¶
Set the value of “use_ants” checkbox in the preferences.
- Parameters:
use_ants – A boolean.
- set_use_freesurfer(use_freesurfer)[source]¶
Set the value of “use_freesurfer” checkbox in the preferences.
- Parameters:
use_freesurfer – A boolean.
- set_use_fsl(use_fsl)[source]¶
Set the value of “use_fsl” checkbox in the preferences.
- Parameters:
use_fsl – A boolean.
- set_use_matlab(use_matlab)[source]¶
Set the value of “use matlab” checkbox in the preferences.
- Parameters:
use_matlab – A boolean.
- set_use_matlab_standalone(use_matlab_standalone)[source]¶
Set the value of “use_matlab_standalone” checkbox in the preferences.
- Parameters:
use_matlab – A boolean.
- set_use_mrtrix(use_mrtrix)[source]¶
Set the value of “use_mrtrix” checkbox in the preferences.
- Parameters:
use_mrtrix – A boolean.
- set_use_spm(use_spm)[source]¶
Set the value of “use spm” checkbox in the preferences.
- Parameters:
use_spm – A boolean.
- set_use_spm_standalone(use_spm_standalone)[source]¶
Set the value of “use spm standalone” checkbox in the preferences.
- Parameters:
use_spm_standalone – A boolean.
- setViewerConfig(config_NeuRad)[source]¶
sets user’s configuration neuro or radio for data_viewer.
neuro: neurological
radio: radiological
- Parameters:
config_NeuRad – A string.
- setViewerFramerate(im_sec)[source]¶
sets user’s framerate for data_viewer.
- Parameters:
im_sec – (int) Number of images per second.
- update_capsul_config()[source]¶
Updates the global CapsulEngine object used for all operations in the Mia application.
The CapsulEngine is created once when needed and updated each time the configuration is saved. This method ensures that all necessary engine modules are loaded and configurations are properly imported from the saved settings.
- Returns:
(capsul.engine.CapsulEngine) The updated CapsulEngine object, or None if the engine is not initialized.
- populse_mia.data_manager.project.safe_connect(signal, slot)[source]¶
Connect a Qt signal to a slot, ensuring a single connection.
First disconnects
signalfromslot(if connected) to avoid duplicate connections, then connects them. This guarantees that the slot is connected exactly once.- Parameters:
signal – The Qt signal to (re)connect.
slot – The slot (callable) to connect to the signal.
- populse_mia.data_manager.project.safe_disconnect(signal, slot)[source]¶
Disconnect a Qt signal from a slot if connected.
Attempts to disconnect
signalfromslotand silently ignores the error raised when the connection does not exist. This makes the operation idempotent and safe to call multiple times.- Parameters:
signal – The Qt signal to disconnect from.
slot – The slot (callable) previously connected to the signal.
- populse_mia.data_manager.project.set_item_data(item, value, value_type)[source]¶
Sets the data for a given item in the data browser based on the expected type.
This function prepares the input value according to the specified value_type, converting it into a format suitable for PyQt’s QVariant. It supports both primitive types (e.g., int, str, float) and more complex types like datetime, date, time, and lists of these types.
- Parameters:
(QStandardItem) (item) – The item to update (expected to support setData method).
(Any) (value) – The new value to set for the item.
(Type) (value_type) – The expected type of the value, which can be a standard Python type (e.g., str, int, float, bool) or a typing-based list type (e.g., list[int], list[datetime]).
- populse_mia.data_manager.project.verCmp(first_ver, sec_ver, comp)[source]¶
Version comparator.
- Compares two versions according to the specified comparator:
‘eq’: Returns True if the first version is equal to the second.
- ‘sup’: Returns True if the first version is greater than or equal
to the second.
- ‘inf’: Returns True if the first version is less than or equal to
the second.
- Parameters:
(str) (comp) – The first version to compare (e.g., ‘0.13.0’).
(str) – The second version to compare (e.g., ‘0.13.0’).
(str) – The comparator to use (‘sup’, ‘inf’, ‘eq’).
- Returns:
True if the comparison condition is satisfied, False otherwise.
- Contains:
- Private function:
normalise: transform a version of a package to a corresponding list of integer
- class populse_mia.data_manager.project.Project(project_root_folder, new_project)[source]¶
Bases:
objectClass that handles projects and their associated database.
- Parameters:
project_root_folder – project’s path
new_project – project’s object
- __init__(project_root_folder, new_project)[source]¶
Initialization of the project class.
- Parameters:
project_root_folder – project’s path
new_project – project’s object
- add_clinical_tags()[source]¶
Add new clinical tags to the project.
- Returns:
list of clinical tags that were added.
- cleanup_orphan_bricks(bricks=None)[source]¶
Remove orphan bricks and their associated files from the database.
This method performs the following cleanup operations: 1. Removes obsolete brick documents from the brick collection 2. Removes orphaned file documents from both current and initial
collections
Deletes the corresponding physical files from the filesystem
- Parameters:
(str) (bricks) – list of brick IDs to check for orphans. If None, checks all bricks in the database.
- cleanup_orphan_history()[source]¶
Remove orphan histories, their associated bricks, and files from the database.
This method performs three cleanup operations: 1. Removes obsolete history documents from the history collection 2. Removes orphaned brick documents from the brick collection 3. Removes orphaned file documents from both current and initial
collections, along with their corresponding physical files
- cleanup_orphan_nonexisting_files(failed=False)[source]¶
Remove database entries for files that are missing on disk.
- This method:
Retrieves filenames considered orphaned (see get_orphan_nonexisting_files),
Deletes their entries from both current and initial collections,
Attempts a defensive filesystem cleanup if the file still exists.
- Parameters:
(bool) (failed) – Passed through to get_orphan_nonexisting_files to control orphan selection.
- del_clinical_tags()[source]¶
Remove clinical tags from the project’s current and initial collections.
Iterates through predefined clinical tags and removes them from both collections if they exist in the current collection’s field names.
- Return (list):
Clinical tags that were successfully removed.
- files_in_project(files)[source]¶
Extract file/directory names from input that are within the project folder.
Recursively processes the input to find all file paths, handling nested data structures. Only paths within the project directory are included.
- Parameters:
files –
Input that may contain file paths. Can be: - str: A single file path - list/tuple/set: Collection of file paths or
nested structures
dict: Only values are processed, keys are ignored
- Return (set):
Relative file paths that exist within the project folder, with paths normalized and made relative to the project directory
- finished_bricks(engine, pipeline=None, include_done=False)[source]¶
Retrieve and process finished bricks from workflows and pipelines.
This method: 1. Gets finished bricks from workflows and optionally a specific
pipeline
Filters them based on their presence in the Mia database
Updates brick metadata with execution status and outputs
Collects all output files that are within the project directory
- Parameters:
engine – Engine instance for retrieving finished bricks
pipeline – Optional pipeline object to filter specific bricks
include_done – If True, includes all bricks regardless of execution status. If False, only includes “Not Done” bricks.
- Return (dict):
Dictionary containing: - ‘bricks’: Dict mapping brick IDs to their metadata - ‘outputs’: Set of output file paths relative to project
directory
- Contains:
- Private function:
- _update_dict: Merge two dictionaries by updating the first
with the second
- _collect_outputs: Recursively collects file paths from
output values that are within the project directory.
- get_data_history(path)[source]¶
Get the processing history for the given data file.
The history dict contains several elements: - parent_files: set of other data used (directly or indirectly) to
produce the data.
- processes: processing bricks set from each ancestor data which
lead to the given one. Elements are process (brick) UUIDs.
- Parameters:
path – Path to the data file
- Returns:
history (dict)
- getDate()[source]¶
Return the date of creation of the project.
- Return (str):
The date of creation of the project if it’s not Unnamed project, otherwise empty string
- get_finished_bricks_in_pipeline(pipeline)[source]¶
Retrieves a dictionary of finished processes (bricks) from a given pipeline, including nested pipelines, if any.
- Parameters:
Process) (pipeline (Pipeline or) – The pipeline or single process to analyze. If a single process is provided, it will be treated as a minimal pipeline.
- Return (dict):
A dictionary where keys are process UUIDs (brick IDs) and values are dictionaries containing the associated process instances.
- get_finished_bricks_in_workflows(engine)[source]¶
Return finished Soma-Workflow jobs indexed by their brick UUID.
A job is considered successful if its termination status is
"finished_regularly". Any other termination status is treated as a failure. A workflow is marked asfailedif at least one of its jobs did not finish successfully.- Parameters:
engine – Engine providing access to the Soma-Workflow controller.
- Return (dict):
Mapping
brick_uuid -> job_infowherejob_infocontains: -workflow(int): Workflow identifier. -job: Soma-Workflow job instance. -job_id(int): Job identifier. -swf_status(tuple): Raw Soma-Workflow statustuple.
running(bool): True of any job in the workflowis running
failed(bool): True if any job in the workflowfailed.
- getFilter(target_filter)[source]¶
Return a Filter object from its name.
- Parameters:
(str) (target_filter) – Filter name
- Return (Filter):
Filter object corresponding to the given name or None if not found
- getFilterName()[source]¶
Input box to type the name of the filter to save.
- Return (str):
Return the name typed by the user or None if cancelled
- getName()[source]¶
Return the name of the project.
- Return (str):
The name of the project if it’s not Unnamed project, otherwise empty string
- get_orphan_bricks(bricks=None)[source]¶
Identifies orphan bricks and their associated weak files.
- Parameters:
set) (bricks (list or) – A list or set of brick IDs to filter the search. If None, all bricks in the database are considered. Defaults to None.
- Return (tuple):
A tuple containing two sets: - orphan (set): Brick IDs considered orphaned, meaning
they have no valid or existing outputs linked to the current database.
- orphan_weak_files (set): Paths to weak files associated
with orphaned bricks, such as script files or files that no longer exist.
- get_orphan_history()[source]¶
Identifies orphaned history entries, their associated orphan bricks, and weak files.
- Return (tuple):
A tuple containing three sets: - orphan_hist (set): IDs of history entries that are no longer
linked to any current document in the database.
- orphan_bricks (set): IDs of bricks associated with orphaned
history entries.
- orphan_weak_files (set): Paths to weak files (e.g., script
files or non-existent files) linked to orphaned history entries.
- get_orphan_nonexisting_files(failed)[source]¶
Return filenames that are recorded in the database but missing on disk.
A file is considered “orphaned” if: - It does not exist on the filesystem, and - It is not associated with any existing bricks, unless failed is True (in which case brick association is ignored).
- Parameters:
(bool) (failed) – If True, include files even if they are linked to existing bricks. If False, exclude such files.
- Return (set):
A set of filenames from the database that are not found on the filesystem and are not associated with existing bricks.
- getSortedTag()[source]¶
Return the sorted tag of the project.
- Return (str):
Sorted tag of the project if it’s not Unnamed project, otherwise empty string
- getSortOrder()[source]¶
Return the sort order of the project.
- Return (str):
Sort order of the project if it’s not Unnamed project, otherwise empty string
- hasUnsavedModifications()[source]¶
Return if the project has unsaved modifications or not.
- Return (bool):
True if the project has pending modifications, False otherwise
- init_filters()[source]¶
Initializes project filters by loading them from stored JSON files.
This method sets the currentFilter to a default empty filter and populates the filters list with Filter objects created
- loadProperties()[source]¶
Loads the project properties from the ‘properties.yml’ file.
This method reads the project’s YAML properties file and returns its contents as a Python dictionary.
- Return (dict):
A dictionary containing the project properties if successfully loaded, or None if an error occurs.
- redo(table)[source]¶
Redo the last action made by the user on the project.
- Parameters:
(QTableWidget) (table) – The table on which to apply the modifications.
- Actions that can be redone:
add_tag
remove_tags
add_scans
modified_values
modified_visibilities
- Raises:
(ValueError) – If an unknown action type is encountered.
- reput_values(values)[source]¶
Re-put the value objects in the database.
- Parameters:
(list) (values) – List of Value objects
- save_current_filter(custom_filters)[source]¶
Save the current filter.
- Parameters:
custom_filters – The customized filter
- setCurrentFilter(new_filter)[source]¶
Set the current filter of the project.
- Parameters:
new_filter – New Filter object
- setName(name)[source]¶
Set the name of the project if it’s not Unnamed project, otherwise does nothing.
- Parameters:
(str) (name) – New name of the project
- setSortedTag(tag)[source]¶
Set the sorted tag of the project.
- Parameters:
tag – New sorted tag of the project
- setSortOrder(order)[source]¶
Set the sort order of the project.
- Parameters:
order – New sort order of the project (ascending or descending)
- undo(table)[source]¶
Undo the last action made by the user on the project.
- Parameters:
table – Table on which to apply the modifications
- Actions that can be undone:
add_tag
remove_tags
add_scans
modified_values
modified_visibilities
- property unsavedModifications¶
Getter for _unsavedModifications.
- update_db_for_paths(new_path=None)[source]¶
Update database paths when renaming or loading a project.
This method updates path references in the database when a project is renamed or loaded from a different location. It scans the HISTORY and BRICK collections to identify the old project path, then systematically replaces it with the new path.
The method looks for the old path in brick input/output fields and history pipeline XML data. If the old path contains ‘data/derived_data’, the method uses the portion before this segment as the base path.
- Parameters:
(str) (new_path) – The new project path. If not provided, the current project folder path is used.
- Contains:
- Private method:
- _update_json_data: Helper method to update paths in JSON
data structures