pyrot.eye_modelling.datamodels.export#

Export eye model geometries and regions of interest from RayOcular.

Functions#

full_export(output_directory, eyemodelnr, ...)

Export all relevant data for a given eye model to a structured output directory.

slugify(→ str)

Replace non-alphanumeric characters with underscores.

set_level_of_detail(patient, structure_set, ...)

Set the level of detail of the structure set.

export_roi_geometries(structure_set, output_directory, ...)

Export ROI geometries from a given structure set to STL files.

export_eye_model(structure_set, output_directory, ...)

Export an eye model to a JSON file.

export_pois(structure_set, output_directory, ...)

Export points of interest (POIs) from a structure set to a JSON file.

Module Contents#

pyrot.eye_modelling.datamodels.export.full_export(output_directory: pathlib.Path | str, eyemodelnr: int, export_suffix: str, roi_export_unit: Literal['Millimeters', 'Centimeters'])#

Export all relevant data for a given eye model to a structured output directory.

This function gathers patient, case, and examination information, creates a uniquely named export directory, and exports ROI geometries, eye model data, and points of interest (POIs) for the specified eye model number.

Parameters#

output_directoryPath or str

The base directory where the export folder will be created.

eyemodelnrint

The identifier number of the eye model to export.

export_suffixstr

Suffix to append to exported files for identification.

roi_export_unitLiteral[“Millimeters”, “Centimeters”]

The unit to use when exporting ROI geometries.

Notes#

  • The export directory is named using the current date and time, patient name, case name, examination name, and eye model number.

  • The function assumes that the current patient, case, and examination are set and accessible.

pyrot.eye_modelling.datamodels.export.slugify(value: str) str#

Replace non-alphanumeric characters with underscores.

Parameters#

valuestr

The string to slugify.

Returns#

str

The slugified string.

pyrot.eye_modelling.datamodels.export.set_level_of_detail(patient, structure_set, level_of_detail: int)#

Set the level of detail of the structure set.

Parameters#

patientobject

The patient object to save after updating.

structure_setobject

The structure set to update.

level_of_detailint

The level of detail value to set.

pyrot.eye_modelling.datamodels.export.export_roi_geometries(structure_set, output_directory: pathlib.Path, examination_name: str, export_suffix: str, roi_export_unit: str)#

Export ROI geometries from a given structure set to STL files.

The function iterates over the ROI geometries in the provided structure set, filters them based on the specified export suffix, and exports each selected geometry as an STL file to the specified output directory. Exported files are named according to the ROI name, with spaces replaced by underscores, and include the export unit in the filename.

Parameters#

structure_setobject

The structure set containing ROI geometries. Must have a RoiGeometries attribute that supports key access.

output_directoryPath

The directory where the exported STL files will be saved.

examination_namestr

The name of the examination (not directly used in the function, but may be required for context).

export_suffixstr

If specified, only ROIs with names ending with this suffix will be exported. If empty, ROIs with automatically generated suffixes are excluded.

roi_export_unitstr

The unit to use when exporting the ROI geometry (e.g., “mm”).

Warns#

UserWarning

If no STL files are found for a given ROI, or if multiple STL files are found (only the first is used).

Notes#

  • Exported STL files are named as {ROI_name}_unit_{roi_export_unit}.stl, with spaces in ROI names replaced by underscores.

  • Temporary directories are used during export to avoid filename conflicts.

  • The function assumes that each geometry object has an ExportRoiGeometryAsSTL method.

pyrot.eye_modelling.datamodels.export.export_eye_model(structure_set, output_directory: pathlib.Path, eyemodelnr: int)#

Export an eye model to a JSON file.

Parameters#

structure_setobject

The structure set containing geometry generators for the eye models.

output_directoryPath

The directory where the exported JSON file will be saved.

eyemodelnrint

The index of the eye model to export from the structure set.

Notes#

The exported file will be named as “eye_model_{eyemodelnr}.json” and will contain the serialized data of the selected eye model.

pyrot.eye_modelling.datamodels.export.export_pois(structure_set, output_directory: pathlib.Path, examination_name: str)#

Export points of interest (POIs) from a structure set to a JSON file.

Parameters#

structure_setobject

The structure set containing POI geometries. Must have a PoiGeometries attribute.

output_directoryPath

The directory where the output JSON file (“pois.json”) will be saved.

examination_namestr

The name of the examination to associate with each POI.

Notes#

The output JSON file will contain a dictionary where each key is the POI name and the value is a dictionary with the POI location, type, and associated examination name.