Skip to content

Commit

Permalink
fix(eyepy.core): fixes bscan_region and bscan_position plotting when …
Browse files Browse the repository at this point in the history
…plotting only a part of the fundus

also adds new header_gif to the README
  • Loading branch information
Oli4 committed Mar 30, 2023
1 parent 3c6ba41 commit 2c88074
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 89 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Use Python to import, analyse and visualize retinal imaging data.
</p>

![header_gif](https://user-images.githubusercontent.com/5720058/218448527-d0477fa3-0cb6-4a3e-88e8-e10a60cc7a91.gif)
![header_gif](https://user-images.githubusercontent.com/5720058/228815448-4b561246-dac9-4f8f-abde-e0dd5457a72b.gif)

[![Documentation](https://img.shields.io/badge/docs-eyepy-blue)](https://MedVisBonn.github.io/eyepy)
[![PyPI version](https://badge.fury.io/py/eyepie.svg)](https://badge.fury.io/py/eyepie)
Expand Down
119 changes: 42 additions & 77 deletions examples/create_header_gif.ipynb

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/eyepy/core/eyeenface.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ def plot(
"""
ax = plt.gca() if ax is None else ax
ax.imshow(self.data[region], cmap='gray')
vmin = np.min(self.data)
vmax = np.max(self.data)

ax.imshow(self.data[region], cmap='gray', vmin=vmin, vmax=vmax)

# Make sure tick labels match the image region
y_start = region[0].start if region[0].start is not None else 0
Expand Down
26 changes: 16 additions & 10 deletions src/eyepy/core/eyevolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,13 +721,15 @@ def _plot_bscan_positions(
for i in bscan_positions:
scale = np.array([self.localizer.scale_x, self.localizer.scale_y])

start = self[i].meta['start_pos'] / scale
end = self[i].meta['end_pos'] / scale
start = self[i].meta['start_pos'] / scale - np.array(
[region[1].start, region[0].start])
end = self[i].meta['end_pos'] / scale - np.array(
[region[1].start, region[0].start])

for pos in [start, end]:
# Check for both axis if pos is in region
if not (region[0].start <= pos[0] <= region[0].stop
and region[1].start <= pos[1] <= region[1].stop):
if not (0 <= pos[0] <= region[0].stop - region[0].start
and 0 <= pos[1] <= region[1].stop - region[1].start):
logger.warning(
'B-scan position can not be plotted because the visualized region does not contain the complete B-scan.'
)
Expand Down Expand Up @@ -755,15 +757,19 @@ def _plot_bscan_region(self,

scale = np.array([self.localizer.scale_x, self.localizer.scale_y])

upper_left = self[-1].meta['start_pos'] / scale
lower_left = self[0].meta['start_pos'] / scale
lower_right = self[0].meta['end_pos'] / scale
upper_right = self[-1].meta['end_pos'] / scale
upper_left = np.array(self[-1].meta['start_pos']) / scale - np.array(
[region[1].start, region[0].start])
lower_left = np.array(self[0].meta['start_pos']) / scale - np.array(
[region[1].start, region[0].start])
lower_right = np.array(self[0].meta['end_pos']) / scale - np.array(
[region[1].start, region[0].start])
upper_right = np.array(self[-1].meta['end_pos']) / scale - np.array(
[region[1].start, region[0].start])

for pos in [upper_left, lower_left, lower_right, upper_right]:
# Check for both axis if pos is in region
if not (region[0].start <= pos[0] <= region[0].stop
and region[1].start <= pos[1] <= region[1].stop):
if not (0 <= pos[0] < region[0].stop - region[0].start
and 0 <= pos[1] < region[1].stop - region[1].start):
logger.warning(
'B-scan region can not be plotted because the visualized region does not contain the complete B-scan region.'
)
Expand Down

0 comments on commit 2c88074

Please sign in to comment.