Пример #1
0
    def __init__(self, parent, db):
        self.view = qt.QTableView(parent)
        self.model = qt.QSqlQueryModel()
        self.statement = """ SELECT 
                            Patients.PatientsName, Patients.PatientID, Patients.PatientsBirthDate,
                            Studies.StudyDate, Studies.StudyDescription, Studies.ModalitiesInStudy,
                            Studies.StudyInstanceUID
                         FROM 
                            Patients,Studies 
                          WHERE 
                            Patients.UID=Studies.PatientsUID
                         ORDER BY 
                            Patients.PatientsName
                         ; """
        self.query = qt.QSqlQuery(db)
        self.query.prepare(self.statement)
        self.query.exec_()
        self.model.setQuery(self.query)

        self.view.setModel(self.model)
        self.view.sortingEnabled = False
        self.view.setSelectionBehavior(self.view.SelectRows)
        self.view.setSelectionMode(self.view.SingleSelection)
        self.view.setColumnWidth(0, 250)
        self.view.setColumnWidth(1, 100)
        self.view.setColumnWidth(2, 150)
        self.view.setColumnWidth(3, 100)
        self.view.setColumnWidth(4, 180)
        self.view.setColumnWidth(5, 180)
        self.view.setColumnWidth(6, 180)
        self.view.verticalHeader().visible = False
Пример #2
0
    def __init__(self, parent, db):
        self.view = qt.QTableView(parent)
        self.model = qt.QSqlQueryModel()

        self.statementFormat = """SELECT
                            Series.SeriesNumber, Series.SeriesDescription, 
                            Series.SeriesDate, Series.SeriesTime, Series.SeriesInstanceUID
                         FROM 
                            Series
                          WHERE 
                            Series.StudyInstanceUID='{StudyInstanceUID}'
                         ORDER BY 
                            Series.SeriesNumber
                         ; """
        self.query = qt.QSqlQuery(db)
        self.query.prepare(
            self.statementFormat.format(StudyInstanceUID='Nothing'))
        self.query.exec_()
        self.model.setQuery(self.query)

        self.view.setModel(self.model)
        self.view.sortingEnabled = False
        self.view.setSelectionBehavior(self.view.SelectRows)
        self.view.setSelectionMode(self.view.SingleSelection)
        self.view.setColumnWidth(0, 250)
        self.view.setColumnWidth(1, 100)
        self.view.setColumnWidth(2, 150)
        self.view.setColumnWidth(3, 100)
        self.view.setColumnWidth(4, 180)
        self.view.setColumnWidth(5, 180)
        self.view.setColumnWidth(6, 180)
        self.view.verticalHeader().visible = False
Пример #3
0
    def __init__(self, parent):
        super(CaseReportsWindow, self).__init__()

        self.mainLayout = qt.QVBoxLayout(self)
        self.setLayout(self.mainLayout)
        self.resize(400, 300)

        self.label = qt.QLabel("Data stored in the module: ")
        self.label.setStyleSheet("margin: 10px 0 15px 0")
        self.mainLayout.addWidget(self.label)

        self.tableView = qt.QTableView()
        self.tableView.setColumnWidth(0,125)

        self.tableView.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding)
        self.mainLayout.addWidget(self.tableView)

        self.exportButton = ctk.ctkPushButton()
        self.exportButton.text = "Export"
        self.exportButton.setFixedWidth(150)
        self.exportButton.setIcon(qt.QIcon("{0}/export-csv.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.exportButton.setIconSize(qt.QSize(24,24))
        self.mainLayout.addWidget(self.exportButton)

        self.removeButton = ctk.ctkPushButton()
        self.removeButton.text = "Clean cache"
        self.removeButton.setIcon(qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeButton.setIconSize(qt.QSize(24,24))
        self.removeButton.setFixedWidth(150)
        self.mainLayout.addWidget(self.removeButton)

        self.exportButton.connect('clicked()', parent.onExport)
        self.removeButton.connect('clicked()', parent.onRemoveStoredData)
Пример #4
0
    def setup(self):

        # Set the grayscaleNode and labelNode to the current active volume and label
        selectionNode = slicer.app.applicationLogic().GetSelectionNode()
        self.grayscaleNode = slicer.util.getNode(
            selectionNode.GetActiveVolumeID())
        self.labelNode = slicer.util.getNode(
            selectionNode.GetActiveLabelVolumeID())

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Calculate Statistics."
        self.applyButton.setStyleSheet("background-color: rgb(230,241,255)")
        self.applyButton.enabled = True
        self.parent.layout().addWidget(self.applyButton)

        # model and view for stats table
        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        self.parent.layout().addWidget(self.view)

        # Chart button
        self.chartFrame = qt.QFrame()
        self.chartFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.chartFrame)
        self.chartButton = qt.QPushButton("Chart")
        self.chartButton.toolTip = "Make a chart from the current statistics."
        self.chartFrame.layout().addWidget(self.chartButton)
        self.chartOption = qt.QComboBox()
        self.chartOption.addItems(self.chartOptions)
        self.chartFrame.layout().addWidget(self.chartOption)
        self.chartIgnoreZero = qt.QCheckBox()
        self.chartIgnoreZero.setText('Ignore Zero')
        self.chartIgnoreZero.checked = False
        self.chartIgnoreZero.setToolTip(
            'Do not include the zero index in the chart to avoid dwarfing other bars'
        )
        self.chartFrame.layout().addWidget(self.chartIgnoreZero)
        self.chartFrame.enabled = False

        # Save button
        self.saveButton = qt.QPushButton("Save")
        self.saveButton.toolTip = "Calculate Statistics."
        self.saveButton.setStyleSheet("background-color: rgb(230,241,255)")
        self.saveButton.enabled = False
        self.parent.layout().addWidget(self.saveButton)

        # Add vertical spacer
        self.parent.layout().addStretch(1)

        # connections
        self.applyButton.connect('clicked()', self.onApply)
        self.chartButton.connect('clicked()', self.onChart)
        self.saveButton.connect('clicked()', self.onSave)
Пример #5
0
    def setup(self):
        #
        # the grayscale volume selector
        #
        self.grayscaleSelectorFrame = qt.QFrame(self.parent)
        self.grayscaleSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.grayscaleSelectorFrame)

        self.grayscaleSelectorLabel = qt.QLabel("Grayscale Volume: ",
                                                self.grayscaleSelectorFrame)
        self.grayscaleSelectorLabel.setToolTip(
            "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations"
        )
        self.grayscaleSelectorFrame.layout().addWidget(
            self.grayscaleSelectorLabel)

        self.grayscaleSelector = slicer.qMRMLNodeComboBox(
            self.grayscaleSelectorFrame)
        self.grayscaleSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.grayscaleSelector.addAttribute("vtkMRMLScalarVolumeNode",
                                            "LabelMap", 0)
        self.grayscaleSelector.selectNodeUponCreation = False
        self.grayscaleSelector.addEnabled = False
        self.grayscaleSelector.removeEnabled = False
        self.grayscaleSelector.noneEnabled = True
        self.grayscaleSelector.showHidden = False
        self.grayscaleSelector.showChildNodeTypes = False
        self.grayscaleSelector.setMRMLScene(slicer.mrmlScene)
        # TODO: need to add a QLabel
        # self.grayscaleSelector.SetLabelText( "Master Volume:" )
        self.grayscaleSelectorFrame.layout().addWidget(self.grayscaleSelector)

        #
        # the label volume selector
        #
        self.labelSelectorFrame = qt.QFrame()
        self.labelSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.labelSelectorFrame)

        self.labelSelectorLabel = qt.QLabel()
        self.labelSelectorLabel.setText("Label Map: ")
        self.labelSelectorFrame.layout().addWidget(self.labelSelectorLabel)

        self.labelSelector = slicer.qMRMLNodeComboBox()
        self.labelSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.labelSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                        "1")
        # todo addAttribute
        self.labelSelector.selectNodeUponCreation = False
        self.labelSelector.addEnabled = False
        self.labelSelector.noneEnabled = True
        self.labelSelector.removeEnabled = False
        self.labelSelector.showHidden = False
        self.labelSelector.showChildNodeTypes = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip("Pick the label map to edit")
        self.labelSelectorFrame.layout().addWidget(self.labelSelector)

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Calculate Statistics."
        self.applyButton.enabled = False
        self.parent.layout().addWidget(self.applyButton)

        # model and view for stats table
        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        self.parent.layout().addWidget(self.view)

        # Save button
        self.saveButton = qt.QPushButton("Save")
        self.saveButton.toolTip = "Calculate Statistics."
        self.saveButton.enabled = False
        self.parent.layout().addWidget(self.saveButton)

        # Add vertical spacer
        self.parent.layout().addStretch(1)

        # connections
        self.applyButton.connect('clicked()', self.onApply)
        self.saveButton.connect('clicked()', self.onSave)
        self.grayscaleSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                       self.onGrayscaleSelect)
        self.labelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.onLabelSelect)
