-
Notifications
You must be signed in to change notification settings - Fork 10
fix: handle undefined SpacingBetweenSlices tag in _fix_direction #435
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
Conversation
📝 WalkthroughWalkthroughGuard added to Scan._fix_direction to skip numeric parsing and subsequent negative-spacing correction when metadata Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/imgtools/coretypes/imagetypes/scan.py (1)
71-75: Consider a more robust check for non-numeric values.The guard for string
'None'addresses the immediate issue, but other non-numeric string values could still cause aValueErroron line 76. A try-except approach would be more defensive:Also, minor nit: there's trailing whitespace on line 74.
♻️ Suggested improvement for robustness
# Check if "SpacingBetweenSlices" is undefined - it's an optional tag so this is possible # https://dicom.innolitics.com/ciods/ct-image/image-plane/00180088 - if self.metadata.get('SpacingBetweenSlices') == 'None': - return - - slice_spacing = float(self.metadata.get("SpacingBetweenSlices") or 0) + raw_spacing = self.metadata.get("SpacingBetweenSlices") + try: + slice_spacing = float(raw_spacing) if raw_spacing else 0.0 + except (ValueError, TypeError): + # SpacingBetweenSlices is undefined or not a valid numeric value + return + if (not slice_spacing) or (slice_spacing >= 0): returnThis handles any non-numeric value (not just
'None') and removes the trailing whitespace.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/imgtools/coretypes/imagetypes/scan.py
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.py
⚙️ CodeRabbit configuration file
Review the Python code for compliance with PEP 8 and PEP 257 (docstring conventions). Ensure the following: - Variables and functions follow meaningful naming conventions. - Docstrings are present, accurate, and align with the implementation. - Code is efficient and avoids redundancy while adhering to DRY principles. - Consider suggestions to enhance readability and maintainability. - Highlight any potential performance issues, edge cases, or logical errors. - Ensure all imported libraries are used and necessary.
Files:
src/imgtools/coretypes/imagetypes/scan.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build-Docs (ubuntu-latest, docs)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #435 +/- ##
==========================================
- Coverage 54.65% 54.60% -0.06%
==========================================
Files 66 66
Lines 4314 4318 +4
==========================================
Hits 2358 2358
- Misses 1956 1960 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.