populse_mia.data_manager.project_properties¶
Module that contains the class to handle the projects saved in the software.
- Contains:
Class: - SavedProjects
Classes
Handles all saved projects in the software. |
- class populse_mia.data_manager.project_properties.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.
- class populse_mia.data_manager.project_properties.SavedProjects[source]¶
Bases:
objectHandles all saved projects in the software.
- - addSavedProject
Adds a new saved project.
- - loadSavedProjects
Loads saved projects from ‘saved_projects.yml’.
- - removeSavedProject
Removes a project from the config file.
- - saveSavedProjects
Saves projects to ‘saved_projects.yml’.
- addSavedProject(newPath)[source]¶
Adds a project path or moves it to the front if it exists.
- Parameters:
(str) (newPath) – Path of the new project.
- Return (list):
Updated project paths list.
- loadSavedProjects()[source]¶
Loads saved projects from ‘saved_projects.yml’, or creates a default file if missing.
- Return (dict):
Loaded project paths.