Skip to main content

ophth_algo_utils

Utilities for ophthalmology plugins.

Module

Functions

center_text_on_strip

def center_text_on_strip(    img: Image.Image,    font: ImageFont.FreeTypeFont,    text_width: int,    text_height: int,    text: str,    strip_width: int,    strip_height: int,    color: tuple[int, int, int] = (0, 0, 0),)> PIL.Image.Image:

Center text on image.

Arguments

  • img: The image to draw the text on.
  • font: The font to use for the text.
  • text_width: The width of the text.
  • text_height: The height of the text.
  • text: The text to draw on the image.
  • strip_width: The width of the strip.
  • strip_height: The height of the strip.
  • color: The color of the text. Defaults to black.

draw_no_markers_detected_on_image_strip

def draw_no_markers_detected_on_image_strip(    img: Image.Image, height: int, width: int,)> PIL.Image.Image:

Draw the "No markers detected" strip on the image.

Arguments

  • img: The image to draw the strip on.
  • height: The height of the image.
  • width: The width of the image.

draw_segmentation_mask_on_orig_image

def draw_segmentation_mask_on_orig_image(    mask: np.ndarray, image: PIL.Image.Image,)> tuple[PIL.Image.Image, dict[str, tuple[int, int, int]]]:

Draw segmentation mask on original image.

get_data_for_files

def get_data_for_files(    datasource: FileSystemIterableSource,    filenames: list[str],    file_key_col: str = '_original_filename',    use_cache: bool = True,)> pandas.core.frame.DataFrame:

Retrieve data from a datasource for a given list of files.

The dataframe returned will be sorted to match the ordering of the files in filenames.

get_dataframe_iterator_from_datasource

def get_dataframe_iterator_from_datasource(    datasource: BaseSource, use_cache: bool = True,)> collections.abc.Iterable[pandas.core.frame.DataFrame]:

Get dataframe iterator from datasource.

Arguments

  • datasource: The datasource to get the dataframe iterator from.
  • use_cache: Whether to use the cache when getting the dataframes.

Returns An iterable of dataframes from the datasource.

get_imgs_with_segmentation_from_enface_slo

def get_imgs_with_segmentation_from_enface_slo(    data: pd.DataFrame,    enface_output: np.ndarray,    slos: np.ndarray,    slo_photo_location_prefixes: Optional[SLOSegmentationLocationPrefix] = None,    slo_image_metadata_columns: Optional[SLOImageMetadataColumns] = None,    oct_image_metadata_columns: Optional[OCTImageMetadataColumns] = None,    colour: Union[str, tuple[int, int, int]] = (0, 255, 255),    alpha: float = 0.75,    threshold: float = 0.7,)> list[PIL.Image.Image]:

Get images with segmentation on SLO image from enfaces.

is_file_iterable_source

def is_file_iterable_source(datasource: BaseSource)> bool:

True iff datasource is a file iterable source (or subclass).

overlay_with_alpha_layer_ga_trial

def overlay_with_alpha_layer_ga_trial(    img: Image.Image,    overlay: np.ndarray,    colour: Union[str, tuple[int, int, int]] = (255, 0, 0),    alpha: float = 0.8,)> PIL.Image.Image:

Overlay an image with a segmentation.

overlay_with_grey_mask_ga_trial

def overlay_with_grey_mask_ga_trial(    img: Image.Image, alpha: float = 0.3,)> PIL.Image.Image:

Overlay an image with a segmentation.

parse_mask_json

def parse_mask_json(json_data: dict[Any, Any], labels: dict[str, int])> numpy.ndarray:

Parse segmentation mask from json.

use_default_rename_columns

def use_default_rename_columns(    datasource: BaseSource, rename_columns: Optional[typing.Mapping[str, str]] = None,)> Optional[Mapping[str, str]]:

Sets the default columns to include based on the datasource.