Skip to content

fix(pipeline): survive heterogeneous or empty DICOM series in preprocessing#152

Merged
Liohtml merged 1 commit into
mainfrom
claude/dependabot-prs-q6u94z
Jul 10, 2026
Merged

fix(pipeline): survive heterogeneous or empty DICOM series in preprocessing#152
Liohtml merged 1 commit into
mainfrom
claude/dependabot-prs-q6u94z

Conversation

@Liohtml

@Liohtml Liohtml commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

_build_volume stacked all slice arrays with np.stack, which raises ValueError when 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 descriptive ValueError
    • PreprocessStep.run: per-series try/except — one malformed series no longer kills the run; skipped series are recorded in context.limitations, which flows into the generated report
  • tests/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 study

Testing

  • Existing tests pass (uv run pytest) — 178 passed
  • New tests added for new functionality — 3 new preprocess tests
  • Coverage does not decrease (uv run pytest --cov-fail-under=85) — 87.51%
  • Linting passes (uv run ruff check .)
  • Type checking passes (uv run mypy src/medcheck --strict)
  • Pre-commit hooks pass — ruff hooks pass locally; full pre-commit not run

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

…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
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Liohtml, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c1a7eee8-b7c8-41bb-ba24-6549d9f04a6d

📥 Commits

Reviewing files that changed from the base of the PR and between 9592f2e and 38e8437.

📒 Files selected for processing (2)
  • src/medcheck/pipeline/preprocess.py
  • tests/unit/test_pipeline/test_preprocess.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/dependabot-prs-q6u94z

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Liohtml Liohtml merged commit 063b913 into main Jul 10, 2026
13 checks passed
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

[repo-health] Medium: _build_volume crashes on heterogeneous or empty DICOM series — np.stack ValueError aborts the whole study

2 participants