Skip to content

Commit

Permalink
Merge pull request #208 from che85/add_html_report
Browse files Browse the repository at this point in the history
ENH: removing unneeded plugins only from instantiated SegmentStatisticsLogic
  • Loading branch information
che85 authored Nov 23, 2017
2 parents abcbf59 + 13c82f2 commit 94eaad6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
22 changes: 16 additions & 6 deletions QuantitativeReporting/QRCustomizations/CustomSegmentStatistics.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import logging
import slicer
import qt

from SlicerDevelopmentToolboxUtils.mixins import ModuleLogicMixin
from SegmentStatistics import SegmentStatisticsLogic
from SegmentStatisticsPlugins import ScalarVolumeSegmentStatisticsPlugin, ClosedSurfaceSegmentStatisticsPlugin
from SegmentStatistics import SegmentStatisticsLogic, SegmentStatisticsParameterEditorDialog
from SegmentStatisticsPlugins import LabelmapSegmentStatisticsPlugin
from DICOMSegmentationPlugin import DICOMSegmentationExporter


class CustomSegmentStatisticsParameterEditorDialog(SegmentStatisticsParameterEditorDialog):

def __init__(self, logic, parent=None, pluginName=None):
super(qt.QDialog, self).__init__(parent)
self.title = "Edit Segment Statistics Parameters"
self.logic = logic
self.parameterNode = self.logic.getParameterNode()
self.pluginName = pluginName
self.setup()


class CustomSegmentStatisticsLogic(SegmentStatisticsLogic):

@staticmethod
Expand All @@ -24,11 +36,9 @@ def segmentationNode(self):
return slicer.mrmlScene.GetNodeByID(self.getParameterNode().GetParameter("Segmentation"))

def __init__(self):
logging.debug("CustomSegmentStatisticsLogic: only using ScalarVolumeSegmentStatisticsPlugin and "
"ClosedSurfaceSegmentStatisticsPlugin")
SegmentStatisticsLogic.registeredPlugins = [ScalarVolumeSegmentStatisticsPlugin,
ClosedSurfaceSegmentStatisticsPlugin]
SegmentStatisticsLogic.__init__(self)
self.plugins = [p for p in self.plugins if not isinstance(p,LabelmapSegmentStatisticsPlugin)]
self.reset()
self.terminologyLogic = slicer.modules.terminologies.logic()

def exportToTable(self, table=None, nonEmptyKeysOnly=True):
Expand Down
12 changes: 7 additions & 5 deletions QuantitativeReporting/QuantitativeReporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import vtkSegmentationCorePython as vtkSegmentationCore
from DICOMSegmentationPlugin import DICOMSegmentationExporter
from SegmentStatistics import SegmentStatisticsParameterEditorDialog

from SlicerDevelopmentToolboxUtils.buttons import CrosshairButton
from SlicerDevelopmentToolboxUtils.buttons import RedSliceLayoutButton, FourUpLayoutButton, FourUpTableViewLayoutButton
Expand All @@ -23,6 +22,7 @@
from QRUtils.htmlReport import HTMLReportCreator
from QRUtils.testdata import TestDataLogic

from QRCustomizations.CustomSegmentStatistics import CustomSegmentStatisticsParameterEditorDialog
from QRCustomizations.CustomSegmentEditor import CustomSegmentEditorWidget
from QRCustomizations.CustomDICOMDetailsWidget import CustomDICOMDetailsWidget

Expand Down Expand Up @@ -63,6 +63,7 @@ def initializeMembers(self):
self.tableNode = None
self.segmentationObservers = []
self.dicomSegmentationExporter = None
self.segmentStatisticsParameterEditorDialog = None

def enter(self):
self.measurementReportSelector.setCurrentNode(None)
Expand Down Expand Up @@ -351,10 +352,11 @@ def setupOtherConnections():

def onEditParameters(self, calculatorName=None):
"""Open dialog box to edit calculator's parameters"""
pNode = self.segmentEditorWidget.logic.segmentStatisticsLogic.getParameterNode()
if pNode:
SegmentStatisticsParameterEditorDialog.editParameters(pNode,calculatorName)
self.updateMeasurementsTable(triggered=True)
segmentStatisticsLogic = self.segmentEditorWidget.logic.segmentStatisticsLogic
if not self.segmentStatisticsParameterEditorDialog:
self.segmentStatisticsParameterEditorDialog = CustomSegmentStatisticsParameterEditorDialog(segmentStatisticsLogic)
self.segmentStatisticsParameterEditorDialog.exec_()
self.updateMeasurementsTable(triggered=True)

def onExportToHTMLButtonClicked(self):
creator = HTMLReportCreator(self.segmentEditorWidget.segmentationNode, self.tableNode)
Expand Down

0 comments on commit 94eaad6

Please sign in to comment.