def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

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

    self.inputDirSelector = ctk.ctkPathLineEdit()
    self.inputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.inputDirSelector.settingKey = 'DicomPatcherInputDir'
    parametersFormLayout.addRow("Input DICOM directory:", self.inputDirSelector)

    self.outputDirSelector = ctk.ctkPathLineEdit()
    self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.outputDirSelector.settingKey = 'DicomPatcherOutputDir'
    parametersFormLayout.addRow("Output DICOM directory:", self.outputDirSelector)

    self.generateMissingIdsCheckBox = qt.QCheckBox()
    self.generateMissingIdsCheckBox.checked = True
    self.generateMissingIdsCheckBox.setToolTip("If checked, then missing patient, study, series IDs are generated. It is assumed that all files in a directory belong to the same series. Fixes error caused by too aggressive anonymization or incorrect DICOM image converters.")
    parametersFormLayout.addRow("Generate missing IDs", self.generateMissingIdsCheckBox)
    
    self.generateImagePositionFromSliceThicknessCheckBox = qt.QCheckBox()
    self.generateImagePositionFromSliceThicknessCheckBox.checked = True
    self.generateImagePositionFromSliceThicknessCheckBox.setToolTip("If checked, then image position sequence is generated for multi-frame files that only have SliceThickness field. Fixes error in Dolphin 3D CBCT scanners.")
    parametersFormLayout.addRow("Generate slice position for multi-frame volumes", self.generateImagePositionFromSliceThicknessCheckBox)
    
    self.anonymizeDicomCheckBox = qt.QCheckBox()
    self.anonymizeDicomCheckBox.checked = False
    self.anonymizeDicomCheckBox.setToolTip("If checked, then some patient identifiable information will be removed from the patched DICOM files. There are many fields that can identify a patient, this function does not remove all of them.")
    parametersFormLayout.addRow("Anonymize DICOM files", self.anonymizeDicomCheckBox)

    #
    # Patch Button
    #
    self.patchButton = qt.QPushButton("Patch")
    self.patchButton.toolTip = "Fix and optionally anonymize DICOM files"
    parametersFormLayout.addRow(self.patchButton)

    # connections
    self.patchButton.connect('clicked(bool)', self.onPatchButton)
    
    self.statusLabel = qt.QPlainTextEdit()
    self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
    parametersFormLayout.addRow(self.statusLabel)

    # Add vertical spacer
    self.layout.addStretch(1)
    
    self.logic = DicomPatcherLogic()
    self.logic.logCallback = self.addLog
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

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

    self.inputDirSelector = ctk.ctkPathLineEdit()
    self.inputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.inputDirSelector.settingKey = 'Philips4dUsDicomPatcherInputDir'
    parametersFormLayout.addRow("Input DICOM directory:", self.inputDirSelector)

    self.outputDirSelector = ctk.ctkPathLineEdit()
    self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.outputDirSelector.settingKey = 'Philips4dUsDicomPatcherOutputDir'
    parametersFormLayout.addRow("Output DICOM directory:", self.outputDirSelector)

    self.enableDicomOutputCheckBox = qt.QCheckBox()
    self.enableDicomOutputCheckBox.checked = True
    self.enableDicomOutputCheckBox.setToolTip("If checked, patched 4D US DICOM files will be saved as DICOM files")
    parametersFormLayout.addRow("Export to DICOM files", self.enableDicomOutputCheckBox)

    self.anonymizeDicomCheckBox = qt.QCheckBox()
    self.anonymizeDicomCheckBox.checked = False
    self.anonymizeDicomCheckBox.setToolTip("If checked, then patient identifiable information will be removed from the patched DICOM files")
    parametersFormLayout.addRow("     Anonymize DICOM files", self.anonymizeDicomCheckBox)

    self.enableNrrdOutputCheckBox = qt.QCheckBox()
    self.enableNrrdOutputCheckBox.checked = False
    self.enableNrrdOutputCheckBox.setToolTip("If checked, 4D US DICOM files will be saved as NRRD files")
    parametersFormLayout.addRow("Export to NRRD files", self.enableNrrdOutputCheckBox)
    
    #
    # Patch Button
    #
    self.patchButton = qt.QPushButton("Patch")
    self.patchButton.toolTip = "Fix and optionally anonymize DICOM files"
    parametersFormLayout.addRow(self.patchButton)

    # connections
    self.patchButton.connect('clicked(bool)', self.onPatchButton)
    
    self.statusLabel = qt.QPlainTextEdit()
    self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
    parametersFormLayout.addRow(self.statusLabel)

    # Add vertical spacer
    self.layout.addStretch(1)
    
    self.logic = Philips4dUsDicomPatcherLogic()
    self.logic.logCallback = self.addLog
Exemple #3
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        # Instantiate and connect widgets ...

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

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

        #
        # Path
        #
        self.dirPath = ctk.ctkPathLineEdit()
        self.dirPath.currentPath = "/tmp"
        parametersFormLayout.addRow(self.dirPath)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)

        # Add vertical spacer
        self.layout.addStretch(1)
    def setup(self):
        # Instantiate and connect widgets ...
        
        # Reload and Test area
        if self.developerMode:
            # section
            reloadCollapsibleButton = ctk.ctkCollapsibleButton()
            reloadCollapsibleButton.text = "Reload && Test"
            self.layout.addWidget(reloadCollapsibleButton)
            reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)
            # reload button
            self.reloadButton = qt.QPushButton("Reload")
            self.reloadButton.toolTip = "Reload this module."
            self.reloadButton.name = "PyDevRemoteDebug Reload"
            reloadFormLayout.addWidget(self.reloadButton)
            self.reloadButton.connect('clicked()', self.onReload)

        # Settings Area
        self.settingsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.settingsCollapsibleButton.text = "Settings"
        self.settingsCollapsibleButton.collapsed = True
        self.layout.addWidget(self.settingsCollapsibleButton)
        settingsFormLayout = qt.QFormLayout(self.settingsCollapsibleButton)
        # pydevd.py path selector
        pydevdDir=self.getPydevdDir()
        self.pydevdDirSelector = ctk.ctkPathLineEdit()
        self.pydevdDirSelector.setCurrentPath(pydevdDir)
        self.pydevdDirSelector.filters=self.pydevdDirSelector.Dirs
        self.pydevdDirSelector.setMaximumWidth(300)
        self.pydevdDirSelector.setToolTip("Set the path to pydevd.py. It is in the eclipse folder within plugins/...pydev.../pysrc.")
        settingsFormLayout.addRow("Path to pydevd.py: ", self.pydevdDirSelector)
        if not self.isValidPydevdDir(pydevdDir):
            self.settingsCollapsibleButton.collapsed = False

        # Connection Area
        connectionCollapsibleButton = ctk.ctkCollapsibleButton()
        connectionCollapsibleButton.text = "Connection"
        connectionCollapsibleButton.collapsed = False
        self.layout.addWidget(connectionCollapsibleButton)
        connectionFormLayout = qt.QFormLayout(connectionCollapsibleButton)
        # Connect Button
        self.connectButton = qt.QPushButton("Connect")
        self.connectButton.toolTip = "Connect to PyDev remote debugger"
        self.connectButton.setAutoFillBackground(True)
        self.connectButton.setStyleSheet("background-color: rgb(150, 255, 150); color: rgb(0, 0, 0)");
        connectionFormLayout.addRow(self.connectButton)

        # Connections
        self.connectButton.connect('clicked(bool)', self.onConnect)

        # Add vertical spacer
        self.layout.addStretch(1)
