Repository navigation
Fix decoding of SR content items with value type WAVEFORM - #473
Merged
CPBridge merged 1 commit intoOct 22, 2026
Merged
Conversation
WaveformContentItem.from_dataset() checked the dataset against value type IMAGE, so WAVEFORM items were rejected while IMAGE items were accepted. WAVEFORM was also missing from the lookup tables used by _assert_value_type() and ContentSequence.from_sequence(), so any SR or KOS document containing a WAVEFORM item failed with a KeyError when parsed. The referenced_waveform_channels property read the Referenced Frame Number attribute instead of Referenced Waveform Channels and therefore always returned None.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #472
WaveformContentItemcould be constructed but not decoded, so any SR or Key Object Selection document with a WAVEFORM item in its content tree failed to load.Changes in
src/highdicom/sr/value_types.py:WaveformContentItem.from_dataset()checked the dataset againstValueTypeValues.IMAGE. It now checks againstValueTypeValues.WAVEFORM.ValueTypeValues.WAVEFORMwas missing from the tables in_assert_value_type()and_get_content_item_class(), soContentSequence.from_sequence()raised aKeyErroron WAVEFORM items. Both tables now include it. Referenced SOP Sequence is the required attribute, as for IMAGE and COMPOSITE.referenced_waveform_channelsreadReferencedFrameNumberand so always returnedNone. It now readsReferencedWaveformChannels, the attribute the constructor writes.referenced_waveform_channelsconstructor parameter now matches the docstring and the implementation (Sequence[tuple[int, int]]). Before, it saidint | Sequence[int].There is no change to the public API.
Tests:
tests/test_sr.py: construction with and without channels,from_dataset()for a WAVEFORM dataset, rejection of an IMAGE dataset, and decoding a WAVEFORM item nested in a CONTAINER.tests/test_ko.py:KeyObjectSelection.from_sequence()with a WAVEFORM reference, thenget_references(value_type=ValueTypeValues.WAVEFORM).Five of the six new tests fail on master. The one that passes on master is the test without channels. All six pass with this change.
Validation:
pytest tests/test_sr.py tests/test_ko.py -k waveform: 6 passedpytest tests: 2044 passed, 153 skippedflake8 --exclude='bin,build,.eggs,.venv': clean