Skip to content

Add docstring note that Transpose/Transposed do not update the affine matrix#8888

Open
Akarsh-Doki wants to merge 1 commit into
Project-MONAI:devfrom
Akarsh-Doki:6711-transpose-affine-docstring
Open

Add docstring note that Transpose/Transposed do not update the affine matrix#8888
Akarsh-Doki wants to merge 1 commit into
Project-MONAI:devfrom
Akarsh-Doki:6711-transpose-affine-docstring

Conversation

@Akarsh-Doki
Copy link
Copy Markdown

Closes #6711.

Description

This PR adds a documentation note to the Transpose and Transposed
transforms clarifying that they do not update the affine matrix in the
image metadata. As established in #5975, this is intended behavior:
applying an affine-dependent transform such as Spacing/Spacingd
after Transpose/Transposed can therefore produce unexpected results.
The note points users to Orientation/Orientationd for affine-aware
reorientation.

This is a documentation-only change; no functional code is modified.

Types of changes

  • 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).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Akarsh Doki <doki.ak@northeastern.edu>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0642cab3-100c-4d60-8226-6f4842e63b9a

📥 Commits

Reviewing files that changed from the base of the PR and between 24da7c7 and e8e2633.

📒 Files selected for processing (2)
  • monai/transforms/utility/array.py
  • monai/transforms/utility/dictionary.py

📝 Walkthrough

Walkthrough

This PR adds documentation notes to the Transpose and Transposed transforms in MONAI's utility module. Both notes clarify that transposition does not update the affine matrix in metadata, which can cause unexpected behavior when affine-dependent transforms (such as Spacing) are applied afterward. The updates point users to Orientation and Orientationd for affine-aware reorientation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately summarizes the main change: adding docstring notes clarifying that Transpose/Transposed do not update affine matrices.
Description check ✅ Passed Description covers all required sections: references linked issue, clearly explains the change, marks non-breaking change, and indicates docstrings updated.
Linked Issues check ✅ Passed PR directly addresses issue #6711 by documenting the intended behavior that Transpose/Transposed do not update affine matrices and warning of downstream effects with affine-dependent transforms.
Out of Scope Changes check ✅ Passed Changes are limited to docstring updates in Transpose and Transposed transforms, staying squarely within the scope of issue #6711.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

Question about using Spacing transform after Transpose transform

1 participant