Пример #6
0
    def setup(self):
        #
        # the grayscale volume selector
        #
        self.grayscaleSelectorFrame = qt.QFrame(self.parent)
        self.grayscaleSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.grayscaleSelectorFrame)

        self.grayscaleSelectorLabel = qt.QLabel("Inspiratory CT: ",
                                                self.grayscaleSelectorFrame)
        self.grayscaleSelectorLabel.setToolTip(
            "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations"
        )
        self.grayscaleSelectorFrame.layout().addWidget(
            self.grayscaleSelectorLabel)

        self.grayscaleSelector = slicer.qMRMLNodeComboBox(
            self.grayscaleSelectorFrame)
        self.grayscaleSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.grayscaleSelector.addAttribute("vtkMRMLScalarVolumeNode",
                                            "LabelMap", 0)
        self.grayscaleSelector.selectNodeUponCreation = False
        self.grayscaleSelector.addEnabled = False
        self.grayscaleSelector.removeEnabled = False
        self.grayscaleSelector.noneEnabled = True
        self.grayscaleSelector.showHidden = False
        self.grayscaleSelector.showChildNodeTypes = False
        self.grayscaleSelector.setMRMLScene(slicer.mrmlScene)
        # TODO: need to add a QLabel
        # self.grayscaleSelector.SetLabelText( "Master Volume:" )
        self.grayscaleSelectorFrame.layout().addWidget(self.grayscaleSelector)

        #
        # the label volume selector
        #
        self.labelSelectorFrame = qt.QFrame()
        self.labelSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.labelSelectorFrame)

        self.labelSelectorLabel = qt.QLabel()
        self.labelSelectorLabel.setText("Emphysema Subtypes: ")
        self.labelSelectorFrame.layout().addWidget(self.labelSelectorLabel)

        self.labelSelector = slicer.qMRMLNodeComboBox()
        self.labelSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.labelSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                        "1")
        # todo addAttribute
        self.labelSelector.selectNodeUponCreation = False
        self.labelSelector.addEnabled = False
        self.labelSelector.noneEnabled = True
        self.labelSelector.removeEnabled = False
        self.labelSelector.showHidden = False
        self.labelSelector.showChildNodeTypes = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip("Pick the label map to edit")
        self.labelSelectorFrame.layout().addWidget(self.labelSelector)

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Calculate Statistics."
        self.applyButton.enabled = False
        self.parent.layout().addWidget(self.applyButton)

        # model and view for stats table
        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        self.parent.layout().addWidget(self.view)

        # Chart button
        self.chartFrame = qt.QFrame()
        self.chartFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.chartFrame)
        self.chartButton = qt.QPushButton("Chart")
        self.chartButton.toolTip = "Make a chart from the current statistics."
        self.chartFrame.layout().addWidget(self.chartButton)
        self.chartOption = qt.QComboBox()
        self.chartOption.addItems(self.chartOptions)
        self.chartFrame.layout().addWidget(self.chartOption)
        self.chartIgnoreZero = qt.QCheckBox()
        self.chartIgnoreZero.setText('Ignore Zero')
        self.chartIgnoreZero.checked = False
        self.chartIgnoreZero.setToolTip(
            'Do not include the zero index in the chart to avoid dwarfing other bars'
        )
        self.chartFrame.layout().addWidget(self.chartIgnoreZero)
        self.chartFrame.enabled = False

        # Save button
        self.saveButton = qt.QPushButton("Save")
        self.saveButton.toolTip = "Calculate Statistics."
        self.saveButton.enabled = False
        self.parent.layout().addWidget(self.saveButton)

        # Add vertical spacer
        self.parent.layout().addStretch(1)

        # connections
        self.applyButton.connect('clicked()', self.onApply)
        self.chartButton.connect('clicked()', self.onChart)
        self.saveButton.connect('clicked()', self.onSave)
        self.grayscaleSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                       self.onGrayscaleSelect)
        self.labelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.onLabelSelect)
Пример #7
0
    def setup(self):
        # Instantiate and connect widgets ...

        w = qt.QWidget()
        layout = qt.QGridLayout()
        w.setLayout(layout)
        self.layout.addWidget(w)
        w.show()
        #self.layout = layout

        if self.isDeveloperMode:
            #
            # Reload and Test area
            #
            reloadCollapsibleButton = ctk.ctkCollapsibleButton()
            reloadCollapsibleButton.text = "Reload && Test"
            self.layout.addWidget(reloadCollapsibleButton)
            reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

            # reload button
            # (use this during development, but remove it when delivering
            #  your module to users)
            self.reloadButton = qt.QPushButton("Reload")
            self.reloadButton.toolTip = "Reload this module."
            self.reloadButton.name = "SequenceLabelStatistics Reload"
            reloadFormLayout.addWidget(self.reloadButton)
            self.reloadButton.connect('clicked()', self.onReload)

            # reload and test button
            # (use this during development, but remove it when delivering
            #  your module to users)
            self.reloadAndTestButton = qt.QPushButton("Reload and Test")
            self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
            reloadFormLayout.addWidget(self.reloadAndTestButton)
            self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

        #
        # Parameter Area
        #
        parametersCollapsibleButton1 = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton1.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton1)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton1)

        #
        # the grayscale volume selector
        #
        self.grayscaleSelector = slicer.qMRMLNodeComboBox()
        self.grayscaleSelector.nodeTypes = (("vtkMRMLSequenceNode"), "")
        self.grayscaleSelector.selectNodeUponCreation = False
        self.grayscaleSelector.addEnabled = False
        self.grayscaleSelector.removeEnabled = False
        self.grayscaleSelector.noneEnabled = False
        self.grayscaleSelector.showHidden = False
        self.grayscaleSelector.showChildNodeTypes = False
        self.grayscaleSelector.setMRMLScene(slicer.mrmlScene)
        self.grayscaleSelector.setToolTip(
            "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations."
        )
        # TODO: need to add a QLabel
        # self.grayscaleSelector.SetLabelText( "Master Volume:" )
        parametersFormLayout.addRow("Grayscale Volume Sequence: ",
                                    self.grayscaleSelector)

        #
        # the label volume selector
        #
        self.labelSelector = slicer.qMRMLNodeComboBox()
        self.labelSelector.nodeTypes = ("vtkMRMLSequenceNode",
                                        "vtkMRMLLabelMapVolumeNode")
        # todo addAttribute
        self.labelSelector.selectNodeUponCreation = False
        self.labelSelector.addEnabled = False
        self.labelSelector.noneEnabled = True
        self.labelSelector.removeEnabled = False
        self.labelSelector.showHidden = False
        self.labelSelector.showChildNodeTypes = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip("Pick the label map to edit")
        parametersFormLayout.addRow("Labelmap/Sequence: ", self.labelSelector)

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Calculate Statistics."
        self.applyButton.enabled = False
        parametersFormLayout.addRow(self.applyButton)

        # model and view for stats table
        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        parametersFormLayout.addRow(self.view)

        # Chart button
        self.chartFrame = qt.QFrame()
        self.chartFrame.setLayout(qt.QHBoxLayout())
        parametersFormLayout.addRow(self.chartFrame)
        self.chartButton = qt.QPushButton("Chart")
        self.chartButton.toolTip = "Make a chart from the current statistics."
        self.chartFrame.layout().addWidget(self.chartButton)
        self.chartOption = qt.QComboBox()
        self.chartOption.addItems(self.chartOptions)
        self.chartFrame.layout().addWidget(self.chartOption)
        self.chartIgnoreZero = qt.QCheckBox()
        self.chartIgnoreZero.setText('Ignore Zero')
        self.chartIgnoreZero.checked = False
        self.chartIgnoreZero.setToolTip(
            'Do not include the zero index in the chart to avoid dwarfing other bars'
        )
        self.chartFrame.layout().addWidget(self.chartIgnoreZero)
        self.chartFrame.enabled = False

        # Save button
        self.saveButton = qt.QPushButton("Save")
        self.saveButton.toolTip = "Calculate Statistics."
        self.saveButton.enabled = False
        parametersFormLayout.addRow(self.saveButton)

        # Add vertical spacer
        self.layout.addStretch(1)

        # connections
        self.applyButton.connect('clicked()', self.onApply)
        self.chartButton.connect('clicked()', self.onChart)
        self.saveButton.connect('clicked()', self.onSave)
        self.grayscaleSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                       self.onGrayscaleSelect)
        self.labelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.onLabelSelect)

        # Set initial state
        self.grayscaleNode = self.grayscaleSelector.currentNode()
        self.labelNode = self.labelSelector.currentNode()
        self.applyButton.enabled = bool(self.grayscaleNode) and bool(
            self.labelNode)
Пример #8
0
  def setup(self):
    # Instantiate and connect widgets ...

    # #
    # # Reload and Test area
    # #
    # reloadCollapsibleButton = ctk.ctkCollapsibleButton()
    # reloadCollapsibleButton.text = "Reload && Test"
    # self.layout.addWidget(reloadCollapsibleButton)
    # reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

    # # reload button
    # # (use this during development, but remove it when delivering
    # #  your module to users)
    # self.reloadButton = qt.QPushButton("Reload")
    # self.reloadButton.toolTip = "Reload this module."
    # self.reloadButton.name = "PortPlacement Reload"
    # reloadFormLayout.addWidget(self.reloadButton)
    # self.reloadButton.connect('clicked()', self.onReload)

    # # reload and test button
    # # (use this during development, but remove it when delivering
    # #  your module to users)
    # self.reloadAndTestButton = qt.QPushButton("Reload and Test")
    # self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
    # reloadFormLayout.addWidget(self.reloadAndTestButton)
    # self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

    #
    # Ports Area
    #
    portsCollapsibleButton = ctk.ctkCollapsibleButton()
    portsCollapsibleButton.text = "Surgical Ports"
    self.layout.addWidget(portsCollapsibleButton)
    portsFormLayout = qt.QFormLayout(portsCollapsibleButton)

    #
    # port fiducial list selector
    #
    self.portListSelector = slicer.qMRMLNodeComboBox()
    self.portListSelector.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
    self.portListSelector.addEnabled = False
    self.portListSelector.removeEnabled = False
    self.portListSelector.noneEnabled = True
    self.portListSelector.setMRMLScene(slicer.mrmlScene)
    self.portListSelector.setToolTip("Add surgical ports from a markups node.")
    portsFormLayout.addRow("Markups node of surgical ports", self.portListSelector)

    #
    # Add Port List button
    #
    self.addPortListButton = qt.QPushButton("Set Port Markups Node")
    self.addPortListButton.enabled = False
    portsFormLayout.addRow(self.addPortListButton)

    #
    # Port table
    #
    self.portsTable = qt.QTableView()
    self.portsTableModel = qt.QStandardItemModel()
    self.portsTable.setModel(self.portsTableModel)
    portsFormLayout.addRow(self.portsTable)

    #
    # Remove Port button
    #
    self.removePortButton = qt.QPushButton("Remove Selected Port")
    self.removePortButton.enabled = False
    portsFormLayout.addRow(self.removePortButton)

    #
    # Target area
    #
    targetCollapsibleButton = ctk.ctkCollapsibleButton()
    targetCollapsibleButton.text = "Surgical Target"
    self.layout.addWidget(targetCollapsibleButton)
    targetFormLayout = qt.QFormLayout(targetCollapsibleButton)

    #
    # target selector
    #
    self.targetSelector = slicer.qMRMLNodeComboBox()
    self.targetSelector.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
    self.targetSelector.addEnabled = False
    self.targetSelector.removeEnabled = False
    self.targetSelector.noneEnabled = True
    self.targetSelector.setMRMLScene(slicer.mrmlScene)
    self.targetSelector.setToolTip("Pick the surgical target that the tools should face.")
    targetFormLayout.addRow("Surgical Target Fiducial", self.targetSelector)

    #
    # Retarget button
    #
    self.retargetButton = qt.QPushButton("Aim Tools at Target")
    self.retargetButton.toolTip = "Reset tool orientations to face target fiducial"
    self.retargetButton.enabled = False
    targetFormLayout.addRow(self.retargetButton)

    #
    # Port Tool Display Options
    #
    toolsCollapsibleButton = ctk.ctkCollapsibleButton()
    toolsCollapsibleButton.text = "Port Tool Display Options"
    self.layout.addWidget(toolsCollapsibleButton)
    toolsFormLayout = qt.QFormLayout(toolsCollapsibleButton)

    #
    # Transform sliders
    #
    self.transformSliders = slicer.qMRMLTransformSliders()
    self.transformSliders.TypeOfTransform = slicer.qMRMLTransformSliders.ROTATION
    self.transformSliders.CoordinateReference = slicer.qMRMLTransformSliders.LOCAL
    self.transformSliders.Title = 'Tool Orientation'
    self.transformSliders.minMaxVisible = False
    toolsFormLayout.addRow(self.transformSliders)

    #
    # radius spin box
    #
    self.radiusSpinBox = qt.QDoubleSpinBox()
    self.radiusSpinBox.setMinimum(0.0)
    self.radiusSpinBox.setMaximum(10.0)
    self.radiusSpinBox.setValue(2.0)
    toolsFormLayout.addRow("Tool radius", self.radiusSpinBox)

    #
    # length spin box
    #
    self.lengthSpinBox = qt.QDoubleSpinBox()
    self.lengthSpinBox.setMinimum(0.0)
    self.lengthSpinBox.setMaximum(250.0)
    self.lengthSpinBox.setValue(150.0)
    toolsFormLayout.addRow("Tool length", self.lengthSpinBox)

    # connections
    self.portListSelector.connect('currentNodeChanged(bool)', self.onPortListSelectorChanged)
    self.targetSelector.connect('currentNodeChanged(bool)', self.onTargetSelectorChanged)
    self.addPortListButton.connect('clicked(bool)', self.onAddPortListButton)
    self.removePortButton.connect('clicked(bool)', self.onRemovePortButton)
    self.retargetButton.connect('clicked(bool)', self.onRetargetButton)
    self.radiusSpinBox.connect('valueChanged(double)', self.onToolShapeChanged)
    self.lengthSpinBox.connect('valueChanged(double)', self.onToolShapeChanged)

    # Add vertical spacer
    self.layout.addStretch(1)

    # Add observer to scene for removal of fiducial nodes
    self.sceneObserverTag = slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeRemovedEvent,
                                                         self.onNodeRemoved)

    # instantiate port placement module logic
    self.logic = PortPlacementLogic()

    self.currentMarkupsNode = None
    self.onMarkupAddedTag = None
