Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ImageIOLoadException #59

Merged
merged 3 commits into from
Mar 22, 2024
Merged

Conversation

K-Meech
Copy link
Contributor

@K-Meech K-Meech commented Mar 21, 2024

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

brainreg currently has a LoadFileException class that should be refactored into brainglobe-utils, and merged with the existing ImageIOLoadException

What does this PR do?

This PR moves the functionality of LoadFileException into ImageIOLoadException, making sure the relevant load functions catch errors like: loading a single tiff from a directory, loading 2D tiffs etc.

References

For brainglobe/brainreg#180
Corresponding PR on brainreg brainglobe/brainreg#186

How has this PR been tested?

Tests were updated, and all pass locally.

Is this a breaking change?

No

Does this PR require an update to the documentation?

No

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@K-Meech K-Meech requested a review from a team March 21, 2024 09:03
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 96.77419% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 84.35%. Comparing base (13d0444) to head (0e4e956).
Report is 24 commits behind head on main.

Files Patch % Lines
brainglobe_utils/image_io/utils.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
+ Coverage   74.55%   84.35%   +9.79%     
==========================================
  Files          25       35      +10     
  Lines         849     1355     +506     
==========================================
+ Hits          633     1143     +510     
+ Misses        216      212       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@alessandrofelder alessandrofelder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome - thanks @K-Meech
Made some tiny suggestions - tests are looking particularly nice!

brainglobe_utils/image_io/load.py Outdated Show resolved Hide resolved
@@ -197,6 +198,9 @@ def load_img_stack(
logging.debug(f"Loading: {stack_path}")
stack = tifffile.imread(stack_path)

if stack.ndim != 3:
raise ImageIOLoadException(error_type="2D tiff")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add the supported data types to the docstring, and specify that 2D tiffs, and paths to folders containing a single tiff or differently shaped tiffs are not supported?

[Edit] Or (better?) specify this by linking to the ImageIOLoadException docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alessandrofelder I've linked to the ImageIOLoadException docs for the load_any function. For the rest, as only some of the errors in ImageIOLoadException are relevant, I've updated the docstrings directly to make this clearer. Could you take a quick look, and merge if you're happy with the new docstrings?

Copy link
Member

@alessandrofelder alessandrofelder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!

@alessandrofelder alessandrofelder merged commit 9221ac8 into main Mar 22, 2024
12 checks passed
@alessandrofelder alessandrofelder deleted the refactor_LoadFileException branch March 22, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants