Skip to content

fix(seg): use buffer-based loader when PerFrameFunctionalGroupsSequence missing - #148

Merged
igoroctaviano merged 2 commits into
masterfrom
fix/seg-missing-perframe-metadata
Oct 6, 2026
Merged

igoroctaviano merged 2 commits into
masterfrom
fix/seg-missing-perframe-metadata

Conversation

@igoroctaviano

@igoroctaviano igoroctaviano commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes SEG loading failures for DICOMweb servers that omit PerFrameFunctionalGroupsSequence from JSON metadata (like IDC's static WADO).

Root Cause Analysis

OHIF 3.13 changed SEG loading from:

  • Old (3.12): createFromDICOMSegBuffer - fetches full DICOM file, parses complete metadata
  • New (3.13): createFromDicomSegImageId - relies on metadata provider (DICOMweb JSON)

IDC's static WADO omits PerFrameFunctionalGroupsSequence from JSON metadata to save bandwidth (this sequence can be huge for SEGs with thousands of frames). The new loader fails because it expects this sequence.

Solution

Detect when PerFrameFunctionalGroupsSequence is missing and fall back to the buffer-based loader:

if (!hasPerFrameFunctionalGroups) {
  // Fetch full DICOM and use createFromDICOMSegBuffer
} else {
  // Use createFromDicomSegImageId (more efficient when metadata is complete)
}

This restores the behavior from OHIF 3.12 while keeping the optimized path for servers with complete metadata.

Upstream PRs

The fix and related improvements have been submitted upstream:

Patches Included

Also includes two backported patches from cornerstone3D that are still needed:

  1. VOI LUT function validation (PR #2856)

    • Prevents "Invalid VOI LUT function" errors
  2. Segment index by SegmentNumber for LABELMAP (PR #2882)

    • Fixes segment color mapping for LABELMAP with SegmentNumber=0

Closed Upstream PRs/Issues

The following were opened during investigation but are no longer needed since the fix is in OHIF:

Testing

  1. Load a SEG from IDC that was previously failing
  2. Verify segments display with correct colors
  3. Verify CT/MR images render without VOI LUT errors

When a SEG frame is missing SegmentIdentificationSequence in both
per-frame and shared functional groups, the code now logs a warning
and skips that frame instead of throwing an error that aborts the
entire segmentation loading.

This follows the same pattern already used for missing imageIds
(lines 587-589) and makes SEG loading more resilient to non-standard
or incomplete DICOM SEG files.

Per DICOM PS3.3 C.8.20.3.1, SegmentIdentificationSequence is required
for LABELMAP segmentations, but graceful degradation is preferred over
hard failure when encountering non-compliant files.
…ce missing

OHIF 3.13 changed SEG loading from createFromDICOMSegBuffer (fetches full
DICOM file) to createFromDicomSegImageId (relies on metadata provider).

This broke SEG loading for DICOMweb servers like IDC's static WADO that omit
PerFrameFunctionalGroupsSequence from JSON metadata to save space (this
sequence can be huge for SEGs with thousands of frames).

The fix detects when PerFrameFunctionalGroupsSequence is missing and falls
back to the buffer-based loader which parses complete metadata directly from
the DICOM binary - restoring the behavior from OHIF 3.12.

Also includes two backported patches from cornerstone3D:
- VOI LUT function validation (PR OHIF#2856)
- Segment index by SegmentNumber for LABELMAP support (PR OHIF#2882)
@igoroctaviano
igoroctaviano merged commit a0b05e9 into master Oct 6, 2026
2 of 3 checks passed

This branch is being deployed

1 queued deployment
fork-pr-approval — 72918277 Deployed Oct 6, 2026 by igoroctaviano via playwright-tests (24.15.0) #126
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