Skip to content

Commit

Permalink
BUG: fix initialization of segment metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov committed Nov 15, 2023
1 parent e91b506 commit 562d680
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions DICOMPlugins/DICOMSegmentationPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,26 @@ def _importSegmentAndRemoveLabel(self, segmentLabelNode, segmentationNode):
if segmentation.GetNumberOfSegments() == 0:
logging.warning("Empty segment loaded from DICOM SEG!")

thisLabelSegmentID = 0
for segmentId in range(numberOfSegmentsBeforeImport, segmentation.GetNumberOfSegments()):
logging.info(f"Setting attributes for segment {segmentId} ...")

segment = segmentation.GetNthSegment(segmentId)
segment.SetName(segmentLabelNode.labelAttributes[segmentId]["Name"])
segment.SetNameAutoGenerated(segmentLabelNode.labelAttributes[segmentId]["NameAutoGenerated"])
segment.SetTag("Description", segmentLabelNode.labelAttributes[segmentId]["Description"])
segment.SetColor([float(segmentLabelNode.labelAttributes[segmentId]["ColorR"]),
float(segmentLabelNode.labelAttributes[segmentId]["ColorG"]),
float(segmentLabelNode.labelAttributes[segmentId]["ColorB"])])
segment.SetName(segmentLabelNode.labelAttributes[thisLabelSegmentID]["Name"])
segment.SetNameAutoGenerated(segmentLabelNode.labelAttributes[thisLabelSegmentID]["NameAutoGenerated"])
segment.SetTag("Description", segmentLabelNode.labelAttributes[thisLabelSegmentID]["Description"])
segment.SetColor([float(segmentLabelNode.labelAttributes[thisLabelSegmentID]["ColorR"]),
float(segmentLabelNode.labelAttributes[thisLabelSegmentID]["ColorG"]),
float(segmentLabelNode.labelAttributes[thisLabelSegmentID]["ColorB"])])
segment.SetTag(vtkSegmentationCore.vtkSegment.GetTerminologyEntryTagName(),
segmentLabelNode.labelAttributes[segmentId]["Terminology"])
algorithmName = segmentLabelNode.labelAttributes[segmentId]["DICOM.SegmentAlgorithmName"]
segmentLabelNode.labelAttributes[thisLabelSegmentID]["Terminology"])
algorithmName = segmentLabelNode.labelAttributes[thisLabelSegmentID]["DICOM.SegmentAlgorithmName"]
if algorithmName is not None:
segment.SetTag("DICOM.SegmentAlgorithmName", algorithmName)
algorithmType = segmentLabelNode.labelAttributes[segmentId]["DICOM.SegmentAlgorithmType"]
algorithmType = segmentLabelNode.labelAttributes[thisLabelSegmentID]["DICOM.SegmentAlgorithmType"]
if algorithmType is not None:
segment.SetTag("DICOM.SegmentAlgorithmType", algorithmType)
thisLabelSegmentID += 1

self._removeLabelNode(segmentLabelNode)

Expand Down

0 comments on commit 562d680

Please sign in to comment.