MONAI icon indicating copy to clipboard operation
MONAI copied to clipboard

feat: Add RandNonCentralChiNoise transform

Open karllandheer opened this issue 2 months ago โ€ข 1 comments

Adds RandNonCentralChiNoise and RandNonCentralChiNoised, which generalize Rician noise to k degrees of freedom. Standard brain MRI typically uses 32 (or more) quadrature coils, so accurate noise simulation requires this modification, especially in the low SNR limit.

Includes array, dictionary, and test files.

Fixes # .

Description

A few sentences describing the changes proposed in this pull request.

Types of changes

  • [x] Non-breaking change (fix or new feature that would not break existing functionality).
  • [ ] Breaking change (fix or new feature that would cause existing functionality to change).
  • [x] New tests added to cover the changes.
  • [ ] Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • [x] Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • [x] In-line docstrings updated.
  • [ ] Documentation updated, tested make html command in the docs/ folder.

karllandheer avatar Nov 02 '25 16:11 karllandheer

[!NOTE]

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This PR adds a new array RandomizableTransform RandNonCentralChiNoise and a dictionary wrapper RandNonCentralChiNoised (aliases RandNonCentralChiNoiseD / RandNonCentralChiNoiseDict); updates monai/transforms/init.py and CHANGELOG.md to export the new symbols; adds unit tests for both array and dict variants; and appends monai-dev/ to .gitignore. The array transform implements non-central chi sampling with degrees_of_freedom validation, channel-wise and global modes, relative/sample_std options, and dtype handling. The dict wrapper preserves MapTransform semantics and forwards RNG state.

Estimated code review effort

๐ŸŽฏ 3 (Moderate) | โฑ๏ธ ~25 minutes

Areas needing attention:

  • monai/transforms/intensity/array.py: non-central-chi sampling logic, root-sum-square aggregation, DoF validation, channel-wise vs global branching, relative/sample_std semantics, and dtype casting.
  • monai/transforms/intensity/dictionary.py: RNG propagation to inner transform, MapTransform key handling, allow_missing_keys behavior, and alias assignments.
  • tests/transforms/*: seeded determinism and analytic expected-value reconstruction for DoF=64 and DoF=2.
  • monai/transforms/init.py and CHANGELOG.md: exported names and changelog entries.
  • .gitignore: new monai-dev/ entry.

Pre-merge checks and finishing touches

โŒ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
โœ… Passed checks (2 passed)
Check name Status Explanation
Title check โœ… Passed Title directly and clearly summarizes the main change: adding a new RandNonCentralChiNoise transform, matching the primary objective.
Description check โœ… Passed Description covers the purpose (generalizing Rician noise), includes context (MRI coils), checks the main template checkboxes (non-breaking change, tests added, quick tests passed, docstrings updated), and lists included file categories.
โœจ Finishing touches
  • [ ] ๐Ÿ“ Generate docstrings
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

๐Ÿ“œ Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between a7f08627bb5d1afcb23dae17453d6146b41417d9 and 936c40e10d20229bf545ced67de6f05898c15926.

๐Ÿ“’ Files selected for processing (1)
  • monai/transforms/__init__.py (2 hunks)
๐Ÿงฐ Additional context used
๐Ÿ““ Path-based instructions (1)
**/*.py

โš™๏ธ CodeRabbit configuration file

Review the Python code for quality and correctness. Ensure variable names adhere to PEP8 style guides, are sensible and informative in regards to their function, though permitting simple names for loop and comprehension variables. Ensure routine names are meaningful in regards to their function and use verbs, adjectives, and nouns in a semantically appropriate way. Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings. Examine code for logical error or inconsistencies, and suggest what may be changed to addressed these. Suggest any enhancements for code improving efficiency, maintainability, comprehensibility, and correctness. Ensure new or modified definitions will be covered by existing or new unit tests.

Files:

  • monai/transforms/__init__.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). (19)
  • GitHub Check: quick-py3 (windows-latest)
  • GitHub Check: quick-py3 (ubuntu-latest)
  • GitHub Check: packaging
  • GitHub Check: quick-py3 (macOS-latest)
  • GitHub Check: build-docs
  • GitHub Check: flake8-py3 (pytype)
  • GitHub Check: flake8-py3 (mypy)
  • GitHub Check: flake8-py3 (codeformat)
  • GitHub Check: min-dep-pytorch (2.8.0)
  • GitHub Check: min-dep-pytorch (2.7.1)
  • GitHub Check: min-dep-pytorch (2.6.0)
  • GitHub Check: min-dep-py3 (3.9)
  • GitHub Check: min-dep-pytorch (2.5.1)
  • GitHub Check: min-dep-py3 (3.12)
  • GitHub Check: min-dep-os (windows-latest)
  • GitHub Check: min-dep-py3 (3.10)
  • GitHub Check: min-dep-py3 (3.11)
  • GitHub Check: min-dep-os (macOS-latest)
  • GitHub Check: min-dep-os (ubuntu-latest)
๐Ÿ”‡ Additional comments (2)
monai/transforms/__init__.py (2)

120-120: LGTM!

Alphabetically ordered and follows naming convention.


203-205: LGTM!

All three dictionary aliases present, alphabetically ordered, consistent with existing patterns.

[!TIP]

๐Ÿ“ Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests โ€” including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. ๐Ÿ“ Description โ€” Summarize the main change in 50โ€“60 words, explaining what was done.
  2. ๐Ÿ““ References โ€” List relevant issues, discussions, documentation, or related PRs.
  3. ๐Ÿ“ฆ Dependencies & Requirements โ€” Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. ๐Ÿ“Š Contributor Summary โ€” Include a Markdown table showing contributions: | Contributor | Lines Added | Lines Removed | Files Changed |
  5. โœ”๏ธ Additional Notes โ€” Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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 and usage tips.

coderabbitai[bot] avatar Nov 02 '25 16:11 coderabbitai[bot]