Sisyphe.core.sisypheDatabase
External packages/modules
PyQt5, Qt GUI, https://www.riverbankcomputing.com/software/pyqt/
- class Sisyphe.core.sisypheDatabase.SisypheDatabase
Description
Class used to manage a patient database.
Scope of methods:
container-like methods to access to patient folder
Get/set/remove volumes/ROIs/meshes to patient folder
search volume/ROI/mesh in database
database backup
Inheritance
object -> SisypheDatabaseItem
Creation: 27/09/2022 Last revision: 10/12/2023
- backupDatabase(backuppath: str, wait: DialogWait | None = None) None
Copy database to a backup directory.
Parameters
- backuppathstr
backup folder name
- waitSisyphe.core.dialogWait.DialogWait
progress bar dialog
- backupIdentity(identity: SisypheVolume | SisypheIdentity, backuppath: str) None
Copy a patient folder to a backup directory.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- backuppathstr
backup folder name
- backupPatient(patient: str, backuppath: str) None
Copy a patient folder to a backup directory.
Parameters
- patientstr
patient folder name
- backuppathstr
backup folder name
- clearDatabase() None
Clear the patient database, deletes all sub-folders of the database directory.
- copyFileToPatient(filename: str, identity: SisypheVolume | SisypheIdentity) None
Copy a file to a patient folder.
Parameters
- filenamestr
file name to copy
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- copyFilesToPatient(filenames: list[str], identity: SisypheVolume | SisypheIdentity) None
Copy a list of files to a patient folder.
Parameters
- filenameslist[str]
list of file names to copy
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- copySisypheMesh(mesh: SisypheMesh, identity: SisypheIdentity) None
Copy a Sisyphe.core.sisypheROI.SisypheROI file (.xmesh) in its patient folder.
Parameters
- meshSisyphe.core.sisypheMesh.SisypheMesh
mesh to copy
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- copySisypheMeshes(meshes: list[SisypheMesh] | SisypheMeshCollection, identity: SisypheIdentity) None
Save a list of Sisyphe.core.sisypheMesh.SisypheMesh files (.xmesh) in the database.
Parameters
- mesheslist[Sisyphe.core.sisypheMesh.SisypheMesh] | Sisyphe.core.sisypheMesh.SisypheMeshCollection
meshes to save
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- copySisypheROI(roi: SisypheROI, identity: SisypheIdentity) None
Copy a Sisyphe.core.sisypheROI.SisypheROI file (.xroi) in its patient folder.
Parameters
- roiSisyphe.core.sisypheROI.SisypheROI
ROI to copy
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- copySisypheROIs(rois: list[SisypheROI] | SisypheROICollection, identity: SisypheIdentity) None
Copy a list of Sisyphe.core.sisypheROI.SisypheROI files (.xroi) in the database.
Parameters
- roislist[Sisyphe.core.sisypheROI.SisypheROI] | Sisyphe.core.sisypheROI.SisypheROICollection
ROIs to copy
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- copySisypheVolume(vol: SisypheVolume) None
Copy a Sisyphe.core.sisypheVolume.SisypheVolume file (.xvol) in its patient folder.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
volume is saved in the patient folder with its file name attribute
- copySisypheVolumes(vols: list[SisypheVolume] | SisypheVolumeCollection) None
Copy a list of Sisyphe.core.sisypheVolume.SisypheVolume file (.xvol) in the database.
Parameters
- volslist[Sisyphe.core.sisypheVolume.SisypheVolume] | Sisyphe.core.sisypheVolume.SisypheVolumeCollection
volumes are saved in the patient folders with their file name attributes
- createPatient(identity: SisypheVolume | SisypheIdentity) None
Add a patient in the database, creates patient sub-folder in the database directory.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- createPatients(identities: list[SisypheVolume] | list[SisypheIdentity]) None
Add a list of patients in the database, creates patient sub-folders in the database directory.
Parameters
- identitieslist[Sisyphe.core.sisypheVolume.SisypheVolume] | list[Sisyphe.core.SisypheImageAttributes.SisypheIdentity]
patient identities
- deleteFileFromPatient(filename: str, identity: SisypheVolume | SisypheIdentity) None
Remove a file from a patient folder.
Parameters
- filenamestr
file name to remove
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- deleteFilesFromPatient(filenames: list[str], identity: SisypheVolume | SisypheIdentity) None
Remove a list of files from patient folder.
Parameters
- filenameslist[str]
list of file names to remove
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- getAbsFolderFromIdentity(identity: SisypheVolume | SisypheIdentity) str
Get patient folder name from identity.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- str
folder name
- classmethod getCreationDate(filename: str, f: str = '%Y-%m-%d %H:%M:%S') str
Get file creation date as str.
Parameters
- filenamestr
file name
- fstr
date format (default ‘%Y-%m-%d %H:%M:%S’)
Returns
- str
date
- classmethod getCreationDateCode(filename: str) float | None
Get file creation date as operating system float code.
Parameters
- filenamestr
file name
Returns
- float | None
float code of the date
- getDatabasePath() str
Get the PySisyphe patient database folder (root folder).
Returns
- str
PySisyphe patient database folder
- classmethod getFilesLastModifiedDate(folder: str) dict[str, float]
Get last modified date of files in a folder as list of operating system float code.
Parameters
- folderstr
folder name
Returns
- dict[str, float]
keys are file names, values are float codes of last modified dates
- classmethod getFolderFromIdentity(identity: SisypheIdentity) str
Get patient folder name from identity (Sisyphe.core.sisypheImageAttributes.SisypheIdentity).
Parameters
identity : Sisyphe.core.sisypheImageAttributes.SisypheIdentity
Returns
- str
folder name
- classmethod getIdentityFromFolder(folder: str) SisypheIdentity
Get patient identity (Sisyphe.core.sisypheImageAttributes.SisypheIdentity) from folder name.
Parameters
- folderstr
folder name
Returns
Sisyphe.core.sisypheImageAttributes.SisypheIdentity
- classmethod getLastModifiedDate(filename: str, f: str = '%Y-%m-%d %H:%M:%S') str
Get file last modified date as str.
Parameters
- filenamestr
file name
- fstr
date format (default ‘%Y-%m-%d %H:%M:%S’)
Returns
- str
last modified date
- classmethod getLastModifiedDateCode(filename: str) float | None
Get file last modified date as operating system float code.
Parameters
- filenamestr
file name
Returns
- float
float code of the last modified date
- getPatientList(flt: str = '*_*_*') list[str]
Get a list of patient folder names from a search filter string.
Parameters
- fltstr
filter format is ‘{lastname}_{firstname}_{birthdate}’, lastname, firstname, birthdate could be replaced by ‘*’ wildcard char. default is ‘_*_’ to get all patient folder names
Returns
- list[str]
patient folder names
- getPatientMeshes(identity: SisypheVolume | SisypheIdentity) list[str]
Get the list of Sisyphe.core.sisypheMesh.SisypheMesh file names (.xmesh) in a patient folder.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- list[str]
Sisyphe.core.sisypheMesh.SisypheMesh file names
- getPatientROIs(identity: SisypheVolume | SisypheIdentity) list[str]
Get the list of Sisyphe.core.sisypheROI.SisypheROI file names (.xroi) in a patient folder.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- list[str]
Sisyphe.core.sisypheROI.SisypheROI file names
- getPatientTools(identity: SisypheVolume | SisypheIdentity) list[str]
Get the list of Sisyphe.widget.toolWidgets.ToolWidgetCollection file names (.xtools) in a patient folder.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- list[str]
Sisyphe.widget.toolWidgets.ToolWidgetCollection file names
- getPatientVolumes(identity: SisypheVolume | SisypheIdentity) list[str]
Get the list of Sisyphe.core.sisypheVolume.SisypheVolume file names (.xvol) in a patient folder.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- list[str]
Sisyphe.core.sisypheVolume.SisypheVolume file names
- hasDatabasePath() bool
Checks whether PySisyphe database folder exists.
Returns
- bool
True if the PySisyphe database folder exists
- hasPatient(identity: SisypheVolume | SisypheIdentity) bool
Checks whether a patient is in SisypheDatabase instance.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- bool
True if patient is in database
- hasSisypheMesh(mesh: SisypheMesh, identity: SisypheIdentity) bool
Checks whether Sisyphe.core.sisypheMesh.SisypheMesh is in the database.
Parameters
- meshSisyphe.core.sisypheMesh.SisypheMesh
mesh to search in database
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- bool
True if mesh is in database
- hasSisypheROI(roi: SisypheROI, identity: SisypheIdentity) bool
Checks whether Sisyphe.core.sisypheROI.SisypheROI is in the database.
Parameters
- roiSisyphe.core.sisypheROI.SisypheROI
ROI to search in database
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- bool
True if roi is in database
- hasSisypheVolume(vol: SisypheVolume) bool
Checks whether Sisyphe.core.sisypheVolume.SisypheVolume is in the database.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
volume to search in database
Returns
- bool
True if vol is in database
- isEmpty() bool
Checks whether patient database is empty.
Returns
- bool
True if patient database is empty
- removePatient(identity: SisypheVolume | SisypheIdentity) None
Remove a patient from the database, delete patient sub-folder of the database directory.
Parameters
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- removePatients(identities: list[SisypheVolume] | list[SisypheIdentity]) None
Removes a list of patients from the database, deletes patient sub-folders of the database directory.
Parameters
- identitieslist[Sisyphe.core.sisypheVolume.SisypheVolume] | list[Sisyphe.core.SisypheImageAttributes.SisypheIdentity]
patient identities
- removeSisypheMesh(mesh: SisypheMesh, identity: SisypheIdentity) None
Remove Sisyphe.core.sisypheMesh.SisypheMesh from the database.
Parameters
- meshSisyphe.core.sisypheMesh.SisypheMesh
mesh to remove
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- removeSisypheROI(roi: SisypheROI, identity: SisypheIdentity) None
Remove Sisyphe.core.sisypheROI.SisypheROI from the database.
Parameters
- roiSisyphe.core.sisypheROI.SisypheROI
ROI to remove
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- removeSisypheVolume(vol: SisypheVolume) None
Remove Sisyphe.core.sisypheVolume.SisypheVolume from the database.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
volume to remove
- saveSisypheMeshtoDatabase(mesh: SisypheMesh, identity: SisypheIdentity, filename: str) None
Save a Sisyphe.core.sisypheMesh.SisypheMesh file (.xmesh) in its patient folder.
Parameters
- meshSisyphe.core.sisypheMesh.SisypheMesh
mesh to save
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- filenamestr
Sisyphe.core.sisypheMesh.SisypheMesh file name
- saveSisypheROItoDatabase(roi: SisypheROI, identity: SisypheIdentity, filename: str) None
Save a Sisyphe.core.sisypheROI.SisypheROI file (.xroi) in its patient folder.
Parameters
- roiSisyphe.core.sisypheROI.SisypheROI
ROI to save
- identitySisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
- filenamestr
Sisyphe.core.sisypheROI.SisypheROI file name
- saveSisypheVolumeToDatabase(vol: SisypheVolume, filename: str) None
Save a Sisyphe.core.sisypheVolume.SisypheVolume file (.xvol) in its patient folder.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
volume to save
- filenamestr
Sisyphe.core.sisypheVolume.SisypheVolume file name
- searchPatients(fltlastname: str = '*', fltfirstname: str = '*', fltdate: str = '*') list[str]
Get a list of patient folder names from a search filter based on identity.
Parameters
- fltlastnamestr
lastname filter, default is ‘*’ wildcard char
- fltfirstnamestr
firstname filter, default is ‘*’ wildcard char.
- fltdatestr
date filter, default is ‘*’ wildcard char.
Returns
- list[str]
patient folder names
- searchSisypheMeshFromID(ID: SisypheVolume | SisypheROI | SisypheTransforms | ToolWidgetCollection | str, identity: SisypheVolume | SisypheIdentity) list[str]
Search Sisyphe.core.sisypheMesh.SisypheMesh from ID (str or ID attributes) in patient folder.
Parameters
ID : str | Sisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.sisypheROI.SisypheROI | Sisyphe.core.sisypheTransform.SisypheTransforms | Sisyphe.widget.toolWidgets.ToolWidgetCollection
ID to search
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- list[str]
list of mesh file names
- searchSisypheROIFromID(ID: SisypheVolume | SisypheMesh | SisypheTransforms | ToolWidgetCollection | str, identity: SisypheVolume | SisypheIdentity) list[str]
Search Sisyphe.core.sisypheROI.SisypheROI from ID (str or ID attributes) in patient folder.
Parameters
ID : str | Sisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.sisypheMesh.SisypheMesh | Sisyphe.core.sisypheTransform.SisypheTransforms | Sisyphe.widget.toolWidgets.ToolWidgetCollection
ID to search
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- list[str]
list of ROI file names
- searchSisypheVolumeFromID(ID: SisypheROI | SisypheMesh | SisypheTransforms | ToolWidgetCollection | str, identity: SisypheVolume | SisypheIdentity) str | None
Search Sisyphe.core.sisypheVolume.SisypheVolume from ID (str or ID attributes) in patient folder.
Parameters
ID : str | Sisyphe.core.sisypheROI.SisypheROI | Sisyphe.core.sisypheMesh.SisypheMesh | Sisyphe.core.sisypheTransform.SisypheTransforms | Sisyphe.widget.toolWidgets.ToolWidgetCollection
ID to search
- identitySisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.SisypheImageAttributes.SisypheIdentity
patient identity
Returns
- str
volume file name
- setDatabasePath(path: str) None
Set the PySisyphe patient database folder (root folder).
Parameters
- pathstr
folder name
- setDatabasePathFromSettings() None
Set the default PySisyphe patient database folder from PySisyphe settings file (~/.PySisyphe/settings.xml in user folder).
- setDefaultDatabasePath() None
Set the PySisyphe patient database folder to ~/.PySisyphe/Database (in user folder).