Пример #9
0
    def setup(self):

        #
        # Reload and Test area
        #
        #reloadCollapsibleButton = ctk.ctkCollapsibleButton()
        #reloadCollapsibleButton.text = "Reload && Test"
        #self.layout.addWidget(reloadCollapsibleButton)
        #self.layout.setSpacing(6)
        #reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        #self.reloadButton = qt.QPushButton("Reload")
        #self.reloadButton.toolTip = "Reload this module."
        #self.reloadButton.name = "InteractiveLobeSegmentation Reload"
        #reloadFormLayout.addWidget(self.reloadButton)
        #self.reloadButton.connect('clicked()', self.onReload)

        # reload and test button
        # (use this during development, but remove it when delivering
        #  your module to users)
        #self.reloadAndTestButton = qt.QPushButton("Reload and Test")
        #self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
        #reloadFormLayout.addWidget(self.reloadAndTestButton)
        #self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

        #
        # the inps volume selector
        #
        self.inspSelectorFrame = qt.QFrame(self.parent)
        self.inspSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.inspSelectorFrame)

        self.inspSelectorLabel = qt.QLabel("Inspiratory CT: ",
                                           self.inspSelectorFrame)
        self.inspSelectorLabel.setToolTip(
            "Select the Inspiratory CT for parenchymal analysis")
        self.inspSelectorFrame.layout().addWidget(self.inspSelectorLabel)

        self.inspSelector = slicer.qMRMLNodeComboBox(self.inspSelectorFrame)
        self.inspSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inspSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                       0)
        self.inspSelector.selectNodeUponCreation = False
        self.inspSelector.addEnabled = False
        self.inspSelector.removeEnabled = False
        self.inspSelector.noneEnabled = True
        self.inspSelector.showHidden = False
        self.inspSelector.showChildNodeTypes = False
        self.inspSelector.setMRMLScene(slicer.mrmlScene)
        # TODO: need to add a QLabel
        # self.inspSelector.SetLabelText( "Master Volume:" )
        self.inspSelectorFrame.layout().addWidget(self.inspSelector)

        #
        # the exp volume selector
        #
        self.expSelectorFrame = qt.QFrame(self.parent)
        self.expSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.expSelectorFrame)

        self.expSelectorLabel = qt.QLabel("Expiratory CT: ",
                                          self.expSelectorFrame)
        self.expSelectorLabel.setToolTip(
            "Select the Expiratory CT for parenchymal analysis")
        self.expSelectorFrame.layout().addWidget(self.expSelectorLabel)

        self.expSelector = slicer.qMRMLNodeComboBox(self.expSelectorFrame)
        self.expSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.expSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", 0)
        self.expSelector.selectNodeUponCreation = False
        self.expSelector.addEnabled = False
        self.expSelector.removeEnabled = False
        self.expSelector.noneEnabled = True
        self.expSelector.showHidden = False
        self.expSelector.showChildNodeTypes = False
        self.expSelector.setMRMLScene(slicer.mrmlScene)
        # TODO: need to add a QLabel
        # self.inspSelector.SetLabelText( "Master Volume:" )
        self.expSelectorFrame.layout().addWidget(self.expSelector)

        #
        # the insp label volume selector
        #
        self.insplabelSelectorFrame = qt.QFrame()
        self.insplabelSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.insplabelSelectorFrame)

        self.insplabelSelectorLabel = qt.QLabel()
        self.insplabelSelectorLabel.setText("Inspiratory Label Map: ")
        self.insplabelSelectorFrame.layout().addWidget(
            self.insplabelSelectorLabel)

        self.insplabelSelector = slicer.qMRMLNodeComboBox()
        #self.insplabelSelector.nodeTypes = ( "vtkMRMLScalarVolumeNode", "" )
        #self.insplabelSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", "1" )
        self.insplabelSelector.nodeTypes = ("vtkMRMLLabelMapVolumeNode", "")

        # todo addAttribute
        self.insplabelSelector.selectNodeUponCreation = False
        self.insplabelSelector.addEnabled = False
        self.insplabelSelector.noneEnabled = True
        self.insplabelSelector.removeEnabled = False
        self.insplabelSelector.showHidden = False
        self.insplabelSelector.showChildNodeTypes = False
        self.insplabelSelector.setMRMLScene(slicer.mrmlScene)
        self.insplabelSelector.setToolTip("Inspiratory label map")
        self.insplabelSelectorFrame.layout().addWidget(self.insplabelSelector)

        #
        # the exp label volume selector
        #
        self.explabelSelectorFrame = qt.QFrame()
        self.explabelSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.explabelSelectorFrame)

        self.explabelSelectorLabel = qt.QLabel()
        self.explabelSelectorLabel.setText("Expiratory Label Map: ")
        self.explabelSelectorFrame.layout().addWidget(
            self.explabelSelectorLabel)

        self.explabelSelector = slicer.qMRMLNodeComboBox()
        #self.explabelSelector.nodeTypes = ( "vtkMRMLScalarVolumeNode", "" )
        #self.explabelSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", "1" )
        self.explabelSelector.nodeTypes = ("vtkMRMLLabelMapVolumeNode", "")

        # todo addAttribute
        self.explabelSelector.selectNodeUponCreation = False
        self.explabelSelector.addEnabled = False
        self.explabelSelector.noneEnabled = True
        self.explabelSelector.removeEnabled = False
        self.explabelSelector.showHidden = False
        self.explabelSelector.showChildNodeTypes = False
        self.explabelSelector.setMRMLScene(slicer.mrmlScene)
        self.explabelSelector.setToolTip("Expiratory label map")
        self.explabelSelectorFrame.layout().addWidget(self.explabelSelector)

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Calculate Parenchyma Phenotypes."
        self.applyButton.enabled = False
        self.parent.layout().addWidget(self.applyButton)

        # model and view for INSP stats table
        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        self.parent.layout().addWidget(self.view)

        # model and view for EXP stats table
        self.viewexp = qt.QTableView()
        self.viewexp.sortingEnabled = True
        self.parent.layout().addWidget(self.viewexp)

        # Chart button
        self.chartFrame = qt.QFrame()
        self.chartFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.chartFrame)
        self.chartButton = qt.QPushButton("Chart")
        self.chartButton.toolTip = "Make a chart from the current statistics."
        self.chartFrame.layout().addWidget(self.chartButton)
        self.chartOption = qt.QComboBox()
        self.chartOption.addItems(self.chartOptions)
        self.chartFrame.layout().addWidget(self.chartOption)
        self.chartIgnoreZero = qt.QCheckBox()
        self.chartIgnoreZero.setText('Ignore Zero')
        self.chartIgnoreZero.checked = False
        self.chartIgnoreZero.setToolTip(
            'Do not include the zero index in the chart to avoid dwarfing other bars'
        )
        #self.chartFrame.layout().addWidget(self.chartIgnoreZero)
        self.chartFrame.enabled = False

        # Save button
        self.saveButton = qt.QPushButton("Save")
        self.saveButton.toolTip = "Save Statistics as a csv file."
        self.saveButton.enabled = False
        self.parent.layout().addWidget(self.saveButton)

        # Add vertical spacer
        self.parent.layout().addStretch(1)

        # connections
        self.applyButton.connect('clicked()', self.onApply)
        self.chartButton.connect('clicked()', self.onChart)
        self.saveButton.connect('clicked()', self.onSave)
        self.inspSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                  self.onInspSelect)
        self.insplabelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                       self.onInspLabelSelect)
        self.expSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                 self.onExpSelect)
        self.explabelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                      self.onExpLabelSelect)
    def setup(self):

        #
        # Reload and Test area
        #
        reloadCollapsibleButton = ctk.ctkCollapsibleButton()
        reloadCollapsibleButton.text = "Reload && Test"
        self.layout.addWidget(reloadCollapsibleButton)
        reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "Radiomics Reload"
        reloadFormLayout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # reload and test button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadAndTestButton = qt.QPushButton("Reload and Test")
        self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
        reloadFormLayout.addWidget(self.reloadAndTestButton)
        # self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)
        reloadCollapsibleButton.collapsed = True
        #---------------------------------------------------------

        #
        # Compute Radiomics area
        #
        self.computeRadiomicsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.computeRadiomicsCollapsibleButton.text = "Slicer Radiomics Platform"
        self.layout.addWidget(self.computeRadiomicsCollapsibleButton)
        self.computeRadiomicsFormLayout = qt.QFormLayout(
            self.computeRadiomicsCollapsibleButton)

        #
        # Universal Advanced Settings Collapsible Button
        #

        self.AdvancedSettingsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.AdvancedSettingsCollapsibleButton.text = "Advanced Settings"
        self.AdvancedSettingsCollapsibleButtonLayout = qt.QHBoxLayout()
        self.AdvancedSettingsCollapsibleButton.setLayout(qt.QHBoxLayout())
        self.computeRadiomicsFormLayout.addWidget(
            self.AdvancedSettingsCollapsibleButton)
        self.AdvancedSettingsCollapsibleButton.collapsed = True

        self.AdvancedSettingsFrame = qt.QFrame(
            self.AdvancedSettingsCollapsibleButton)
        self.AdvancedSettingsFrameLayout = qt.QFormLayout()
        self.AdvancedSettingsFrame.setLayout(self.AdvancedSettingsFrameLayout)
        self.AdvancedSettingsCollapsibleButton.layout().addWidget(
            self.AdvancedSettingsFrame)

        # Label Values
        self.inputLabelValues = qt.QLabel("Label Values:",
                                          self.AdvancedSettingsFrame)
        self.inputLabelValuesField = qt.QLineEdit("1",
                                                  self.AdvancedSettingsFrame)
        self.AdvancedSettingsFrameLayout.addRow(self.inputLabelValues,
                                                self.inputLabelValuesField)

        # Interpolation Settings
        self.settingsRadioButtonFrame = qt.QFrame(self.AdvancedSettingsFrame)
        self.settingsRadioButtonFrame.setLayout(qt.QHBoxLayout())
        self.interpolationsGroup = qt.QButtonGroup(
            self.settingsRadioButtonFrame)
        self.ipRawButton = qt.QRadioButton("Raw")
        self.ip1x1x1Button = qt.QRadioButton("(1,1,1)")
        self.ip2x2x2Button = qt.QRadioButton("(2,2,2)")
        self.ip3x3x3Button = qt.QRadioButton("(3,3,3)")
        self.ipRawButton.checked = True
        self.interpolationsGroup.addButton(self.ipRawButton)
        self.interpolationsGroup.addButton(self.ip1x1x1Button)
        self.interpolationsGroup.addButton(self.ip2x2x2Button)
        self.interpolationsGroup.addButton(self.ip3x3x3Button)
        self.settingsRadioButtonFrame.layout().addWidget(self.ipRawButton)
        self.settingsRadioButtonFrame.layout().addWidget(self.ip1x1x1Button)
        self.settingsRadioButtonFrame.layout().addWidget(self.ip2x2x2Button)
        self.settingsRadioButtonFrame.layout().addWidget(self.ip3x3x3Button)
        self.interpHeader = qt.QLabel("Interpolation:")
        self.AdvancedSettingsFrameLayout.addRow(self.interpHeader,
                                                self.settingsRadioButtonFrame)

        # Bin Width
        self.inputBinWidth = qt.QLabel("Bin Width:",
                                       self.AdvancedSettingsFrame)
        self.inputBinWidthField = qt.QLineEdit("25",
                                               self.AdvancedSettingsFrame)
        self.AdvancedSettingsFrameLayout.addRow(self.inputBinWidth,
                                                self.inputBinWidthField)

        # Modality Radio Buttons Frame
        self.ModalityRadioButtonFrame = qt.QFrame(self.AdvancedSettingsFrame)
        self.ModalityRadioButtonFrame.setLayout(qt.QHBoxLayout())
        self.ModalityFileFormatGroup = qt.QButtonGroup(
            self.ModalityRadioButtonFrame)
        self.CTButton = qt.QRadioButton("CT")
        self.CTButton.checked = True
        self.MRIButton = qt.QRadioButton("MRI")
        self.PETButton = qt.QRadioButton("PET")
        self.ModalityFileFormatGroup.addButton(self.CTButton)
        self.ModalityFileFormatGroup.addButton(self.MRIButton)
        self.ModalityFileFormatGroup.addButton(self.PETButton)
        self.ModalityRadioButtonFrame.layout().addWidget(self.CTButton)
        self.ModalityRadioButtonFrame.layout().addWidget(self.MRIButton)
        self.ModalityRadioButtonFrame.layout().addWidget(self.PETButton)
        self.ModalityInputLabel = qt.QLabel("Image Modality:",
                                            self.AdvancedSettingsFrame)
        self.AdvancedSettingsFrameLayout.addRow(self.ModalityInputLabel,
                                                self.ModalityRadioButtonFrame)
        #
        # End Universal Advanced Settings Collapsible Button
        #

        # Parent Tab Widget
        self.computeRadiomicsTabWidget = qt.QTabWidget()
        self.computeRadiomicsFormLayout.addWidget(
            self.computeRadiomicsTabWidget)

        #  Radiomics Current Mode
        self.tabComputeRadiomicsCurr = qt.QWidget()
        self.singleCaseInputFormLayout = qt.QFormLayout()
        self.tabComputeRadiomicsCurr.setLayout(self.singleCaseInputFormLayout)
        self.tabComputeRadiomicsCurrName = "Single Case Mode"
        self.computeRadiomicsTabWidget.addTab(self.tabComputeRadiomicsCurr,
                                              self.tabComputeRadiomicsCurrName)

        # Input 1: Input Image
        self.input1Frame = qt.QFrame(self.tabComputeRadiomicsCurr)
        self.input1Frame.setLayout(qt.QHBoxLayout())
        self.singleCaseInputFormLayout.addWidget(self.input1Frame)
        self.input1Selector = qt.QLabel("Input Image: ", self.input1Frame)
        self.input1Frame.layout().addWidget(self.input1Selector)
        self.input1Selector = slicer.qMRMLNodeComboBox(self.input1Frame)
        self.input1Selector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.input1Selector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                         0)
        self.input1Selector.addEnabled = False
        self.input1Selector.removeEnabled = False
        self.input1Selector.setMRMLScene(slicer.mrmlScene)
        self.input1Frame.layout().addWidget(self.input1Selector)

        # Input 2: Input Segmentation
        self.input2Frame = qt.QFrame(self.tabComputeRadiomicsCurr)
        self.input2Frame.setLayout(qt.QHBoxLayout())
        self.singleCaseInputFormLayout.addWidget(self.input2Frame)
        self.input2Selector = qt.QLabel("Input Label:  ", self.input2Frame)
        self.input2Frame.layout().addWidget(self.input2Selector)
        self.input2Selector = slicer.qMRMLNodeComboBox(self.input2Frame)
        self.input2Selector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.input2Selector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                         1)
        self.input2Selector.addEnabled = False
        self.input2Selector.removeEnabled = False
        self.input2Selector.setMRMLScene(slicer.mrmlScene)
        self.input2Frame.layout().addWidget(self.input2Selector)

        # Settings Collapsible Button
        self.SettingsCollapsibleButtonCurr = ctk.ctkCollapsibleButton()
        self.SettingsCollapsibleButtonCurr.text = "Settings"
        self.SettingsCollapsibleButtonCurrLayout = qt.QHBoxLayout()
        self.SettingsCollapsibleButtonCurr.setLayout(
            self.SettingsCollapsibleButtonCurrLayout)
        self.singleCaseInputFormLayout.addWidget(
            self.SettingsCollapsibleButtonCurr)
        self.SettingsCollapsibleButtonCurr.collapsed = False
        self.SettingsFrameCurr = qt.QFrame(self.SettingsCollapsibleButtonCurr)
        self.SettingsFrameCurr.setLayout(qt.QFormLayout())
        self.SettingsCollapsibleButtonCurrLayout.addWidget(
            self.SettingsFrameCurr)

        # Settings
        self.para2curr = qt.QCheckBox("Use MatlabBridge",
                                      self.tabComputeRadiomicsCurr)
        self.para2curr.toolTip = "When checked: Matlab features extracted"
        self.para2curr.checked = False
        self.SettingsFrameCurr.layout().addRow(self.para2curr)

        # Apply Radiomics button
        self.RadiomicCurrButtonsFrame = qt.QFrame(self.tabComputeRadiomicsCurr)
        self.RadiomicCurrButtonsFrame.setLayout(qt.QHBoxLayout())
        self.singleCaseInputFormLayout.addWidget(self.RadiomicCurrButtonsFrame)

        self.radiomicsCurrButton = qt.QPushButton(
            "Compute Radiomics Features (Single Case)",
            self.RadiomicCurrButtonsFrame)
        self.radiomicsCurrButton.enabled = True
        self.radiomicsCurrButton.toolTip = "Run the feature extraction for a single case."
        self.RadiomicCurrButtonsFrame.layout().addWidget(
            self.radiomicsCurrButton)

        # Chart
        self.RadiomicsTableFrame = qt.QFrame(self.tabComputeRadiomicsCurr)
        self.RadiomicsTableFrameLayout = qt.QHBoxLayout()
        self.RadiomicsTableFrame.setLayout(self.RadiomicsTableFrameLayout)
        self.singleCaseInputFormLayout.addWidget(self.RadiomicsTableFrame)

        self.RadiomicsTableView = qt.QTableView(self.RadiomicsTableFrame)
        self.RadiomicsTableView.sortingEnabled = True
        self.RadiomicsTableView.minimumHeight = 175
        self.RadiomicsTableView.verticalHeader().visible = False
        self.RadiomicsTableView.setColumnWidth(0, 30)
        self.RadiomicsTableFrameLayout.addWidget(self.RadiomicsTableView)
        self.RadiomicsTableModel = qt.QStandardItemModel()

        # Save Table Button
        self.saveButton = qt.QPushButton("Save Table to CSV File",
                                         self.RadiomicCurrButtonsFrame)
        self.saveButton.toolTip = "Save Radiomics Feature from table to CSV file"
        self.saveButton.enabled = False
        self.singleCaseInputFormLayout.layout().addWidget(self.saveButton)
        """
    #
    # The interface we use for batch mode (not part of this module)
    #
    
    #---------------------------------------------------------
    # Radiomics Batch
    self.tabComputeRadiomicsBatch = qt.QWidget()
    self.RadiomicsFormLayout = qt.QFormLayout()
    self.tabComputeRadiomicsBatch.setLayout(self.RadiomicsFormLayout)
    self.tabComputeRadiomicsBatchName = "Batch Mode"
    self.computeRadiomicsTabWidget.addTab(self.tabComputeRadiomicsBatch, self.tabComputeRadiomicsBatchName)
    
    # Input 3: Database selection
    self.input3Frame = qt.QFrame(self.tabComputeRadiomicsBatch)
    self.input3Frame.setLayout(qt.QHBoxLayout())
    self.RadiomicsFormLayout.addWidget(self.input3Frame)
    self.DatabaseButton = qt.QPushButton("Set Root Patient Directory")
    self.DatabaseButton.toolTip = "Set the main Patient Data location"
    self.DatabaseButton.enabled = True
    self.input3Frame.layout().addWidget(self.DatabaseButton)
    self.PatientSelector = qt.QComboBox()
    self.PatientSelector.enabled = False
    self.input3Frame.layout().addWidget(self.PatientSelector)
    
    # Settings Collapsible Button
    self.SettingsCollapsibleButton = ctk.ctkCollapsibleButton()
    self.SettingsCollapsibleButton.text = "Settings"
    self.SettingsCollapsibleButtonLayout = qt.QHBoxLayout()
    self.SettingsCollapsibleButton.setLayout(self.SettingsCollapsibleButtonLayout)    
    self.RadiomicsFormLayout.addWidget(self.SettingsCollapsibleButton)
    self.SettingsCollapsibleButton.collapsed = False
    self.SettingsFrame = qt.QFrame(self.SettingsCollapsibleButton)
    self.SettingsFrame.setLayout(qt.QFormLayout())
    self.SettingsCollapsibleButtonLayout.addWidget(self.SettingsFrame)
    
    # Settings 
    self.para2 = qt.QCheckBox("Use MatlabBridge", self.SettingsFrame)
    self.para2.toolTip = "When checked: Matlab features extracted"
    self.para2.checked = True
    self.SettingsFrame.layout().addRow(self.para2)

    self.para3 = qt.QCheckBox("Clear Database", self.SettingsFrame)
    self.para3.toolTip = "When checked: old database is cleared"
    self.para3.checked = True
    self.SettingsFrame.layout().addRow(self.para3)

    # Keywords Collapsible Button
    self.KeywordsCollapsibleButton = ctk.ctkCollapsibleButton()
    self.KeywordsCollapsibleButton.text = "Keyword Matching"
    self.KeywordsCollapsibleButtonLayout = qt.QHBoxLayout()
    self.KeywordsCollapsibleButton.setLayout(self.KeywordsCollapsibleButtonLayout)    
    self.SettingsFrame.layout().addRow(self.KeywordsCollapsibleButton)
    self.KeywordsCollapsibleButton.collapsed = True
    
    self.keywordsFrame = qt.QFrame(self.KeywordsCollapsibleButton)
    self.keywordsFrame.setLayout(qt.QFormLayout())
    self.KeywordsCollapsibleButtonLayout.addWidget(self.keywordsFrame)
    self.keywordsHeader = qt.QLabel("Keyword Matching:", self.keywordsFrame)
    self.keywordsFrame.layout().addRow(self.keywordsHeader)
    
    # File Type Radio Buttons Frame
    self.radioButtonFrame = qt.QFrame(self.keywordsFrame)
    self.radioButtonFrame.setLayout(qt.QFormLayout())
    self.fileFormatGroup = qt.QButtonGroup(self.radioButtonFrame)
    self.nrrdButton = qt.QRadioButton("NRRD")
    self.nrrdButton.checked = True
    self.niftiButton = qt.QRadioButton("NIFTI")
    self.fileFormatGroup.addButton(self.nrrdButton)
    self.fileFormatGroup.addButton(self.niftiButton)
    self.radioButtonFrame.layout().addRow(self.nrrdButton, self.niftiButton)
    self.inputMaskHeader = qt.QLabel("Input Image File Type:", self.keywordsFrame)
    self.keywordsFrame.layout().addRow(self.inputMaskHeader, self.radioButtonFrame)
    
    # Keywords Frame
    self.inputImageKeywords = qt.QLabel("Input Image Keywords:", self.keywordsFrame)
    self.inputImageKeywordsField = qt.QLineEdit("",self.keywordsFrame)
    self.keywordsFrame.layout().addRow(self.inputImageKeywords, self.inputImageKeywordsField )
    
    self.inputImageExclusionKeywords = qt.QLabel("Input Image Exclusion Keywords:", self.keywordsFrame)
    self.inputImageExclusionKeywordsField = qt.QLineEdit("",self.keywordsFrame)
    self.keywordsFrame.layout().addRow(self.inputImageExclusionKeywords, self.inputImageExclusionKeywordsField )
    
    self.inputLabelKeywords = qt.QLabel("Input Label Keywords:", self.keywordsFrame)
    self.inputLabelKeywordsField = qt.QLineEdit("",self.keywordsFrame)
    self.keywordsFrame.layout().addRow(self.inputLabelKeywords, self.inputLabelKeywordsField )
    
    self.inputLabelExclusionKeywords = qt.QLabel("Input Label Exclusion Keywords:", self.keywordsFrame)
    self.inputLabelExclusionKeywordsField = qt.QLineEdit("",self.keywordsFrame)
    self.keywordsFrame.layout().addRow(self.inputLabelExclusionKeywords, self.inputLabelExclusionKeywordsField )
    
    # Radiomic Mode Buttons
    self.RadiomicButtonsFrame = qt.QFrame(self.tabComputeRadiomicsBatch)
    self.RadiomicButtonsFrame.setLayout(qt.QHBoxLayout())
    self.RadiomicsFormLayout.addWidget(self.RadiomicButtonsFrame)
    self.radiomicsBatchButton = qt.QPushButton("Compute Radiomics Features (Batch Mode)")
    self.radiomicsBatchButton.toolTip = "Run the feature extraction for database batch."
    self.radiomicsBatchButton.enabled = True
    self.RadiomicButtonsFrame.layout().addWidget(self.radiomicsBatchButton)
    self.RadiomicButtonsFrame.enabled = True
    """

        #---------------------------------------------------------
        # Connections
        #self.DatabaseButton.connect('clicked(bool)', self.onDatabaseButton)
        self.radiomicsCurrButton.connect('clicked(bool)', self.onRadiomicsCurr)
        #self.radiomicsBatchButton.connect('clicked(bool)', self.onRadiomicsBatch)
        self.saveButton.connect('clicked()', self.onSave)

        self.layout.addStretch(1)  # Add vertical spacer
