Skip to content

fix(planar): map dynamic-volume flattened indices to their group-local slice#2801

Merged
sedghi merged 1 commit into
mainfrom
fix/planar-dynamic-volume-slice-index
Jul 11, 2026
Merged

fix(planar): map dynamic-volume flattened indices to their group-local slice#2801
sedghi merged 1 commit into
mainfrom
fix/planar-dynamic-volume-slice-index

Conversation

@sedghi

@sedghi sedghi commented Jul 11, 2026

Copy link
Copy Markdown
Member

Context

Follow-up to #2800. getVolumeImageIdIndexWorldPoint assumes a one-to-one imageId-to-k-slice mapping, but StreamingDynamicImageVolume flattens its imageIds across all dimension groups while dimensions[2] is the slice count of a single group. A referenced image (navigation) or an explicitly carried initial slice from any later dimension group therefore has a flattened index of at least dimensions[2], and the clamp sent every such image to the final slice instead of its group-local k.

Changes & Results

  • Convert the flattened index through the volume's own flatImageIdIndexToImageIdIndex mapping (the k axis repeats per dimension group) before resolving the IJK world center. Duck-typed: static volumes have no such method and pass through unchanged, keeping fix(planar): anchor imageId-addressed slices at their exact IJK world center #2800's behavior identical for 3D volumes.
  • Both consumers (view-reference navigation by referencedImageId / snapped plane points, and the mount-time initialImageIdIndex) route through this shared helper, so one conversion covers both.
  • New test: a 3-group dynamic-volume mock asserts flattened index 14 (group 3, local slice 2) resolves to slice 2's world center rather than the raw-clamp result (final slice), and that first-group indices pass through unchanged.

Testing

  • npx jest (packages/core): 31 suites, 535 passed.
  • pnpm --filter @cornerstonejs/core run build:esm clean.

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Summary by CodeRabbit

  • Bug Fixes

    • Improved world-point calculations for dynamic 4D volumes with flattened image indexes.
    • Ensured slice positions are mapped to the correct dimension group instead of being incorrectly clamped.
  • Tests

    • Added coverage for flattened dynamic-volume index mapping, including cross-group and first-group scenarios.

…l slice

getVolumeImageIdIndexWorldPoint assumed a one-to-one imageId to k-slice
mapping, but StreamingDynamicImageVolume flattens its imageIds across
all dimension groups while dimensions[2] is the slice count of a single
group. A referenced image or explicitly carried initial slice from any
later dimension group therefore had a flattened index of at least
dimensions[2], and the clamp sent every such image to the final slice.
Convert the flattened index through the volume's own
flatImageIdIndexToImageIdIndex mapping (duck-typed; static volumes have
no such method and pass through unchanged) before resolving the IJK
world center.
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b867c6f3-44c8-44a1-87be-8ad4eeb2785b

📥 Commits

Reviewing files that changed from the base of the PR and between 6d2d80b and 024609c.

📒 Files selected for processing (2)
  • packages/core/src/RenderingEngine/GenericViewport/Planar/planarSliceBasis.ts
  • packages/core/test/planarSliceBasis.jest.js

📝 Walkthrough

Walkthrough

The planar slice world-point calculation now maps flattened dynamic-volume image indices to group-local slice indices before computing coordinates. A Jest test covers both remapped and unchanged indices.

Changes

Dynamic volume world-point mapping

Layer / File(s) Summary
Map flattened indices to slice coordinates
packages/core/src/RenderingEngine/GenericViewport/Planar/planarSliceBasis.ts, packages/core/test/planarSliceBasis.jest.js
The calculation optionally uses flatImageIdIndexToImageIdIndex, clamps the resulting local slice index, and tests remapped and pass-through indices.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, descriptive, and accurately reflects the main change to dynamic-volume index mapping.
Description check ✅ Passed The description follows the template well with clear Context, Changes & Results, Testing, and checklist details.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/planar-dynamic-volume-slice-index

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.

@sedghi sedghi merged commit abc6380 into main Jul 11, 2026
17 checks passed
@sedghi sedghi deleted the fix/planar-dynamic-volume-slice-index branch July 11, 2026 03:11
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.

1 participant