Skip to content

Commit

Permalink
unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
Oli4 committed Dec 3, 2020
1 parent c265d6c commit b518e0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
24 changes: 18 additions & 6 deletions eyepy/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,23 @@ def __repr__(self):


class EnfaceImage:
def __init__(self, data):
def __init__(self, data, name=None):
self._data = data
self._name = name

@property
def data(self):
""" Return the enface image as numpy array """
if callable(self._data):
self._data = self._data()
return self._data

@property
def name(self):
if self._name is None:
raise ValueError("This EnfaceImage has no respective filename")
else:
return self._name


class Annotation(MutableMapping):
Expand Down Expand Up @@ -185,6 +193,7 @@ def __init__(self,
annotation: Dict holding B-Scan annotations
meta : A dictionary holding the B-Scans meta informations or
oct_obj : Reference to the OCT Volume holding the B-Scan
name : Filename of the B-Scan if B-Scan is save as individual file
"""
self._scan_raw = data
self._scan = None
Expand Down Expand Up @@ -411,11 +420,14 @@ def __init__(self,

def __getitem__(self, index) -> Bscan:
""" The B-Scan at the given index"""
x = self.bscans[index]
if callable(x):
self.bscans[index] = x()
self.bscans[index].oct_obj = self
return self.bscans[index]
if type(index) == slice:
return [self[i] for i in range(*index.indices(len(self)))]
else:
bscan = self.bscans[index]
if callable(bscan):
self.bscans[index] = bscan()
self.bscans[index].oct_obj = self
return self.bscans[index]

def __len__(self):
""" The number of B-Scans """
Expand Down
13 changes: 8 additions & 5 deletions eyepy/io/heyex/xml_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ def scan_reader(path):

return self._bscans

@property
def localizer_name(self):
lclzr_pattern = ".//ImageType[Type='LOCALIZER']../ImageData/ExamURL"
return (self.xml_root[0].find(lclzr_pattern).text.split("\\")[-1])


@property
def localizer(self):
if self._localizer is None:
lclzr_pattern = ".//ImageType[Type='LOCALIZER']../ImageData/ExamURL"
localizer_path = (self.path.parent /
self.xml_root[0].find(lclzr_pattern).text
.split("\\")[-1])


self._localizer = EnfaceImage(
data=lambda: imageio.imread(localizer_path))
data=lambda: imageio.imread(self.path.parent / self.localizer_name), name=self.localizer_name)

return self._localizer

Expand Down

0 comments on commit b518e0c

Please sign in to comment.