fix(pipeline): survive heterogeneous or empty DICOM series in preprocessing#152
Conversation
…essing _build_volume stacked all slice arrays with np.stack, which raises ValueError when a series mixes matrix sizes (embedded localizers, mixed acquisitions) or is empty — aborting the entire study with a raw numpy traceback. Now: deviating slices are dropped in favor of the series' dominant shape (with a warning), empty series raise a descriptive error, and PreprocessStep degrades per-series instead of crashing, recording skipped series in the report's limitations. Fixes #138 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4svt5QTs4WUMSy4HwiVt9
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
_build_volumestacked all slice arrays withnp.stack, which raisesValueErrorwhen a series mixes matrix sizes (embedded localizers, mixed acquisitions — common in real MRI studies) or is empty, aborting the entire study with a raw numpy traceback.Fixes #138
Changes
src/medcheck/pipeline/preprocess.py:_build_volume: slices whose shape deviates from the series' dominant shape are dropped with a console warning; empty series raise a descriptiveValueErrorPreprocessStep.run: per-series try/except — one malformed series no longer kills the run; skipped series are recorded incontext.limitations, which flows into the generated reporttests/unit/test_pipeline/test_preprocess.py: 3 new tests — mixed slice shapes keep the dominant group, empty series skipped with a limitation note, a completely broken series doesn't abort the studyTesting
uv run pytest) — 178 passeduv run pytest --cov-fail-under=85) — 87.51%uv run ruff check .)uv run mypy src/medcheck --strict)Additional Notes
Dropped/skipped series are deliberately surfaced in the report's limitations section rather than only logged — for a medical-imaging pipeline, silent data loss is the failure mode to avoid (see also #135, which addresses the series-keying collision separately).
🤖 Generated with Claude Code
https://claude.ai/code/session_01W4svt5QTs4WUMSy4HwiVt9
Generated by Claude Code