Skip to content

Commit

Permalink
refactor: Improve error handling in CellMapImage
Browse files Browse the repository at this point in the history
Improve error handling in the CellMapImage class by providing a fallback mechanism when unable to retrieve class counts from metadata. Instead of printing the error message, a more informative message is printed, indicating that the foreground will be assigned 1 pixel and the rest will be considered as background.
  • Loading branch information
rhoadesScholar committed Oct 17, 2024
1 parent bcef819 commit 638d70f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cellmap_data/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ def class_counts(self) -> float:
) * np.prod(list(self.scale.values()))
self._bg_count = bg_count * np.prod(list(self.scale.values()))
except Exception as e:
print(f"Error: {e}")
# print(f"Error: {e}")
print(
"Unable to get class counts from metadata, falling back to giving foreground 1 pixel, and the rest to background."
)
self._class_counts = np.prod(list(self.scale.values()))
self._bg_count = (
np.prod(self.group[self.scale_level].shape) - 1
Expand Down

0 comments on commit 638d70f

Please sign in to comment.