openlifu.db.database.Database¶
- class openlifu.db.database.Database(path: str | None = None)[source]¶
Bases:
object- static get_default_path()[source]¶
Get the default path for the database
- Returns:
Default path for the database
- static get_default_user_dir()[source]¶
Get the default user directory for the database
- Returns:
Default user directory
- get_photocollection_absolute_filepaths(subject_id: str, session_id: str, reference_number: str) List[Path][source]¶
get the absolute filepaths of all photos in a specific photocollection.
- Parameters:
subject_id (str) – The subject ID.
session_id (str) – The session ID.
reference_number (str) – The reference number of the photocollection.
- Returns:
List of absolute file paths to the photos in the photocollection.
- Return type:
List[Path]
- get_photocollection_reference_numbers(subject_id: str, session_id: str) List[str][source]¶
Get a list of reference numbers of the photocollections associated with the given session
- get_photocollections_filename(subject_id, session_id) Path[source]¶
Get the path to the overall photocollections json file for the requested session
- get_photoscan_absolute_filepaths_info(subject_id, session_id, photoscan_id)[source]¶
Returns the photoscan information with absolute paths to any data
- get_photoscan_ids(subject_id: str, session_id: str) List[str][source]¶
Get a list of IDs of the photoscans associated with the given session
- get_photoscans_filename(subject_id, session_id) Path[source]¶
Get the path to the overall photoscans json file for the requested session
- get_solution_filepath(subject_id, session_id, solution_id) Path[source]¶
Get the solution json file for the solution with the given ID
- get_solution_ids(subject_id: str, session_id: str) List[str][source]¶
Get a list of IDs of the solutions associated with the given session
- get_solutions_filename(subject_id, session_id) Path[source]¶
Get the path to the overall solutions json file for the requested session
- get_transducer_absolute_filepaths(transducer_id: str) Dict[str, str | None][source]¶
Returns the absolute filepaths to the model data files i.e. transducer body and registration surface model files affiliated with the transducer, with ID transducer_id. Unlike load_transducer, which specifies the relative paths to the model datafiles along with other transducer attributes, this function only returns the absolute filepaths to the datafiles based on the Database directory.
- Parameters:
transducer_id – Transducer ID
- Returns:
- A dictionary containing the absolute filepaths to the affiliated transducer data files with the following possible keys:
”id” (str): transducer ID
”name” (str): transducer name
”registration_surface_abspath” (str or None): absolute path to the transducer registration surface (open-surface mesh used for transducer tracking registration). This key is only included if there is an affiliated registration surface. None if no registration surface is available.
”transducer_body_abspath” (str or None): absolute path to the transducer body model (closed-surface mesh for visualizing the transducer). This key is only included if there is an affiliated body model. None if no transducer body is available.
- Return type:
dict
- static initialize_empty_database(database_filepath: str | PathLike) Database[source]¶
Initializes an empty database at the given database_filepath
- load_photoscan(subject_id, session_id, photoscan_id, load_data=False)[source]¶
Returns a photoscan object and optionally, also returns the loaded model and texture data as Tuple[vtkPolyData, vtkImageData] if load_data = True.
- load_solution(session: Session, solution_id: str) Solution[source]¶
Load the Solution of the given ID that is associated with the given Session
- load_transducer(transducer_id, convert_array: bool = True) Transducer | TransducerArray[source]¶
Given a transducer_id, reads the corresponding transducer file from database and returns a transducer object. Note: the transducer object includes the relative path to the affiliated transducer model data. get_transducer_absolute_filepaths, should be used to obtain the absolute data filepaths based on the Database directory path. :param transducer_id: Transducer ID :param convert_array: When enabled, if a TransducerArray is encountered then it is converted to a Transducer.
- Returns:
Corresponding Transducer object
- load_volume(subject, volume_id)[source]¶
Load the volume with the given ID for the specified subject.
- write_photocollection(subject_id, session_id, reference_number: str, photo_paths: List[str | PathLike], on_conflict=OnConflictOpts.ERROR)[source]¶
Writes a photocollection to database and copies the associated photos into the database, specified by the subject, session, and reference_number of the photocollection.
- write_photoscan(subject_id, session_id, photoscan: Photoscan, model_data_filepath: str | None = None, texture_data_filepath: str | None = None, mtl_data_filepath: str | None = None, on_conflict=OnConflictOpts.ERROR)[source]¶
Writes a photoscan object to database and copies the associated model and texture data filepaths that are required for generating a photoscan into the database. .mtl files are not required for generating a photoscan but can be provided if present. When a photoscan that is already present in the database is being re-written,the associated model and texture files do not need to be provided
- write_run(run: Run, session: Session | None = None, protocol: Protocol | None = None, on_conflict=OnConflictOpts.ERROR)[source]¶
Write a run with a snapshot of session and a snapshot of protocol if provided
- Parameters:
run – Run to be written
session (optional) – the Session used in the Run, it will have a snapshot written alongside the Run
protocol (optional) – the Protocol used in the Run, it will have a snapshot written alongside the Run
- Returns:
This method does not return a value
- Return type:
None
- write_solution_ids(session: Session, solution_ids: List[str])[source]¶
Write to the list of overall solution IDs
- write_transducer(transducer, registration_surface_model_filepath: PathLike | None = None, transducer_body_model_filepath: PathLike | None = None, on_conflict: OnConflictOpts = OnConflictOpts.ERROR) None[source]¶
Writes a transducer object to database and copies the affiliated transducer data files to the database if provided. When a transducer that is already present in the database is being re-written, the associated model data files do not need to be provided if they have previously been added to the database. :param transducer: Transducer to be written :param transducer_body_model_filepath: Model file containing a mesh of transducer body mesh. This is a closed surface meant for visualization of the transducer. :type transducer_body_model_filepath: optional :param registration_surface_model_filepath: Model file containing an open-surface sub-mesh of the transducer body model. This model is meant to be used for registration during transducer tracking. :type registration_surface_model_filepath: optional
- Returns:
This method does not return a value
- Return type:
None