Skip to content

Commit

Permalink
Merge pull request #198 from che85/fix_api_calls
Browse files Browse the repository at this point in the history
WIP: fixes wrong api calls caused by Slicer Core changes (issue #197)
  • Loading branch information
che85 authored Sep 18, 2017
2 parents 0530006 + 151ddc4 commit 8ca6da0
Show file tree
Hide file tree
Showing 2 changed files with 19 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 @@ -563,14 +571,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
11 changes: 2 additions & 9 deletions QuantitativeReporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ def setup(self):
super(QuantitativeReportingSegmentEditorWidget, self).setup()
if self.developerMode:
self.reloadCollapsibleButton.hide()
self.editor.switchToSegmentationsButtonVisible = False
self.editor.segmentationNodeSelectorVisible = False
self.editor.setEffectButtonStyle(qt.Qt.ToolButtonIconOnly)
self.clearSegmentationEditorSelectors()
Expand Down Expand Up @@ -973,7 +974,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 +1006,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 8ca6da0

Please sign in to comment.