Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Oli4 committed Feb 10, 2021
1 parent 1bb8f33 commit b6833a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
24 changes: 20 additions & 4 deletions eyepy/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,15 @@ def drusen(self):
return self._oct_obj.drusen[..., self.index]

def plot(self, ax=None, layers=None, drusen=False, layers_kwargs=None,
layers_color=None, annotation_only=False, region=np.s_[:,:]):
layers_color=None, annotation_only=False, region=np.s_[:, :]):
""" Plot B-Scan with segmented Layers """
if ax is None:
ax = plt.gca()

if layers is None:
layers = []
elif layers == "all":
layers = config.SEG_MAPPING.keys()
layers = self.layers.keys()

if layers_kwargs is None:
layers_kwargs = config.layers_kwargs
Expand All @@ -328,8 +328,9 @@ def plot(self, ax=None, layers=None, drusen=False, layers_kwargs=None,
try:
layer_data = self.layers[layer]
if region[0].start is not None:
layer_data -= region[0].start
ax.plot(layer_data, color=color, label=layer,
layer_data = layer_data - region[0].start
ax.plot(layer_data[region[1].start:region[1].stop],
color=color, label=layer,
**layers_kwargs)
except KeyError:
warnings.warn(f"Layer '{layer}' has no Segmentation",
Expand Down Expand Up @@ -449,6 +450,21 @@ def from_heyex_vol(cls, path):
localizer=reader.localizer,
meta=reader.oct_meta,
data_path=Path(path).parent)
@classmethod
def from_duke_mat(cls, path):
import scipy.io as sio
loaded = sio.loadmat(path)
data = np.moveaxis(loaded["images"], -1, 0)
label = np.swapaxes(loaded["layerMaps"], 1, 2)

bscans = []
mapping = {"BM": 2, "RPE": 1, "ILM": 0}
for d, l in zip(data, label):
annotation = Annotation({"layers": LayerAnnotation(l, mapping)})
bscans.append(Bscan(d, annotation=annotation))
return cls(bscans=bscans,
meta=Meta(**{"Age": loaded["Age"]}),
data_path=Path(path).parent)

@classmethod
def from_folder(cls, path):
Expand Down
1 change: 1 addition & 0 deletions eyepy/io/heyex/xml_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ def layers_dict(bscan_obj):
f"{bscan_obj} contains no segmentation", UserWarning)

return {"layers": layers_dict, }

0 comments on commit b6833a1

Please sign in to comment.