Пример #11
0
    def setup(self):
        #Instantiate and Connect Widgets
        #################################################
        #HeterogeneityCAD Inputs Collapsible Button

        self.inputHeterogeneityCADCollapsibleButton = ctk.ctkCollapsibleButton(
        )
        self.inputHeterogeneityCADCollapsibleButton.text = "HeterogeneityCAD Input"
        self.layout.addWidget(self.inputHeterogeneityCADCollapsibleButton)
        self.inputHeterogeneityCADLayout = qt.QFormLayout(
            self.inputHeterogeneityCADCollapsibleButton)

        ##Input Volume as a PET/CT/MRI image or parameter map converted to a volume
        self.inputVolHetFrame = qt.QFrame(
            self.inputHeterogeneityCADCollapsibleButton)
        self.inputVolHetFrame.setLayout(qt.QHBoxLayout())
        self.inputHeterogeneityCADLayout.addRow(self.inputVolHetFrame)
        # label for selecting individual node
        self.inputVolHet = qt.QLabel("Input Node: ", self.inputVolHetFrame)
        self.inputVolHetFrame.layout().addWidget(self.inputVolHet)
        # select individual nodes
        self.inputSelectorVolHet = slicer.qMRMLNodeComboBox(
            self.inputVolHetFrame)
        self.inputSelectorVolHet.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelectorVolHet.selectNodeUponCreation = False
        self.inputSelectorVolHet.addEnabled = False
        self.inputSelectorVolHet.removeEnabled = False
        self.inputSelectorVolHet.setMRMLScene(slicer.mrmlScene)
        self.inputVolHetFrame.layout().addWidget(self.inputSelectorVolHet)
        # add Data Node button
        self.addDataNodeButton = qt.QPushButton("Add Node",
                                                self.inputVolHetFrame)
        self.addDataNodeButton.objectName = 'AddDataNodeButton'
        self.addDataNodeButton.setToolTip("Add a Node to Queue")
        self.addDataNodeButton.connect('clicked()',
                                       self.onAddDataNodeButtonClicked)
        self.inputVolHetFrame.layout().addWidget(self.addDataNodeButton)

        ## data nodes Frame
        self.dataNodesFrame = ctk.ctkCollapsibleGroupBox(
            self.inputHeterogeneityCADCollapsibleButton)
        self.dataNodesFrame.title = "Nodes List"
        self.dataNodesFrame.collapsed = False
        self.dataNodesFrame.setLayout(qt.QVBoxLayout())
        # all buttons frame
        self.allButtonsFrame = qt.QFrame(
            self.inputHeterogeneityCADCollapsibleButton)
        self.allButtonsFrame.objectName = 'AllButtonsFrameButton'
        self.allButtonsFrame.setLayout(qt.QVBoxLayout())
        self.inputHeterogeneityCADLayout.addRow(self.dataNodesFrame,
                                                self.allButtonsFrame)
        # Data Nodes view
        # Use list view here with scroll area widget.
        self.dataScrollArea = qt.QScrollArea()
        self.dataNodesListWidget = qt.QListWidget()
        self.dataNodesListWidget.name = 'dataNodesListWidget'
        self.dataScrollArea.setWidget(self.dataNodesListWidget)
        self.dataNodesListWidget.resize(350, 100)
        self.dataNodesFrame.layout().addWidget(self.dataScrollArea)
        #self.listWidget.setProperty('SH_ItemView_ActivateItemOnSingleClick', 1)
        #self.listWidget.connect('activated(QModelIndex)', self.onActivated)
        # add all Data Nodes from scene button
        self.addAllDataNodesButton = qt.QPushButton("Add All Nodes From Scene",
                                                    self.allButtonsFrame)
        self.addAllDataNodesButton.objectName = 'AddAllDataNodesButton'
        self.addAllDataNodesButton.setToolTip(
            "Add all Nodes from the Scene to Queue")
        self.addAllDataNodesButton.connect('clicked()',
                                           self.onAddAllDataNodesButtonClicked)
        self.allButtonsFrame.layout().addWidget(self.addAllDataNodesButton)
        # remove single Data Node
        self.removeDataNodeButton = qt.QPushButton("Remove Node",
                                                   self.allButtonsFrame)
        self.removeDataNodeButton.objectName = 'RemoveDataNodeButton'
        self.removeDataNodeButton.setToolTip(
            "Removes Selected Node from the Queue.")
        self.removeDataNodeButton.connect('clicked()',
                                          self.onRemoveDataNodeButtonClicked)
        self.allButtonsFrame.layout().addWidget(self.removeDataNodeButton)
        # remove all Data Nodes button
        self.removeAllDataNodesButton = qt.QPushButton("Remove All Nodes",
                                                       self.allButtonsFrame)
        self.removeAllDataNodesButton.objectName = 'RemoveAllDataNodesButton'
        self.removeAllDataNodesButton.setToolTip(
            "Removes All Nodes from the Queue.")
        self.removeAllDataNodesButton.connect(
            'clicked()', self.onRemoveAllDataNodesButtonClicked)
        self.allButtonsFrame.layout().addWidget(self.removeAllDataNodesButton)

        # Use Label Map as ROI(segmentation output or user-selected ROI)
        self.inputLabelROIFrame = qt.QFrame(
            self.inputHeterogeneityCADCollapsibleButton)
        self.inputLabelROIFrame.setLayout(qt.QHBoxLayout())
        self.inputHeterogeneityCADLayout.addRow(self.inputLabelROIFrame)
        # Enable Input Label Map as ROI
        self.inputLabelROI = qt.QLabel("Label Map ROI: ",
                                       self.inputLabelROIFrame)
        self.inputLabelROIFrame.layout().addWidget(self.inputLabelROI)
        # Select Input Label Map as ROI
        self.inputSelectorLabel = slicer.qMRMLNodeComboBox(
            self.inputLabelROIFrame)
        self.inputSelectorLabel.nodeTypes = (("vtkMRMLLabelMapVolumeNode"), "")
        self.inputSelectorLabel.selectNodeUponCreation = False
        self.inputSelectorLabel.renameEnabled = True
        self.inputSelectorLabel.removeEnabled = False
        self.inputSelectorLabel.noneEnabled = True
        self.inputSelectorLabel.addEnabled = False
        self.inputSelectorLabel.setMRMLScene(slicer.mrmlScene)
        self.inputLabelROIFrame.layout().addWidget(self.inputSelectorLabel)

        #End HeterogeneityCAD Inputs Collapsible Button
        #################################################
        #HeterogeneityCAD Features Collapsible Button

        self.HeterogeneityCADCollapsibleButton = ctk.ctkCollapsibleButton()
        self.HeterogeneityCADCollapsibleButton.text = "HeterogeneityCAD Features Selection"
        self.layout.addWidget(self.HeterogeneityCADCollapsibleButton)
        self.featuresHeterogeneityCADLayout = qt.QFormLayout(
            self.HeterogeneityCADCollapsibleButton)

        # auto-generate QTabWidget Tabs and QCheckBoxes (subclassed in FeatureWidgetHelperLib)
        self.tabsFeatureClasses = FeatureWidgetHelperLib.CheckableTabWidget()
        self.featuresHeterogeneityCADLayout.addRow(self.tabsFeatureClasses)

        gridWidth, gridHeight = 3, 9
        for featureClass in self.featureClassKeys:
            # by default, features from the following features classes are checked:
            if featureClass in [
                    "Node Information", "First-Order Statistics",
                    "Morphology and Shape", "Texture: GLCM", "Texture: GLRL"
            ]:
                check = True
            else:
                check = False
            tabFeatureClass = qt.QWidget()
            tabFeatureClass.setLayout(qt.QGridLayout())
            #featureList = (feature for feature in self.featureClassKeys[featureClass])
            gridLayoutCoordinates = ((row, col) for col in range(gridWidth)
                                     for row in range(gridHeight))
            for featureName in self.featureClassKeys[featureClass]:
                row, col = next(gridLayoutCoordinates, None)
                if featureName is None or row is None or col is None:
                    break
                featureCheckboxWidget = FeatureWidgetHelperLib.FeatureWidget()
                featureCheckboxWidget.Setup(featureName=featureName,
                                            checkStatus=check)

                tabFeatureClass.layout().addWidget(featureCheckboxWidget, row,
                                                   col)
                self.featureWidgets[featureClass].append(featureCheckboxWidget)
            self.tabsFeatureClasses.addTab(tabFeatureClass,
                                           featureClass,
                                           self.featureWidgets[featureClass],
                                           checkStatus=check)

        self.tabsFeatureClasses.setCurrentIndex(1)

        # note: try using itertools list merging with lists of GLRL diagonal
        self.heterogeneityFeatureWidgets = list(
            itertools.chain.from_iterable(self.featureWidgets.values()))
        self.classes = list(self.featureWidgets.keys())
        # or reduce(lambda x,y: x+y, self.featureWidgets.values())

        ########## Parameter options
        # add parameters for top-level feature classes
        self.tabsFeatureClasses.addParameter("Geometrical Measures",
                                             "Extrusion Parameter 1")
        self.tabsFeatureClasses.addParameter("Texture: GLCM",
                                             "GLCM Matrix Parameter 1")
        self.tabsFeatureClasses.addParameter("Texture: GLRL",
                                             "GLRL Matrix Parameter 1")

        # compile dict of feature classes with parameter names and values
        self.featureClassParametersDict = collections.OrderedDict()
        for featureClassWidget in self.tabsFeatureClasses.getFeatureClassWidgets(
        ):
            featureClassName = featureClassWidget.getName()
            self.featureClassParametersDict[
                featureClassName] = collections.OrderedDict()
            self.updateFeatureClassParameterDict(0, featureClassWidget)
            for parameterName in featureClassWidget.widgetMenu.parameters:
                featureClassWidget.getParameterEditWindow(
                    parameterName).connect(
                        'intValueChanged(int)',
                        lambda intValue, featureClassWidget=featureClassWidget:
                        self.updateFeatureClassParameterDict(
                            intValue, featureClassWidget))

        # add parameters for individual features
        for featureWidget in self.heterogeneityFeatureWidgets:
            if featureWidget.getName() == "Voxel Count":
                featureWidget.addParameter("Example Parameter 1")
                featureWidget.addParameter("Example Parameter 2")
            if featureWidget.getName() == "Gray Levels":
                featureWidget.addParameter("Example Parameter 1-GL")
                featureWidget.addParameter("Example Parameter 2-GL")

        # compile dict of features with parameter names and values
        self.featureParametersDict = collections.OrderedDict()
        for featureWidget in self.heterogeneityFeatureWidgets:
            featureName = featureWidget.getName()
            self.featureParametersDict[featureName] = collections.OrderedDict()
            self.updateFeatureParameterDict(0, featureWidget)
            for parameterName in featureWidget.widgetMenu.parameters:
                featureWidget.getParameterEditWindow(parameterName).connect(
                    'intValueChanged(int)',
                    lambda intValue, featureWidget=featureWidget: self.
                    updateFeatureParameterDict(intValue, featureWidget)
                )  #connect intvaluechanged signals to updateParamaterDict function
        ##########

        # Feature Buttons Frame and Layout
        self.featureButtonFrame = qt.QFrame(
            self.HeterogeneityCADCollapsibleButton)
        self.featureButtonFrame.setLayout(qt.QHBoxLayout())
        self.featuresHeterogeneityCADLayout.addRow(self.featureButtonFrame)

        # HeterogeneityCAD Apply Button
        self.HeterogeneityCADButton = qt.QPushButton("Apply HeterogeneityCAD",
                                                     self.featureButtonFrame)
        self.HeterogeneityCADButton.toolTip = "Analyze input volume using selected Heterogeneity Features."
        self.featureButtonFrame.layout().addWidget(self.HeterogeneityCADButton)
        self.HeterogeneityCADButton.connect(
            'clicked()', self.onHeterogeneityCADButtonClicked)

        # Save Button
        self.saveButton = qt.QPushButton("Save to File",
                                         self.featureButtonFrame)
        self.saveButton.toolTip = "Save analyses to CSV file"
        self.saveButton.enabled = False
        self.featureButtonFrame.layout().addWidget(self.saveButton)
        self.saveButton.connect('clicked()', self.onSave)

        #End HeterogeneityCAD Features Collapsible Button
        #################################################
        #Feature Summary Chart

        #Complete chart options, export list of user-selected options identified via connections to labelstatistics module
        self.chartOptions = ("Count", "Volume mm^3", "Volume cc", "Min", "Max",
                             "Mean", "StdDev")
        self.StatisticsChartCollapsibleButton = ctk.ctkCollapsibleButton()
        self.StatisticsChartCollapsibleButton.text = "HeterogeneityCAD Features Summary"
        self.layout.addWidget(self.StatisticsChartCollapsibleButton)
        self.StatisticsChartLayout = qt.QFormLayout(
            self.StatisticsChartCollapsibleButton)
        self.StatisticsChartCollapsibleButton.collapsed = False

        #Table View to display Label statistics
        self.view = qt.QTableView(self.StatisticsChartCollapsibleButton)
        self.view.sortingEnabled = True
        self.StatisticsChartLayout.addWidget(self.view)
        self.view.minimumHeight = 175
