Repository navigation
Conversation
…tics Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to DatasetSummary now skips samples with no foreground and gives a clear error when none exist. No merge-blocking risk was found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@monai/data/dataset_summary.py`:
- Around line 171-175: Complete the Google-style docstrings for
calculate_statistics and calculate_percentiles in monai/data/dataset_summary.py,
documenting their Raises behavior and Returns as None. Also add descriptive
docstrings for the mixed foreground/background and all-background error tests in
tests/data/test_dataset_summary.py at lines 103 and 124, respectively.
In `@tests/data/test_dataset_summary.py`:
- Around line 127-130: Update both assertRaisesRegex checks around
calculator.calculate_statistics() and calculator.calculate_percentiles() to
match the complete remediation text, including the exact recommendation
foreground_threshold=-1, rather than only the parameter name.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 31ab911b-369d-4c2e-af71-268749401698
📒 Files selected for processing (2)
monai/data/dataset_summary.pytests/data/test_dataset_summary.py
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Description
DatasetSummary.calculate_statisticscrashed with a bareRuntimeErroron any sample whose label had no foreground voxels at the givenforeground_threshold(common with 2D slices or sparse annotations), and if every sample lacked foreground it would divide by zero in the mean/std.calculate_percentileshad the same empty-accumulation hazard. Both methods now skip empty foreground selections and, when no sample contributes any foreground voxels, raise an actionableValueErrorthat namesforeground_thresholdand points to setting it to-1to compute statistics over whole images:monai/data/dataset_summary.py—calculate_statisticscontinues past empty foreground selections and guardsvoxel_ct == 0;calculate_percentilesskips empty selections and guards the accumulated list before callingnp.percentile.tests/data/test_dataset_summary.py— two new tests: a mixed foreground/background dataset (statistics and percentiles computed from the remaining foreground), and an all-background dataset (ValueErrorraised by both methods).Behavior verified end-to-end: a dataset with one normal and one all-background sample now produces statistics from the normal sample (previously it crashed), and an all-background dataset raises the actionable
ValueErrorfrom bothcalculate_statisticsandcalculate_percentiles.Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.