Exemple #5
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        # Instantiate and connect widgets ...

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

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

        #
        # Configuration Selection
        #
        self.configPathEdit = ctk.ctkPathLineEdit()
        self.configPathEdit.toolTip = "A json file in the format described in the help tab above."
        parametersFormLayout.addRow('Config File', self.configPathEdit)

        self.targetDirectoryButton = ctk.ctkDirectoryButton()
        self.targetDirectoryButton.directory = slicer.app.temporaryPath
        self.targetDirectoryButton.toolTip = "Where you want the customized Slicer application to be created.  By default it is the current Slicer temporary directory."
        parametersFormLayout.addRow('Target Directory',
                                    self.targetDirectoryButton)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Generate")
        self.applyButton.toolTip = "Generate the Custom Slicer."
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)

        # Possible use for error messages
        self.message = qt.QErrorMessage()
        self.message.setWindowTitle("CustomSlicerGenerator")

        # Add vertical spacer
        self.layout.addStretch(1)
        self.logic = CustomSlicerGeneratorLogic()

        # QPushButton used for signal connection between widget and logic
        self.myQObject = qt.QPushButton()
        self.myQObject.connect('clicked(bool)', self.doneGenerating)
    def __init__(self, parent):
        self.vLayout = qt.QVBoxLayout(parent)
        self.formLayout = qt.QFormLayout()

        self.componentName = qt.QLineEdit()
        self.formLayout.addRow("Name:", self.componentName)

        self.componentType = qt.QComboBox()
        self.formLayout.addRow("Type:", self.componentType)

        self.destination = ctk.ctkPathLineEdit()
        self.destination.filters = ctk.ctkPathLineEdit.Dirs
        self.formLayout.addRow("Destination:", self.destination)

        self.vLayout.addLayout(self.formLayout)
        self.vLayout.addStretch(1)

        self.buttonBox = qt.QDialogButtonBox()
        self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok
                                          | qt.QDialogButtonBox.Cancel)
        self.vLayout.addWidget(self.buttonBox)
  def __init__(self, parent):
    self.vLayout = qt.QVBoxLayout(parent)
    self.formLayout = qt.QFormLayout()

    self.componentName = qt.QLineEdit()
    self.formLayout.addRow("Name:", self.componentName)

    self.componentType = qt.QComboBox()
    self.formLayout.addRow("Type:", self.componentType)

    self.destination = ctk.ctkPathLineEdit()
    self.destination.filters = ctk.ctkPathLineEdit.Dirs
    self.formLayout.addRow("Destination:", self.destination)

    self.vLayout.addLayout(self.formLayout)
    self.vLayout.addStretch(1)

    self.buttonBox = qt.QDialogButtonBox()
    self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok |
                                      qt.QDialogButtonBox.Cancel)
    self.vLayout.addWidget(self.buttonBox)
    def setup(self):
        # Instantiate and connect widgets ...

        # Collapsible button
        sampleCollapsibleButton = ctk.ctkCollapsibleButton()
        sampleCollapsibleButton.text = "Directory to Monitor"
        self.layout.addWidget(sampleCollapsibleButton)

        # Layout within the sample collapsible button
        sampleFormLayout = qt.QFormLayout(sampleCollapsibleButton)

        #directory selector
        self.outputDirSelector = ctk.ctkPathLineEdit()
        self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
        self.outputDirSelector.settingKey = 'BlenderMonitorDir'
        sampleFormLayout.addRow("Blender tmp directory:",
                                self.outputDirSelector)

        if not self.outputDirSelector.currentPath:
            self_dir = os.path.dirname(os.path.abspath(__file__))
            defaultOutputPath = os.path.join(self_dir, "tmp")

            if not os.path.exists(defaultOutputPath):
                print(defaultOutputPath)
                defaultOutputPath = slicer.app.defaultScenePath

            self.outputDirSelector.setCurrentPath(defaultOutputPath)

        # Play button
        playButton = qt.QPushButton("Start")
        playButton.toolTip = "Start Monitoring Directory."
        playButton.checkable = True
        sampleFormLayout.addRow(playButton)
        playButton.connect('toggled(bool)', self.onPlayButtonToggled)
        self.playButton = playButton

        #Report Window
        self.text_report = qt.QTextEdit()
        self.text_report.setText('Report file changes here')
        sampleFormLayout.addRow('Dir Status:', self.text_report)
    def setup(self):

        # Do not show reload&test in developer mode, as debugger is mostly used by developers
        # but they are not interested in debugging this module.
        # ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        # Settings Area
        self.settingsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.settingsCollapsibleButton.text = "Settings"
        self.settingsCollapsibleButton.collapsed = True
        self.layout.addWidget(self.settingsCollapsibleButton)
        settingsFormLayout = qt.QFormLayout(self.settingsCollapsibleButton)

        # Debugger selector
        self.debuggerSelector = qt.QComboBox()
        self.debuggerSelector.toolTip = "Chose debugger server."
        debugger = self.logic.getDebugger()
        self.debuggerSelector.addItem("Eclipse")
        self.debuggerSelector.addItem("PyCharm")
        if debugger == 'Eclipse':
            self.debuggerSelector.currentIndex = 0
        elif debugger == 'PyCharm':
            self.debuggerSelector.currentIndex = 1
        else:
            self.debuggerSelector.currentIndex = -1
        settingsFormLayout.addRow("Debugger: ", self.debuggerSelector)
        self.debuggerSelector.connect('currentIndexChanged(int)',
                                      self.onDebuggerSelected)

        # pydevd.py path selector
        pydevdDir = self.logic.getEclipsePydevdDir(
            enableAutoDetect=(debugger == 'Eclipse'))
        self.pydevdDirSelector = ctk.ctkPathLineEdit()
        self.pydevdDirSelector.setCurrentPath(pydevdDir)
        self.pydevdDirSelector.filters = self.pydevdDirSelector.Dirs
        self.pydevdDirSelector.setMaximumWidth(300)
        self.pydevdDirSelector.setToolTip(
            "Set the path to pydevd.py. It is in the eclipse folder within plugins/...pydev.../pysrc."
        )
        settingsFormLayout.addRow("Eclipse pydevd.py directory:",
                                  self.pydevdDirSelector)

        # pycharm-debug.egg path selector
        pyCharmDebugEggPathSelector = self.logic.getPyCharmDebugEggPath(
            enableAutoDetect=(debugger == 'PyCharm'))
        self.pyCharmDebugEggPathSelector = ctk.ctkPathLineEdit()
        self.pyCharmDebugEggPathSelector.setCurrentPath(
            pyCharmDebugEggPathSelector)
        self.pyCharmDebugEggPathSelector.nameFilters = ['pycharm-debug.egg']
        self.pyCharmDebugEggPathSelector.setMaximumWidth(300)
        self.pyCharmDebugEggPathSelector.setToolTip(
            "Set the path to pycharm-debug.egg . It is in the .../PyCharm/debug-eggs folder."
        )
        settingsFormLayout.addRow("PyCharm pycharm-debug.egg path:",
                                  self.pyCharmDebugEggPathSelector)

        if not self.isCurrentSettingValid():
            self.settingsCollapsibleButton.collapsed = False

        # Connection Area
        connectionCollapsibleButton = ctk.ctkCollapsibleButton()
        connectionCollapsibleButton.text = "Connection"
        connectionCollapsibleButton.collapsed = False
        self.layout.addWidget(connectionCollapsibleButton)
        connectionFormLayout = qt.QFormLayout(connectionCollapsibleButton)

        # Connect Button
        self.connectButton = qt.QPushButton("Connect to debug server")
        self.connectButton.toolTip = "Connect to remote debug server"
        self.connectButton.setAutoFillBackground(True)
        self.connectButton.setStyleSheet(
            "background-color: rgb(150, 255, 150); color: rgb(0, 0, 0)")
        connectionFormLayout.addRow(self.connectButton)

        # Auto-connect button (only show after a successful connection to make sure
        # Slicer does not hang on startup due to failed attempt to connect to debugger)
        self.autoConnectCheckBox = qt.QCheckBox()
        self.autoConnectCheckBox.visible = False
        self.autoConnectCheckBox.checked = self.logic.getDebuggerAutoConnect()
        self.autoConnectCheckBox.setToolTip(
            "If checked, Slicer will attempt to connect to the remote debugger on startup."
        )
        self.autoConnectCheckBoxLabel = qt.QLabel(
            "Auto-connect on next application startup:")
        self.autoConnectCheckBoxLabel.visible = False
        connectionFormLayout.addRow(self.autoConnectCheckBoxLabel,
                                    self.autoConnectCheckBox)

        if self.logic.isConnected():
            # already connected
            self.onConnectionComplete(True)

        # Connections
        self.connectButton.connect('clicked(bool)', self.onConnect)
        self.autoConnectCheckBox.connect('toggled(bool)',
                                         self.onAutoConnectChanged)

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

        self.onDebuggerSelected()
Exemple #10
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

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

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

        self.inputDirSelector = ctk.ctkPathLineEdit()
        self.inputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
        self.inputDirSelector.settingKey = 'Philips4dUsDicomPatcherInputDir'
        parametersFormLayout.addRow("Input DICOM directory:",
                                    self.inputDirSelector)

        self.outputDirSelector = ctk.ctkPathLineEdit()
        self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
        self.outputDirSelector.settingKey = 'Philips4dUsDicomPatcherOutputDir'
        parametersFormLayout.addRow("Output DICOM directory:",
                                    self.outputDirSelector)

        self.enableDicomOutputCheckBox = qt.QCheckBox()
        self.enableDicomOutputCheckBox.checked = True
        self.enableDicomOutputCheckBox.setToolTip(
            "If checked, patched 4D US DICOM files will be saved as DICOM files"
        )
        parametersFormLayout.addRow("Export to DICOM files",
                                    self.enableDicomOutputCheckBox)

        self.anonymizeDicomCheckBox = qt.QCheckBox()
        self.anonymizeDicomCheckBox.checked = False
        self.anonymizeDicomCheckBox.setToolTip(
            "If checked, then patient identifiable information will be removed from the patched DICOM files"
        )
        parametersFormLayout.addRow("     Anonymize DICOM files",
                                    self.anonymizeDicomCheckBox)

        self.enableNrrdOutputCheckBox = qt.QCheckBox()
        self.enableNrrdOutputCheckBox.checked = False
        self.enableNrrdOutputCheckBox.setToolTip(
            "If checked, 4D US DICOM files will be saved as NRRD files")
        parametersFormLayout.addRow("Export to NRRD files",
                                    self.enableNrrdOutputCheckBox)

        #
        # Patch Button
        #
        self.patchButton = qt.QPushButton("Patch")
        self.patchButton.toolTip = "Fix and optionally anonymize DICOM files"
        parametersFormLayout.addRow(self.patchButton)

        # connections
        self.patchButton.connect('clicked(bool)', self.onPatchButton)

        self.statusLabel = qt.QPlainTextEdit()
        self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
        parametersFormLayout.addRow(self.statusLabel)

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

        self.logic = Philips4dUsDicomPatcherLogic()
        self.logic.logCallback = self.addLog
