Skip to content

Use reoriented image shape for MAISI training data resize - #2087

Open
Don-Yin wants to merge 1 commit into
Project-MONAI:mainfrom
Don-Yin:fix-maisi-reoriented-dim
Open

Don-Yin wants to merge 1 commit into
Project-MONAI:mainfrom
Don-Yin:fix-maisi-reoriented-dim

Conversation

@Don-Yin

@Don-Yin Don-Yin commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The resize target was read from the original NIfTI header, so for non-RAS images it came out in the wrong axis order after reorientation. Using the shape of the reoriented image fixes it.

Fixes #2012.

screenshot

Summary by CodeRabbit

  • Bug Fixes
    • Training-data image resizing now uses the spatial dimensions of the loaded image rather than dimensions from its metadata. Each dimension is rounded before resizing, keeping the existing rounding behavior while aligning the resize dimensions with the loaded image. This change applies to training-data generation and does not alter the available resizing options.

Signed-off-by: Don Yin <Don_Yin@outlook.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a9827e2d-7c3a-4e36-8151-31de809be9bd
Commits

Reviewing files that changed from the base of the PR and between 7beffcf and d19414b.

Files selected for processing: 1
  • generation/maisi/scripts/diff_model_create_training_data.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

Training-data generation now derives resized dimensions from the loaded image tensor’s spatial shape instead of its NIfTI metadata dimensions. It rounds each spatial dimension before creating the resize transform.

Changes

Training-data dimension calculation

Layer / File(s) Summary
Derive resize dimensions from the tensor
generation/maisi/scripts/diff_model_create_training_data.py
The loop loads the image through plain_transforms and rounds its tensor spatial dimensions to create new_dim.

Priority: Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: dongyang0122

Merge Risk: Minimal · up to d1941

No actionable merge-blocking risk was identified in the reviewed change.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: using the reoriented image shape for MAISI training-data resizing.
Description check Passed The description explains the axis-order defect, the correction, and the linked issue. It does not use the template headings or include the checklist, but the core change information is complete.
Linked Issues check Passed Issue #2012 requires MAISI preparation to use dimensions after RAS reorientation. The change loads the transformed image once and derives new_dim from image.shape[1:]. This replaces the original N…
Out of Scope Changes check Passed The whole-PR diff changes only the resize-dimension calculation in generation/maisi/scripts/diff_model_create_training_data.py. The change directly supports issue #2012 and shows no unrelated behavi…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #2012 requires MAISI preparation to use dimensions after RAS reorientation. The change loads the transformed image once and derives new_dim from image.shape[1:]. This replaces the original NIfTI metadata dimensions. The code then rounds each spatial dimension before creating the resize transform.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff changes only the resize-dimension calculation in generation/maisi/scripts/diff_model_create_training_data.py. The change directly supports issue #2012 and shows no unrelated behavior or files.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

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.

Data preparation for MAISI tutorial is wrong for non-RAS data

1 participant