feat: add XA Enhanced DICOM support #38
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds full support for Siemens syngo MR XA Enhanced DICOM files (XA30, XA60, and newer versions), resolving Issue #31.
This PR is based on PR #37 which adds the
CsaHeader.from_dicom()convenience method. This PR extends that method to support XA Enhanced format.XA Enhanced DICOMs store protocol data in XProtocol format (ASCII/XML-like) within
SharedFunctionalGroupsSequencerather than using the standard binary CSA tags. The library now automatically detects and handles both formats seamlessly.Problem
Users reported (#31) that XA Enhanced DICOM files failed to parse with the error:
This occurred because the library tried to parse XProtocol data (ASCII) as binary CSA format.
Solution
This PR extends the
from_dicom()method (from PR #37) to automatically detect and parse XA Enhanced format:SharedFunctionalGroupsSequenceCsaAsciiHeader(which can parse XProtocol) instead ofCsaHeaderChanges
Core Implementation (
csa_header/header.py)XA_ENHANCED_TAGSclass constant with XA-specific tag definitions_extract_xa_enhanced_protocol()static method to extract XProtocol from SharedFunctionalGroupsSequencefrom_dicom()method to:CsaAsciiHeaderfor XA Enhanced formatCsaHeaderfor standard formatCsaHeader | CsaAsciiHeader | NoneTests (
tests/test_xa_enhanced.py)Added comprehensive test suite with 23 new tests:
Test Data (
tests/files/xa_enhanced/)xa30_sample.dcm- XA30 (MAGNETOM Prisma Fit, syngo MR XA30)xa60_sample.dcm- XA60 (MAGNETOM Terra.X, syngo MR XA60)tests/fixtures.pywith file pathsDocumentation
README.md:
XA_ENHANCED_ANALYSIS.md: (technical reference)
Usage
The API automatically detects the format:
Or use a unified approach:
Test Results
✅ All 223 tests pass (200 existing + 19 from #37 + 23 XA Enhanced, 4 skipped)
✅ 94% code coverage maintained
✅ Zero regressions - all existing functionality preserved
✅ Issue #31 validated - XA Enhanced files parse successfully
Technical Details
Format Differences
CsaHeaderCsaAsciiHeader.read()method.parsedpropertyDetection Flow
Breaking Changes
None. The API is fully backward compatible.
Test Data Sources
Merge Strategy
This PR should be merged after PR #37 is merged, or both can be merged together since #38 is based on #37.
Closes
Fixes #31
Depends On
CsaHeader.from_dicom()method)🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com