Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fixes wrong api calls caused by Slicer Core changes (issue #197) #198

Merged
merged 2 commits into from
Sep 18, 2017
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
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
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