Skip to content

feat(tools): add veterinary (quadruped) orientation label support#2783

Open
volkan-interpacs wants to merge 2 commits into
cornerstonejs:mainfrom
InterPacs:feat/veterinary-orientation-labels
Open

feat(tools): add veterinary (quadruped) orientation label support#2783
volkan-interpacs wants to merge 2 commits into
cornerstonejs:mainfrom
InterPacs:feat/veterinary-orientation-labels

Conversation

@volkan-interpacs

@volkan-interpacs volkan-interpacs commented Jul 4, 2026

Copy link
Copy Markdown

Context

The orientation utilities (getOrientationStringLPS, invertOrientationStringLPS) only support human (biped) anatomical designators (L/R, A/P, H/F). Veterinary imaging needs different designators per DICOM PS3.3 C.7.6.1.1.1 (Patient Orientation): when AnatomicalOrientationType (0010,2210) is QUADRUPED, dorsal/ventral and cranial/caudal labels are used instead.
Quadruped designators are body-region-specific (not a single mapping): the trunk/neck/tail use cranial/caudal on the long axis, the head uses rostral/caudal, and limbs use proximal/distal (positioning-dependent).

Changes & Results

  • Add packages/tools/src/utilities/orientation/orientationLabels.ts:
    • OrientationLabels type (designator per patient axis)
    • BIPED_ORIENTATION_LABELS (human, the existing default)
    • QUADRUPED_TRUNK_ORIENTATION_LABELS (LE/RT, D/V, CR/CD, the mapping in the standard's worked abdomen example "LEV\CD")
    • QUADRUPED_HEAD_ORIENTATION_LABELS (LE/RT, D/V, R/CD, rostral for the head)
    • limbs documented (proximal/distal, palmar/plantar) for the caller to configure per study, since they have no fixed-axis mapping
    • getOrientationStringLPS and invertOrientationStringLPS accept an optional labels argument (defaults to BIPED, fully backward compatible). The LPS coordinate math is unchanged for any species/region.
// Human (unchanged)
getOrientationStringLPS([0, 0, 1]);                                     // 'H'
// Veterinary — trunk
getOrientationStringLPS([0, 0, 1], QUADRUPED_TRUNK_ORIENTATION_LABELS); // 'CR' (Cranial)
// Veterinary — head
getOrientationStringLPS([0, 0, 1], QUADRUPED_HEAD_ORIENTATION_LABELS);  // 'R' (Rostral)

Testing

  • Unit tests: packages/tools/src/utilities/orientation/getOrientationStringLPS.spec.ts covers biped, quadruped-trunk and quadruped-head cases for both functions (10 tests).
    • Run locally:
      • pnpm install
      • build deps: pnpm --filter @cornerstonejs/utils build && pnpm --filter @cornerstonejs/metadata build && pnpm --filter @cornerstonejs/core build
      • pnpm --filter @cornerstonejs/tools build
      • npx jest --config packages/tools/jest.config.js src/utilities/orientation/getOrientationStringLPS.spec.ts

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.)

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API additions or removals. (Public API reference is auto-generated by TypeDoc from the TSDoc on the new OrientationLabels type and presets.)

Tested Environment

  • OS: Windows 11 Pro (26200)
  • Node version: 24.15.0 (CI) / 26.4.0 (local)
  • Browser: N/A (pure utility, no rendering)

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds configurable orientation label sets, updates orientation string generation and inversion to use them, re-exports the new labels, and adds Jest coverage for biped and quadruped cases.

Changes

Orientation label configurability

Layer / File(s) Summary
Orientation label definitions
packages/tools/src/utilities/orientation/orientationLabels.ts
Adds the OrientationLabels type and biped, quadruped trunk, and quadruped head label constants.
getOrientationStringLPS label-based lookup
packages/tools/src/utilities/orientation/getOrientationStringLPS.ts
Adds an optional labels parameter and uses it to select axis designators by vector sign.
invertOrientationStringLPS label-aware inversion
packages/tools/src/utilities/orientation/invertOrientationStringLPS.ts
Adds an optional labels parameter and rewrites inversion to use a longest-first designator swap table.
Exports and tests
packages/tools/src/utilities/orientation/index.ts, packages/tools/src/utilities/orientation/getOrientationStringLPS.spec.ts
Re-exports the labels and type, and adds Jest coverage for default, trunk, and head mappings and inversions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title is concise, descriptive, and matches the main change: veterinary quadruped orientation label support.
Description check ✅ Passed The description follows the template with Context, Changes & Results, Testing, and a completed checklist.
✨ 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.

@sedghi sedghi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not a veterinary expert, gpt flagged this please check

[P2] Avoid a generic quadruped label preset — /Users/alireza/open-source/clean/cornerstone3D/packages/tools/src/
utilities/orientation/orientationLabels.ts:57-64
When AnatomicalOrientationType is QUADRUPED, DICOM does not map every study to D/V and CR/CD: head images use rostral/
caudal for +Z/-Z and limb images use proximal/distal (and proximal limbs use cranial/caudal on another axis). This
exported preset is advertised for veterinary QUADRUPED images in general, so callers will produce non-DICOM orientation
strings such as CR instead of R/PR for common head or limb studies; the API needs body-region-specific presets or must
not present this as the general quadruped mapping.

@volkan-interpacs

Copy link
Copy Markdown
Author

Valid point agreed. The quadruped designators are body-region-specific (cranial/caudal for the trunk, rostral/caudal for the head, proximal/distal for limbs), per the designator list in PS3.3 C.7.6.1.1.1. I split the preset into trunk + head and documented limbs. PR updated.

@volkan-interpacs
volkan-interpacs requested a review from sedghi July 9, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants