Skip to content

Commit

Permalink
Added name to Bscan. If B-Scans are save as individual files, this is…
Browse files Browse the repository at this point in the history
… the respective filename, else it becomes a string version of the B-Scan index
  • Loading branch information
Oli4 committed Oct 5, 2020
1 parent dd352c6 commit 0b09ebe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 11 additions & 3 deletions eyepy/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def bscan(self, value: "Bscan"):

class Bscan:
def __new__(cls, data, annotation=None, meta=None, data_processing=None,
oct_obj=None, *args, **kwargs):
oct_obj=None, name=None, *args, **kwargs):

def annotation_func_builder(x):
return lambda self: self.annotation[x]
Expand All @@ -129,7 +129,8 @@ def __init__(self,
annotation: Optional[Annotation] = None,
meta: Optional[Union[Dict, Meta]] = None,
data_processing: Optional[Callable] = None,
oct_obj: Optional["Oct"] = None):
oct_obj: Optional["Oct"] = None,
name: Optional[str] = None):
"""
Parameters
Expand All @@ -156,6 +157,7 @@ def __init__(self,
else:
self._data_processing = data_processing

self._name = name
self._layer_indices = None

@property
Expand All @@ -168,6 +170,12 @@ def oct_obj(self):
def oct_obj(self, value):
self._oct_obj = value

@property
def name(self):
if self._name is None:
self._name = str(self.index)
return self._name

@property
def index(self):
return self.oct_obj.bscans.index(self)
Expand Down Expand Up @@ -406,7 +414,7 @@ def from_folder(cls, path):
def read_func(p):
return lambda: imageio.imread(p)

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

def estimate_bscan_distance(self):
Expand Down
6 changes: 3 additions & 3 deletions eyepy/io/heyex/xml_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def bscans(self):
if self._bscans is None:
self._bscans = []

def bscan_builder(d, a, bmeta, p):
return lambda: Bscan(d, a, bmeta, p)
def bscan_builder(d, a, bmeta, p, n):
return lambda: Bscan(d, a, bmeta, p, name=n)

def scan_reader(path):
return lambda: imageio.imread(path)
Expand All @@ -71,7 +71,7 @@ def scan_reader(path):
bscan, HEXML_BSCAN_VERSIONS(self.version)))

self._bscans.append(bscan_builder(
data, annotation, bscan_meta, self._data_processing))
data, annotation, bscan_meta, self._data_processing, scan_name))

return self._bscans

Expand Down

0 comments on commit 0b09ebe

Please sign in to comment.