Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/highdicom/seg/sop.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,15 @@ def _add_segment_descriptions(
# descriptions having a positive value can remain in place.
bg_description.SegmentNumber = 0

# Remove the algorithm identification sequence, since it is not
# actually required (highdicom is stricter than the standard here)
# and doesn't make sense for a background class
if bg_algo_id is not None:
delattr(
bg_description,
'SegmentationAlgorithmIdentificationSequence'
)

self.SegmentSequence = [
bg_description,
*segment_descriptions
Expand Down
13 changes: 13 additions & 0 deletions tests/test_seg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,19 @@ def test_construction_8(self):
assert not hasattr(instance, 'ExtendedOffsetTable')
assert not hasattr(instance, 'ExtendedOffsetTableLengths')

# Segment descriptions include background
assert (
len(instance.SegmentSequence) ==
len(self._segment_descriptions) + 1
)

# Background segment has no algorithm identification
bg_desc = instance.SegmentSequence[0]
assert not hasattr(
bg_desc,
'SegmentationAlgorithmIdentificationSequence'
)

def test_construction_9(self):
# A label with a palette color LUT
instance = Segmentation(
Expand Down
Loading