Пример #12
0
    def setup(self):
        # reload button
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "HeterogeneityCAD Reload"
        self.layout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # Tumor Segmentation Collapsible Button
        self.TumorSegmentationCollapsibleButton = ctk.ctkCollapsibleButton()
        self.TumorSegmentationCollapsibleButton.text = "SegmentCAD Segmentation"
        self.layout.addWidget(self.TumorSegmentationCollapsibleButton)
        self.TumorSegmentationLayout = qt.QFormLayout(
            self.TumorSegmentationCollapsibleButton)

        # Select Volumes Collapsible Button
        self.selectionsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.selectionsCollapsibleButton.text = "Select DCE-MRI Volumes for Segmentation"
        self.TumorSegmentationLayout.addWidget(
            self.selectionsCollapsibleButton)
        # Layout within the collapsible button
        self.volumesLayout = qt.QFormLayout(self.selectionsCollapsibleButton)

        # Use Multivolume Node as input
        self.enableMultiVolume = qt.QCheckBox(self.selectionsCollapsibleButton)
        self.enableMultiVolume.setText('Input Multi-Volume Node')
        self.enableMultiVolume.checked = True
        self.enableMultiVolume.setToolTip(
            'Use Multi-Volume Node, with volumes imported in the correct order'
        )
        self.inputSelectorMultiVolume = slicer.qMRMLNodeComboBox(
            self.selectionsCollapsibleButton)
        self.inputSelectorMultiVolume.nodeTypes = (("vtkMRMLMultiVolumeNode"),
                                                   "")
        self.inputSelectorMultiVolume.selectNodeUponCreation = False
        self.inputSelectorMultiVolume.renameEnabled = True
        self.inputSelectorMultiVolume.removeEnabled = False
        self.inputSelectorMultiVolume.noneEnabled = True
        self.inputSelectorMultiVolume.addEnabled = False
        self.inputSelectorMultiVolume.setMRMLScene(slicer.mrmlScene)
        self.inputSelectorMultiVolume.setToolTip(
            'Use Multi-Volume Node, with volumes imported in the correct order'
        )

        self.volumesLayout.addRow(self.enableMultiVolume,
                                  self.inputSelectorMultiVolume)

        self.nodeInputFrame = ctk.ctkCollapsibleGroupBox(
            self.selectionsCollapsibleButton)
        self.nodeInputFrame.title = "Input Scalar Volume Nodes"
        self.nodeInputFrame.collapsed = True
        self.nodeInputFrame.enabled = False
        self.nodeInputFrame.setLayout(qt.QFormLayout())
        self.volumesLayout.addRow(self.nodeInputFrame)

        # Select Pre Node
        self.inputPre = qt.QLabel("Pre-contrast Volume", self.nodeInputFrame)
        self.inputPre.setToolTip(
            'Select the initial pre-contrast volume node.')
        self.inputSelectorPre = slicer.qMRMLNodeComboBox(self.nodeInputFrame)
        self.inputSelectorPre.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelectorPre.selectNodeUponCreation = False
        self.inputSelectorPre.addEnabled = False
        self.inputSelectorPre.removeEnabled = False
        self.inputSelectorPre.noneEnabled = True
        self.inputSelectorPre.noneDisplay = 'Please Select Volume'
        self.inputSelectorPre.setMRMLScene(slicer.mrmlScene)
        self.inputSelectorPre.setToolTip(
            'Select the initial pre-contrast volume node.')
        #self.volumesLayout.addRow(self.inputPre, self.inputSelectorPre)
        self.nodeInputFrame.layout().addRow(self.inputPre,
                                            self.inputSelectorPre)

        # Select First Node
        self.inputFirst = qt.QLabel("First Post-contrast Volume",
                                    self.nodeInputFrame)
        self.inputFirst.setToolTip(
            'Select the first post-contrast volume node to calculate intitial enhancement and curve type.'
        )
        self.inputSelectorFirst = slicer.qMRMLNodeComboBox(self.nodeInputFrame)
        self.inputSelectorFirst.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelectorFirst.selectNodeUponCreation = False
        self.inputSelectorFirst.addEnabled = False
        self.inputSelectorFirst.removeEnabled = False
        self.inputSelectorFirst.noneEnabled = True
        self.inputSelectorFirst.noneDisplay = 'Please Select Volume'
        self.inputSelectorFirst.setMRMLScene(slicer.mrmlScene)
        self.inputSelectorFirst.setToolTip(
            'Select the first post-contrast volume node to calculate intitial enhancement and curve type.'
        )
        #self.volumesLayout.addRow(self.inputFirst, self.inputSelectorFirst)
        self.nodeInputFrame.layout().addRow(self.inputFirst,
                                            self.inputSelectorFirst)

        # Select Second Node
        self.inputSecond = qt.QLabel("Second Post-contrast Volume",
                                     self.nodeInputFrame)
        self.inputSecond.setToolTip(
            'Select a second post-contrast volume node (not required).')
        self.inputSelectorSecond = slicer.qMRMLNodeComboBox(
            self.nodeInputFrame)
        self.inputSelectorSecond.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelectorSecond.selectNodeUponCreation = False
        self.inputSelectorSecond.addEnabled = False
        self.inputSelectorSecond.removeEnabled = False
        self.inputSelectorSecond.noneEnabled = True
        self.inputSelectorSecond.noneDisplay = 'Please Select Volume'
        self.inputSelectorSecond.setMRMLScene(slicer.mrmlScene)
        self.inputSelectorSecond.setToolTip(
            'Select a second post-contrast volume node (not required).')
        #self.volumesLayout.addRow(self.inputSecond, self.inputSelectorSecond)
        self.nodeInputFrame.layout().addRow(self.inputSecond,
                                            self.inputSelectorSecond)

        # Select Third Node
        self.inputThird = qt.QLabel("Third Post-contrast Volume",
                                    self.nodeInputFrame)
        self.inputThird.setToolTip(
            'Select a third post-contrast volume node (not required).')
        self.inputSelectorThird = slicer.qMRMLNodeComboBox(self.nodeInputFrame)
        self.inputSelectorThird.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelectorThird.selectNodeUponCreation = False
        self.inputSelectorThird.addEnabled = False
        self.inputSelectorThird.removeEnabled = False
        self.inputSelectorThird.noneEnabled = True
        self.inputSelectorThird.noneDisplay = 'Please Select Volume'
        self.inputSelectorThird.setMRMLScene(slicer.mrmlScene)
        self.inputSelectorThird.setToolTip(
            'Select a third post-contrast volume node (not required).')
        #self.volumesLayout.addRow(self.inputThird, self.inputSelectorThird)
        self.nodeInputFrame.layout().addRow(self.inputThird,
                                            self.inputSelectorThird)

        # Select Fourth Node
        self.inputFourth = qt.QLabel("Fourth Post-contrast Volume",
                                     self.nodeInputFrame)
        self.inputFourth.setToolTip(
            'Select the fourth or final post-contrast volume node to calculate curve type based on the delayed curve slope.'
        )
        self.inputSelectorFourth = slicer.qMRMLNodeComboBox(
            self.nodeInputFrame)
        self.inputSelectorFourth.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelectorFourth.selectNodeUponCreation = False
        self.inputSelectorFourth.addEnabled = False
        self.inputSelectorFourth.removeEnabled = False
        self.inputSelectorFourth.noneEnabled = True
        self.inputSelectorFourth.noneDisplay = 'Please Select Volume'
        self.inputSelectorFourth.setMRMLScene(slicer.mrmlScene)
        self.inputSelectorFourth.setToolTip(
            'Select the fourth or final post-contrast volume node to calculate curve type based on the delayed curve slope.'
        )
        #self.volumesLayout.addRow(self.inputFourth, self.inputSelectorFourth)
        self.nodeInputFrame.layout().addRow(self.inputFourth,
                                            self.inputSelectorFourth)

        # Enable and Select Input Label Map as ROI
        self.enableLabel = qt.QCheckBox(self.selectionsCollapsibleButton)
        self.enableLabel.setText('Use Label Map as ROI')
        self.enableLabel.checked = True
        self.enableLabel.setToolTip(
            'Select and identify a custom label map node to define an ROI over the input volumes for faster segmentation.'
        )
        self.inputSelectorLabel = slicer.qMRMLNodeComboBox(
            self.selectionsCollapsibleButton)
        self.inputSelectorLabel.nodeTypes = (("vtkMRMLLabelMapVolumeNode"), "")
        self.inputSelectorLabel.selectNodeUponCreation = False
        self.inputSelectorLabel.renameEnabled = True
        self.inputSelectorLabel.removeEnabled = False
        self.inputSelectorLabel.noneEnabled = True
        self.inputSelectorLabel.addEnabled = False
        self.inputSelectorLabel.setMRMLScene(slicer.mrmlScene)
        self.inputSelectorLabel.setToolTip(
            'Select and identify a custom label map node to define an ROI over the input volumes for faster segmentation.'
        )
        self.volumesLayout.addRow(self.enableLabel, self.inputSelectorLabel)

        # Select output SegmentCAD Label collapsible button
        self.outlabelCollapsibleButton = ctk.ctkCollapsibleButton()
        self.outlabelCollapsibleButton.text = "Select or Create Output SegmentCAD Label Map"
        self.TumorSegmentationLayout.addWidget(self.outlabelCollapsibleButton)
        # Layout within the collapsible button
        self.outlabelLayout = qt.QFormLayout(self.outlabelCollapsibleButton)
        # Select or create output SegmentCAD Label Map
        self.outputLabel = qt.QLabel("Output SegmentCAD Label Map",
                                     self.outlabelCollapsibleButton)
        self.outputLabel.setToolTip(
            'Select or create a label map volume node as the SegmentCAD segmentation output.'
        )
        self.outputSelectorLabel = slicer.qMRMLNodeComboBox(
            self.outlabelCollapsibleButton)
        self.outputSelectorLabel.nodeTypes = (("vtkMRMLLabelMapVolumeNode"),
                                              "")
        self.outputSelectorLabel.baseName = "SegmentCAD Label Map"
        self.outputSelectorLabel.selectNodeUponCreation = True
        self.outputSelectorLabel.renameEnabled = True
        self.outputSelectorLabel.removeEnabled = True
        self.outputSelectorLabel.noneEnabled = False
        self.outputSelectorLabel.addEnabled = True
        self.outputSelectorLabel.setMRMLScene(slicer.mrmlScene)
        self.outputSelectorLabel.setToolTip(
            'Select or create a label map volume node as the SegmentCAD segmentation output.'
        )
        self.outlabelLayout.addRow(self.outputLabel, self.outputSelectorLabel)
        # SegmentCAD Label Map Legend
        self.outputLegend = qt.QLabel(
            "| Type I Persistent: Blue | Type II Plateau: Yellow | Type III Washout: Red |",
            self.outlabelCollapsibleButton)
        self.outputLegend.setToolTip(
            'SegmentCAD Label Map Legend  | Blue: Type I Persistent curve  |  Yellow: Type II Plateau curve  |  Red: Type III Washout curve  |'
        )
        self.outlabelLayout.addRow(self.outputLegend)
        # Enable Volume Rendering of the SegmentCAD label map
        self.enableVolumeRendering = qt.QCheckBox(
            self.selectionsCollapsibleButton)
        self.enableVolumeRendering.setText('Display Volume Rendering')
        self.enableVolumeRendering.checked = True
        self.enableVolumeRendering.setToolTip(
            'Display volume rendering of the SegmentCAD Label Map in the 3D View'
        )
        self.outlabelLayout.addRow(self.enableVolumeRendering)
        # Enable Label Statistics Table and Data
        self.enableStats = qt.QCheckBox(self.selectionsCollapsibleButton)
        self.enableStats.setText('Calculate SegmentCAD Label statistics')
        self.enableStats.checked = False
        self.enableStats.setToolTip(
            'Use logic from Label Statistics Module to calculate statistics for first post-contrast voxels within the SegmentCAD Label Map.'
        )
        self.outlabelLayout.addRow(self.enableStats)

        # Set Advanced Parameters Collapsible Button
        self.parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        self.parametersCollapsibleButton.text = "Set Advanced Segmentation Parameters"
        self.TumorSegmentationLayout.addWidget(
            self.parametersCollapsibleButton)
        self.parametersCollapsibleButton.collapsed = True
        # Layout within the collapsible button
        self.parametersLayout = qt.QFormLayout(
            self.parametersCollapsibleButton)
        # Set Minimum Threshold of Percentage Increase to First Post-Contrast Image
        self.inputMinimumThreshold = qt.QLabel(
            "Minimum Threshold of Increase", self.parametersCollapsibleButton)
        self.inputMinimumThreshold.setToolTip(
            'Minimum Threshold of Percentage Increase (Pre- to First Post-contrast (Range: 10% to 150%)'
        )
        self.inputSelectorMinimumThreshold = qt.QDoubleSpinBox(
            self.parametersCollapsibleButton)
        self.inputSelectorMinimumThreshold.setSuffix("%")
        self.inputSelectorMinimumThreshold.singleStep = (1)
        self.inputSelectorMinimumThreshold.minimum = (10)
        self.inputSelectorMinimumThreshold.maximum = (150)
        self.inputSelectorMinimumThreshold.value = (75)
        self.inputSelectorMinimumThreshold.setToolTip(
            'Minimum Threshold of Percentage Increase (Pre- to First Post-contrast (Range: 10% to 150%)'
        )
        self.parametersLayout.addRow(self.inputMinimumThreshold,
                                     self.inputSelectorMinimumThreshold)
        # Curve 1 Type Parameters (Slopes from First to Fourth Post-Contrast Images)
        self.inputCurve1 = qt.QLabel("Type 1 (Persistent) Curve Minimum Slope",
                                     self.parametersCollapsibleButton)
        self.inputCurve1.setToolTip(
            'Minimum Slope of Delayed Curve to classify as Persistent (Range: 0.02 to 0.3)'
        )
        self.inputSelectorCurve1 = qt.QDoubleSpinBox(
            self.parametersCollapsibleButton)
        self.inputSelectorCurve1.singleStep = (0.02)
        self.inputSelectorCurve1.minimum = (0.02)
        self.inputSelectorCurve1.maximum = (0.3)
        self.inputSelectorCurve1.value = (0.20)
        self.inputSelectorCurve1.setToolTip(
            'Minimum Slope of Delayed Curve to classify as Persistent (Range: 0.02 to 0.3)'
        )
        self.parametersLayout.addRow(self.inputCurve1,
                                     self.inputSelectorCurve1)
        # Curve 3 Type Parameters (Slopes from First to Fourth Post-Contrast Images)
        self.inputCurve3 = qt.QLabel("Type 3 (Washout) Curve Maximum Slope",
                                     self.parametersCollapsibleButton)
        self.inputCurve3.setToolTip(
            'Maximum Slope of Delayed Curve to classify as Washout (Range: -0.02 to -0.3)'
        )
        self.inputSelectorCurve3 = qt.QDoubleSpinBox(
            self.parametersCollapsibleButton)
        self.inputSelectorCurve3.singleStep = (0.02)
        self.inputSelectorCurve3.setPrefix("-")
        self.inputSelectorCurve3.minimum = (0.02)
        self.inputSelectorCurve3.maximum = (0.30)
        self.inputSelectorCurve3.value = (0.20)
        self.inputSelectorCurve3.setToolTip(
            'Maximum Slope of Delayed Curve to classify as Washout (Range: -0.02 to -0.3)'
        )
        self.parametersLayout.addRow(self.inputCurve3,
                                     self.inputSelectorCurve3)
        # Apply Tumor Adaptive Segmentation button
        self.SegmentCADButton = qt.QPushButton("Apply SegmentCAD")
        self.SegmentCADButton.toolTip = "Apply SegmentCAD segmentation to selected volumes."
        self.TumorSegmentationLayout.addWidget(self.SegmentCADButton)

        # LabelStatistics Table Collapsible Button
        self.labelstatisticsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.labelstatisticsCollapsibleButton.text = "SegmentCAD Label Statistics"
        self.layout.addWidget(self.labelstatisticsCollapsibleButton)
        self.labelstatisticsCollapsibleButton.collapsed = True
        # Layout within the collapsible button
        self.labelstatisticsLayout = qt.QFormLayout(
            self.labelstatisticsCollapsibleButton)
        # Table View to display Label statistics
        self.labelStatisticsTableView = qt.QTableView()
        self.labelStatisticsTableView.sortingEnabled = True
        self.labelstatisticsLayout.addWidget(self.labelStatisticsTableView)
        self.labelStatisticsTableView.minimumHeight = 200
        # Charting Statistics Button
        self.chartOptions = ("Volume", "Curve Type", "Voxel Count",
                             "Volume mm^3", "Volume cc", "Minimum Intensity",
                             "Maximum Intensity", "Mean Intensity",
                             "Standard Deviation")
        self.chartFrame = qt.QFrame()
        self.chartFrame.setLayout(qt.QHBoxLayout())
        self.labelstatisticsLayout.addWidget(self.chartFrame)
        self.chartButton = qt.QPushButton(
            "Chart Statistics", self.labelstatisticsCollapsibleButton)
        self.chartButton.toolTip = "Make a chart from the current statistics."
        self.chartFrame.layout().addWidget(self.chartButton)
        self.chartOption = qt.QComboBox(self.labelstatisticsCollapsibleButton)
        self.chartOption.addItems(self.chartOptions)
        self.chartFrame.layout().addWidget(self.chartOption)
        self.chartIgnoreZero = qt.QCheckBox(
            self.labelstatisticsCollapsibleButton)
        self.chartIgnoreZero.setText('Ignore Zero Label')
        self.chartIgnoreZero.checked = False
        self.chartIgnoreZero.setToolTip(
            'Do not include the zero index in the chart to avoid dwarfing other bars'
        )
        self.chartFrame.layout().addWidget(self.chartIgnoreZero)
        self.chartButton.enabled = False

        # Interactive Charting Settings Collapsible Button
        self.iChartingCollapsibleButton = ctk.ctkCollapsibleButton()
        self.iChartingCollapsibleButton.text = "Interactive Charting Settings"
        self.iChartingCollapsibleButton.collapsed = True
        self.layout.addWidget(self.iChartingCollapsibleButton)
        # Layout within the collapsible button
        self.iChartingLayout = qt.QFormLayout(self.iChartingCollapsibleButton)
        # iCharting toggle button
        self.iCharting = qt.QPushButton("Enable Interactive Charting")
        self.iCharting.checkable = True
        self.iCharting.setChecked(False)
        self.iCharting.enabled = False
        self.iCharting.toolTip = "Toggle the real-time charting of the %increase from baseline of the selected voxel from each input volume."
        self.iChartingLayout.addRow(self.iCharting)

        # Initialize slice observers (from DataProbe.py)
        # Keep list of pairs: [observee,tag] so they can be removed easily
        self.styleObserverTags = []
        # Keep a map of interactor styles to sliceWidgets so we can easily get sliceLogic
        self.sliceWidgetsPerStyle = {}
        self.refreshObservers()

        # Connections
        self.SegmentCADButton.connect('clicked()',
                                      self.onSegmentCADButtonClicked)
        self.enableLabel.connect('stateChanged(int)', self.onEnableLabel)
        self.enableMultiVolume.connect('stateChanged(int)',
                                       self.onEnableMultiVolume)
        self.chartButton.connect('clicked()', self.onChart)
        self.iCharting.connect('toggled(bool)',
                               self.onInteractiveChartingChanged)
