Skip to content

Commit

Permalink
Merge pull request #119 from marksgraham/118_e2e_multiplevolumefile_i…
Browse files Browse the repository at this point in the history
…ssue

Fix errors reading E2EMultipleVolumeFile
  • Loading branch information
marksgraham authored Jul 26, 2023
2 parents 0188cc4 + 7295495 commit 26bb88f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions oct_converter/readers/e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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)
Expand Down Expand Up @@ -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(
Expand All @@ -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")
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)
Expand Down

0 comments on commit 26bb88f

Please sign in to comment.