Sisyphe.core.sisypheSettings
External packages/modules
PyQt5, Qt GUI, https://www.riverbankcomputing.com/software/pyqt/
- class Sisyphe.core.sisypheSettings.SisypheDialogsSettings
SisypheDialogsSettings class
Description
Management of application dialogs from XML file (dialogs.xml by default).
Inheritance
object -> SisypheSettings -> SisypheDialogsSettings
Creation: 08/09/2022 Last Revision: 15/12/2023
- class Sisyphe.core.sisypheSettings.SisypheFunctionsSettings
SisypheFunctionsSettings class
Description
Management of application function settings from XML file (functions.xml by default).
Inheritance
object -> SisypheSettings -> SisypheFunctionsSettings
Creation: 08/09/2022 Last revision: 15/12/2023
- class Sisyphe.core.sisypheSettings.SisypheSettings(setting: str = 'user')
SisypheSettings class
Description
Management of application settings from XML file (settings.xml by default).
Inheritance
object -> SisypheSettings
Creation: 08/09/2022 Last revisions: 15/03/2025
- fieldsFromDict(section: str, fields: dict[str, int | float | bool | str | list[int] | list[float] | list[bool] | list[str] | QFont | None])
Copy section field values of the current SisypheSettings instance from a dict.
Parameters
- sectionstr
section name
- fieldsdict
dict keys are field names, and dict values are field values
- fieldsToDict(section: str) dict[str, int | float | bool | str | list[int] | list[float] | list[bool] | list[str] | QFont | None]
Copy section fields of the current SisypheSettings instance into a dict.
Returns
- dict
dict keys are field names, and dict values are field values
- classmethod getAttributes() tuple[str, ...]
Get node attribute names of the xml settings file format.
Returns
- tuple[str, …]
node attribute names
- classmethod getDefaultSettings() str
Get default settings xml file name (./Sisyphe/settings/settings.xml).
Returns
- str
default settings xml file name
- getFieldNode(section: str, field: str) Element | None
Get a field node (minidom.Element) from the current SisypheSettings instance.
Parameters
- sectionstr
section name
- fieldstr
field name
Returns
- minidom.Element | None
section node
- getFieldValue(section: str, field: str) int | float | bool | str | list[int] | list[float] | list[bool] | list[str] | QFont | None
Get the value of a field in the current SisypheSettings instance.
Parameters
- sectionstr
section name
- fieldstr
field name
Returns
- int | float | bool | str | list[int] | list[float] | list[bool] | list[str] | None
vartype / return type, return type depends on the field vartype
‘str’, str
‘vol’, str
‘roi’, str
‘dcm’, str
‘dir’, str
‘vols’, list[str]
‘rois’, list[str]
‘dcms’, list[str]
‘dirs’, list[str]
‘date’, str
‘int’, int
‘float’, float
‘percent’, float
‘bool’, bool
‘visibility’, bool
‘lstr’, list[str]
‘lint’, list[int]
‘lfloat’, list[float]
‘lbool’, list[bool]
‘lut’, str
‘color’, list[float, float, float]
‘font’, str
‘txt’, str text file name (in ./Sisyphe/doc folder if path attribute is not defined)
- getFieldVartype(section: str, field: str) str
Get the vartype of a field in the current SisypheSettings instance.
Parameters
- sectionstr
section name
- fieldstr
field name
Returns
- str
field vartype, vartypes are :
‘str’: str
‘vol’: str, PySisyphe volume filename
‘roi’: str, PySisyphe ROI filename
‘dcm’: str, DICOM filename
‘dir’: str, path name
‘vols’: list[str], list of PySisyphe volume filenames
‘rois’: list[str], list of PySisyphe ROI filenames
‘dcms’: list[str], list of DICOM filenames
‘dirs’: list[str], list of path names
‘date’: str, format ‘DDMMYYYY’
‘int’: int
‘float’: float
‘percent’: float, percent value between 0.0 and 100.0
‘bool’: bool
‘visibility’: bool
‘lstr’: list[str]
‘lint’: list[int]
‘lfloat’: list[float]
‘lbool’: list[bool]
‘lut’: str, lut name
‘color’: list[float, float, float], each float between 0.0 and 1.0
‘font’: str, font name
‘txt’, str text file name (in ./Sisyphe/doc folder if path attribute is not defined)
- getFilename() str
Get the custom save name of the current SisypheSettings instance. Save name is only defined in a custom instance. Save name is empty in a user instance.
Returns
- str
xml file name
- getSectionFieldsList(section: str) list[str]
Get the list of fields in a section of the current SisypheSettings instance.
Parameters
- sectionstr
section name
Returns
- list[str]
list of fields in a section
- getSectionNode(section: str) Element | None
Get a section node (minidom.Element) from the current SisypheSettings instance.
Parameters
- sectionstr
section name
Returns
- minidom.Element | None
section node
- getSectionsList() list[str]
Get the section list of the current SisypheSettings instance.
Returns
- list[str]
list of sections
- classmethod getUserSettings() str
Get user settings xml file name (~/.PySisyphe/settings/settings.xml). if user settings xml file does not exist, create it from a copy of the default xml file.
Returns
- str
user settings xml file name
- classmethod getVartypes()
Get vartype names of the xml settings file format.
Returns
- tuple[str, …]
vartype names
- hasField(section: str, field: str) bool
Check whether the current SisypheSettings instance contains a section/field key.
Parameters
- sectionstr
section name
- fieldstr
field name
Returns
- bool
True if section/field are defined
- hasSection(section: str) bool
Check whether the current SisypheSettings instance contains a section.
Parameters
- sectionstr
section name
Returns
- bool
True if section is defined
- isCustom() bool
Check whether the current SisypheSettings is a custom settings instance. In this case, the associated xml settings file is defined in a custom save name attribute.
Returns
- bool
True if custom save name attribute is defined
- isEmpty() int
Check whether the current SisypheSettings instance is empty (No section and no field).
Returns
- bool
True is empty
- isUser() bool
Check whether the current SisypheSettings is a user settings instance. In this case, the associated xml settings file is ~/.PySisyphe/settings/settings.xml and the custom save name attribute is empty (‘’).
Returns
- bool
True if custom save name attribute is empty
- classmethod isValidAttribute(v: str) bool
Check whether a str is a valid node attribute name of the xml settings file format.
Parameters
- vstr
node attribute name to check
Returns
- bool
True if v is a valid node attribute name
- classmethod isValidVartype(v: str) bool
Check whether a str is a valid vartype name of the xml settings file format.
Parameters
- vstr
vartype name to check
Returns
- bool
True if v is a valid vartype name
- loadCustomFileSettings(filename: str) None
Load the current SisypheSettings from a custom xml settings file.
Parameters
- filenamestr
custom xml settings file name, filename becomes the current save name used by save() method and the instance becomes custom
- loadDefaultFileSettings() None
Load the current SisypheSettings from the default settings file (./Sisyphe/settings/settings.xml).
- loadUserFileSettings() None
Load the current SisypheSettings from the user settings file (~/.PySisyphe/settings/settings.xml).
- newField(section: str, field: str, attrs: dict)
Create a new field in a section of the current SisypheSettings instance.
Parameters
- sectionstr
section name
- fieldstr
field name
- attrsdict
dict keys are field attributes
‘label’, str, optional label displayed in the gui widget
‘icon’, str, required for ‘visibility’ vartype, bitmap file name (.png) in ./Sisyphe/gui/darkicons or ./Sisyphe/gui/lighticons folder
‘vartype’, str, always required, field vartypes are ‘str’, ‘vol’, ‘roi’, ‘dir’, ‘vols’, ‘rois’, ‘dirs’, ‘date’, ‘int’, ‘float’, ‘percent’, ‘bool’, ‘visibility’, ‘lstr’, ‘lint’, ‘lfloat’, ‘lbool’, ‘color’
‘varmin’, int | float, optional, minimum field value (for ‘int’ or ‘float’ vartype)
‘varmax’, int | float, optional, maximum field value (for ‘int’ or ‘float’ vartype)
‘step’, int, optional, step of the associated QSpinbox widget
- newSection(section: str)
Create a new section in the current SisypheSettings instance.
Parameters
- sectionstr
section name
- save() None
Save the current SisypheSettings instance. In case of custom instance, saved with the custom save name attribute. In case of user instance, saved in ~/.PySisyphe/settings/settings.xml.
- saveAs(filename: str, current: bool = True, pretty: bool = False) None
Save the current SisypheSettings instance to a xml file.
Parameters
- filenamestr
xml file name
- currentbool
if True, filename becomes the current save name used by save() method and the instance becomes custom
- prettybool
if True, pretty xml formatting
- saveToDefault() None
Save the current SisypheSettings instance to the default settings file. It is not recommended, because the original settings are lost and the file may be corrupted (./Sisyphe/settings/settings.xml).
- setFieldValue(section: str, field: str, v: int | float | bool | str | list[int] | list[float] | list[bool] | list[str] | QFont | None) None
Set the field value of the current SisypheSettings instance.
Parameters
- sectionstr
section name
- fieldstr
field name
- vint | float | bool | str | list[int] | list[float] | list[bool] | list[str] | None
field value, type depends on the vartype of the field
‘str’, str
‘vol’, str
‘roi’, str
‘dcm’, str
‘dir’, str
‘vols’, list[str]
‘rois’, list[str]
‘dcms’, list[str]
‘dirs’, list[str]
‘date’, str
‘int’, int
‘float’, float
‘percent’, float
‘bool’, bool
‘visibility’, bool
‘lstr’, list[str]
‘lint’, list[int]
‘lfloat’, list[float]
‘lbool’, list[bool]
‘lut’, str
‘color’, list[float, float, float]
‘font’, str | QFont
‘txt’, str, text file name (in ./Sisyphe/doc folder if path attribute is not defined)
- class Sisyphe.core.sisypheSettings.SisypheTooltips
SisypheTooltips class
Description
Management of function tooltips from XML file (tooltips.xml by default).
Inheritance
object -> SisypheSettings -> SisypheTooltips
Creation: 05/10/2024
- Sisyphe.core.sisypheSettings.getUserPath() str
Get user path of the current session.
Returns
- str
user path of the current session
- Sisyphe.core.sisypheSettings.getUserPySisyphePath() str
Get PySisyphe user path of the current session.
Returns
- str
user PySisyphe path of the current session
- Sisyphe.core.sisypheSettings.getUsername() str
Get username of the current session.
Returns
- str
username of the current session
- Sisyphe.core.sisypheSettings.initPySisypheUserPath() None
Creates user PySisyphe directory. Creates database, models and segmentation subdirectories. Copy default xml files (settings.xml and functions.xml) to PySisyphe user directory.
- Sisyphe.core.sisypheSettings.setUserSettingsToDefault() None
Copy default xml files (settings.xml and functions.xml) to PySisyphe user directory.