Пример #13
0
    def setup(self):
        # Instantiate and connect widgets ...

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)

        # Collapsible button
        dummyCollapsibleButton = ctk.ctkCollapsibleButton()
        dummyCollapsibleButton.text = "Parameters"
        self.layout.addWidget(dummyCollapsibleButton)

        # Layout within the dummy collapsible button
        dummyFormLayout = qt.QFormLayout(dummyCollapsibleButton)

        #LABEL VOLUME SELECTOR

        self.labelSelectorFrame = qt.QFrame()
        self.labelSelectorFrame.setLayout(qt.QHBoxLayout())
        dummyFormLayout.addWidget(self.labelSelectorFrame)

        self.labelSelectorLabel = qt.QLabel()
        self.labelSelectorLabel.setText("Label Map: ")
        dummyFormLayout.addWidget(self.labelSelectorLabel)

        self.labelSelector = slicer.qMRMLNodeComboBox()
        self.labelSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.labelSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                        "1")
        # todo addAttribute
        self.labelSelector.selectNodeUponCreation = False
        self.labelSelector.addEnabled = False
        self.labelSelector.noneEnabled = True
        self.labelSelector.removeEnabled = False
        self.labelSelector.showHidden = False
        self.labelSelector.showChildNodeTypes = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip("Pick the label map to edit")
        dummyFormLayout.addWidget(self.labelSelector)
        self.labelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.onLabelSelect)

        # the grayscale volume selector
        #
        self.grayscaleSelectorFrame = qt.QFrame(self.parent)
        self.grayscaleSelectorFrame.setLayout(qt.QHBoxLayout())
        dummyFormLayout.addWidget(self.grayscaleSelectorFrame)

        self.grayscaleSelectorLabel = qt.QLabel("Grayscale Volume: ",
                                                self.grayscaleSelectorFrame)
        self.grayscaleSelectorLabel.setToolTip(
            "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations"
        )
        dummyFormLayout.addWidget(self.grayscaleSelectorLabel)

        self.grayscaleSelector = slicer.qMRMLNodeComboBox(
            self.grayscaleSelectorFrame)
        self.grayscaleSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.grayscaleSelector.addAttribute("vtkMRMLScalarVolumeNode",
                                            "LabelMap", 0)
        self.grayscaleSelector.selectNodeUponCreation = False
        self.grayscaleSelector.addEnabled = False
        self.grayscaleSelector.removeEnabled = False
        self.grayscaleSelector.noneEnabled = True
        self.grayscaleSelector.showHidden = False
        self.grayscaleSelector.showChildNodeTypes = False
        self.grayscaleSelector.setMRMLScene(slicer.mrmlScene)
        # TODO: need to add a QLabel
        # self.grayscaleSelector.SetLabelText( "Master Volume:" )
        dummyFormLayout.addWidget(self.grayscaleSelector)
        self.grayscaleSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                       self.onGrayscaleSelect)

        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "diagnosis Reload"
        self.layout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # Calculate button
        self.calcButton = qt.QPushButton("Calculates")
        self.calcButton.toolTip = "Calculates the level of stenosis on the most patological slice"
        dummyFormLayout.addWidget(self.calcButton)
        self.calcButton.enabled = False
        self.calcButton.connect('clicked(bool)', self.onCalcButtonClicked)

        # Botton temporal para llenar tabla ***************************************
        self.fillTable = qt.QPushButton("Fill")
        self.fillTable.toolTip = "Testing"
        dummyFormLayout.addWidget(self.fillTable)
        self.fillTable.enabled = True
        self.fillTable.connect('clicked(bool)', self.onFillButtonClicked)

        # Add Vertical Spacer
        self.layout.addStretch(1)

        # Parametros tabla
        self.vista = qt.QTableView()
        self.vista.sortingEnabled = False
        self.vista.visible = False
        self.vista.verticalHeader().visible = False
        self.vista.horizontalHeader().visible = False
        self.vista.setAlternatingRowColors(True)
        dummyFormLayout.addWidget(self.vista)

        # Add vertical spacer
        self.layout.addStretch(1)