-
Notifications
You must be signed in to change notification settings - Fork 78
When transforming DataTree elements, discard scales resulting in zero shape #948
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
When transforming DataTree elements, discard scales resulting in zero shape #948
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #948 +/- ##
=======================================
Coverage 92.20% 92.21%
=======================================
Files 49 49
Lines 7572 7576 +4
=======================================
+ Hits 6982 6986 +4
Misses 590 590
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses issue #947 by implementing logic to discard scales that result in zero shape when transforming multi-scale images, similar to the existing pattern in bounding_box_query. When scale0 (highest resolution) results in zero shape, an error is raised instead.
- Adds zero-shape detection and filtering logic in the DataTree transform function
- Raises a ValueError when scale0 (highest resolution) results in zero shape
- Adds a test to verify zero-shape scale handling
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/spatialdata/_core/operations/transform.py | Adds logic to detect and skip scales with zero shape during transformation, with special error handling for scale0 |
| tests/core/operations/test_transform.py | Adds test for zero-shape scale handling and imports Image2DModel |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…albert/spatialdata into fix_multiscaleimage_transform
|
Thanks for catching this and making a fix! I made only minor changes. Waiting until it's green and then merging. |
|
Thanks Luca! |
This PR implements a fix for #947.
Problem summary:
spatialdata.transformtransforms each of the scales of a multi-scale image and it can happen that (especially lower resolution) scales result in shape 0. One one hand it doesn't make sense to keep zero shape scales, on the other this leads to an error later on when the scale factors of the resulting image are extracted.Fix proposed in this PR: scales resulting in zero shape are discarded, similarly to the postprocessing of
bounding_box_query:spatialdata/src/spatialdata/_core/query/_utils.py
Lines 116 to 126 in 7604a3d
In the case of 'scale0' resulting in zero shape, the PR proposes to raise an error.
Happy to work on any review points!