From e1fde017f7b13e10b00f5eb18ebc7d47a8ce2576 Mon Sep 17 00:00:00 2001 From: Mark Graham Date: Mon, 13 Nov 2023 16:59:15 +0000 Subject: [PATCH] Adds option to extract apparent e2e fundus repeats --- oct_converter/readers/e2e.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/oct_converter/readers/e2e.py b/oct_converter/readers/e2e.py index 15e72b3..1f694e8 100644 --- a/oct_converter/readers/e2e.py +++ b/oct_converter/readers/e2e.py @@ -295,9 +295,14 @@ def _make_lut(): return oct_volumes - def read_fundus_image(self) -> list[FundusImageWithMetaData]: + def read_fundus_image( + self, extract_scan_repeats: bool = False + ) -> list[FundusImageWithMetaData]: """Reads fundus data. + Args: + extract_scan_repeats: if True, extract all fundus images, including those that appear repeated. Defaults to False. + Returns: A sequence of FundusImageWithMetaData. """ @@ -360,9 +365,20 @@ def read_fundus_image(self) -> list[FundusImageWithMetaData]: image = np.array(raw_volume).reshape( image_data.height, image_data.width ) + image_string = "{}_{}_{}".format( chunk.patient_db_id, chunk.study_id, chunk.series_id ) + if ( + image_string in image_array_dict.keys() + and extract_scan_repeats + ): + is_in_keys = True + while is_in_keys: + image_string = image_string + "_" + if image_string not in image_array_dict.keys(): + is_in_keys = False + image_array_dict[image_string] = image # here assumes laterality stored in chunk before the image itself laterality_dict[image_string] = laterality