From be334be092b2d6713c815089844d72f6efea0296 Mon Sep 17 00:00:00 2001 From: Mark Graham Date: Tue, 25 Jul 2023 11:22:03 +0100 Subject: [PATCH 1/4] Adjusts byte_skip --- oct_converter/readers/e2e.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oct_converter/readers/e2e.py b/oct_converter/readers/e2e.py index 4691b37..7e887d7 100644 --- a/oct_converter/readers/e2e.py +++ b/oct_converter/readers/e2e.py @@ -56,7 +56,7 @@ def _make_lut(): with open(self.filepath, "rb") as f: raw = f.read(200) - self.byte_skip = raw.find(b"CMDb") + self.byte_skip = raw.find(b"CMDb")-1 if self.byte_skip == -1: raise ValueError("CMDb not found in file header") else: @@ -258,7 +258,7 @@ def _make_lut(): ): # remove any initalised volumes that never had image data attached volume = [slc for slc in volume if not isinstance(slc, int)] - if volume is None: + if volume is None or len(volume) == 0: continue oct_volumes.append( OCTVolumeWithMetaData( @@ -284,7 +284,7 @@ def read_fundus_image(self) -> list[FundusImageWithMetaData]: """ with open(self.filepath, "rb") as f: raw = f.read(200) - self.byte_skip = raw.find(b"CMDb") + self.byte_skip = raw.find(b"CMDb") - 1 if self.byte_skip == -1: raise ValueError("CMDb not found in file header") else: From 0273b3dbfea97aa69b9f31b40d7c85f4bcbec905 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 10:25:32 +0000 Subject: [PATCH 2/4] [pre-commit.ci lite] apply automatic fixes --- oct_converter/readers/e2e.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oct_converter/readers/e2e.py b/oct_converter/readers/e2e.py index 7e887d7..cf41a51 100644 --- a/oct_converter/readers/e2e.py +++ b/oct_converter/readers/e2e.py @@ -56,7 +56,7 @@ def _make_lut(): with open(self.filepath, "rb") as f: raw = f.read(200) - self.byte_skip = raw.find(b"CMDb")-1 + self.byte_skip = raw.find(b"CMDb") - 1 if self.byte_skip == -1: raise ValueError("CMDb not found in file header") else: From fa92b095d3042f9d6eee5132b5474741d5974328 Mon Sep 17 00:00:00 2001 From: Mark Graham Date: Wed, 26 Jul 2023 16:33:06 +0100 Subject: [PATCH 3/4] Fixes byte_skip to 64 --- oct_converter/readers/e2e.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/oct_converter/readers/e2e.py b/oct_converter/readers/e2e.py index 7e887d7..2ae7d49 100644 --- a/oct_converter/readers/e2e.py +++ b/oct_converter/readers/e2e.py @@ -55,12 +55,12 @@ def _make_lut(): LUT = _make_lut() with open(self.filepath, "rb") as f: - raw = f.read(200) - self.byte_skip = raw.find(b"CMDb")-1 - if self.byte_skip == -1: - raise ValueError("CMDb not found in file header") + raw = f.read(21) + if raw == b'E2EMultipleVolumeFile': + self.byte_skip = 64 else: - f.seek(self.byte_skip) + self.byte_skip = 0 + f.seek(self.byte_skip) raw = f.read(36) header = e2e_binary.header_structure.parse(raw) @@ -283,12 +283,12 @@ def read_fundus_image(self) -> list[FundusImageWithMetaData]: A sequence of FundusImageWithMetaData. """ with open(self.filepath, "rb") as f: - raw = f.read(200) - self.byte_skip = raw.find(b"CMDb") - 1 - if self.byte_skip == -1: - raise ValueError("CMDb not found in file header") + raw = f.read(21) + if raw == b'E2EMultipleVolumeFile': + self.byte_skip = 64 else: - f.seek(self.byte_skip) + self.byte_skip = 0 + f.seek(self.byte_skip) raw = f.read(36) header = e2e_binary.header_structure.parse(raw) raw = f.read(52) From 7295495560ff9fdbd5a05929ae4cb30191fe1dbf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Wed, 26 Jul 2023 15:35:07 +0000 Subject: [PATCH 4/4] [pre-commit.ci lite] apply automatic fixes --- oct_converter/readers/e2e.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oct_converter/readers/e2e.py b/oct_converter/readers/e2e.py index 2ae7d49..1420abf 100644 --- a/oct_converter/readers/e2e.py +++ b/oct_converter/readers/e2e.py @@ -56,7 +56,7 @@ def _make_lut(): with open(self.filepath, "rb") as f: raw = f.read(21) - if raw == b'E2EMultipleVolumeFile': + if raw == b"E2EMultipleVolumeFile": self.byte_skip = 64 else: self.byte_skip = 0 @@ -284,7 +284,7 @@ def read_fundus_image(self) -> list[FundusImageWithMetaData]: """ with open(self.filepath, "rb") as f: raw = f.read(21) - if raw == b'E2EMultipleVolumeFile': + if raw == b"E2EMultipleVolumeFile": self.byte_skip = 64 else: self.byte_skip = 0