populse_mia.utils package

Utilities and tools used across Mia

Contains:
Modules:
  • utils.py

Submodules

populse_mia.utils.utils module

Module that contains multiple functions used across Mia.

Contains:
Classes:
  • PackagesInstall

Functions:
  • check_python_version

  • check_value_type

  • launch_mia

  • message_already_exists

  • set_filters_directory_as_default

  • set_item_data

  • set_projects_directory_as_default

  • table_to_database

  • verCmp

  • verify_processes

  • verify_setup

class populse_mia.utils.utils.PackagesInstall[source]

Bases: object

Help to make available a pipeline package in the Mia pipeline library, in a recursive way.

Contains:
Method:
  • __init__: constructor

  • add_package: provide recursive representation of a package

__init__()[source]

Initialise the packages instance attribute.

add_package(module_name, class_name=None)[source]

Provide recursive representation of a package and its subpackages/modules, to construct the Mia’s pipeline library.

Parameters:
  • module_name – name of the module to add in the pipeline library

  • class_name – only this pipeline will be added to the pipeline library (optional)

Returns:

dictionary of dictionaries containing package/subpackages/pipelines status. ex: {package: {subpackage: {pipeline: ‘process_enabled’}}}

populse_mia.utils.utils.check_python_version()[source]

Check Python version used.

Returns an AssertionError exception if the version is lower than 3.5.

populse_mia.utils.utils.check_value_type(value, value_type, is_subvalue=False)[source]

Checks the type of new value in a table cell (QTableWidget).

Parameters:
  • value – Value of the cell

  • value_type – Type expected

  • is_subvalue – To know if the value is a subvalue of a list

Returns:

True if the value is valid to replace the old one, False otherwise

populse_mia.utils.utils.launch_mia(app)[source]

Actual launch of the Mia software.

Overload the sys.excepthook handler with the _my_excepthook private function. Check if the software is already opened in another instance. If not, the list of opened projects is cleared. Checks if saved projects known in the Mia software still exist, and updates if necessary. Instantiates a ‘project’ object that handles projects and their associated database and finally launch of the Mia’s GUI.

Contains:
Private function:
  • _my_excepthook: log all uncaught exceptions in non-interactive mode

  • _verify_saved_projects: checks if the projects are still existing

populse_mia.utils.utils.message_already_exists()[source]

Displays a message box to tell that a project name already exists.

populse_mia.utils.utils.set_filters_directory_as_default(dialog)[source]

Sets the filters directory as default (Json files)

Parameters:

dialog – current file dialog

populse_mia.utils.utils.set_item_data(item, value, value_type)[source]

Sets the item data in the data browser.

Parameters:
  • item – item to set

  • value – new item value

  • value_type – new value type

populse_mia.utils.utils.set_projects_directory_as_default(dialog)[source]

Sets the projects directory as default.

Parameters:

dialog – current file dialog

populse_mia.utils.utils.table_to_database(value, value_type)[source]

Prepares the value to the database.

Parameters:
  • value – Value to convert

  • value_type – Value type

Returns:

The value converted for the database

populse_mia.utils.utils.verCmp(first_ver, sec_ver, comp)[source]

Version comparator.

The verCmp() function returns a boolean value to indicate whether its first argument (first_ver) is equal to, less or equal to, or greater or equal to its second argument (sec_ver), as follows:

  • if third argument (comp) is ‘eq’: when the first argument is equal to the second argument, return True (False if not).

  • if third argument (comp) is ‘sup’: when the first argument is greater than the second argument, return True (False if not).

  • if third argument (comp) is ‘inf’: when the first argument is less than the second argument, return True (False if not).

Parameters:
  • first_ver – the version of a package (a string; ex. ‘0.13.0’)

  • sec_ver – the version of a package (a string; ex. ‘0.13.0’)

  • comp – comparator argument (accepted values: ‘sup’, ‘inf’ and ‘eq’ )

Returns:

False or True

Contains:
Private function:
  • normalise: transform a version of a package to a corresponding list of integer

populse_mia.utils.utils.verify_processes(nipypeVer, miaProcVer, capsulVer)[source]

Install or update to the last version available on the station, for nipype, capsul and mia_processes processes libraries.

Parameters:
  • nipypeVer – nipype version currently installed (str).

  • miaProcVer – mia_processes version currently installed (str).

  • capsulVer – capsul version currently installed (str).

By default, Mia provides three process libraries in the pipeline library (available in Pipeline Manager tab). The nipype, given as it is because it is developed by another team (https://github.com/nipy/nipype), and mia_processes, capsul which are developed under the umbrella of populse (https://github.com/populse/mia_processes). When installing Mia in user mode, these three libraries are automatically installed on the station. The idea is to use the versioning available with pypi (https://pypi.org/). Thus, it is sufficient for the user to change the version of the library installed on the station (pip install…) to also change the version available in Mia. Indeed, when starting Mia, the verify_processes function will update the nipype, capsul and mia_processes libraries in the pipeline library accordingly. Currently, it is mandatory to have nipype, capsul and mia_processes installed in the station. All this information, as well as the installed versions and package paths are saved in the properties_path/properties/process_config.yml file. When an upgrade or downgrade is performed for a package, the last configuration used by the user is kept (if a pipeline was visible, it remains so and vice versa). However, if a new pipeline is available in the new version it is automatically marked as visible in the library.

Contains:
Private function:
  • _deepCompDic: keep the previous config existing before packages update

populse_mia.utils.utils.verify_setup(dev_mode, pypath=[], dot_mia_config='/home/econdami/.populse_mia/configuration_path.yml')[source]

check whether the configuration is valid and try to correct it if it is not.

Parameters:
  • dev_mode – the current developer mode (bool). (if True: dev, if False: user)

  • pypath – a list of path for the capsul config (list)

Dot_mia_config:

the path to the configuration_path.yml file

Contains:

Private function:
  • _browse_properties_path: the user define the properties_path parameter

  • _cancel_clicked: exit form Mia

  • _make_default_config: make default configuration

  • _save_yml_file: save data in a YAML file

  • _verify_miaConfig: check the config and try to fix if necessary