Exemple #11
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

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

    self.inputDirSelector = ctk.ctkPathLineEdit()
    self.inputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.inputDirSelector.settingKey = 'DICOMPatcherInputDir'
    parametersFormLayout.addRow("Input DICOM directory:", self.inputDirSelector)

    self.outputDirSelector = ctk.ctkPathLineEdit()
    self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.outputDirSelector.settingKey = 'DICOMPatcherOutputDir'
    parametersFormLayout.addRow("Output DICOM directory:", self.outputDirSelector)

    self.normalizeFileNamesCheckBox = qt.QCheckBox()
    self.normalizeFileNamesCheckBox.checked = True
    self.normalizeFileNamesCheckBox.setToolTip("Replace file and folder names with automatically generated names."
      " Fixes errors caused by file path containins special characters or being too long.")
    parametersFormLayout.addRow("Normalize file names", self.normalizeFileNamesCheckBox)

    self.forceSamePatientNameIdInEachDirectoryCheckBox = qt.QCheckBox()
    self.forceSamePatientNameIdInEachDirectoryCheckBox.checked = False
    self.forceSamePatientNameIdInEachDirectoryCheckBox.setToolTip("Generate patient name and ID from the first file in a directory"
      " and force all other files in the same directory to have the same patient name and ID."
      " Enable this option if a separate patient directory is created for each patched file.")
    parametersFormLayout.addRow("Force same patient name and ID in each directory", self.forceSamePatientNameIdInEachDirectoryCheckBox)

    self.generateMissingIdsCheckBox = qt.QCheckBox()
    self.generateMissingIdsCheckBox.checked = True
    self.generateMissingIdsCheckBox.setToolTip("Generate missing patient, study, series IDs. It is assumed that"
      " all files in a directory belong to the same series. Fixes error caused by too aggressive anonymization"
      " or incorrect DICOM image converters.")
    parametersFormLayout.addRow("Generate missing patient/study/series IDs", self.generateMissingIdsCheckBox)

    self.generateImagePositionFromSliceThicknessCheckBox = qt.QCheckBox()
    self.generateImagePositionFromSliceThicknessCheckBox.checked = True
    self.generateImagePositionFromSliceThicknessCheckBox.setToolTip("Generate 'image position sequence' for"
      " multi-frame files that only have 'SliceThickness' field. Fixes error in Dolphin 3D CBCT scanners.")
    parametersFormLayout.addRow("Generate slice position for multi-frame volumes", self.generateImagePositionFromSliceThicknessCheckBox)

    self.anonymizeDicomCheckBox = qt.QCheckBox()
    self.anonymizeDicomCheckBox.checked = False
    self.anonymizeDicomCheckBox.setToolTip("If checked, then some patient identifiable information will be removed"
      " from the patched DICOM files. There are many fields that can identify a patient, this function does not remove all of them.")
    parametersFormLayout.addRow("Partially anonymize", self.anonymizeDicomCheckBox)

    #
    # Patch Button
    #
    self.patchButton = qt.QPushButton("Patch")
    self.patchButton.toolTip = "Fix DICOM files in input directory and write them to output directory"
    parametersFormLayout.addRow(self.patchButton)

    #
    # Import Button
    #
    self.importButton = qt.QPushButton("Import")
    self.importButton.toolTip = "Import DICOM files in output directory into Slicer DICOM database"
    parametersFormLayout.addRow(self.importButton)

    #
    # Switch to DICOM module Button
    #
    self.switchToDICOMModuleButton = qt.QPushButton("Go to DICOM module")
    self.switchToDICOMModuleButton.toolTip = "Open DICOM module where imported data can be loaded into the scene"
    parametersFormLayout.addRow(self.switchToDICOMModuleButton)

    # connections
    self.patchButton.connect('clicked(bool)', self.onPatchButton)
    self.importButton.connect('clicked(bool)', self.onImportButton)
    self.switchToDICOMModuleButton.connect('clicked(bool)', self.onSwitchToDICOMModuleButton)

    self.statusLabel = qt.QPlainTextEdit()
    self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
    parametersFormLayout.addRow(self.statusLabel)

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

    self.logic = DICOMPatcherLogic()
    self.logic.logCallback = self.addLog
    def setup(self):
        #
        # Input
        #
        self.inputCollapsibleButton = ctk.ctkCollapsibleButton()
        self.inputCollapsibleButton.text = "Input"
        self.layout.addWidget(self.inputCollapsibleButton)

        # Layout within the input collapsible button
        self.inputFormLayout = qt.QFormLayout(self.inputCollapsibleButton)

        import platform
        self.inputJsonFn = ctk.ctkPathLineEdit()
        self.inputFormLayout.addRow("Input Json:", self.inputJsonFn)
        #self.inputJsonFn.setCurrentPath('input.json')
        if platform.system() == 'Linux':
            self.inputJsonFn.setCurrentPath(
                '/home/mrusu/Projects/RadPathFusion/prostate/4_histology/')
        if platform.system() == 'Windows':
            self.inputJsonFn.setCurrentPath(
                'C:/Projects/rad-path-fusion/prostate_RP/3_histology/')
        #self.inputJsonFn.setMaximumWidth(425)
        self.inputJsonFn.addCurrentPathToHistory()

        #
        # input fixed volume selector
        #
        self.inputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.inputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.inputVolumeSelector.selectNodeUponCreation = True
        self.inputVolumeSelector.addEnabled = False
        self.inputVolumeSelector.renameEnabled = True
        self.inputVolumeSelector.removeEnabled = True
        self.inputVolumeSelector.noneEnabled = True
        self.inputVolumeSelector.showHidden = False
        self.inputVolumeSelector.showChildNodeTypes = False
        self.inputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.inputFormLayout.addRow("Fixed Volume: ", self.inputVolumeSelector)

        #
        # input fixed volume selector
        #
        self.inputMaskSelector = slicer.qMRMLNodeComboBox()
        self.inputMaskSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.inputMaskSelector.selectNodeUponCreation = True
        self.inputMaskSelector.addEnabled = False
        self.inputMaskSelector.renameEnabled = True
        self.inputMaskSelector.removeEnabled = True
        self.inputMaskSelector.noneEnabled = True
        self.inputMaskSelector.showHidden = False
        self.inputMaskSelector.showChildNodeTypes = False
        self.inputMaskSelector.setMRMLScene(slicer.mrmlScene)
        self.inputFormLayout.addRow("Fixed Mask: ", self.inputMaskSelector)

        #
        #Output
        #
        self.outputCollapsibleButton = ctk.ctkCollapsibleButton()
        self.outputCollapsibleButton.text = "Output"
        self.layout.addWidget(self.outputCollapsibleButton)

        # Layout within the output collapsible button
        self.outputFormLayout = qt.QFormLayout(self.outputCollapsibleButton)
        """
        self.outputJsonFn = ctk.ctkPathLineEdit()
        self.outputFormLayout.addRow("Output Json:", self.outputJsonFn)
        if platform.system() == 'Linux':
            self.outputJsonFn.setCurrentPath('/home/mrusu/Projects/RadPathFusion/prostate/4_histology/')
        if platform.system() == 'Windows':
            self.outputJsonFn.setCurrentPath( 'C:/Projects/rad-path-fusion/prostate_RP/3_histology/')
            
        #self.outputJsonFn.setMaximumWidth(400)
        """

        #
        # output volume selector
        #
        self.outputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.outputVolumeSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.outputVolumeSelector.selectNodeUponCreation = True
        self.outputVolumeSelector.addEnabled = True
        self.outputVolumeSelector.renameEnabled = True
        self.outputVolumeSelector.removeEnabled = True
        self.outputVolumeSelector.noneEnabled = True
        self.outputVolumeSelector.showHidden = False
        self.outputVolumeSelector.showChildNodeTypes = False
        self.outputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.outputFormLayout.addRow("Output Volume: ",
                                     self.outputVolumeSelector)
        #self.outputVolumeSelector.setMaximumWidth(400)

        #
        # output mask volume selector
        #
        self.outputMaskVolumeSelector = slicer.qMRMLNodeComboBox()
        self.outputMaskVolumeSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.outputMaskVolumeSelector.selectNodeUponCreation = True
        self.outputMaskVolumeSelector.addEnabled = True
        self.outputMaskVolumeSelector.renameEnabled = True
        self.outputMaskVolumeSelector.removeEnabled = True
        self.outputMaskVolumeSelector.noneEnabled = True
        self.outputMaskVolumeSelector.showHidden = False
        self.outputMaskVolumeSelector.showChildNodeTypes = False
        self.outputMaskVolumeSelector.setMRMLScene(slicer.mrmlScene)
        # maskIDselector
        self.maskIdSelector = qt.QComboBox()
        self.populateMaskId()

        self.outputFormLayout.addRow("Output Mask: ",
                                     self.outputMaskVolumeSelector)
        self.outputFormLayout.addRow("Mask ID", self.maskIdSelector)
        #self.outputMaskVolumeSelector.setMaximumWidth(400)

        #
        # Status and Progress
        #
        statusLabel = qt.QLabel("Status: ")
        self.currentStatusLabel = qt.QLabel("Idle")
        hlayout = qt.QHBoxLayout()
        hlayout.addStretch(1)
        hlayout.addWidget(statusLabel)
        hlayout.addWidget(self.currentStatusLabel)
        self.layout.addLayout(hlayout)

        self.progress = qt.QProgressBar()
        self.progress.setRange(0, 0)
        #self.progress.setValue(0)
        self.layout.addWidget(self.progress)
        self.progress.hide()

        #Load Input
        self.loadJsonButton = qt.QPushButton("Load Json")
        self.loadJsonButton.toolTip = "Load the json file."
        self.loadJsonButton.enabled = True

        # Save Output Json
        self.saveJsonButton = qt.QPushButton("Save Json")
        self.saveJsonButton.toolTip = "Save the json file."
        self.saveJsonButton.enabled = False

        # ReconstructVolume
        self.refineVolumeButton = qt.QPushButton("Refine Volume")
        self.refineVolumeButton.toolTip = "Refine."
        self.refineVolumeButton.enabled = True

        # RegisterVolume
        self.registerVolumeButton = qt.QPushButton("Register")
        self.registerVolumeButton.toolTip = "Register"
        self.registerVolumeButton.enabled = True

        # LoadVolume
        self.loadVolumeButton = qt.QPushButton("Load Volume")
        self.loadVolumeButton.toolTip = "Load Volume."
        self.loadVolumeButton.enabled = True

        # LoadMask
        self.loadMaskVolumeButton = qt.QPushButton("Load Mask")
        self.loadMaskVolumeButton.toolTip = "Load a Mask"
        self.loadMaskVolumeButton.enabled = True

        # Clear
        self.clearAllVolumeButton = qt.QPushButton("Clear ALL")
        self.clearAllVolumeButton.toolTip = "Clear"
        self.clearAllVolumeButton.enabled = False

        hlayout = qt.QHBoxLayout()

        hlayout.addWidget(self.loadJsonButton)
        hlayout.addWidget(self.refineVolumeButton)
        hlayout.addWidget(self.registerVolumeButton)
        hlayout.addWidget(self.loadVolumeButton)
        hlayout.addWidget(self.loadMaskVolumeButton)
        hlayout.addWidget(self.clearAllVolumeButton)
        hlayout.addStretch(1)
        hlayout.addWidget(self.saveJsonButton)
        self.layout.addLayout(hlayout)

        self.loadJsonButton.connect('clicked(bool)', self.onLoadJson)
        self.saveJsonButton.connect('clicked(bool)', self.onSaveJson)
        self.refineVolumeButton.connect('clicked(bool)', self.onRefineVolume)
        self.registerVolumeButton.connect('clicked(bool)',
                                          self.onRegisterVolume)
        self.loadVolumeButton.connect('clicked(bool)', self.onLoadVolume)
        self.loadMaskVolumeButton.connect('clicked(bool)',
                                          self.onLoadMaskVolume)
        self.clearAllVolumeButton.connect('clicked(bool)', self.onClearAll)

        self.maskIdSelector.connect('currentIndexChanged(int)',
                                    self.onMaskIDSelect)

        #
        # advanced
        #
        self.advancedCollapsibleButton = ctk.ctkCollapsibleButton()
        self.advancedCollapsibleButton.text = "Advanced"
        self.layout.addWidget(self.advancedCollapsibleButton)
        self.advancedCollapsibleButton.enabled = False

        self.advancedFormLayout = qt.QFormLayout(
            self.advancedCollapsibleButton)

        # Add vertical spacer
        self.layout.addStretch(1)
    def populate_advanced_tab(self):
        jsonUIInfo = self.logic.getJsonInfo4UI(self.inputJsonFn.currentPath)

        self.advancedOptions = []
        for el in jsonUIInfo:
            #print(el)

            self.idxSlide = ctk.ctkDoubleSpinBox()
            self.advancedFormLayout.addRow("Idx:", self.idxSlide)
            self.idxSlide.setValue(int(el[1]))
            self.idxSlide.setEnabled(False)

            self.rgbPath = ctk.ctkPathLineEdit()
            self.advancedFormLayout.addRow("    Rgb Image:", self.rgbPath)
            self.rgbPath.setCurrentPath(el[2])

            self.doFlip = ctk.ctkCheckBox()
            self.advancedFormLayout.addRow("    Flip:", self.doFlip)
            if (not el[4] == None) and el[4] == 1:
                self.doFlip.setChecked(True)
            else:
                self.doFlip.setChecked(False)

            self.doRotate = ctk.ctkDoubleSpinBox()
            self.advancedFormLayout.addRow("    Rotation angle:",
                                           self.doRotate)
            self.doRotate.minimum = 0.0
            self.doRotate.maximum = 360.0
            self.doRotate.singleStep = 90.0
            if el[5]:
                self.doRotate.setValue(int(el[5]))

            for maskEl in el[3]:
                print(maskEl)
                self.idxMask2 = ctk.ctkDoubleSpinBox()
                self.advancedFormLayout.addRow("        Mask Idx:",
                                               self.idxMask2)
                self.idxMask2.setValue(int(maskEl[0]))
                self.idxMask2.setEnabled(False)

                self.maskPath = ctk.ctkPathLineEdit()
                self.advancedFormLayout.addRow("        Mask Image:",
                                               self.maskPath)
                self.maskPath.setCurrentPath(maskEl[1])

                self.idxMask2.connect(
                    'valueChanged(double)',
                    lambda value, idxSlice=el[0], idxMask=int(maskEl[
                        0]): self.onMaskIdxChange(value, idxSlice, idxMask))

                self.maskPath.connect(
                    'currentPathChanged(QString)',
                    lambda value, idxSlice=el[0], idxMask=int(maskEl[
                        0]): self.onMaskFileChange(value, idxSlice, idxMask))

            Separador = qt.QFrame()
            Separador.setFrameShape(qt.QFrame.HLine)
            Separador.setLineWidth(1)
            self.advancedFormLayout.addRow(Separador)

            self.idxSlide.connect(
                'valueChanged(double)',
                lambda value, idx=el[0]: self.onSliceIdxChange(value, idx))

            self.rgbPath.connect('currentPathChanged(QString)',
                                 lambda value, idx=el[0]: self.
                                 onSliceJsonFileChange(value, idx))

            self.doFlip.connect(
                'stateChanged(int)',
                lambda value, idx=el[0]: self.onSliceFlipChange(value, idx))

            self.doRotate.connect('valueChanged(double)',
                                  lambda value, idx=el[0]: self.
                                  onSliceDoRotateChange(value, idx))

            advancedUIEl = [
                el[0], self.idxSlide, self.rgbPath, self.doRotate,
                self.doRotate
            ]
            self.advancedOptions.append(advancedUIEl)
  def setup(self):

    # Do not show reload&test in developer mode, as debugger is mostly used by developers
    # but they are not interested in debugging this module.
    # ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...


    # Settings Area
    self.settingsCollapsibleButton = ctk.ctkCollapsibleButton()
    self.settingsCollapsibleButton.text = "Settings"
    self.settingsCollapsibleButton.collapsed = True
    self.layout.addWidget(self.settingsCollapsibleButton)
    settingsFormLayout = qt.QFormLayout(self.settingsCollapsibleButton)
    
    # Debugger selector
    self.debuggerSelector = qt.QComboBox()
    self.debuggerSelector.toolTip = "Chose debugger server."
    debugger = self.logic.getDebugger()
    self.debuggerSelector.addItem("Eclipse")
    self.debuggerSelector.addItem("PyCharm")
    if debugger=='Eclipse':
      self.debuggerSelector.currentIndex = 0
    elif debugger=='PyCharm':
      self.debuggerSelector.currentIndex = 1
    else:
      self.debuggerSelector.currentIndex = -1
    settingsFormLayout.addRow("Debugger: ", self.debuggerSelector)
    self.debuggerSelector.connect('currentIndexChanged(int)', self.onDebuggerSelected)
    
    # pydevd.py path selector
    pydevdDir=self.logic.getEclipsePydevdDir(enableAutoDetect=(debugger=='Eclipse'))
    self.pydevdDirSelector = ctk.ctkPathLineEdit()
    self.pydevdDirSelector.setCurrentPath(pydevdDir)
    self.pydevdDirSelector.filters=self.pydevdDirSelector.Dirs
    self.pydevdDirSelector.setMaximumWidth(300)
    self.pydevdDirSelector.setToolTip("Set the path to pydevd.py. It is in the eclipse folder within plugins/...pydev.../pysrc.")
    settingsFormLayout.addRow("Eclipse pydevd.py directory:", self.pydevdDirSelector)

    # pycharm-debug.egg path selector
    pyCharmDebugEggPathSelector=self.logic.getPyCharmDebugEggPath(enableAutoDetect=(debugger=='PyCharm'))
    self.pyCharmDebugEggPathSelector = ctk.ctkPathLineEdit()
    self.pyCharmDebugEggPathSelector.setCurrentPath(pyCharmDebugEggPathSelector)
    self.pyCharmDebugEggPathSelector.nameFilters=['pycharm-debug.egg']
    self.pyCharmDebugEggPathSelector.setMaximumWidth(300)
    self.pyCharmDebugEggPathSelector.setToolTip("Set the path to pycharm-debug.egg . It is in the .../PyCharm/debug-eggs folder.")
    settingsFormLayout.addRow("PyCharm pycharm-debug.egg path:", self.pyCharmDebugEggPathSelector)

    if not self.isCurrentSettingValid():
      self.settingsCollapsibleButton.collapsed = False
    
    # Connection Area
    connectionCollapsibleButton = ctk.ctkCollapsibleButton()
    connectionCollapsibleButton.text = "Connection"
    connectionCollapsibleButton.collapsed = False
    self.layout.addWidget(connectionCollapsibleButton)
    connectionFormLayout = qt.QFormLayout(connectionCollapsibleButton)

    # Connect Button
    self.connectButton = qt.QPushButton("Connect to debug server")
    self.connectButton.toolTip = "Connect to remote debug server"
    self.connectButton.setAutoFillBackground(True)
    self.connectButton.setStyleSheet("background-color: rgb(150, 255, 150); color: rgb(0, 0, 0)")
    connectionFormLayout.addRow(self.connectButton)

    # Auto-connect button (only show after a successful connection to make sure
    # Slicer does not hang on startup due to failed attempt to connect to debugger)
    self.autoConnectCheckBox = qt.QCheckBox()
    self.autoConnectCheckBox.visible = False
    self.autoConnectCheckBox.checked = self.logic.getDebuggerAutoConnect()
    self.autoConnectCheckBox.setToolTip("If checked, Slicer will attempt to connect to the remote debugger on startup.")
    self.autoConnectCheckBoxLabel = qt.QLabel("Auto-connect on next application startup:")
    self.autoConnectCheckBoxLabel.visible = False
    connectionFormLayout.addRow(self.autoConnectCheckBoxLabel, self.autoConnectCheckBox)

    if self.logic.isConnected():
      # already connected
      self.onConnectionComplete(True)
    
    # Connections
    self.connectButton.connect('clicked(bool)', self.onConnect)
    self.autoConnectCheckBox.connect('toggled(bool)', self.onAutoConnectChanged)

    # Add vertical spacer
    self.layout.addStretch(1)
    
    self.onDebuggerSelected()
    def setup(self):
        #
        # Configuration
        #
        self.configCollapsibleButton = ctk.ctkCollapsibleButton()
        self.configCollapsibleButton.text = "Configuration"
        self.layout.addWidget(self.configCollapsibleButton)

        # Layout within the configuration collapsible button
        self.configFormLayout = qt.QFormLayout(self.configCollapsibleButton)

        import platform
        self.elastixPath = ctk.ctkPathLineEdit()
        self.elastixPath.filters = ctk.ctkPathLineEdit.Dirs
        self.configFormLayout.addRow("Elastix Executable Path:",
                                     self.elastixPath)

        if platform.system() == 'Linux':
            self.elastixPath.setCurrentPath(
                '/home/mrusu/Programs/elastix-4.9.0-linux/bin/')
        if platform.system() == 'Windows':
            self.elastixPath.setCurrentPath("C:/Programs/elastix-4.9.0-win64/")

        self.slicerElastixPath = ctk.ctkPathLineEdit()
        self.slicerElastixPath.filters = ctk.ctkPathLineEdit.Dirs
        self.configFormLayout.addRow("Slicer Elastix Path:",
                                     self.slicerElastixPath)

        if platform.system() == 'Linux':
            self.slicerElastixPath.setCurrentPath(
                '/home/mrusu/Programs/SlicerElastix/Elastix')
        if platform.system() == 'Windows':
            self.slicerElastixPath.setCurrentPath(
                "C:/Programs/SlicerElastix/Elastix/")

        #
        # Input
        #
        self.inputCollapsibleButton = ctk.ctkCollapsibleButton()
        self.inputCollapsibleButton.text = "Input"
        self.layout.addWidget(self.inputCollapsibleButton)

        # Layout within the input collapsible button
        self.inputFormLayout = qt.QFormLayout(self.inputCollapsibleButton)

        #
        # rgb volume selector
        #
        self.inputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.inputVolumeSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.inputVolumeSelector.selectNodeUponCreation = True
        self.inputVolumeSelector.addEnabled = False
        self.inputVolumeSelector.removeEnabled = False
        self.inputVolumeSelector.noneEnabled = False
        self.inputVolumeSelector.showHidden = False
        self.inputVolumeSelector.showChildNodeTypes = False
        self.inputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.inputFormLayout.addRow("Fixed volume: ", self.inputVolumeSelector)

        ###
        """
        self.fixedVolumeMaskSelector = slicer.qMRMLNodeComboBox()
        self.fixedVolumeMaskSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.fixedVolumeMaskSelector.addEnabled = False
        self.fixedVolumeMaskSelector.removeEnabled = False
        self.fixedVolumeMaskSelector.noneEnabled = True
        self.fixedVolumeMaskSelector.showHidden = False
        self.fixedVolumeMaskSelector.showChildNodeTypes = False
        self.fixedVolumeMaskSelector.setMRMLScene( slicer.mrmlScene )
        self.inputFormLayout.addRow("Fixed volume mask: ", self.fixedVolumeMaskSelector)
        
        self.movingVolumeSelector = slicer.qMRMLNodeComboBox()
        self.movingVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.movingVolumeSelector.selectNodeUponCreation = True
        self.movingVolumeSelector.addEnabled = False
        self.movingVolumeSelector.removeEnabled = False
        self.movingVolumeSelector.noneEnabled = False
        self.movingVolumeSelector.showHidden = False
        self.movingVolumeSelector.showChildNodeTypes = False
        self.movingVolumeSelector.setMRMLScene( slicer.mrmlScene )
        self.inputFormLayout.addRow("Moving volume: ", self.movingVolumeSelector)


        #
        # moving volume mask selector
        #
        self.movingVolumeMaskSelector = slicer.qMRMLNodeComboBox()
        self.movingVolumeMaskSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.movingVolumeMaskSelector.selectNodeUponCreation = True
        self.movingVolumeMaskSelector.addEnabled = False
        self.movingVolumeMaskSelector.removeEnabled = False
        self.movingVolumeMaskSelector.noneEnabled = True
        self.movingVolumeMaskSelector.showHidden = False
        self.movingVolumeMaskSelector.showChildNodeTypes = False
        self.movingVolumeMaskSelector.setMRMLScene( slicer.mrmlScene )
        self.movingVolumeMaskSelector.setToolTip("Moving volume mask")
        self.inputFormLayout.addRow("Moving volume mask: ", self.movingVolumeMaskSelector)
        """

        #
        #Output
        #
        self.outputCollapsibleButton = ctk.ctkCollapsibleButton()
        self.outputCollapsibleButton.text = "Output"
        self.layout.addWidget(self.outputCollapsibleButton)

        # Layout within the output collapsible button
        self.outputFormLayout = qt.QFormLayout(self.outputCollapsibleButton)

        #
        # output volume selector
        #
        self.outputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.outputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.outputVolumeSelector.selectNodeUponCreation = True
        self.outputVolumeSelector.addEnabled = True
        self.outputVolumeSelector.renameEnabled = True
        self.outputVolumeSelector.removeEnabled = True
        self.outputVolumeSelector.noneEnabled = True
        self.outputVolumeSelector.showHidden = False
        self.outputVolumeSelector.showChildNodeTypes = False
        self.outputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.outputFormLayout.addRow("Output volume: ",
                                     self.outputVolumeSelector)
        """
        #
        # output transform selector
        #
        self.outputTransformSelector = slicer.qMRMLNodeComboBox()
        self.outputTransformSelector.nodeTypes = ["vtkMRMLTransformNode"]
        self.outputTransformSelector.selectNodeUponCreation = True
        self.outputTransformSelector.addEnabled = True
        self.outputTransformSelector.renameEnabled = True
        self.outputTransformSelector.removeEnabled = True
        self.outputTransformSelector.noneEnabled = True
        self.outputTransformSelector.showHidden = False
        self.outputTransformSelector.showChildNodeTypes = False
        self.outputTransformSelector.setMRMLScene( slicer.mrmlScene )
        self.outputFormLayout.addRow("Output transform: ", self.outputTransformSelector)

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

        #
        # Status and Progress
        #
        statusLabel = qt.QLabel("Status: ")
        self.currentStatusLabel = qt.QLabel("Idle")
        hlayout = qt.QHBoxLayout()
        hlayout.addStretch(1)
        hlayout.addWidget(statusLabel)
        hlayout.addWidget(self.currentStatusLabel)
        self.layout.addLayout(hlayout)

        self.progress = qt.QProgressBar()
        self.progress.setRange(0, 1000)
        self.progress.setValue(0)
        self.layout.addWidget(self.progress)
        self.progress.hide()

        #Cancel
        self.cancelButton = qt.QPushButton("Cancel")
        self.cancelButton.toolTip = "Abort the algorithm."
        self.cancelButton.enabled = False

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the Radiology-Pathology Fusion."
        self.applyButton.enabled = True

        # Test button
        self.testButton = qt.QPushButton("Test")
        self.testButton.toolTip = "Text elastix."
        self.testButton.enabled = True

        hlayout = qt.QHBoxLayout()

        hlayout.addWidget(self.testButton)
        hlayout.addStretch(1)
        hlayout.addWidget(self.cancelButton)
        hlayout.addWidget(self.applyButton)
        self.layout.addLayout(hlayout)

        self.cancelButton.connect('clicked(bool)', self.onCancel)
        self.applyButton.connect('clicked(bool)', self.onApply)
        self.testButton.connect('clicked(bool)', self.onTest)
Exemple #16
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

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

    self.inputDirSelector = ctk.ctkPathLineEdit()
    self.inputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.inputDirSelector.settingKey = 'DICOMPatcherInputDir'
    parametersFormLayout.addRow("Input DICOM directory:", self.inputDirSelector)

    self.outputDirSelector = ctk.ctkPathLineEdit()
    self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.outputDirSelector.settingKey = 'DICOMPatcherOutputDir'
    parametersFormLayout.addRow("Output DICOM directory:", self.outputDirSelector)

    self.normalizeFileNamesCheckBox = qt.QCheckBox()
    self.normalizeFileNamesCheckBox.checked = True
    self.normalizeFileNamesCheckBox.setToolTip("Replace file and folder names with automatically generated names."
      " Fixes errors caused by file path containins special characters or being too long.")
    parametersFormLayout.addRow("Normalize file names", self.normalizeFileNamesCheckBox)

    self.forceSamePatientNameIdInEachDirectoryCheckBox = qt.QCheckBox()
    self.forceSamePatientNameIdInEachDirectoryCheckBox.checked = False
    self.forceSamePatientNameIdInEachDirectoryCheckBox.setToolTip("Generate patient name and ID from the first file in a directory"
      " and force all other files in the same directory to have the same patient name and ID."
      " Enable this option if a separate patient directory is created for each patched file.")
    parametersFormLayout.addRow("Force same patient name and ID in each directory", self.forceSamePatientNameIdInEachDirectoryCheckBox)

    self.generateMissingIdsCheckBox = qt.QCheckBox()
    self.generateMissingIdsCheckBox.checked = True
    self.generateMissingIdsCheckBox.setToolTip("Generate missing patient, study, series IDs. It is assumed that"
      " all files in a directory belong to the same series. Fixes error caused by too aggressive anonymization"
      " or incorrect DICOM image converters.")
    parametersFormLayout.addRow("Generate missing patient/study/series IDs", self.generateMissingIdsCheckBox)

    self.generateImagePositionFromSliceThicknessCheckBox = qt.QCheckBox()
    self.generateImagePositionFromSliceThicknessCheckBox.checked = True
    self.generateImagePositionFromSliceThicknessCheckBox.setToolTip("Generate 'image position sequence' for"
      " multi-frame files that only have 'SliceThickness' field. Fixes error in Dolphin 3D CBCT scanners.")
    parametersFormLayout.addRow("Generate slice position for multi-frame volumes", self.generateImagePositionFromSliceThicknessCheckBox)

    self.anonymizeDicomCheckBox = qt.QCheckBox()
    self.anonymizeDicomCheckBox.checked = False
    self.anonymizeDicomCheckBox.setToolTip("If checked, then some patient identifiable information will be removed"
      " from the patched DICOM files. There are many fields that can identify a patient, this function does not remove all of them.")
    parametersFormLayout.addRow("Partially anonymize", self.anonymizeDicomCheckBox)

    #
    # Patch Button
    #
    self.patchButton = qt.QPushButton("Patch")
    self.patchButton.toolTip = "Fix DICOM files in input directory and write them to output directory"
    parametersFormLayout.addRow(self.patchButton)

    #
    # Import Button
    #
    self.importButton = qt.QPushButton("Import")
    self.importButton.toolTip = "Import DICOM files in output directory into Slicer DICOM database"
    parametersFormLayout.addRow(self.importButton)

    #
    # Switch to DICOM module Button
    #
    self.switchToDICOMModuleButton = qt.QPushButton("Go to DICOM module")
    self.switchToDICOMModuleButton.toolTip = "Open DICOM module where imported data can be loaded into the scene"
    parametersFormLayout.addRow(self.switchToDICOMModuleButton)

    # connections
    self.patchButton.connect('clicked(bool)', self.onPatchButton)
    self.importButton.connect('clicked(bool)', self.onImportButton)
    self.switchToDICOMModuleButton.connect('clicked(bool)', self.onSwitchToDICOMModuleButton)

    self.statusLabel = qt.QPlainTextEdit()
    self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
    parametersFormLayout.addRow(self.statusLabel)

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

    self.logic = DICOMPatcherLogic()
    self.logic.logCallback = self.addLog
Exemple #17
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 = "BabyBrowser 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)

    #
    # Data Area
    #
    dataCollapsibleButton = ctk.ctkCollapsibleButton()
    dataCollapsibleButton.text = "Data"
    self.layout.addWidget(dataCollapsibleButton)
    dataFormLayout = qt.QFormLayout(dataCollapsibleButton)

    # pick the data directory and file pattern
    self.pathEdit = ctk.ctkPathLineEdit()
    self.pathEdit.setCurrentPath('/Users/pieper/data/babybrains/to_mprage-19/')
    self.patternEdit = qt.QLineEdit()
    self.patternEdit.setText('mprage-%d.nrrd')
    self.loadButton = qt.QPushButton()
    self.loadButton.text = "Load Data"
    self.dataSlider = ctk.ctkSliderWidget()
    self.dataSlider.setDecimals(0)
    self.dataSlider.enabled = False
    dataFormLayout.addRow("Data path: ", self.pathEdit)
    dataFormLayout.addRow("Data pattern: ", self.patternEdit)
    dataFormLayout.addRow(self.loadButton)
    dataFormLayout.addRow("Data Select", self.dataSlider)

    self.loadButton.connect('clicked()', self.onLoad)
    self.dataSlider.connect('valueChanged(double)', self.onDataSlider)


    #
    # Parameters Area
    #
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters"
    parametersCollapsibleButton.collapsed = True
    self.layout.addWidget(parametersCollapsibleButton)

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

    #
    # input volume selector
    #
    self.inputSelector = slicer.qMRMLNodeComboBox()
    self.inputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    self.inputSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 )
    self.inputSelector.selectNodeUponCreation = True
    self.inputSelector.addEnabled = False
    self.inputSelector.removeEnabled = False
    self.inputSelector.noneEnabled = False
    self.inputSelector.showHidden = False
    self.inputSelector.showChildNodeTypes = False
    self.inputSelector.setMRMLScene( slicer.mrmlScene )
    self.inputSelector.setToolTip( "Pick the input to the algorithm." )
    parametersFormLayout.addRow("Input Volume: ", self.inputSelector)

    #
    # output volume selector
    #
    self.outputSelector = slicer.qMRMLNodeComboBox()
    self.outputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    self.outputSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 )
    self.outputSelector.selectNodeUponCreation = False
    self.outputSelector.addEnabled = True
    self.outputSelector.removeEnabled = True
    self.outputSelector.noneEnabled = False
    self.outputSelector.showHidden = False
    self.outputSelector.showChildNodeTypes = False
    self.outputSelector.setMRMLScene( slicer.mrmlScene )
    self.outputSelector.setToolTip( "Pick the output to the algorithm." )
    parametersFormLayout.addRow("Output Volume: ", self.outputSelector)

    #
    # Apply Button
    #
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = False
    parametersFormLayout.addRow(self.applyButton)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

    # Add vertical spacer
    self.layout.addStretch(1)
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

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

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

        self.inputDirSelector = ctk.ctkPathLineEdit()
        self.inputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
        self.inputDirSelector.settingKey = 'DicomPatcherInputDir'
        parametersFormLayout.addRow("Input DICOM directory:",
                                    self.inputDirSelector)

        self.outputDirSelector = ctk.ctkPathLineEdit()
        self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
        self.outputDirSelector.settingKey = 'DicomPatcherOutputDir'
        parametersFormLayout.addRow("Output DICOM directory:",
                                    self.outputDirSelector)

        self.generateMissingIdsCheckBox = qt.QCheckBox()
        self.generateMissingIdsCheckBox.checked = True
        self.generateMissingIdsCheckBox.setToolTip(
            "If checked, then missing patient, study, series IDs are generated. It is assumed that all files in a directory belong to the same series. Fixes error caused by too aggressive anonymization or incorrect DICOM image converters."
        )
        parametersFormLayout.addRow("Generate missing IDs",
                                    self.generateMissingIdsCheckBox)

        self.generateImagePositionFromSliceThicknessCheckBox = qt.QCheckBox()
        self.generateImagePositionFromSliceThicknessCheckBox.checked = True
        self.generateImagePositionFromSliceThicknessCheckBox.setToolTip(
            "If checked, then image position sequence is generated for multi-frame files that only have SliceThickness field. Fixes error in Dolphin 3D CBCT scanners."
        )
        parametersFormLayout.addRow(
            "Generate slice position for multi-frame volumes",
            self.generateImagePositionFromSliceThicknessCheckBox)

        self.anonymizeDicomCheckBox = qt.QCheckBox()
        self.anonymizeDicomCheckBox.checked = False
        self.anonymizeDicomCheckBox.setToolTip(
            "If checked, then some patient identifiable information will be removed from the patched DICOM files. There are many fields that can identify a patient, this function does not remove all of them."
        )
        parametersFormLayout.addRow("Anonymize DICOM files",
                                    self.anonymizeDicomCheckBox)

        #
        # Patch Button
        #
        self.patchButton = qt.QPushButton("Patch")
        self.patchButton.toolTip = "Fix and optionally anonymize DICOM files"
        parametersFormLayout.addRow(self.patchButton)

        # connections
        self.patchButton.connect('clicked(bool)', self.onPatchButton)

        self.statusLabel = qt.QPlainTextEdit()
        self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
        parametersFormLayout.addRow(self.statusLabel)

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

        self.logic = DicomPatcherLogic()
        self.logic.logCallback = self.addLog
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = BitmapGeneratorLogic()

        # Instantiate and connect widgets ...

        #
        # Printer parameters Area
        #
        printerParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        printerParametersCollapsibleButton.text = "Printer parameters"
        self.layout.addWidget(printerParametersCollapsibleButton)

        # Layout within the dummy collapsible button
        printerParametersFormLayout = qt.QFormLayout(
            printerParametersCollapsibleButton)

        self.xResolutionDpiSpinBox = ctk.ctkDoubleSpinBox()
        self.xResolutionDpiSpinBox.setToolTip(
            "Resolution of exported images along X axis.")
        self.xResolutionDpiSpinBox.decimals = 0
        self.xResolutionDpiSpinBox.minimum = 60
        self.xResolutionDpiSpinBox.maximum = 2400
        self.xResolutionDpiSpinBox.suffix = "DPI"
        self.xResolutionDpiSpinBox.value = self.logic.xResolutionDpi
        self.xResolutionDpiSpinBox.singleStep = 100
        printerParametersFormLayout.addRow("X resolution: ",
                                           self.xResolutionDpiSpinBox)

        self.yResolutionDpiSpinBox = ctk.ctkDoubleSpinBox()
        self.yResolutionDpiSpinBox.setToolTip(
            "Resolution of exported images along Y axis.")
        self.yResolutionDpiSpinBox.decimals = 0
        self.yResolutionDpiSpinBox.minimum = 60
        self.yResolutionDpiSpinBox.maximum = 2400
        self.yResolutionDpiSpinBox.suffix = "DPI"
        self.yResolutionDpiSpinBox.value = self.logic.yResolutionDpi
        self.yResolutionDpiSpinBox.singleStep = 100
        printerParametersFormLayout.addRow("Y resolution: ",
                                           self.yResolutionDpiSpinBox)

        self.layerThicknessMmSpinBox = ctk.ctkDoubleSpinBox()
        self.layerThicknessMmSpinBox.setToolTip(
            "Distance between extracted image slices.")
        self.layerThicknessMmSpinBox.decimals = 4
        self.layerThicknessMmSpinBox.minimum = 0.0001
        self.layerThicknessMmSpinBox.maximum = 50.0
        self.layerThicknessMmSpinBox.suffix = "mm"
        self.layerThicknessMmSpinBox.value = self.logic.slabSpacingMm
        self.layerThicknessMmSpinBox.singleStep = 0.1
        printerParametersFormLayout.addRow("Layer thickness: ",
                                           self.layerThicknessMmSpinBox)

        #
        # Output parameters Area
        #
        outputParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        outputParametersCollapsibleButton.text = "Output parameters"
        self.layout.addWidget(outputParametersCollapsibleButton)

        # Layout within the dummy collapsible button
        outputParametersFormLayout = qt.QFormLayout(
            outputParametersCollapsibleButton)

        self.printScaleSpinBox = ctk.ctkDoubleSpinBox()
        self.printScaleSpinBox.setToolTip(
            "Scale of print size relative to real life size. 1.0 means printing in real life size, <1.0 means printed objects are smaller than in real life."
        )
        self.printScaleSpinBox.decimals = 3
        self.printScaleSpinBox.minimum = 0.01
        self.printScaleSpinBox.maximum = 100.0
        self.printScaleSpinBox.suffix = "x"
        self.printScaleSpinBox.value = self.logic.printScale
        self.printScaleSpinBox.singleStep = 0.1
        outputParametersFormLayout.addRow("Scale: ", self.printScaleSpinBox)

        #
        # Path
        #
        self.dirPath = ctk.ctkPathLineEdit()
        self.dirPath.filters = ctk.ctkPathLineEdit.Dirs
        self.dirPath.settingKey = 'BitmapGeneratorOutputFolder'
        #self.dirPath.currentPath = "/tmp"
        outputParametersFormLayout.addRow("Output folder: ", self.dirPath)

        #
        # Apply Button
        #
        self.applyButtonLabelGenerate = "Generate bitmaps"
        self.applyButtonLabelCancel = "Cancel"
        self.applyButton = qt.QPushButton(self.applyButtonLabelGenerate)
        self.applyButton.toolTip = "Start/cancel bitmap generation"
        outputParametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)

        # Add vertical spacer
        self.layout.addStretch(1)
Exemple #20
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        #
        # Multi Texture Section
        #

        multiTextureParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        multiTextureParametersCollapsibleButton.text = "Import Multi Texture OBJ"
        self.layout.addWidget(multiTextureParametersCollapsibleButton)
        multiTextureParametersCollapsibleButton.collapsed = True

        # Layout within the dummy collapsible button
        multiTextureparametersFormLayout = qt.QFormLayout(
            multiTextureParametersCollapsibleButton)

        # Input OBJ file path
        self.baseMeshSelector = ctk.ctkPathLineEdit()
        self.baseMeshSelector.nameFilters = ["*.obj"]
        multiTextureparametersFormLayout.addRow("Model file: ",
                                                self.baseMeshSelector)

        # Input MTL file path
        self.materialFileSelector = ctk.ctkPathLineEdit()
        self.materialFileSelector.nameFilters = ["*.mtl"]
        multiTextureparametersFormLayout.addRow("Material file: ",
                                                self.materialFileSelector)

        # Input texture image directory path
        self.textureDirectory = ctk.ctkPathLineEdit()
        self.textureDirectory.filters = ctk.ctkPathLineEdit.Dirs
        self.textureDirectory.setToolTip(
            "Select directory containing texture images")
        multiTextureparametersFormLayout.addRow("Texture directory: ",
                                                self.textureDirectory)

        self.multiTextureAddColorAsPointAttributeComboBox = qt.QComboBox()
        self.multiTextureAddColorAsPointAttributeComboBox.addItem("disabled")
        self.multiTextureAddColorAsPointAttributeComboBox.addItem(
            "separate scalars")
        self.multiTextureAddColorAsPointAttributeComboBox.addItem(
            "single vector")
        self.multiTextureAddColorAsPointAttributeComboBox.setCurrentIndex(0)
        self.multiTextureAddColorAsPointAttributeComboBox.setToolTip(
            "It is useful if further color-based filtering will be performed on the model."
        )
        multiTextureparametersFormLayout.addRow(
            "Save color information as point data: ",
            self.multiTextureAddColorAsPointAttributeComboBox)

        #
        # Apply Button
        #
        self.multiTextureApplyButton = qt.QPushButton("Import")
        self.multiTextureApplyButton.toolTip = "Import model with multiple texture images to scene."
        self.multiTextureApplyButton.enabled = False
        multiTextureparametersFormLayout.addRow(self.multiTextureApplyButton)

        # connections
        self.multiTextureApplyButton.connect('clicked(bool)',
                                             self.onMultiTextureApplyButton)
        self.baseMeshSelector.connect("validInputChanged(bool)",
                                      self.onMultiTextureSelect)
        self.materialFileSelector.connect("validInputChanged(bool)",
                                          self.onMultiTextureSelect)
        self.textureDirectory.connect("validInputChanged(bool)",
                                      self.onMultiTextureSelect)

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

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

        #
        # input volume selector
        #
        self.inputModelSelector = slicer.qMRMLNodeComboBox()
        self.inputModelSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.inputModelSelector.addEnabled = False
        self.inputModelSelector.removeEnabled = True
        self.inputModelSelector.renameEnabled = True
        self.inputModelSelector.noneEnabled = False
        self.inputModelSelector.showHidden = False
        self.inputModelSelector.showChildNodeTypes = False
        self.inputModelSelector.setMRMLScene(slicer.mrmlScene)
        self.inputModelSelector.setToolTip(
            "Model node containing geometry and texture coordinates.")
        parametersFormLayout.addRow("Model: ", self.inputModelSelector)

        #input texture selector
        self.inputTextureSelector = slicer.qMRMLNodeComboBox()
        self.inputTextureSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.inputTextureSelector.addEnabled = False
        self.inputTextureSelector.removeEnabled = True
        self.inputTextureSelector.renameEnabled = True
        self.inputTextureSelector.noneEnabled = False
        self.inputTextureSelector.showHidden = False
        self.inputTextureSelector.showChildNodeTypes = False
        self.inputTextureSelector.setMRMLScene(slicer.mrmlScene)
        self.inputTextureSelector.setToolTip(
            "Color image containing texture image.")
        parametersFormLayout.addRow("Texture: ", self.inputTextureSelector)

        self.addColorAsPointAttributeComboBox = qt.QComboBox()
        self.addColorAsPointAttributeComboBox.addItem("disabled")
        self.addColorAsPointAttributeComboBox.addItem("separate scalars")
        self.addColorAsPointAttributeComboBox.addItem("single vector")
        self.addColorAsPointAttributeComboBox.setCurrentIndex(0)
        self.addColorAsPointAttributeComboBox.setToolTip(
            "It is useful if further color-based filtering will be performed on the model."
        )
        parametersFormLayout.addRow("Save color information as point data: ",
                                    self.addColorAsPointAttributeComboBox)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Apply texture to selected model."
        self.applyButton.enabled = False
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.inputModelSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                        self.onSelect)
        self.inputTextureSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                          self.onSelect)

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

        # Refresh Apply button state
        self.onSelect()
        self.onMultiTextureSelect()
Exemple #21
0
    def setupAdvancedPanel(self):
        logging.debug('setupAdvancedPanel')

        self.advancedCollapsibleButton.setProperty('collapsedHeight', 20)
        self.advancedCollapsibleButton.text = "Settings"
        self.sliceletPanelLayout.addWidget(self.advancedCollapsibleButton)

        self.advancedLayout = qt.QFormLayout(self.advancedCollapsibleButton)
        self.advancedLayout.setContentsMargins(12, 4, 4, 4)
        self.advancedLayout.setSpacing(4)

        # Layout selection combo box
        self.viewSelectorComboBox = qt.QComboBox(
            self.advancedCollapsibleButton)
        self.setupViewerLayouts()
        self.advancedLayout.addRow("Layout: ", self.viewSelectorComboBox)

        self.registerCustomLayouts()

        self.selectView(self.VIEW_ULTRASOUND_3D)

        # OpenIGTLink connector node selection
        self.linkInputSelector = slicer.qMRMLNodeComboBox()
        self.linkInputSelector.nodeTypes = ("vtkMRMLIGTLConnectorNode", "")
        self.linkInputSelector.selectNodeUponCreation = True
        self.linkInputSelector.addEnabled = False
        self.linkInputSelector.removeEnabled = True
        self.linkInputSelector.noneEnabled = False
        self.linkInputSelector.showHidden = False
        self.linkInputSelector.showChildNodeTypes = False
        self.linkInputSelector.setMRMLScene(slicer.mrmlScene)
        self.linkInputSelector.setToolTip("Select connector node")
        self.advancedLayout.addRow("OpenIGTLink connector: ",
                                   self.linkInputSelector)

        self.showFullSlicerInterfaceButton = qt.QPushButton()
        self.showFullSlicerInterfaceButton.setText(
            "Show 3D Slicer user interface")
        self.advancedLayout.addRow(self.showFullSlicerInterfaceButton)

        self.showGuideletFullscreenButton = qt.QPushButton()
        self.showGuideletFullscreenButton.setText(
            "Show Guidelet in full screen")
        self.advancedLayout.addRow(self.showGuideletFullscreenButton)

        self.saveSceneButton = qt.QPushButton()
        self.saveSceneButton.setText("Save Guidelet scene")
        self.advancedLayout.addRow(self.saveSceneButton)

        self.saveDirectoryLineEdit = ctk.ctkPathLineEdit()
        node = self.logic.getParameterNode()
        sceneSaveDirectory = node.GetParameter('SavedScenesDirectory')
        self.saveDirectoryLineEdit.currentPath = sceneSaveDirectory
        self.saveDirectoryLineEdit.filters = ctk.ctkPathLineEdit.Dirs
        self.saveDirectoryLineEdit.options = ctk.ctkPathLineEdit.DontUseSheet
        self.saveDirectoryLineEdit.options = ctk.ctkPathLineEdit.ShowDirsOnly
        self.saveDirectoryLineEdit.showHistoryButton = False
        self.saveDirectoryLineEdit.setMinimumWidth(100)
        self.saveDirectoryLineEdit.setMaximumWidth(500)

        saveLabel = qt.QLabel()
        saveLabel.setText("Save scene directory:")
        hbox = qt.QHBoxLayout()
        hbox.addWidget(saveLabel)
        hbox.addWidget(self.saveDirectoryLineEdit)
        self.advancedLayout.addRow(hbox)

        self.exitButton = qt.QPushButton()
        self.exitButton.setText("Exit")
        self.advancedLayout.addRow(self.exitButton)
Exemple #22
0
  def setupAdvancedPanel(self):
    logging.debug('setupAdvancedPanel')

    self.advancedCollapsibleButton.setProperty('collapsedHeight', 20)
    self.advancedCollapsibleButton.text = "Settings"
    self.sliceletPanelLayout.addWidget(self.advancedCollapsibleButton)

    self.advancedLayout = qt.QFormLayout(self.advancedCollapsibleButton)
    self.advancedLayout.setContentsMargins(12, 4, 4, 4)
    self.advancedLayout.setSpacing(4)

    # Layout selection combo box
    self.viewSelectorComboBox = qt.QComboBox(self.advancedCollapsibleButton)
    self.advancedLayout.addRow("Layout: ", self.viewSelectorComboBox)

    self.registerDefaultGuideletLayouts()

    self.selectView(self.VIEW_ULTRASOUND_3D)

    # OpenIGTLink connector node selection
    self.linkInputSelector = slicer.qMRMLNodeComboBox()
    self.linkInputSelector.nodeTypes = ("vtkMRMLIGTLConnectorNode", "")
    self.linkInputSelector.selectNodeUponCreation = True
    self.linkInputSelector.addEnabled = False
    self.linkInputSelector.removeEnabled = True
    self.linkInputSelector.noneEnabled = False
    self.linkInputSelector.showHidden = False
    self.linkInputSelector.showChildNodeTypes = False
    self.linkInputSelector.setMRMLScene( slicer.mrmlScene )
    self.linkInputSelector.setToolTip( "Select connector node" )
    self.advancedLayout.addRow("OpenIGTLink connector: ", self.linkInputSelector)

    self.showFullSlicerInterfaceButton = qt.QPushButton()
    self.showFullSlicerInterfaceButton.setText("Show 3D Slicer user interface")
    self.advancedLayout.addRow(self.showFullSlicerInterfaceButton)

    self.showGuideletFullscreenButton = qt.QPushButton()
    self.showGuideletFullscreenButton.setText("Show Guidelet in full screen")
    self.advancedLayout.addRow(self.showGuideletFullscreenButton)

    self.saveSceneButton = qt.QPushButton()
    self.saveSceneButton.setText("Save Guidelet scene")
    self.advancedLayout.addRow(self.saveSceneButton)

    self.saveDirectoryLineEdit = ctk.ctkPathLineEdit()
    node = self.logic.getParameterNode()
    sceneSaveDirectory = node.GetParameter('SavedScenesDirectory')
    self.saveDirectoryLineEdit.currentPath = sceneSaveDirectory
    self.saveDirectoryLineEdit.filters = ctk.ctkPathLineEdit.Dirs
    self.saveDirectoryLineEdit.options = ctk.ctkPathLineEdit.DontUseSheet
    self.saveDirectoryLineEdit.options = ctk.ctkPathLineEdit.ShowDirsOnly
    self.saveDirectoryLineEdit.showHistoryButton = False
    self.saveDirectoryLineEdit.setMinimumWidth(100)
    self.saveDirectoryLineEdit.setMaximumWidth(500)

    saveLabel = qt.QLabel()
    saveLabel.setText("Save scene directory:")
    hbox = qt.QHBoxLayout()
    hbox.addWidget(saveLabel)
    hbox.addWidget(self.saveDirectoryLineEdit)
    self.advancedLayout.addRow(hbox)

    self.exitButton = qt.QPushButton()
    self.exitButton.setText("Exit")
    self.advancedLayout.addRow(self.exitButton)