Skip to content

Commit

Permalink
BUG: fixes wrong api calls caused by Slicer Core changes (issue #197)
Browse files Browse the repository at this point in the history
  • Loading branch information
che85 committed Sep 18, 2017
1 parent aec1e97 commit 5731bb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
34 changes: 17 additions & 17 deletions DICOMPlugins/DICOMSegmentationPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,14 @@ def load(self,loadable):
regionModCode, regionModCodingScheme, regionModCodeMeaning = \
self.getValuesFromCodeSequence(segment, "AnatomicRegionModifierSequence")

dummyTerminologyWidget = slicer.qSlicerTerminologyNavigatorWidget() # Still cannot call static methods from python
segmentTerminologyTag = dummyTerminologyWidget.serializeTerminologyEntry(
loadable.name,
categoryCode, categoryCodingScheme, categoryCodeMeaning,
typeCode, typeCodingScheme, typeCodeMeaning,
typeModCode, typeModCodingScheme, typeModCodeMeaning,
loadable.name,
regionCode, regionCodingScheme, regionCodeMeaning,
regionModCode, regionModCodingScheme, regionModCodeMeaning)
segmentTerminologyTag = terminologiesLogic.SerializeTerminologyEntry(
loadable.name,
categoryCode, categoryCodingScheme, categoryCodeMeaning,
typeCode, typeCodingScheme, typeCodeMeaning,
typeModCode, typeModCodingScheme, typeModCodeMeaning,
loadable.name,
regionCode, regionCodingScheme, regionCodeMeaning,
regionModCode, regionModCodingScheme, regionModCodeMeaning)
# end of processing a line of terminology

# TODO: Create logic class that both CLI and this plugin uses so that we don't need to have temporary NRRD
Expand Down Expand Up @@ -334,6 +333,15 @@ class EmptySegmentsFoundError(ValueError):
class NoNonEmptySegmentsFoundError(ValueError):
pass

@staticmethod
def getDeserializedTerminologyEntry(vtkSegment):
terminologyEntry = slicer.vtkSlicerTerminologyEntry()
tag = vtk.mutable("")
vtkSegment.GetTag(vtkSegment.GetTerminologyEntryTagName(), tag)
terminologyLogic = slicer.modules.terminologies.logic()
terminologyLogic.DeserializeTerminologyEntry(tag, terminologyEntry)
return terminologyEntry

@staticmethod
def saveJSON(data, destination):
with open(os.path.join(destination), 'w') as outfile:
Expand Down Expand Up @@ -551,14 +559,6 @@ def checkTerminologyOfSegments(self, segmentIDs):
if any(v is None for v in [category, propType]):
raise ValueError("Segment {} has missing attributes. Make sure to set terminology.".format(segment.GetName()))

def getDeserializedTerminologyEntry(self, vtkSegment):
terminologyWidget = slicer.qSlicerTerminologyNavigatorWidget()
terminologyEntry = slicer.vtkSlicerTerminologyEntry()
tag = vtk.mutable("")
vtkSegment.GetTag(vtkSegment.GetTerminologyEntryTagName(), tag)
terminologyWidget.deserializeTerminologyEntry(tag, terminologyEntry)
return terminologyEntry

def createJSONFromTerminologyContext(self, terminologyEntry):
segmentData = dict()

Expand Down
10 changes: 1 addition & 9 deletions QuantitativeReporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ def generateJSON4DcmSR(self, dcmSegmentationFile, sourceVolumeNode):
data["segmentationSOPInstanceUID"] = segmentationSOPInstanceUID
segment = self.segmentationNode.GetSegmentation().GetSegment(segmentID)

terminologyEntry = self.getDeserializedTerminologyEntry(segment)
terminologyEntry = DICOMSegmentationExporter.getDeserializedTerminologyEntry(segment)

data["Finding"] = self.createJSONFromTerminologyContext(terminologyEntry)["SegmentedPropertyTypeCodeSequence"]
anatomicContext = self.createJSONFromAnatomicContext(terminologyEntry)
Expand Down Expand Up @@ -1005,14 +1005,6 @@ def _createCodeSequence(self, vtkStringifiedCodedEntry):
codeSequence[key] = value
return codeSequence

def getDeserializedTerminologyEntry(self, segment):
terminologyWidget = slicer.qSlicerTerminologyNavigatorWidget()
terminologyEntry = slicer.vtkSlicerTerminologyEntry()
tag = vtk.mutable("")
segment.GetTag(segment.GetTerminologyEntryTagName(), tag)
terminologyWidget.deserializeTerminologyEntry(tag, terminologyEntry)
return terminologyEntry


class CustomDICOMDetailsWidget(DICOMDetailsWidget, ParameterNodeObservationMixin):

Expand Down

0 comments on commit 5731bb6

Please sign in to comment.