Skip to content

Commit

Permalink
Default empty LayerAnnotation works
Browse files Browse the repository at this point in the history
  • Loading branch information
Oli4 committed Oct 5, 2020
1 parent fa5ee81 commit 72a6a43
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions eyepy/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,10 @@ def __init__(self,
self._scan = None
self._meta = meta
self._oct_obj = oct_obj

if annotation is None:
n_layers = np.zeros((max(config.SEG_MAPPING.values()) + 1))
l_annotation = LayerAnnotation(n_layers, self.oct_obj.SizeX)
annotation = {"layers": l_annotation}


self._annotation = annotation
self._annotation.bscan = self
if self._annotation is not None:
self._annotation.bscan = self

if data_processing is None:
self._data_processing = lambda x: x
Expand Down Expand Up @@ -244,6 +240,11 @@ def meta(self):
@property
def annotation(self):
""" A dict holding all Bscan annotation data """
if self._annotation is None:
empty_layers = np.zeros((max(config.SEG_MAPPING.values()) + 1, self.shape[1]))
l_annotation = LayerAnnotation(empty_layers)
self._annotation = Annotation({"layers": l_annotation})
self._annotation.bscan = self
return self._annotation

@property
Expand Down Expand Up @@ -271,7 +272,10 @@ def scan(self):

@property
def shape(self):
return self.scan.shape
try:
return (self.oct_obj.SizeZ, self.oct_obj.SizeX)
except AttributeError:
return self.scan.shape

@property
def layers(self):
Expand Down Expand Up @@ -422,7 +426,7 @@ def __getitem__(self, index) -> Bscan:
x = self.bscans[index]
if callable(x):
self.bscans[index] = x()
self.bscans[index].oct_obj = self
self.bscans[index].oct_obj = self
return self.bscans[index]

def __len__(self):
Expand Down Expand Up @@ -455,7 +459,7 @@ def from_folder(cls, path):
def read_func(p):
return lambda: imageio.imread(p)

bscans = [Bscan(read_func(p), name=p.name) for p in img_paths]
bscans = [lambda: Bscan(read_func(p), name=p.name) for p in img_paths]
return cls(bscans=bscans, data_path=path)

def estimate_bscan_distance(self):
Expand Down

0 comments on commit 72a6a43

Please sign in to comment.