コード例 #1
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)

    #
    # Select landmark folder to import
    #

    self.inputDirectory = ctk.ctkDirectoryButton()
    self.inputDirectory.directory = qt.QDir.homePath()
    self.inputDirectory.setToolTip('Select Directory with fcsv lanmark files')
    parametersFormLayout.addRow("Input Directory:", self.inputDirectory)

    #
    # output directory selector
    #
    self.outputDirectory = ctk.ctkDirectoryButton()
    self.outputDirectory.directory = qt.QDir.homePath()
    parametersFormLayout.addRow("Output Directory:", self.outputDirectory)

    #
    # enter filename for output
    #
    self.outputFileName = qt.QLineEdit()
    self.outputFileName.text = "morphoJOutput"
    parametersFormLayout.addRow("Name of output file:", self.outputFileName)

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

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

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

    # Refresh Apply button state
    self.onSelectInput()
コード例 #2
0
ファイル: PIS.py プロジェクト: YuliethMunoz/3D-Slicer
    def setup(self):

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

        ######Importar el volumen en formato DICOM#####################################
        importDataCollapsibleButton = ctk.ctkCollapsibleButton()
        importDataCollapsibleButton.text = "DICOM"
        self.layout.addWidget(importDataCollapsibleButton)

        importDataFormLayout = qt.QFormLayout(importDataCollapsibleButton)

        self.__fDialog = ctk.ctkDirectoryButton()
        self.__fDialog.caption = 'Input directory'
        importDataFormLayout.addRow('Input directory:', self.__fDialog)

        # Boton de importar

        self.buttonImport = qt.QPushButton("Boton")
        self.buttonImport.toolTip = "Run the algorithm."
        ##self.buttonImport.enabled = True
        importDataFormLayout.addRow("                                       ",
                                    self.buttonImport)

        self.buttonImport.connect('clicked(bool)', self.importFunction)

        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLMultiVolumeNode"]
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = True
        self.inputSelector.noneEnabled = True
        self.inputSelector.showHidden = True
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip("Pick the input to the algorithm.")
        importDataFormLayout.addRow("Volumen 4D: ", self.inputSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.inputSelector, 'setMRMLScene(vtkMRMLScene*)')

        #### Crear desplegable para seleccionar direccion del volumen
        self.__fDialogOutput = ctk.ctkDirectoryButton()
        self.__fDialogOutput.caption = 'DICOM directory'
        importDataFormLayout.addRow('DiCOM directory:', self.__fDialogOutput)
コード例 #3
0
    def __init__(self, parent):
        vBoxLayout = qt.QVBoxLayout(parent)
        # Add generic settings
        genericGroupBox = ctk.ctkCollapsibleGroupBox()
        genericGroupBox.title = "Generic DICOM settings"
        genericGroupBoxFormLayout = qt.QFormLayout(genericGroupBox)

        directoryButton = ctk.ctkDirectoryButton()
        genericGroupBoxFormLayout.addRow("Database location:", directoryButton)
        parent.registerProperty(slicer.dicomDatabaseDirectorySettingsKey,
                                directoryButton, "directory",
                                str(qt.SIGNAL("directoryChanged(QString)")),
                                "DICOM general settings",
                                ctk.ctkSettingsPanel.OptionRequireRestart)
        # Restart is forced because no mechanism is implemented that would reopen the DICOM database after
        # folder location is changed. It is easier to restart the application than implementing an update
        # mechanism.

        loadReferencesComboBox = ctk.ctkComboBox()
        loadReferencesComboBox.toolTip = "Determines whether referenced DICOM series are " \
          "offered when loading DICOM, or the automatic behavior if interaction is disabled. " \
          "Interactive selection of referenced series is the default selection"
        loadReferencesComboBox.addItem("Ask user", qt.QMessageBox.InvalidRole)
        loadReferencesComboBox.addItem("Always", qt.QMessageBox.Yes)
        loadReferencesComboBox.addItem("Never", qt.QMessageBox.No)
        loadReferencesComboBox.currentIndex = 0
        genericGroupBoxFormLayout.addRow("Load referenced series:",
                                         loadReferencesComboBox)
        parent.registerProperty("DICOM/automaticallyLoadReferences",
                                loadReferencesComboBox,
                                "currentUserDataAsString",
                                str(qt.SIGNAL("currentIndexChanged(int)")))

        detailedLoggingCheckBox = qt.QCheckBox()
        detailedLoggingCheckBox.toolTip = (
            "Log more details during DICOM operations."
            " Useful for investigating DICOM loading issues but may impact performance."
        )
        genericGroupBoxFormLayout.addRow("Detailed logging:",
                                         detailedLoggingCheckBox)
        detailedLoggingMapper = ctk.ctkBooleanMapper(
            detailedLoggingCheckBox, "checked",
            str(qt.SIGNAL("toggled(bool)")))
        parent.registerProperty("DICOM/detailedLogging", detailedLoggingMapper,
                                "valueAsInt",
                                str(qt.SIGNAL("valueAsIntChanged(int)")))

        vBoxLayout.addWidget(genericGroupBox)

        # Add settings panel for the plugins
        plugins = slicer.modules.dicomPlugins
        for pluginName in plugins.keys():
            if hasattr(plugins[pluginName], 'settingsPanelEntry'):
                pluginGroupBox = ctk.ctkCollapsibleGroupBox()
                pluginGroupBox.title = pluginName
                vBoxLayout.addWidget(pluginGroupBox)
                plugins[pluginName].settingsPanelEntry(parent, pluginGroupBox)
        vBoxLayout.addStretch(1)
コード例 #4
0
 def setupsetupUI(self):
   self.setupUserName = qt.QLineEdit()
   self.setupGroupBoxLayout.addRow("Username:"******"Password:"******"Data directory:") )
   self.setupGroupBoxLayout.addWidget(self.dataDirButton)
コード例 #5
0
 def setupsubmissionUI(self):
     self.dataDirButton = ctk.ctkDirectoryButton()
     self.submissionGroupBoxLayout.addWidget(qt.QLabel("Data directory:"))
     self.submissionGroupBoxLayout.addWidget(self.dataDirButton)
     self.SaveButton = qt.QPushButton("Save")
     self.submissionGroupBoxLayout.addWidget(self.SaveButton)
     self.SaveButton.connect('clicked()', self.onSaveButtonClicked)
     self.WebSaveButton = qt.QPushButton("Submit to web")
     self.submissionGroupBoxLayout.addWidget(self.WebSaveButton)
     self.WebSaveButton.connect('clicked()', self.onWebSaveButtonClicked)
コード例 #6
0
 def setupsubmissionUI(self):
   self.dataDirButton = ctk.ctkDirectoryButton()
   self.submissionGroupBoxLayout.addWidget(qt.QLabel("Data directory:") )
   self.submissionGroupBoxLayout.addWidget(self.dataDirButton)
   self.SaveButton = qt.QPushButton("Save")
   self.submissionGroupBoxLayout.addWidget(self.SaveButton)
   self.SaveButton.connect('clicked()', self.onSaveButtonClicked)
   self.WebSaveButton = qt.QPushButton("Submit to web")
   self.submissionGroupBoxLayout.addWidget(self.WebSaveButton)
   self.WebSaveButton.connect('clicked()', self.onWebSaveButtonClicked)
コード例 #7
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)

    #
    # Select landmark file to import
    #
    self.inputFileSelector = ctk.ctkPathLineEdit()
    self.inputFileSelector.filters  = ctk.ctkPathLineEdit().Files
    self.inputFileSelector.setToolTip( "Select Morphologika landmark file for conversion" )
    parametersFormLayout.addRow("Select file containing landmark names and coordinates to load:", self.inputFileSelector)

    #
    # output directory selector
    #
    self.outputDirectory = ctk.ctkDirectoryButton()
    self.outputDirectory.directory = qt.QDir.homePath()
    parametersFormLayout.addRow("Output Directory:", self.outputDirectory)

    #
    # check box to trigger taking screen shots for later use in tutorials
    #
    self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
    self.enableScreenshotsFlagCheckBox.checked = 0
    self.enableScreenshotsFlagCheckBox.setToolTip("If checked, take screen shots for tutorials. Use Save Data to write them to disk.")
    parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox)

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

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

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

    # Refresh Apply button state
    self.onSelectInput()
コード例 #8
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        settings = qt.QSettings()
        if settings.value("lapdMouseDBBrowserLocalCacheFolder", "") == "":
            settings.setValue("lapdMouseDBBrowserLocalCacheFolder",
                              "./lapdMouse")
            settings.sync()
        databaseDirectory = settings.value(
            "lapdMouseDBBrowserLocalCacheFolder")

        self.browserWindow = lapdMouseBrowserWindow()
        self.browserWindow.localCashFolder = databaseDirectory
        self.browserWindow.load()
        self.browserWindow.show()

        self.logic = lapdMouseDBBrowserLogic()

        # Instantiate and connect widgets ...

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

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

        # extract/merge
        self.openBrowserWindowButton = qt.QPushButton("Show browser")
        self.openBrowserWindowButton.toolTip = "Open lapdMouse database browser window."
        self.openBrowserWindowButton.connect('clicked()',
                                             self.browserWindow.show)
        parametersFormLayout.addRow("Window:", self.openBrowserWindowButton)

        settingsCollapsibleButton = ctk.ctkCollapsibleButton()
        settingsCollapsibleButton.text = "Settings"
        self.layout.addWidget(settingsCollapsibleButton)
        settingsGridLayout = qt.QGridLayout(settingsCollapsibleButton)
        settingsCollapsibleButton.collapsed = False

        self.storagePath = self.browserWindow.localCashFolder
        storagePathLabel = qt.QLabel("Storage Folder: ")
        self.storagePathButton = ctk.ctkDirectoryButton()
        self.storagePathButton.directory = self.storagePath
        settingsGridLayout.addWidget(storagePathLabel, 0, 0, 1, 1)
        settingsGridLayout.addWidget(self.storagePathButton, 0, 1, 1, 4)

        self.storagePathButton.connect('directoryChanged(const QString &)',
                                       self.onStorageChanged)

        self.layout.addStretch(1)
コード例 #9
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)

        #
        # atlases directory
        #
        self.atlasDirectoryButton = ctk.ctkDirectoryButton()
        parametersFormLayout.addRow("Directory: ", self.atlasDirectoryButton)

        #
        # atlas combo box
        #
        self.atlasComboBox = qt.QComboBox()
        parametersFormLayout.addRow("Atlas: ", self.atlasComboBox)

        #
        # Import Button
        #
        self.importButton = qt.QPushButton("Import")
        self.importButton.toolTip = "Import atlas."
        self.importButton.enabled = False
        parametersFormLayout.addRow(self.importButton)

        # connections
        self.importButton.connect('clicked(bool)', self.onImportButton)
        self.atlasDirectoryButton.directoryChanged.connect(
            self.onAtlasDirectoryChanged)
        #self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
        #self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

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

        # Refresh dir

        modulePath = os.path.split(__file__)[0]
        with open(
                os.path.join(modulePath, 'Resources', 'previousDirectory.txt'),
                'r') as f:
            directory = f.readlines()[0]
        self.atlasDirectoryButton.directory = directory if os.path.isdir(
            directory) else '.'
コード例 #10
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

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

        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        self.inputDirButton = ctk.ctkDirectoryButton()
        parametersFormLayout.addRow("Input directory:", self.inputDirButton)

        self.outputDirButton = ctk.ctkDirectoryButton()
        parametersFormLayout.addRow("Output directory:", self.outputDirButton)

        self.copyDICOMButton = qt.QCheckBox()
        self.copyDICOMButton.setChecked(0)
        parametersFormLayout.addRow("Organize DICOMs:", self.copyDICOMButton)

        applyButton = qt.QPushButton('Run')
        parametersFormLayout.addRow(applyButton)

        applyButton.connect('clicked()', self.onRunClicked)
コード例 #11
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

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

    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

    self.inputDirButton = ctk.ctkDirectoryButton()
    parametersFormLayout.addRow("Input directory:", self.inputDirButton)

    self.outputDirButton = ctk.ctkDirectoryButton()
    parametersFormLayout.addRow("Output directory:", self.outputDirButton)

    self.copyDICOMButton = qt.QCheckBox()
    self.copyDICOMButton.setChecked(0)
    parametersFormLayout.addRow("Organize DICOMs:", self.copyDICOMButton)

    applyButton = qt.QPushButton('Run')
    parametersFormLayout.addRow(applyButton)

    applyButton.connect('clicked()', self.onRunClicked)
コード例 #12
0
    def __init__(self, parent):
        layout = qt.QFormLayout(parent)

        self.leadDBSPathButton = ctk.ctkDirectoryButton()
        self.leadDBSPathButton.directory = LeadDBSPath().getValue()
        self.leadDBSPathButton.setToolTip("Lead-DBS install directory")
        self.leadDBSPathButton.directoryChanged.connect(
            self.onLeadDBSPathChanged)
        layout.addRow("Lead-DBS Path: ", self.leadDBSPathButton)

        self.useSmoothAtlasCheckBox = qt.QCheckBox()
        self.useSmoothAtlasCheckBox.checked = UseSmoothAtlas().getValue()
        self.useSmoothAtlasCheckBox.setToolTip(
            "When checked, smoothed version will be used when loading atlases."
        )
        self.useSmoothAtlasCheckBox.connect(
            "toggled(bool)", self.onUseSmoothAtlasCheckBoxToggled)
        layout.addRow("Use smooth atlases: ", self.useSmoothAtlasCheckBox)
コード例 #13
0
    def classificationLayout(self):
        classificationFormLayout = qt.QFormLayout(self.classificationFrame)
        self.classificationLabellingMethodComboBox = qt.QComboBox()
        self.classificationLabellingMethodComboBox.addItems(
            ["Unlabelled", "Single Label"])
        self.labellingMethod = self.classificationLabellingMethodComboBox.currentText
        classificationFormLayout.addWidget(
            self.classificationLabellingMethodComboBox)

        self.classificationLabelTypeLineEdit = qt.QLineEdit("Label Title")
        classificationFormLayout.addWidget(
            self.classificationLabelTypeLineEdit)
        self.classificationLabelTypeLineEdit.visible = False

        self.classificationLabelNameLineEdit = qt.QLineEdit("Label")
        classificationFormLayout.addWidget(
            self.classificationLabelNameLineEdit)
        self.classificationLabelNameLineEdit.visible = False

        self.autoLabelFilePathSelector = ctk.ctkDirectoryButton()
        self.autoLabelPath = os.path.join(self.moduleDir, os.pardir,
                                          "Datasets")
        self.autoLabelFilePathSelector.directory = self.autoLabelPath
        classificationFormLayout.addWidget(self.autoLabelFilePathSelector)
        self.autoLabelFilePathSelector.visible = False

        self.autoLabelFileNameLineEdit = qt.QLineEdit("Auto_Labels.csv")
        classificationFormLayout.addWidget(self.autoLabelFileNameLineEdit)
        self.autoLabelFileNameLineEdit.visible = False

        self.classificationLabellingMethodComboBox.connect(
            'currentIndexChanged(int)', self.onLabellingMethodSelected)
        self.autoLabelFilePathSelector.connect('currentPathChanged(QString)',
                                               self.onAutoLabelFileChanged)
        self.autoLabelFileNameLineEdit.connect('textChanged(QString)',
                                               self.onAutoLabelFileChanged)
コード例 #14
0
    def setup(self):

        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

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

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

        # vf image (mrml input)
        self.vfMRMLSelector = slicer.qMRMLNodeComboBox()
        self.vfMRMLSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.vfMRMLSelector.selectNodeUponCreation = True
        self.vfMRMLSelector.addEnabled = False
        self.vfMRMLSelector.removeEnabled = False
        self.vfMRMLSelector.noneEnabled = True
        self.vfMRMLSelector.showHidden = False
        self.vfMRMLSelector.setMRMLScene(slicer.mrmlScene)
        self.vfMRMLSelector.setToolTip("Pick the input to the algorithm.")
        inputFormLayout.addRow("Vector Field image: ", self.vfMRMLSelector)

        # variables
        self.minJacobianValue = 1
        self.maxJacobianValue = 1

        # vf image (directory input)
        self.vfInputDirectory = ctk.ctkDirectoryButton()
        self.vfInputDirectory.directory = qt.QDir.homePath()
        inputFormLayout.addRow("Input Directory:", self.vfInputDirectory)

        # Fixed image (for geometry info)
        self.fixedImage = slicer.qMRMLNodeComboBox()
        self.fixedImage.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.fixedImage.setMRMLScene(slicer.mrmlScene)
        self.fixedImage.selectNodeUponCreation = True
        self.fixedImage.addEnabled = False
        self.fixedImage.renameEnabled = True
        self.fixedImage.noneEnabled = True
        self.fixedImage.setToolTip("Output image of Jacobian matrix.vtkSlicerPlastimatchModuleLogicPython")
        inputFormLayout.addRow("Fixed image (for geometry info): ", self.fixedImage)

        # Apply Button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = True
        self.layout.addWidget(self.applyButton)

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

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

        # Jacobian image (mrml output)
        self.outputJacobian = slicer.qMRMLNodeComboBox()
        self.outputJacobian.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.outputJacobian.setMRMLScene(slicer.mrmlScene)
        self.outputJacobian.addEnabled = True
        self.outputJacobian.renameEnabled = True
        # self.outputJacobian.layout().addWidget(self.outputSelector)
        self.outputJacobian.setToolTip("Output image of Jacobian matrix.vtkSlicerPlastimatchModuleLogicPython")
        outputFormLayout.addRow("Jacobian image: ", self.outputJacobian)

        # output directory selector
        #    self.outputDirectory = ctk.ctkDirectoryButton()
        #    self.outputDirectory.directory = qt.QDir.homePath()
        #    outputFormLayout.addRow("Output Directory: ", self.outputDirectory)

        # output statistics
        buttonLayout = qt.QHBoxLayout()
        self.minJacobian = qt.QLineEdit()
        self.minJacobian.setToolTip("Minimum value of Jacobian matrix")
        buttonLayout.addWidget(self.minJacobian)
        outputFormLayout.addRow("Minimum Jacobian:", buttonLayout)

        buttonLayout = qt.QHBoxLayout()
        self.maxJacobian = qt.QLineEdit()
        self.maxJacobian.setToolTip("Maximum value of Jacobian matrix")
        buttonLayout.addWidget(self.maxJacobian)
        outputFormLayout.addRow("Maximum Jacobian:", buttonLayout)

        # connections
        self.applyButton.connect("clicked(bool)", self.onJacobianApply)
        self.outputJacobian.connect("currentNodeChanged(vtkMRMLNode*)", self.onOutputJacobianSelect)
        self.fixedImage.connect("currentNodeChanged(vtkMRMLNode*)", self.onFixedImageSelect)
        self.vfMRMLSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onvfMRMLSelect)

        # Add vertical spacer
        self.layout.addStretch(1)
コード例 #15
0
ファイル: ARHealth.py プロジェクト: BIIG-UC3M/OpenARHealth
  def setup(self):

    ScriptedLoadableModuleWidget.setup(self)

    self.logic = ARHealthLogic()

    # Layout setup
    self.layoutManager = slicer.app.layoutManager()
    self.setCustomLayout()
    self.layoutManager.setLayout(self.customLayout_1_ID) # Set 3D only view layout

    #-------------------------------------------------------#
    #------------------- Load Models -----------------------#
    #-------------------------------------------------------#
    
    # Creacion layout
    self.collapsibleButtonInit = ctk.ctkCollapsibleButton()
    self.collapsibleButtonInit.text = "INITIALIZATION"
    self.collapsibleButtonInit.collapsed = False
    self.layout.addWidget(self.collapsibleButtonInit)
    formLayout_init = qt.QFormLayout(self.collapsibleButtonInit)

    # Reset button
    self.resetButton = qt.QPushButton("RESET")
    self.resetButton.toolTip = "Reset scene."
    self.resetButton.enabled = True
    formLayout_init.addRow(self.resetButton) 

    # Mode selection
    self.modeSelection_GroupBox = ctk.ctkCollapsibleGroupBox()
    self.modeSelection_GroupBox.setTitle("Mode")
    self.modeSelection_GroupBox.enabled = True
    formLayout_init.addRow(self.modeSelection_GroupBox)
    modeSelection_GroupBox_Layout = qt.QFormLayout(self.modeSelection_GroupBox)
    modeSelection_H_Layout = qt.QHBoxLayout()
    modeSelection_GroupBox_Layout.addRow(modeSelection_H_Layout)

    ## Visualization mode radio button
    self.mode1_radioButton = qt.QRadioButton('Visualization')
    self.mode1_radioButton.checked = True
    modeSelection_H_Layout.addWidget(self.mode1_radioButton)

    ## Registration mode radio button
    self.mode2_radioButton = qt.QRadioButton('Registration')
    modeSelection_H_Layout.addWidget(self.mode2_radioButton)

    ## Mode icons display
    icons_path = slicer.modules.arhealth.path.replace("ARHealth.py", "") + "Resources/Icons/"
    self.mode_1_icon = qt.QLabel()
    self.mode_1_icon_pixmap = qt.QPixmap(icons_path + '/Mode1.jpg')
    self.mode_1_icon.setPixmap(self.mode_1_icon_pixmap.scaledToWidth(400))
    self.mode_1_icon.visible = True
    modeSelection_GroupBox_Layout.addRow(self.mode_1_icon)    
    self.mode_2_icon = qt.QLabel()
    self.mode_2_icon_pixmap = qt.QPixmap(icons_path + '/Mode2.jpg')
    self.mode_2_icon.setPixmap(self.mode_2_icon_pixmap.scaledToWidth(400))
    self.mode_2_icon.visible = False
    modeSelection_GroupBox_Layout.addRow(self.mode_2_icon)

    # Button Load Marker Model
    self.loadMarkerButton = qt.QPushButton("Load Marker Model")
    self.loadMarkerButton.toolTip = "Load Marker Model"
    self.loadMarkerButton.enabled = True
    formLayout_init.addRow(self.loadMarkerButton) 

    """
    # Text to load model
    self.inputModel_label = qt.QLabel("Model Path: ")
    self.inputModel_textInput = qt.QLineEdit()
    self.inputModel_textInput.text = ""
    formLayout_init.addRow(self.inputModel_label, self.inputModel_textInput)
    """
    ## Load Models
    self.LoadModelsGroupBox = ctk.ctkCollapsibleGroupBox()
    self.LoadModelsGroupBox.setTitle("Load Models")
    self.LoadModelsGroupBox.collapsed = True
    formLayout_init.addRow(self.LoadModelsGroupBox)
    LoadModelsGroupBox_Layout = qt.QFormLayout(self.LoadModelsGroupBox)

    # Data Stream File Path Selector
    self.modelsPathEdit = ctk.ctkPathLineEdit()
    self.modelsPathEdit.enabled = False
    LoadModelsGroupBox_Layout.addRow("Model Path: ", self.modelsPathEdit)

    # Button to load model
    self.loadModelButton = qt.QPushButton("Load Model")
    self.loadModelButton.toolTip = "Load Model"
    self.loadModelButton.enabled = False
    LoadModelsGroupBox_Layout.addRow(self.loadModelButton)

    # Create List
    self.modelsListWidget = qt.QListWidget()
    LoadModelsGroupBox_Layout.addRow(self.modelsListWidget)

    # Create buttons to delete models o delete all
    deleteOneOrAllModels_Layout = qt.QHBoxLayout()
    LoadModelsGroupBox_Layout.addRow(deleteOneOrAllModels_Layout)

    self.removeSelectedModelButton = qt.QPushButton("Remove Model")
    self.removeSelectedModelButton.enabled = False
    deleteOneOrAllModels_Layout.addWidget(self.removeSelectedModelButton)
    
    self.removeAllModelsButton = qt.QPushButton("Remove All")
    self.removeAllModelsButton.enabled = False
    deleteOneOrAllModels_Layout.addWidget(self.removeAllModelsButton) 

    # Button to move models to origin
    self.moveToOriginlButton = qt.QPushButton("Finish and Center")
    self.moveToOriginlButton.enabled = False
    formLayout_init.addRow(self.moveToOriginlButton)
    # self.layout.addStretch(1)

    #-------------------------------------------------------#
    #------------------- Positioning -----------------------#
    #-------------------------------------------------------#

    # Creacion layout
    self.collapsibleButtonPos = ctk.ctkCollapsibleButton()
    self.collapsibleButtonPos.text = "POSITIONING"
    self.collapsibleButtonPos.collapsed = True
    # self.collapsibleButtonPos.enabled = False
    self.layout.addWidget(self.collapsibleButtonPos)

    formLayout_pos = qt.QFormLayout(self.collapsibleButtonPos) 
    ## Base Model Height
    self.BaseGroupBox = ctk.ctkCollapsibleGroupBox()
    self.BaseGroupBox.setTitle("AR Marker Adaptor Height")
    self.BaseGroupBox.visible = False
    formLayout_pos.addRow(self.BaseGroupBox)
    BaseGroupBox_Layout = qt.QFormLayout(self.BaseGroupBox)

    self.baseHeightSliderWidget = ctk.ctkSliderWidget()
    self.baseHeightSliderWidget.singleStep = 10
    self.baseHeightSliderWidget.minimum = 10
    self.baseHeightSliderWidget.maximum = 50
    self.baseHeightSliderWidget.value = 10
    BaseGroupBox_Layout.addRow("[mm]: ", self.baseHeightSliderWidget)

    ## Slider Scale
    ScaleGroupBox = ctk.ctkCollapsibleGroupBox()
    ScaleGroupBox.setTitle("Scale")
    formLayout_pos.addRow(ScaleGroupBox)
    ScaleGroupBox_Layout = qt.QFormLayout(ScaleGroupBox)

    self.scaleSliderWidget = ctk.ctkSliderWidget()
    self.scaleSliderWidget.singleStep = 1
    self.scaleSliderWidget.minimum = 0.0000000001
    self.scaleSliderWidget.maximum = 500
    self.scaleSliderWidget.value = 100
    ScaleGroupBox_Layout.addRow("[%]: ", self.scaleSliderWidget)

    ## Slider Translation

    TranslationGroupBox = ctk.ctkCollapsibleGroupBox()
    TranslationGroupBox.setTitle("Translation")
    formLayout_pos.addRow(TranslationGroupBox)
    TranlationGroupBox_Layout = qt.QFormLayout(TranslationGroupBox)

    self.lrTranslationSliderWidget = ctk.ctkSliderWidget()
    self.lrTranslationSliderWidget.singleStep = 0.5
    self.lrTranslationSliderWidget.minimum = -1000
    self.lrTranslationSliderWidget.maximum = 1000
    self.lrTranslationSliderWidget.value = 0
    self.lrTranslationSliderWidget.setToolTip("Z Translation Transform")
    TranlationGroupBox_Layout.addRow("LR: ", self.lrTranslationSliderWidget)

    self.paTranslationSliderWidget = ctk.ctkSliderWidget()
    self.paTranslationSliderWidget.singleStep = 0.5
    self.paTranslationSliderWidget.minimum = -1000
    self.paTranslationSliderWidget.maximum = 1000
    self.paTranslationSliderWidget.value = 0
    self.paTranslationSliderWidget.setToolTip("Z Translation Transform")
    TranlationGroupBox_Layout.addRow("PA: ", self.paTranslationSliderWidget)

    self.isTranslationSliderWidget = ctk.ctkSliderWidget()
    self.isTranslationSliderWidget.singleStep = 0.5
    self.isTranslationSliderWidget.minimum = -1000
    self.isTranslationSliderWidget.maximum = 1000
    self.isTranslationSliderWidget.value = 0
    self.isTranslationSliderWidget.setToolTip("Z Translation Transform")
    TranlationGroupBox_Layout.addRow("IS: ", self.isTranslationSliderWidget)
    
    ## Slider Rotation
    RotationGroupBox = ctk.ctkCollapsibleGroupBox()
    RotationGroupBox.setTitle("Rotation")
    formLayout_pos.addRow(RotationGroupBox)
    RotationGroupBox_Layout = qt.QFormLayout(RotationGroupBox)

    self.lrRotationSliderWidget = ctk.ctkSliderWidget()
    self.lrRotationSliderWidget.singleStep = 1
    self.lrRotationSliderWidget.minimum = -180
    self.lrRotationSliderWidget.maximum = 180
    self.lrRotationSliderWidget.value = 0
    self.lrRotationSliderWidget.setToolTip("LR Rotation")
    RotationGroupBox_Layout.addRow("LR: ", self.lrRotationSliderWidget)

    self.paRotationSliderWidget = ctk.ctkSliderWidget()
    self.paRotationSliderWidget.singleStep = 1
    self.paRotationSliderWidget.minimum = -180
    self.paRotationSliderWidget.maximum = 180
    self.paRotationSliderWidget.value = 0
    self.paRotationSliderWidget.setToolTip("PA Rotation")
    RotationGroupBox_Layout.addRow("PA: ", self.paRotationSliderWidget)

    self.isRotationSliderWidget = ctk.ctkSliderWidget()
    self.isRotationSliderWidget.singleStep = 1
    self.isRotationSliderWidget.minimum = -180
    self.isRotationSliderWidget.maximum = 180
    self.isRotationSliderWidget.value = 0
    self.isRotationSliderWidget.setToolTip("IS Rotation")
    RotationGroupBox_Layout.addRow("IS: ", self.isRotationSliderWidget)

    ## Button reset
    self.resetPosButton = qt.QPushButton("Reset Position")
    self.resetPosButton.enabled = True
    formLayout_pos.addRow(self.resetPosButton) 

    """
    #-------------------------------------------------------#
    #------------------- Appereance -----------------------#
    #-------------------------------------------------------#

    # Init layout
    collapsibleButtonAppereance = ctk.ctkCollapsibleButton()
    collapsibleButtonAppereance.text = "Appereance"
    self.layout.addWidget(collapsibleButtonAppereance)
    formLayout_init = qt.QFormLayout(collapsibleButtonAppereance)
    """

    #-------------------------------------------------------#
    #------------------- Save Models -----------------------#
    #-------------------------------------------------------#

    # Init layout
    self.collapsibleButtonSaveModels = ctk.ctkCollapsibleButton()
    self.collapsibleButtonSaveModels.text = "SAVE MODELS"
    self.collapsibleButtonSaveModels.collapsed = True
    self.layout.addWidget(self.collapsibleButtonSaveModels)
    formLayout_saveModels = qt.QFormLayout(self.collapsibleButtonSaveModels)

    # Data Stream File Path Selector
    self.saveDirectoryButton = ctk.ctkDirectoryButton()
    formLayout_saveModels.addRow("Save Model Path: ", self.saveDirectoryButton)

    # Button to load model
    self.saveModelButton = qt.QPushButton("Save Models")
    self.saveModelButton.toolTip = "Save Models"
    self.saveModelButton.enabled = False
    formLayout_saveModels.addRow(self.saveModelButton) # incluimos el boton al layout

    # Info Save Models
    self.saveModels_InfoText = qt.QLabel('')
    formLayout_saveModels.addRow(self.saveModels_InfoText)

    self.layout.addStretch(1)

    #########################################################################################
    #########################################################################################
    #########################################################################################

    # Connections
    self.resetButton.connect("clicked(bool)", self.onResetButton)
    self.mode1_radioButton.connect('clicked(bool)', self.onModeSelected)
    self.mode2_radioButton.connect('clicked(bool)', self.onModeSelected)
    self.loadMarkerButton.connect("clicked(bool)", self.onLoadMarkerButton)
    self.loadModelButton.connect("clicked(bool)", self.onLoadModelsButton)
    self.removeSelectedModelButton.connect("clicked(bool)", self.onRemoveSelectedModelButton)
    self.removeAllModelsButton.connect("clicked(bool)", self.onRemoveAllModelsButton)
    self.moveToOriginlButton.connect("clicked(bool)", self.onMoveToOriginlButton)
    self.baseHeightSliderWidget.connect("valueChanged(double)", self.onBaseHeightSliderWidgetChanged)
    self.scaleSliderWidget.connect("valueChanged(double)", self.onScaleSliderWidgetChanged)
    self.lrTranslationSliderWidget.connect("valueChanged(double)", self.onLRTranslationSliderWidgetChanged)
    self.paTranslationSliderWidget.connect("valueChanged(double)", self.onPATranslationSliderWidgetChanged)
    self.isTranslationSliderWidget.connect("valueChanged(double)", self.onISTranslationSliderWidgetChanged)
    self.lrRotationSliderWidget.connect("valueChanged(double)", self.onLRRotationSliderWidgetChanged)
    self.paRotationSliderWidget.connect("valueChanged(double)", self.onPARotationSliderWidgetChanged)
    self.isRotationSliderWidget.connect("valueChanged(double)", self.onISRotationSliderWidgetChanged)
    self.resetPosButton.connect("clicked(bool)", self.onResetPosButton)
    self.saveModelButton.connect("clicked(bool)", self.onsaveModelButton) 
コード例 #16
0
    def setup(self):
        """This is called one time when the module GUI is initialized
        """
        ScriptedLoadableModuleWidget.setup(self)

        # Create objects that can be used anywhere in the module. Example: in most cases there should be just one
        # object of the logic class
        self.logic = CIP_ParenchymaSubtypeTrainingLogic()
        self.currentVolumeLoaded = None
        self.blockNodeEvents = False

        ##########
        # Main area
        self.mainAreaCollapsibleButton = ctk.ctkCollapsibleButton()
        self.mainAreaCollapsibleButton.text = "Main area"
        self.layout.addWidget(self.mainAreaCollapsibleButton,
                              SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.mainLayout = qt.QGridLayout(self.mainAreaCollapsibleButton)

        # Node selector
        volumeLabel = qt.QLabel("Active volume: ")
        volumeLabel.setStyleSheet("margin-left:5px")
        self.mainLayout.addWidget(volumeLabel, 0, 0)
        self.volumeSelector = slicer.qMRMLNodeComboBox()
        self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.volumeSelector.selectNodeUponCreation = True
        self.volumeSelector.autoFillBackground = True
        self.volumeSelector.addEnabled = False
        self.volumeSelector.noneEnabled = False
        self.volumeSelector.removeEnabled = False
        self.volumeSelector.showHidden = False
        self.volumeSelector.showChildNodeTypes = False
        self.volumeSelector.setMRMLScene(slicer.mrmlScene)
        self.volumeSelector.setFixedWidth(250)
        self.volumeSelector.setStyleSheet("margin: 15px 0")
        #self.volumeSelector.selectNodeUponCreation = False
        self.mainLayout.addWidget(self.volumeSelector, 0, 1, 1, 3)

        labelsStyle = "font-weight: bold; margin: 0 0 5px 5px;"
        # Types Radio Buttons
        typesLabel = qt.QLabel("Select the type")
        typesLabel.setStyleSheet(labelsStyle)
        typesLabel.setFixedHeight(15)
        self.mainLayout.addWidget(typesLabel, 1, 0)
        self.typesFrame = qt.QFrame()
        self.typesLayout = qt.QVBoxLayout(self.typesFrame)
        self.mainLayout.addWidget(self.typesFrame, 2, 0,
                                  SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.typesRadioButtonGroup = qt.QButtonGroup()
        for key in self.logic.params.mainTypes.iterkeys():
            rbitem = qt.QRadioButton(self.logic.params.getMainTypeLabel(key))
            self.typesRadioButtonGroup.addButton(rbitem, key)
            self.typesLayout.addWidget(rbitem)
        self.typesRadioButtonGroup.buttons()[0].setChecked(True)

        # Subtypes Radio buttons
        subtypesLabel = qt.QLabel("Select the subtype")
        subtypesLabel.setStyleSheet(labelsStyle)
        subtypesLabel.setFixedHeight(15)
        self.mainLayout.addWidget(subtypesLabel, 1, 1)
        self.subtypesRadioButtonGroup = qt.QButtonGroup()
        self.subtypesFrame = qt.QFrame()
        self.subtypesFrame.setMinimumHeight(275)
        self.subtypesLayout = qt.QVBoxLayout(self.subtypesFrame)
        self.subtypesLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.subtypesLayout.setStretch(0, 0)
        self.mainLayout.addWidget(
            self.subtypesFrame, 2, 1,
            SlicerUtil.ALIGNMENT_VERTICAL_TOP)  # Put the frame in the top
        # The content will be loaded dynamically every time the main type is modified

        # Artifact radio buttons
        self.artifactsLabel = qt.QLabel("Artifact")
        self.artifactsLabel.setStyleSheet(labelsStyle)
        self.artifactsLabel.setFixedHeight(15)
        self.mainLayout.addWidget(self.artifactsLabel, 1, 2)
        #self.mainLayout.addWidget(qt.QLabel("Select the artifact"), 1, 1)
        self.artifactsRadioButtonGroup = qt.QButtonGroup()
        self.artifactsFrame = qt.QFrame()
        self.artifactsLayout = qt.QVBoxLayout(self.artifactsFrame)
        self.mainLayout.addWidget(self.artifactsFrame, 2, 2,
                                  SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.artifactsRadioButtonGroup = qt.QButtonGroup()
        for artifactId in self.logic.params.artifacts.iterkeys():
            rbitem = qt.QRadioButton(
                self.logic.params.getArtifactLabel(artifactId))
            self.artifactsRadioButtonGroup.addButton(rbitem, artifactId)
            self.artifactsLayout.addWidget(rbitem)
        self.artifactsRadioButtonGroup.buttons()[0].setChecked(True)

        # Load caselist button
        self.loadButton = ctk.ctkPushButton()
        self.loadButton.text = "Load fiducials file"
        self.loadButton.setIcon(
            qt.QIcon("{0}/open_file.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.loadButton.setIconSize(qt.QSize(20, 20))
        self.loadButton.setFixedWidth(135)
        self.mainLayout.addWidget(self.loadButton, 3, 0)

        # Remove fiducial button
        self.removeLastFiducialButton = ctk.ctkPushButton()
        self.removeLastFiducialButton.text = "Remove last fiducial"
        self.removeLastFiducialButton.toolTip = "Remove the last fiducial added"
        self.removeLastFiducialButton.setIcon(
            qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeLastFiducialButton.setIconSize(qt.QSize(20, 20))
        self.removeLastFiducialButton.setFixedWidth(200)
        self.mainLayout.addWidget(self.removeLastFiducialButton, 3, 1)

        # Save results button
        self.saveResultsButton = ctk.ctkPushButton()
        self.saveResultsButton.setText("Save markups")
        self.saveResultsButton.toolTip = "Save the markups in the specified directory"
        self.saveResultsButton.setIcon(
            qt.QIcon("{0}/Save.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.saveResultsButton.setIconSize(qt.QSize(20, 20))
        self.mainLayout.addWidget(self.saveResultsButton, 4, 0)

        # Save results directory button
        defaultPath = os.path.join(
            SlicerUtil.getSettingsDataFolder(self.moduleName),
            "results")  # Assign a default path for the results
        path = SlicerUtil.settingGetOrSetDefault(self.moduleName,
                                                 "SaveResultsDirectory",
                                                 defaultPath)
        self.saveResultsDirectoryButton = ctk.ctkDirectoryButton()
        self.saveResultsDirectoryButton.directory = path
        self.saveResultsDirectoryButton.setMaximumWidth(375)
        self.mainLayout.addWidget(self.saveResultsDirectoryButton, 4, 1, 1, 2)

        #####
        # Case navigator
        self.caseNavigatorWidget = None
        if SlicerUtil.isSlicerACILLoaded():
            caseNavigatorAreaCollapsibleButton = ctk.ctkCollapsibleButton()
            caseNavigatorAreaCollapsibleButton.text = "Case navigator"
            self.layout.addWidget(caseNavigatorAreaCollapsibleButton, 0x0020)
            # caseNavigatorLayout = qt.QVBoxLayout(caseNavigatorAreaCollapsibleButton)

            # Add a case list navigator
            from ACIL.ui import CaseNavigatorWidget
            self.caseNavigatorWidget = CaseNavigatorWidget(
                self.moduleName, caseNavigatorAreaCollapsibleButton)
            self.caseNavigatorWidget.setup()
            # Listen for the event of loading a new labelmap
            self.caseNavigatorWidget.addObservable(
                self.caseNavigatorWidget.EVENT_LABELMAP_LOADED,
                self.__onNewILDClassificationLabelmapLoaded__)

        self.layout.addStretch()

        self.updateState()

        # Connections
        self.typesRadioButtonGroup.connect("buttonClicked (QAbstractButton*)",
                                           self.__onTypesRadioButtonClicked__)
        self.subtypesRadioButtonGroup.connect(
            "buttonClicked (QAbstractButton*)",
            self.__onSubtypesRadioButtonClicked__)
        self.artifactsRadioButtonGroup.connect(
            "buttonClicked (QAbstractButton*)",
            self.__onSubtypesRadioButtonClicked__)

        self.volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                    self.__onCurrentNodeChanged__)
        self.loadButton.connect('clicked()', self.openFiducialsFile)
        self.removeLastFiducialButton.connect(
            'clicked()', self.__onRemoveLastFiducialButtonClicked__)
        # self.saveResultsOpenDirectoryDialogButton.connect('clicked()', self.onOpenDirectoryDialogButtonClicked)
        self.saveResultsDirectoryButton.connect(
            "directoryChanged (QString)",
            self.__onSaveResultsDirectoryChanged__)
        self.saveResultsButton.connect('clicked()',
                                       self.__onSaveResultsButtonClicked__)

        self.observers = []
        self.observers.append(
            slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent,
                                         self.__onNodeAddedObserver__))
        self.observers.append(
            slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.EndCloseEvent,
                                         self.__onSceneClosed__))
コード例 #17
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        #
        # Subject Directory Area
        #

        self.subjectDirectoryButton = ctk.ctkDirectoryButton()
        self.subjectDirectoryButton.text = "Select Lead-DBS directory"
        self.layout.addWidget(self.subjectDirectoryButton)

        #
        # Images Area
        #
        imagesCollapsibleButton = ctk.ctkCollapsibleButton()
        imagesCollapsibleButton.text = "Images"
        self.layout.addWidget(imagesCollapsibleButton)

        # Layout within the dummy collapsible button
        imagesFormLayout = qt.QFormLayout(imagesCollapsibleButton)

        #
        # select images list
        #

        self.imagesList = qt.QListWidget()
        self.imagesList.setSelectionMode(
            qt.QAbstractItemView.ExtendedSelection)
        imagesFormLayout.addRow(self.imagesList)

        #
        # Transforms Area
        #
        transformsCollapsibleButton = ctk.ctkCollapsibleButton()
        transformsCollapsibleButton.text = "Transforms"
        self.layout.addWidget(transformsCollapsibleButton)

        # Layout within the dummy collapsible button
        transformsFormLayout = qt.QFormLayout(transformsCollapsibleButton)

        # converts transforms
        self.updateTransformButton = qt.QPushButton('Update Transform')
        self.updateTransformButton.visible = False
        transformsFormLayout.addRow(self.updateTransformButton)

        #
        # check box select transforms
        #

        self.transformsList = qt.QListWidget()
        self.transformsList.setSelectionMode(
            qt.QAbstractItemView.ExtendedSelection)
        imagesFormLayout.addRow(self.transformsList)

        #
        # Import Button
        #
        self.importButton = qt.QPushButton("Import")
        self.importButton.toolTip = "Import selected options."
        self.importButton.enabled = True
        self.layout.addWidget(self.importButton)

        # connections
        self.importButton.connect('clicked(bool)', self.onImportButton)
        self.updateTransformButton.connect('clicked(bool)',
                                           self.onUpdateTransformButton)
        self.subjectDirectoryButton.directoryChanged.connect(
            self.onSubjectDirectoryChanged)

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

        # Refresh Apply button state
        self.onSubjectDirectoryChanged('.')
コード例 #18
0
 def createDirectoryButton(self, **kwargs):
     button = ctk.ctkDirectoryButton()
     for key, value in kwargs.iteritems():
         if hasattr(button, key):
             setattr(button, key, value)
     return button
コード例 #19
0
    def setup(self):
        """This is called one time when the module GUI is initialized
        """
        ScriptedLoadableModuleWidget.setup(self)

        # Create objects that can be used anywhere in the module. Example: in most cases there should be just one
        # object of the logic class
        self._initLogic_()
        self.currentVolumeLoaded = None
        self.blockNodeEvents = False

        ##########
        # Main area
        self.mainAreaCollapsibleButton = ctk.ctkCollapsibleButton()
        self.mainAreaCollapsibleButton.text = "Main area"
        self.layout.addWidget(self.mainAreaCollapsibleButton,
                              SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.mainLayout = qt.QGridLayout(self.mainAreaCollapsibleButton)

        # Node selector
        volumeLabel = qt.QLabel("Active volume: ")
        volumeLabel.setStyleSheet("margin-left:5px")
        self.mainLayout.addWidget(volumeLabel, 0, 0)
        self.volumeSelector = slicer.qMRMLNodeComboBox()
        self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.volumeSelector.selectNodeUponCreation = True
        self.volumeSelector.autoFillBackground = True
        self.volumeSelector.addEnabled = False
        self.volumeSelector.noneEnabled = False
        self.volumeSelector.removeEnabled = False
        self.volumeSelector.showHidden = False
        self.volumeSelector.showChildNodeTypes = False
        self.volumeSelector.setMRMLScene(slicer.mrmlScene)
        self.volumeSelector.setFixedWidth(250)
        self.volumeSelector.setStyleSheet("margin: 15px 0")
        #self.volumeSelector.selectNodeUponCreation = False
        self.mainLayout.addWidget(self.volumeSelector, 0, 1, 1, 3)
        self.volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                    self.__onCurrentNodeChanged__)

        # Radio buttons frame. This will be filled by every child module
        self.radioButtonsFrame = qt.QFrame()
        self.mainLayout.addWidget(self.radioButtonsFrame, 2, 0, 1, 3,
                                  SlicerUtil.ALIGNMENT_VERTICAL_TOP)

        # Load caselist button
        self.loadButton = ctk.ctkPushButton()
        self.loadButton.text = "Load fiducials file"
        self.loadButton.setIcon(
            qt.QIcon("{0}/open_file.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.loadButton.setIconSize(qt.QSize(20, 20))
        self.loadButton.setFixedWidth(135)
        self.mainLayout.addWidget(self.loadButton, 3, 0)
        self.loadButton.connect('clicked()', self.openFiducialsFile)

        # Remove fiducial button
        self.removeLastFiducialButton = ctk.ctkPushButton()
        self.removeLastFiducialButton.text = "Remove last fiducial"
        self.removeLastFiducialButton.toolTip = "Remove the last fiducial added"
        self.removeLastFiducialButton.setIcon(
            qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeLastFiducialButton.setIconSize(qt.QSize(20, 20))
        self.removeLastFiducialButton.setFixedWidth(200)
        self.mainLayout.addWidget(self.removeLastFiducialButton, 3, 1)
        self.removeLastFiducialButton.connect(
            'clicked()', self.__onRemoveLastFiducialButtonClicked__)

        # Save results button
        self.saveResultsButton = ctk.ctkPushButton()
        self.saveResultsButton.setText("Save markups")
        self.saveResultsButton.toolTip = "Save the markups in the specified directory"
        self.saveResultsButton.setIcon(
            qt.QIcon("{0}/Save.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.saveResultsButton.setIconSize(qt.QSize(20, 20))
        self.saveResultsButton.setFixedWidth(135)
        self.mainLayout.addWidget(self.saveResultsButton, 4, 0)
        self.saveResultsButton.connect('clicked()',
                                       self.__onSaveResultsButtonClicked__)

        # Save results directory button
        defaultPath = os.path.join(
            SlicerUtil.getSettingsDataFolder(self.moduleName),
            "results")  # Assign a default path for the results
        path = SlicerUtil.settingGetOrSetDefault(self.moduleName,
                                                 "SaveResultsDirectory",
                                                 defaultPath)
        self.saveResultsDirectoryButton = ctk.ctkDirectoryButton()
        self.saveResultsDirectoryButton.directory = path
        self.saveResultsDirectoryButton.setMaximumWidth(375)
        self.mainLayout.addWidget(self.saveResultsDirectoryButton, 4, 1, 1, 2)
        self.saveResultsDirectoryButton.connect(
            "directoryChanged (QString)",
            self.__onSaveResultsDirectoryChanged__)

        #####
        # Case navigator
        self.caseNavigatorWidget = None
        if SlicerUtil.isSlicerACILLoaded():
            caseNavigatorAreaCollapsibleButton = ctk.ctkCollapsibleButton()
            caseNavigatorAreaCollapsibleButton.text = "Case navigator"
            self.layout.addWidget(caseNavigatorAreaCollapsibleButton, 0x0020)
            # caseNavigatorLayout = qt.QVBoxLayout(caseNavigatorAreaCollapsibleButton)

            # Add a case list navigator
            from ACIL.ui import CaseNavigatorWidget
            self.caseNavigatorWidget = CaseNavigatorWidget(
                self.moduleName, caseNavigatorAreaCollapsibleButton)
            self.caseNavigatorWidget.setup()
            # Listen for the event of loading a new labelmap
            # self.caseNavigatorWidget.addObservable(self.caseNavigatorWidget.EVENT_LABELMAP_LOADED, self.__onNewILDClassificationLabelmapLoaded__)
            self.caseNavigatorWidget.addObservable(
                self.caseNavigatorWidget.EVENT_BUNDLE_CASE_FINISHED,
                self.__onFinishCaseBundleLoad__)

        self.layout.addStretch()

        # Extra Connections
        self._createSceneObservers_()
コード例 #20
0
ファイル: DicomSroExport.py プロジェクト: ming-hai/SlicerRT
  def setup(self):

    ScriptedLoadableModuleWidget.setup(self)

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

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

    # fixed image (mrml input)
    self.fixedMRMLSelector = slicer.qMRMLNodeComboBox()
    self.fixedMRMLSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.fixedMRMLSelector.selectNodeUponCreation = True
    self.fixedMRMLSelector.addEnabled = False
    self.fixedMRMLSelector.removeEnabled = False
    self.fixedMRMLSelector.noneEnabled = False
    self.fixedMRMLSelector.showHidden = False
    self.fixedMRMLSelector.showChildNodeTypes = False
    self.fixedMRMLSelector.setMRMLScene( slicer.mrmlScene )
    self.fixedMRMLSelector.setToolTip ("Choose either an image within the MRML scene, or a directory containing a DICOM image")
    parametersFormLayout.addRow("Fixed image: ", self.fixedMRMLSelector)

    # fixed image (directory input)
    self.fixedInputDirectory = ctk.ctkDirectoryButton()
    self.fixedInputDirectory.directory = qt.QDir.homePath()
    parametersFormLayout.addRow("", self.fixedInputDirectory)

    # moving image (mrml input)
    self.movingMRMLSelector = slicer.qMRMLNodeComboBox()
    self.movingMRMLSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.movingMRMLSelector.selectNodeUponCreation = True
    self.movingMRMLSelector.addEnabled = False
    self.movingMRMLSelector.removeEnabled = False
    self.movingMRMLSelector.noneEnabled = False
    self.movingMRMLSelector.showHidden = False
    self.movingMRMLSelector.showChildNodeTypes = False
    self.movingMRMLSelector.setMRMLScene( slicer.mrmlScene )
    self.fixedMRMLSelector.setToolTip ("Choose either an image within the MRML scene, or a directory containing a DICOM image")
    parametersFormLayout.addRow("Moving image: ", self.movingMRMLSelector)

    # moving image (directory input)
    self.movingInputDirectory = ctk.ctkDirectoryButton()
    self.movingInputDirectory.directory = qt.QDir.homePath()
    parametersFormLayout.addRow("", self.movingInputDirectory)

    # transform (mrml input)
    self.xformMRMLSelector = slicer.qMRMLNodeComboBox()
    self.xformMRMLSelector.nodeTypes = ["vtkMRMLLinearTransformNode"]
    self.xformMRMLSelector.selectNodeUponCreation = True
    self.xformMRMLSelector.addEnabled = False
    self.xformMRMLSelector.removeEnabled = False
    self.xformMRMLSelector.noneEnabled = False
    self.xformMRMLSelector.showHidden = False
    self.xformMRMLSelector.showChildNodeTypes = False
    self.xformMRMLSelector.setMRMLScene( slicer.mrmlScene )
    #self.xformMRMLSelector.setToolTip( "Pick the input to the algorithm." )
    parametersFormLayout.addRow("Transform: ", self.xformMRMLSelector)

    # output directory selector
    self.outputDirectory = ctk.ctkDirectoryButton()
    self.outputDirectory.directory = qt.QDir.homePath()
    parametersFormLayout.addRow("Output Directory: ", self.outputDirectory)
    
    # check box to trigger taking screen shots for later use in tutorials
    self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
    self.enableScreenshotsFlagCheckBox.checked = 0
    self.enableScreenshotsFlagCheckBox.setToolTip("If checked, take screen shots for tutorials. Use Save Data to write them to disk.")
    #    parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox)

    # scale factor for screen shots
    self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget()
    self.screenshotScaleFactorSliderWidget.singleStep = 1.0
    self.screenshotScaleFactorSliderWidget.minimum = 1.0
    self.screenshotScaleFactorSliderWidget.maximum = 50.0
    self.screenshotScaleFactorSliderWidget.value = 1.0
    self.screenshotScaleFactorSliderWidget.setToolTip("Set scale factor for the screen shots.")
    #    parametersFormLayout.addRow("Screenshot scale factor", self.screenshotScaleFactorSliderWidget)

    # Apply Button
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = False
    if (self.fixedMRMLSelector.currentNode()
        and self.movingMRMLSelector.currentNode()
        and self.xformMRMLSelector.currentNode()):
      self.applyButton.enabled = True
    parametersFormLayout.addRow(self.applyButton)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.fixedMRMLSelector.connect(
      "currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.movingMRMLSelector.connect(
      "currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.xformMRMLSelector.connect(
      "currentNodeChanged(vtkMRMLNode*)", self.onSelect)

    # Add vertical spacer
    self.layout.addStretch(1)
コード例 #21
0
ファイル: Q3DC.py プロジェクト: luciemac/Q3DCExtension
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        
        # GLOBALS:
        self.logic = Q3DCLogic()
        self.markupsDictionary = dict()
        self.markupsDictionary.clear()
        self.numOfMarkupsNode = slicer.mrmlScene.GetNumberOfNodesByClass("vtkMRMLMarkupsNode")

        self.correspondenceLandmarkDict = dict()  #  key: Landmark Index
                                                  #  Value: MarkupsNodeID

        self.computedDistanceList = list()
        self.computedAnglesList = list()
        
        self.renderer1 = None
        self.actor1 = None
        
        self.renderer2 = None
        self.actor2 = None
        
        # -------------- Input Models ----------------
        self.treeViewGroupBox = ctk.ctkCollapsibleButton()
        self.treeViewGroupBox.setText('Visibility of Models ') 
        self.treeViewGroupBox.collapsed = True
        self.parent.layout().addWidget(self.treeViewGroupBox)
        treeView = slicer.qMRMLTreeView()
        treeView.setMRMLScene(slicer.app.mrmlScene())
        treeView.setSceneModelType('Displayable')
        treeView.sceneModel().setHorizontalHeaderLabels(["Models"])
        treeView.sortFilterProxyModel().nodeTypes = ['vtkMRMLModelNode']
        header = treeView.header()
        header.setResizeMode(0, qt.QHeaderView.Stretch)
        header.setVisible(False)
        self.treeLayout = qt.QVBoxLayout()
        self.treeLayout.addWidget(treeView)
        self.treeViewGroupBox.setLayout(self.treeLayout)

        numNodes = slicer.mrmlScene.GetNumberOfNodesByClass("vtkMRMLModelNode")
        for i in range (3,numNodes):
            self.elements = slicer.mrmlScene.GetNthNodeByClass(i,"vtkMRMLModelNode" )
            print self.elements.GetName()

        
        landmarkFrame = qt.QFrame()
        landmarkFrame.setLayout(qt.QHBoxLayout())
        inputLabel = qt.QLabel('Model of Reference: ')
        self.modelComboBox = slicer.qMRMLNodeComboBox()
        self.modelComboBox.nodeTypes = ['vtkMRMLModelNode']
        self.modelComboBox.addEnabled = False
        self.modelComboBox.removeEnabled = False
        self.modelComboBox.noneEnabled = True
        self.modelComboBox.showHidden = False
        self.modelComboBox.showChildNodeTypes = False
        self.modelComboBox.setMRMLScene(slicer.mrmlScene)
        addLandmarkButton = qt.QPushButton(qt.QIcon(":/Icons/plus.png"), " ")
        addLandmarkButton.connect('clicked()', self.onAddLandmarkButtonClicked)
        landmarkFrame.layout().addWidget(inputLabel)
        landmarkFrame.layout().addWidget(self.modelComboBox)
        landmarkFrame.layout().addWidget(addLandmarkButton)

        self.parent.layout().addWidget(landmarkFrame)
        
        #        ----------------- Compute Mid Point -------------   
        self.midPointGroupBox = ctk.ctkCollapsibleButton()
        self.midPointGroupBox.setText('Define middle point between two landmarks') 
        self.midPointGroupBox.collapsed = True
        self.parent.layout().addWidget(self.midPointGroupBox)
        self.landmarkComboBox1 = qt.QComboBox()
        self.landmarkComboBox2 = qt.QComboBox()
        landmark1Layout = qt.QFormLayout()
        landmark1Layout.addRow('Landmark A: ', self.landmarkComboBox1)
        landmark1Layout.addRow('Landmark B: ', self.landmarkComboBox2)

        self.defineMiddlePointButton = qt.QPushButton(' Define middle  point ')
        self.midPointOnSurfaceCheckBox = qt.QCheckBox('On Surface')
        self.midPointOnSurfaceCheckBox.setChecked(False)
        exportLayout_1 = qt.QFormLayout()
        exportLayout_1.addRow(self.midPointOnSurfaceCheckBox, self.defineMiddlePointButton)
        self.midPointLayout = qt.QVBoxLayout()
        self.midPointLayout.addLayout(landmark1Layout)
        self.midPointLayout.addLayout(exportLayout_1)
        self.midPointGroupBox.setLayout(self.midPointLayout)

        self.defineMiddlePointButton.connect('clicked()', self.onDefineMidPointClicked)
        self.landmarkComboBox1.connect('currentIndexChanged(int)', self.UpdateInterface)
        self.landmarkComboBox2.connect('currentIndexChanged(int)', self.UpdateInterface)

#        ------------------- 1st OPTION -------------------
#        GroupBox
        self.distanceGroupBox = ctk.ctkCollapsibleButton()
        self.distanceGroupBox.setText('Calculate distance between two landmarks: ') 
        self.distanceGroupBox.collapsed = True
        self.parent.layout().addWidget(self.distanceGroupBox)
        
        self.landmarkComboBoxA = qt.QComboBox()
        self.landmarkComboBoxB = qt.QComboBox()
        landmark2Layout = qt.QFormLayout()
        landmark2Layout.addRow('Landmark A: ', self.landmarkComboBoxA)
        landmark2Layout.addRow('Landmark B: ', self.landmarkComboBoxB)
        self.computeDistancesPushButton = qt.QPushButton(' Calculate ')
        self.distanceLayout = qt.QVBoxLayout()
        self.distanceLayout.addLayout(landmark2Layout)
        self.distanceLayout.addWidget(self.computeDistancesPushButton)
        self.distanceGroupBox.setLayout(self.distanceLayout)
        
        self.computeDistancesPushButton.connect('clicked()', self.onComputeDistanceClicked)
        self.landmarkComboBoxA.connect('currentIndexChanged(int)', self.UpdateInterface)
        self.landmarkComboBoxB.connect('currentIndexChanged(int)', self.UpdateInterface)
        
        self.distanceTable = qt.QTableWidget()
        # ---------------------------- Directory - Export Button -----------------------------
        self.directoryExportDistance = ctk.ctkDirectoryButton()
        self.exportDistanceButton = qt.QPushButton(" Export ")
        self.exportDistanceButton.enabled = True
        self.exportDistanceLayout = qt.QHBoxLayout()
        self.exportDistanceLayout.addWidget(self.directoryExportDistance)
        self.exportDistanceLayout.addWidget(self.exportDistanceButton)
        
        self.tableAndExportLayout = qt.QVBoxLayout()
        self.tableAndExportLayout.addWidget(self.distanceTable)
        self.tableAndExportLayout.addLayout(self.exportDistanceLayout)
        
        
#       ------------------- 2nd OPTION -------------------
#       GroupBox
        self.angleGroupBox = ctk.ctkCollapsibleButton()
        self.angleGroupBox.setText('Calculate angle between two lines: ') 
        self.angleGroupBox.collapsed = True
        self.parent.layout().addWidget(self.angleGroupBox)
        
        self.line1LAComboBox = qt.QComboBox()
        self.line1LBComboBox = qt.QComboBox()
        self.line2LAComboBox = qt.QComboBox()
        self.line2LBComboBox = qt.QComboBox()
        
        landmark3Layout = qt.QFormLayout()
        landmark3Layout.addRow('Line 1 Landmark A: ', self.line1LAComboBox)
        landmark3Layout.addRow('Line 1 Landmark B:', self.line1LBComboBox)
        landmark3Layout.addRow('Line 2 Landmark A: ', self.line2LAComboBox)
        landmark3Layout.addRow('Line 2 Landmark B:', self.line2LBComboBox)
        
        layout = qt.QHBoxLayout()
        self.picthCheckBox = qt.QCheckBox('Calculate Pitch')
        self.rollCheckBox = qt.QCheckBox('Calculate Roll')
        self.yawCheckBox = qt.QCheckBox('Calculate Yaw')
        layout.addWidget(self.picthCheckBox)
        layout.addWidget(self.rollCheckBox)
        layout.addWidget(self.yawCheckBox)

        self.angleLayout = qt.QVBoxLayout()
        self.angleLayout.addLayout(landmark3Layout)
        self.angleLayout.addLayout(layout)
        
        self.angleGroupBox.setLayout(self.angleLayout)

        self.computeAnglesPushButton = qt.QPushButton(' Calculate ')
        self.angleLayout.addWidget(self.computeAnglesPushButton)
        
        self.anglesTable = qt.QTableWidget()
        
        self.directoryExportAngle = ctk.ctkDirectoryButton()
        self.exportAngleButton = qt.QPushButton("Export")
        self.exportAngleButton.enabled = True
        self.exportAngleLayout = qt.QHBoxLayout()
        self.exportAngleLayout.addWidget(self.directoryExportAngle)
        self.exportAngleLayout.addWidget(self.exportAngleButton)
        
        self.tableAndExportAngleLayout = qt.QVBoxLayout()
        self.tableAndExportAngleLayout.addWidget(self.anglesTable)
        self.tableAndExportAngleLayout.addLayout(self.exportAngleLayout)
        
        self.computeAnglesPushButton.connect('clicked()', self.onComputeAnglesClicked)
        self.line1LAComboBox.connect('currentIndexChanged(int)', self.UpdateInterface)
        self.line1LBComboBox.connect('currentIndexChanged(int)', self.UpdateInterface)
        self.line2LAComboBox.connect('currentIndexChanged(int)', self.UpdateInterface)
        self.line2LBComboBox.connect('currentIndexChanged(int)', self.UpdateInterface)
        
        self.picthCheckBox.connect('clicked(bool)', self.UpdateInterface)
        self.rollCheckBox.connect('clicked(bool)', self.UpdateInterface)
        self.yawCheckBox.connect('clicked(bool)', self.UpdateInterface)


        # CONNECTIONS:
        slicer.app.mrmlScene().AddObserver(slicer.mrmlScene.NodeAddedEvent, self.NodeAdded)
        
        def onCloseScene(obj, event):
            if self.renderer1 :
                self.renderer1.RemoveActor(self.actor1)
            if self.renderer2 :
                self.renderer2.RemoveActor(self.actor2)
            globals()["Q3DC"] = slicer.util.reloadScriptedModule("Q3DC")
        slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent, onCloseScene)
        
        self.UpdateInterface()
        self.layout.addStretch(1)
コード例 #22
0
    def setup(self):

        ScriptedLoadableModuleWidget.setup(self)

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

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

        # fixed image (mrml input)
        self.fixedMRMLSelector = slicer.qMRMLNodeComboBox()
        self.fixedMRMLSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.fixedMRMLSelector.selectNodeUponCreation = True
        self.fixedMRMLSelector.addEnabled = False
        self.fixedMRMLSelector.removeEnabled = False
        self.fixedMRMLSelector.noneEnabled = False
        self.fixedMRMLSelector.showHidden = False
        self.fixedMRMLSelector.showChildNodeTypes = False
        self.fixedMRMLSelector.setMRMLScene(slicer.mrmlScene)
        self.fixedMRMLSelector.setToolTip(
            "Choose either an image within the MRML scene, or a directory containing a DICOM image"
        )
        parametersFormLayout.addRow("Fixed image: ", self.fixedMRMLSelector)

        # fixed image (directory input)
        self.fixedInputDirectory = ctk.ctkDirectoryButton()
        self.fixedInputDirectory.directory = qt.QDir.homePath()
        parametersFormLayout.addRow("", self.fixedInputDirectory)

        # moving image (mrml input)
        self.movingMRMLSelector = slicer.qMRMLNodeComboBox()
        self.movingMRMLSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.movingMRMLSelector.selectNodeUponCreation = True
        self.movingMRMLSelector.addEnabled = False
        self.movingMRMLSelector.removeEnabled = False
        self.movingMRMLSelector.noneEnabled = False
        self.movingMRMLSelector.showHidden = False
        self.movingMRMLSelector.showChildNodeTypes = False
        self.movingMRMLSelector.setMRMLScene(slicer.mrmlScene)
        self.fixedMRMLSelector.setToolTip(
            "Choose either an image within the MRML scene, or a directory containing a DICOM image"
        )
        parametersFormLayout.addRow("Moving image: ", self.movingMRMLSelector)

        # moving image (directory input)
        self.movingInputDirectory = ctk.ctkDirectoryButton()
        self.movingInputDirectory.directory = qt.QDir.homePath()
        parametersFormLayout.addRow("", self.movingInputDirectory)

        # transform (mrml input)
        self.xformMRMLSelector = slicer.qMRMLNodeComboBox()
        self.xformMRMLSelector.nodeTypes = ["vtkMRMLLinearTransformNode"]
        self.xformMRMLSelector.selectNodeUponCreation = True
        self.xformMRMLSelector.addEnabled = False
        self.xformMRMLSelector.removeEnabled = False
        self.xformMRMLSelector.noneEnabled = False
        self.xformMRMLSelector.showHidden = False
        self.xformMRMLSelector.showChildNodeTypes = False
        self.xformMRMLSelector.setMRMLScene(slicer.mrmlScene)
        #self.xformMRMLSelector.setToolTip( "Pick the input to the algorithm." )
        parametersFormLayout.addRow("Transform: ", self.xformMRMLSelector)

        # output directory selector
        self.outputDirectory = ctk.ctkDirectoryButton()
        self.outputDirectory.directory = qt.QDir.homePath()
        parametersFormLayout.addRow("Output Directory: ", self.outputDirectory)

        # check box to trigger taking screen shots for later use in tutorials
        self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
        self.enableScreenshotsFlagCheckBox.checked = 0
        self.enableScreenshotsFlagCheckBox.setToolTip(
            "If checked, take screen shots for tutorials. Use Save Data to write them to disk."
        )
        #    parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox)

        # scale factor for screen shots
        self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget()
        self.screenshotScaleFactorSliderWidget.singleStep = 1.0
        self.screenshotScaleFactorSliderWidget.minimum = 1.0
        self.screenshotScaleFactorSliderWidget.maximum = 50.0
        self.screenshotScaleFactorSliderWidget.value = 1.0
        self.screenshotScaleFactorSliderWidget.setToolTip(
            "Set scale factor for the screen shots.")
        #    parametersFormLayout.addRow("Screenshot scale factor", self.screenshotScaleFactorSliderWidget)

        # Apply Button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = False
        if (self.fixedMRMLSelector.currentNode()
                and self.movingMRMLSelector.currentNode()
                and self.xformMRMLSelector.currentNode()):
            self.applyButton.enabled = True
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.fixedMRMLSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                       self.onSelect)
        self.movingMRMLSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                        self.onSelect)
        self.xformMRMLSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                       self.onSelect)

        # Add vertical spacer
        self.layout.addStretch(1)
コード例 #23
0
ファイル: mixins.py プロジェクト: rcc-uchicago/PCampReview
 def createDirectoryButton(self, **kwargs):
   button = ctk.ctkDirectoryButton()
   for key, value in kwargs.iteritems():
     if hasattr(button, key):
       setattr(button, key, value)
   return button
コード例 #24
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)

        #
        # Select landmark file to import
        #
        self.inputFileSelector = ctk.ctkPathLineEdit()
        self.inputFileSelector.filters = ctk.ctkPathLineEdit().Files
        self.inputFileSelector.setToolTip("Select landmark file for import")
        parametersFormLayout.addRow(
            "Select file containing landmark names and coordinates to load:",
            self.inputFileSelector)

        #
        # output directory selector
        #
        self.outputDirectory = ctk.ctkDirectoryButton()
        self.outputDirectory.directory = slicer.mrmlScene.GetCacheManager(
        ).GetRemoteCacheDirectory()
        parametersFormLayout.addRow("Output Directory:", self.outputDirectory)

        #
        # Get header length
        #
        self.headerLengthWidget = ctk.ctkDoubleSpinBox()
        self.headerLengthWidget.value = 2
        self.headerLengthWidget.minimum = 0
        self.headerLengthWidget.singleStep = 1
        self.headerLengthWidget.setToolTip(
            "Input the number of lines in header")
        parametersFormLayout.addRow("Header length:", self.headerLengthWidget)

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        self.loadLandmarkNode = qt.QCheckBox()
        self.loadLandmarkNode.checked = 0
        self.loadLandmarkNode.setToolTip(
            "After conversion, load landmarks into the scene.")
        parametersFormLayout.addRow("Load landmarks into scene",
                                    self.loadLandmarkNode)

        #
        # 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.inputFileSelector.connect('validInputChanged(bool)',
                                       self.onSelect)

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

        # Refresh Apply button state
        self.onSelect()
コード例 #25
0
  def setup(self):

    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

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

   # fixed landmarks (mrml input)
    self.fixedLandmarks = slicer.qMRMLNodeComboBox()
    self.fixedLandmarks.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
    self.fixedLandmarks.selectNodeUponCreation = True
    self.fixedLandmarks.addEnabled = False
    self.fixedLandmarks.removeEnabled = False
    self.fixedLandmarks.noneEnabled = True
    self.fixedLandmarks.showHidden = False
    self.fixedLandmarks.renameEnabled = True
    self.fixedLandmarks.setMRMLScene( slicer.mrmlScene )
    self.fixedLandmarks.setToolTip( "Landmarks on fixed image." )
    inputFormLayout.addRow("Fixed landmarks: ", self.fixedLandmarks)

    # fixed landmarks (directory input)
    self.fixedLandmarksDirectory = ctk.ctkDirectoryButton()
    self.fixedLandmarksDirectory.directory = qt.QDir.homePath()
    inputFormLayout.addRow("", self.fixedLandmarksDirectory)

    # moving landmarks (mrml input)
    self.movingLandmarks = slicer.qMRMLNodeComboBox()
    self.movingLandmarks.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
    self.movingLandmarks.selectNodeUponCreation = True
    self.movingLandmarks.addEnabled = False
    self.movingLandmarks.removeEnabled = False
    self.movingLandmarks.noneEnabled = True
    self.movingLandmarks.showHidden = False
    self.movingLandmarks.showChildNodeTypes = False
    self.movingLandmarks.setMRMLScene( slicer.mrmlScene )
    self.movingLandmarks.setToolTip( "Landmarks on moving image." )
    inputFormLayout.addRow("Moving landmarks: ", self.movingLandmarks)

    self.view = qt.QTableView()
    self.view.sortingEnabled = True
    self.parent.layout().addWidget(self.view)

    # moving landmarks (directory input)
    self.movingLandmarksDirectory = ctk.ctkDirectoryButton()
    self.movingLandmarksDirectory.directory = qt.QDir.homePath()
    inputFormLayout.addRow("", self.movingLandmarksDirectory) 

    # Apply Button
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = True
    self.layout.addWidget(self.applyButton)

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

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

    # output statistics 
    buttonLayout = qt.QHBoxLayout()
    self.averageError = qt.QLineEdit()
    self.averageErrorValue = 1
    self.averageError.setToolTip( "Average landmark separation" )
    buttonLayout.addWidget(self.averageError)
    outputFormLayout.addRow("Average error:", buttonLayout)
     
    buttonLayout = qt.QHBoxLayout()
    self.Variance = qt.QLineEdit()
    self.VarianceValue = 1
    self.Variance.setToolTip( "Variance" )
    buttonLayout.addWidget(self.Variance)
    outputFormLayout.addRow("Variance:", buttonLayout)

    buttonLayout = qt.QHBoxLayout()
    self.stDev = qt.QLineEdit()
    self.stDevValue = 1
    self.stDev.setToolTip( "Standard deviation" )
    buttonLayout.addWidget(self.stDev)
    outputFormLayout.addRow("Standard deviation:", buttonLayout)

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

    # connections
    self.fixedLandmarks.connect("currentNodeChanged(vtkMRMLNode*)",  self.onFixedLandmarksSelect)
    self.movingLandmarks.connect("currentNodeChanged(vtkMRMLNode*)", self.onMovingLandmarksSelect)
    self.applyButton.connect('clicked(bool)', self.onMismatchErrorApply)
コード例 #26
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

    # Layout within the dummy collapsible button
    parametersInputFormLayout = qt.QFormLayout(parametersInputCollapsibleButton)

    #
    # input T1 volume selector
    #
    self.inputT1Selector = slicer.qMRMLNodeComboBox()
    self.inputT1Selector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputT1Selector.selectNodeUponCreation = True
    self.inputT1Selector.addEnabled = False
    self.inputT1Selector.removeEnabled = True
    self.inputT1Selector.noneEnabled = True
    self.inputT1Selector.showHidden = False
    self.inputT1Selector.showChildNodeTypes = False
    self.inputT1Selector.setMRMLScene(slicer.mrmlScene)
    self.inputT1Selector.setToolTip("A T1 weighted MRI image from a healthy individual.")
    parametersInputFormLayout.addRow("T1 Volume ", self.inputT1Selector)

    #
    # input T2 volume selector
    #
    self.inputT2Selector = slicer.qMRMLNodeComboBox()
    self.inputT2Selector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputT2Selector.selectNodeUponCreation = False
    self.inputT2Selector.addEnabled = False
    self.inputT2Selector.removeEnabled = True
    self.inputT2Selector.noneEnabled = True
    self.inputT2Selector.showHidden = False
    self.inputT2Selector.showChildNodeTypes = False
    self.inputT2Selector.setMRMLScene(slicer.mrmlScene)
    self.inputT2Selector.setToolTip("A T2 weighted MRI image from a healthy individual.")
    parametersInputFormLayout.addRow("T2 Volume ", self.inputT2Selector)

    #
    # input FLAIR volume selector
    #
    self.inputFLAIRSelector = slicer.qMRMLNodeComboBox()
    self.inputFLAIRSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputFLAIRSelector.selectNodeUponCreation = False
    self.inputFLAIRSelector.addEnabled = False
    self.inputFLAIRSelector.removeEnabled = True
    self.inputFLAIRSelector.noneEnabled = True
    self.inputFLAIRSelector.showHidden = False
    self.inputFLAIRSelector.showChildNodeTypes = False
    self.inputFLAIRSelector.setMRMLScene(slicer.mrmlScene)
    self.inputFLAIRSelector.setToolTip("A T2-FLAIR weighted MRI image from a healthy individual.")
    parametersInputFormLayout.addRow("T2-FLAIR Volume ", self.inputFLAIRSelector)

    #
    # input PD volume selector
    #
    self.inputPDSelector = slicer.qMRMLNodeComboBox()
    self.inputPDSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputPDSelector.selectNodeUponCreation = False
    self.inputPDSelector.addEnabled = False
    self.inputPDSelector.removeEnabled = True
    self.inputPDSelector.noneEnabled = True
    self.inputPDSelector.showHidden = False
    self.inputPDSelector.showChildNodeTypes = False
    self.inputPDSelector.setMRMLScene(slicer.mrmlScene)
    self.inputPDSelector.setToolTip("A PD weighted MRI image from a healthy individual.")
    parametersInputFormLayout.addRow("PD Volume ", self.inputPDSelector)

    #
    # input DTI-FA volume selector
    #
    self.inputFASelector = slicer.qMRMLNodeComboBox()
    self.inputFASelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputFASelector.selectNodeUponCreation = False
    self.inputFASelector.addEnabled = False
    self.inputFASelector.removeEnabled = True
    self.inputFASelector.noneEnabled = True
    self.inputFASelector.showHidden = False
    self.inputFASelector.showChildNodeTypes = False
    self.inputFASelector.setMRMLScene(slicer.mrmlScene)
    self.inputFASelector.setToolTip("A DTI-FA map from a healthy individual.")
    parametersInputFormLayout.addRow("DTI-FA Map ", self.inputFASelector)

    #
    # input DTI-ADC volume selector
    #
    self.inputADCSelector = slicer.qMRMLNodeComboBox()
    self.inputADCSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputADCSelector.selectNodeUponCreation = False
    self.inputADCSelector.addEnabled = False
    self.inputADCSelector.removeEnabled = True
    self.inputADCSelector.noneEnabled = True
    self.inputADCSelector.showHidden = False
    self.inputADCSelector.showChildNodeTypes = False
    self.inputADCSelector.setMRMLScene(slicer.mrmlScene)
    self.inputADCSelector.setToolTip("A DTI-ADC map from a healthy individual.")
    parametersInputFormLayout.addRow("DTI-ADC Map ", self.inputADCSelector)

    #
    # Return inputs to original space
    #
    self.setReturnOriginalSpaceBooleanWidget = ctk.ctkCheckBox()
    self.setReturnOriginalSpaceBooleanWidget.setChecked(False)
    self.setReturnOriginalSpaceBooleanWidget.setToolTip(
      "Choose if you want to transform the final images to its original space. If not, all the input images will be in T1 space. NOTE: This choice only takes "
      "effect on the baseline MS lesion simulation, i.e. the longitudinal lesion simulation (if checked) will always return the data using the T1 space.")
    parametersInputFormLayout.addRow("Return output data in the original space",
                                      self.setReturnOriginalSpaceBooleanWidget)

    #
    # Is brain extracted?
    #
    self.setIsBETBooleanWidget = ctk.ctkCheckBox()
    self.setIsBETBooleanWidget.setChecked(False)
    self.setIsBETBooleanWidget.setToolTip(
      "Is the input data already brain extracted? This information is only used for MNI152 template, where it helps to the registration process.")
    parametersInputFormLayout.addRow("Is brain extraced?",
                                      self.setIsBETBooleanWidget)

    #
    # is input data on MNI space?
    #
    self.setIsMNIBooleanWidget = ctk.ctkCheckBox()
    self.setIsMNIBooleanWidget.setChecked(False)
    self.setIsMNIBooleanWidget.setToolTip(
      "Is the input data already in MNI space? If the input volumes are already in the MNI space, the time-consuming registration step will be skipped.")
    parametersInputFormLayout.addRow("Is data in MNI space?",
                                     self.setIsMNIBooleanWidget)

    #
    # Lesion Load value
    #
    self.lesionLoadSliderWidget = ctk.ctkSliderWidget()
    self.lesionLoadSliderWidget.singleStep = 1
    self.lesionLoadSliderWidget.minimum = 5
    self.lesionLoadSliderWidget.maximum = 50
    self.lesionLoadSliderWidget.value = 10
    self.lesionLoadSliderWidget.setToolTip("Set the desired lesion load to be used for MS lesion generation.")
    parametersInputFormLayout.addRow("Lesion Load", self.lesionLoadSliderWidget)

    #
    # MS Longitudinal Lesion Simulation Parameters Area
    #
    parametersMSLongitudinalLesionSimulationCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersMSLongitudinalLesionSimulationCollapsibleButton.text = "MS Longitudinal Lesion Simulation Parameters"
    self.layout.addWidget(parametersMSLongitudinalLesionSimulationCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersMSLongitudinalLesionSimulationFormLayout = qt.QFormLayout(parametersMSLongitudinalLesionSimulationCollapsibleButton)

    #
    # Simulate follow-up?
    #
    self.setSimulateFollowUpBooleanWidget = ctk.ctkCheckBox()
    self.setSimulateFollowUpBooleanWidget.setChecked(False)
    self.setSimulateFollowUpBooleanWidget.setToolTip(
      "Simulate an additional longitudinal sequence (given the same input data)? If checked, the MS Lesion Simulator tool will recreate a sequence of exams with "
      "longitudinal MS lesion pattern.")
    parametersMSLongitudinalLesionSimulationFormLayout.addRow("Simulate Longitudinal Exams?",
                                      self.setSimulateFollowUpBooleanWidget)

    #
    # Follow-ups
    #
    self.followUpsSliderWidget = ctk.ctkSliderWidget()
    self.followUpsSliderWidget.singleStep = 1
    self.followUpsSliderWidget.minimum = 2
    self.followUpsSliderWidget.maximum = 6
    self.followUpsSliderWidget.value = 2
    self.followUpsSliderWidget.setToolTip("Set the desired number of follow-up acquisitions that will be simulated.")
    parametersMSLongitudinalLesionSimulationFormLayout.addRow("Follow-ups", self.followUpsSliderWidget)

    #
    # Balance: Hypointense to isointense lesions
    #
    self.setBalanceHypo2IsoWidget = qt.QSpinBox()
    self.setBalanceHypo2IsoWidget.setMaximum(100)
    self.setBalanceHypo2IsoWidget.setMinimum(1)
    self.setBalanceHypo2IsoWidget.setSingleStep(0.1)
    self.setBalanceHypo2IsoWidget.setValue(56)
    self.setBalanceHypo2IsoWidget.setToolTip(
      "Set the percentage of lesions that will change its original signal state along the follow-ups.")
    parametersMSLongitudinalLesionSimulationFormLayout.addRow("Changing Contrast Balance ", self.setBalanceHypo2IsoWidget)

    #
    # output follow-ups selector
    #
    self.outputFollowUpsSelector = ctk.ctkDirectoryButton()
    self.outputFollowUpsSelector.setToolTip("Output folder where follow-up image files will be saved.")
    if platform.system() is "Windows":
      home = expanduser("%userprofile%")
    else:
      home = expanduser("~")
    self.outputFollowUpsSelector.directory = home
    parametersMSLongitudinalLesionSimulationFormLayout.addRow("Output Follow-Up ", self.outputFollowUpsSelector)

    #
    # Advanced Parameters Area
    #
    parametersAdvancedParametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersAdvancedParametersCollapsibleButton.text = "Advanced Parameters"
    self.layout.addWidget(parametersAdvancedParametersCollapsibleButton)
    parametersAdvancedParametersCollapsibleButton.click()

    # Layout within the dummy collapsible button
    parametersAdvancedParametersFormLayout = qt.QFormLayout(parametersAdvancedParametersCollapsibleButton)

    #
    # White Matter Threshold
    #
    self.setWMThresholdWidget = qt.QDoubleSpinBox()
    self.setWMThresholdWidget.setMaximum(5)
    self.setWMThresholdWidget.setMinimum(0.1)
    self.setWMThresholdWidget.setSingleStep(0.01)
    self.setWMThresholdWidget.setValue(1.5)
    self.setWMThresholdWidget.setToolTip("Set the White Matter threshold used to refine the simulated lesion map. The simulation supose that the MS lesions"
                                         "belongs only in the White Matter space. This variable is related to the voxel intensity and the White Matter probability"
                                         " distribution (standard deviation).")
    parametersAdvancedParametersFormLayout.addRow("White Matter Threshold ", self.setWMThresholdWidget)

    #
    # Percentage Sampling Area
    #
    self.setPercSamplingQWidget = qt.QDoubleSpinBox()
    self.setPercSamplingQWidget.setDecimals(4)
    self.setPercSamplingQWidget.setMaximum(1)
    self.setPercSamplingQWidget.setMinimum(0.0001)
    self.setPercSamplingQWidget.setSingleStep(0.001)
    self.setPercSamplingQWidget.setValue(0.05)
    self.setPercSamplingQWidget.setToolTip("Percentage of voxel used in registration.")
    parametersAdvancedParametersFormLayout.addRow("Percentage Of Samples ", self.setPercSamplingQWidget)

    #
    # BSpline Grid
    #
    self.setBSplineGridWidget = qt.QLineEdit()
    self.setBSplineGridWidget.setText('5,5,5')
    self.setBSplineGridWidget.setToolTip("Set the BSpline grid for non linear structural adjustments.")
    parametersAdvancedParametersFormLayout.addRow("BSpline Grid ", self.setBSplineGridWidget)

    #
    # Initiation Method Area
    #
    self.setInitiationRegistrationBooleanWidget = ctk.ctkComboBox()
    self.setInitiationRegistrationBooleanWidget.addItem("useCenterOfHeadAlign")
    self.setInitiationRegistrationBooleanWidget.addItem("Off")
    self.setInitiationRegistrationBooleanWidget.addItem("useMomentsAlign")
    self.setInitiationRegistrationBooleanWidget.addItem("useGeometryAlign")
    self.setInitiationRegistrationBooleanWidget.setToolTip(
      "Initialization method used for the MNI152 registration.")
    parametersAdvancedParametersFormLayout.addRow("Initiation Method ", self.setInitiationRegistrationBooleanWidget)

    #
    # Number of Threads in Segmentation Steps
    #
    self.setNumberOfThreadsWidget = qt.QSpinBox()
    self.setNumberOfThreadsWidget.setMaximum(multiprocessing.cpu_count())
    self.setNumberOfThreadsWidget.setMinimum(-1)
    self.setNumberOfThreadsWidget.setSingleStep(1)
    self.setNumberOfThreadsWidget.setValue(-1)
    self.setNumberOfThreadsWidget.setToolTip("Number of threads to be used in segmentation steps. -1 equals to all possible threads being used.")
    parametersAdvancedParametersFormLayout.addRow("Number of Threads ", self.setNumberOfThreadsWidget)

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

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.inputT1Selector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.inputT2Selector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.inputFLAIRSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.inputPDSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

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

    # Refresh Apply button state
    self.onSelect()
コード例 #27
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)

        # input directory selector
        self.InputDirectorySelector = ctk.ctkDirectoryButton()
        self.InputDirectorySelector.caption = 'Input Data Directory'
        self.InputDirectorySelector.directory = INPUT_DIR
        self.UpdateDirectoryButtonText(self.InputDirectorySelector)
        self.InputDirectorySelector.connect('directoryChanged(QString)', self.onInputDirectoryChanged)
        parametersFormLayout.addRow("Data Directory", self.InputDirectorySelector)

        # Output file name
        self.outputFileName = qt.QLineEdit("ToothFractureWaveletStatistics.csv")
        parametersFormLayout.addRow("Output File Name", self.outputFileName)

        #
        # threshold value
        #
        self.imageThresholdSliderWidget = ctk.ctkSliderWidget()
        self.imageThresholdSliderWidget.singleStep = 1.0
        self.imageThresholdSliderWidget.minimum = 0
        self.imageThresholdSliderWidget.maximum = 100
        self.imageThresholdSliderWidget.value = 95
        self.imageThresholdSliderWidget.setToolTip(
            "Set the percentile value to record if Use Percentile checkbox is checked.")
        parametersFormLayout.addRow("Precentile", self.imageThresholdSliderWidget)

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
        self.enableScreenshotsFlagCheckBox.checked = 0
        self.enableScreenshotsFlagCheckBox.setToolTip(
            "If checked, use n'th percentile value (chosen from above slider) as the feature value, else just the max.")
        parametersFormLayout.addRow("Use Percentile", self.enableScreenshotsFlagCheckBox)

        #
        # 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)

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

        # Refresh Apply button state
        self.onSelect()
コード例 #28
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)

        #
        # input landmark directory selector
        #
        self.inputLandmarkDirectory = ctk.ctkDirectoryButton()
        self.inputLandmarkDirectory.directory = qt.QDir.homePath()
        parametersFormLayout.addRow("Landmark Directory:",
                                    self.inputLandmarkDirectory)
        self.inputLandmarkDirectory.setToolTip(
            "Select directory containing landmark files")

        #
        # input landmark numbers for grid
        #
        gridPointsLayout = qt.QGridLayout()
        self.landmarkGridPoint1 = ctk.ctkDoubleSpinBox()
        self.landmarkGridPoint1.minimum = 0
        self.landmarkGridPoint1.singleStep = 1
        self.landmarkGridPoint1.setDecimals(0)
        self.landmarkGridPoint1.setToolTip(
            "Input the landmark numbers to create grid")

        self.landmarkGridPoint2 = ctk.ctkDoubleSpinBox()
        self.landmarkGridPoint2.minimum = 0
        self.landmarkGridPoint2.singleStep = 1
        self.landmarkGridPoint2.setDecimals(0)
        self.landmarkGridPoint2.setToolTip(
            "Input the landmark numbers to create grid")

        self.landmarkGridPoint3 = ctk.ctkDoubleSpinBox()
        self.landmarkGridPoint3.minimum = 0
        self.landmarkGridPoint3.singleStep = 1
        self.landmarkGridPoint3.setDecimals(0)
        self.landmarkGridPoint3.setToolTip(
            "Input the landmark numbers to create grid")

        self.landmarkGridPoint4 = ctk.ctkDoubleSpinBox()
        self.landmarkGridPoint4.minimum = 0
        self.landmarkGridPoint4.singleStep = 1
        self.landmarkGridPoint4.setDecimals(0)
        self.landmarkGridPoint4.setToolTip(
            "Input the landmark numbers to create grid")

        gridPointsLayout.addWidget(self.landmarkGridPoint1, 1, 2)
        gridPointsLayout.addWidget(self.landmarkGridPoint2, 1, 3)
        gridPointsLayout.addWidget(self.landmarkGridPoint3, 1, 4)
        gridPointsLayout.addWidget(self.landmarkGridPoint4, 1, 5)

        parametersFormLayout.addRow("Semi-landmark grid points:",
                                    gridPointsLayout)

        #
        # input mesh directory selector
        #
        self.inputMeshDirectory = ctk.ctkDirectoryButton()
        self.inputMeshDirectory.directory = qt.QDir.homePath()
        parametersFormLayout.addRow("Mesh Directory:", self.inputMeshDirectory)
        self.inputMeshDirectory.setToolTip(
            "Select directory containing mesh files")

        #
        # output directory selector
        #
        self.outputDirectory = ctk.ctkDirectoryButton()
        self.outputDirectory.directory = qt.QDir.homePath()
        parametersFormLayout.addRow("Output Directory:", self.outputDirectory)
        self.inputMeshDirectory.setToolTip(
            "Select directory for output semi-landmark files")

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
        self.enableScreenshotsFlagCheckBox.checked = 0
        self.enableScreenshotsFlagCheckBox.setToolTip(
            "If checked, take screen shots for tutorials. Use Save Data to write them to disk."
        )
        parametersFormLayout.addRow("Enable Screenshots",
                                    self.enableScreenshotsFlagCheckBox)

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

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

        # Add vertical spacer
        self.layout.addStretch(1)
コード例 #29
0
ファイル: Groups.py プロジェクト: mmmosman88/GROUPS
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        ###################################################################
        ##                                                               ##
        ##  Collapsible part for input/output parameters for Groups CLI  ##
        ##                                                               ##
        ###################################################################

        self.ioCollapsibleButton = ctk.ctkCollapsibleButton()
        self.ioCollapsibleButton.text = "IO"
        self.layout.addWidget(self.ioCollapsibleButton)
        self.ioQVBox = qt.QVBoxLayout(self.ioCollapsibleButton)

        # --------------------------------- #
        # ----- Group Box DIRECTORIES ----- #
        # --------------------------------- #
        self.directoryGroupBox = qt.QGroupBox("Groups Dircetories")
        self.ioQVBox.addWidget(self.directoryGroupBox)
        self.ioQFormLayout = qt.QFormLayout(self.directoryGroupBox)

        # Selection of the directory containing the input models (option: --surfaceDir) and option procalign shape
        self.inputMeshTypeHBox = qt.QVBoxLayout(self.directoryGroupBox)
        self.inputModelsDirectorySelector = ctk.ctkDirectoryButton()
        
        self.inputMeshTypeHBox.addWidget(self.inputModelsDirectorySelector)
        self.ioQFormLayout.addRow(qt.QLabel("Input Models Directory:"), self.inputMeshTypeHBox)

        # Selection of the directory which contains each spherical model (option: --sphereDir)
        self.sphericalModelsDirectorySelector = ctk.ctkDirectoryButton()
        self.ioQFormLayout.addRow("Spherical Models Directory:", self.sphericalModelsDirectorySelector)

        # Selection of the output directory for Groups (option: --outputDir)
        self.outputDirectorySelector = ctk.ctkDirectoryButton()
        self.ioQFormLayout.addRow(qt.QLabel("Output Directory:"), self.outputDirectorySelector)

        # CheckBox. If checked, Group Box 'Parameters' will be enabled
        self.enableRigidAlignmentCB = ctk.ctkCheckBox()
        self.enableRigidAlignmentCB.setText("Perform Rigid Alignment")
        self.ioQFormLayout.addRow(self.enableRigidAlignmentCB)

        # CheckBox. If checked, Group Box 'Parameters' will be enabled
        self.enableParamCB = ctk.ctkCheckBox()
        self.enableParamCB.setText("Personalize Groups parameters")
        self.ioQFormLayout.addRow(self.enableParamCB)

        # Connections
        self.inputModelsDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect)
        self.sphericalModelsDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect)
        self.outputDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect)
        self.enableRigidAlignmentCB.connect("stateChanged(int)", self.onCheckBoxRigidAlignment)
        self.enableParamCB.connect("stateChanged(int)", self.onCheckBoxParam)

        # Name simplification (string)
        self.modelsDirectory = str(self.inputModelsDirectorySelector.directory)
        self.sphericalmodelsDirectory = str(self.sphericalModelsDirectorySelector.directory)
        self.outputDirectory = str(self.outputDirectorySelector.directory)


        # ------------------------------------------ #
        # ----- RigidAlignment Box DIRECTORIES ----- #
        # ------------------------------------------ #

        self.rigidalignmentdirectoryGroupBox = qt.QGroupBox("Rigid Alignment Directories")
        self.ioQVBox.addWidget(self.rigidalignmentdirectoryGroupBox)
        self.ioQFormLayout = qt.QFormLayout(self.rigidalignmentdirectoryGroupBox)
        self.rigidalignmentdirectoryGroupBox.setEnabled(False)

        # Selection of the directory which contains each landmark fcsv file (option: --landmark)
        self.inputlandmarksfiducialfilesDirectorySelector = ctk.ctkDirectoryButton()
        self.ioQFormLayout.addRow("Input Landmarks Fiducial Files Directory:", self.inputlandmarksfiducialfilesDirectorySelector)

        # Selection of the directory which contains common unit sphere file (option: --sphere)
        self.inputunitspherefileDirectorySelector = ctk.ctkDirectoryButton()
        self.ioQFormLayout.addRow("Input Unit Sphere File Directory:", self.inputunitspherefileDirectorySelector)

        # Connections
        self.inputlandmarksfiducialfilesDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect)
        self.inputunitspherefileDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect)

        # Name simplification (string)
        self.landmarksDirectory = str(self.inputlandmarksfiducialfilesDirectorySelector.directory)
        self.sphereDirectory = str(self.inputunitspherefileDirectorySelector.directory)

        # -------------------------------- #
        # ----- Group Box PARAMETERS ----- #
        # -------------------------------- #
        self.parametersGroupBox = qt.QGroupBox("Groups Parameters")
        self.ioQVBox.addWidget(self.parametersGroupBox)
        self.paramQFormLayout = qt.QFormLayout(self.parametersGroupBox)
        self.parametersGroupBox.setEnabled(False)

        # Selection of the property we want to use 
        self.specifyPropertySelector = ctk.ctkCheckableComboBox()
        self.specifyPropertySelector.addItems(("Curvedness","Shape_Index"))
        self.paramQFormLayout.addRow(qt.QLabel("Properties name to use:"), self.specifyPropertySelector)

        # Weights of each property - Choices on 1 lines 
        self.weightLayout = qt.QVBoxLayout(self.parametersGroupBox)
        self.weightline1 = qt.QHBoxLayout(self.parametersGroupBox)  # Line 1
        self.weightLayout.addLayout(self.weightline1)

        # Fill out first line
        self.labelCurvedness = qt.QLabel("Curvedness")
        self.weightline1.addWidget(self.labelCurvedness)
        self.weightCurvedness = ctk.ctkDoubleSpinBox()
        self.weightCurvedness.enabled = False
        self.weightCurvedness.value = 1
        self.weightline1.addWidget(self.weightCurvedness)

        self.labelShape_Index = qt.QLabel(" Shape_Index")
        self.weightline1.addWidget(self.labelShape_Index)
        self.weightShape_Index = ctk.ctkDoubleSpinBox()
        self.weightShape_Index.enabled = False
        self.weightShape_Index.value = 1
        self.weightline1.addWidget(self.weightShape_Index)

        self.paramQFormLayout.addRow("Weight of each property:", self.weightLayout)

        # CheckBox. If checked, Landmarks enabled
        self.enableLandmarks = ctk.ctkCheckBox()
        self.enableLandmarks.setText("Enable Landmarks")
        self.paramQFormLayout.addRow(self.enableLandmarks)

        # Specification of the SPHARM decomposition degree (option: -d)
        self.degreeSpharm = ctk.ctkSliderWidget()
        self.degreeSpharm.minimum = 0
        self.degreeSpharm.maximum = 50
        self.degreeSpharm.value = 5        # initial value
        self.degreeSpharm.setDecimals(0)
        self.paramQFormLayout.addRow(qt.QLabel("Degree of SPHARM decomposition:"), self.degreeSpharm)

        # Maximum iteration (option: --maxIter)
        self.maxIter = qt.QSpinBox()
        self.maxIter.minimum = 0            # Check the range authorized
        self.maxIter.maximum = 100000
        self.maxIter.value = 5000
        self.paramQFormLayout.addRow("Maximum number of iteration:", self.maxIter)


        # Name simplification
        self.property = ""
        self.propertyValue = ""

        # Connections
        self.specifyPropertySelector.connect("checkedIndexesChanged()", self.onSpecifyPropertyChanged)

        # ------------------------------------------ #
        # ----- Apply button to launch the CLI ----- #
        # ------------------------------------------ #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.enabled = False
        self.ioQVBox.addWidget(self.applyButton)

        self.errorLabel = qt.QLabel("Error: Invalide inputs")
        self.errorLabel.hide()
        self.errorLabel.setStyleSheet("color: rgb(255, 0, 0);")
        self.ioQVBox.addWidget(self.errorLabel)

        # Connections
        self.applyButton.connect('clicked(bool)', self.onApplyButtonClicked)

        # ----- Add vertical spacer ----- #
        self.layout.addStretch(1)
コード例 #30
0
  def setup(self):

    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

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

    # vf image (mrml input)
    self.vfMRMLSelector = slicer.qMRMLNodeComboBox()
    self.vfMRMLSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
    self.vfMRMLSelector.selectNodeUponCreation = True
    self.vfMRMLSelector.addEnabled = False
    self.vfMRMLSelector.removeEnabled = False
    self.vfMRMLSelector.noneEnabled = True
    self.vfMRMLSelector.showHidden = False
    self.vfMRMLSelector.setMRMLScene( slicer.mrmlScene )
    self.vfMRMLSelector.setToolTip( "Pick the input to the algorithm." )
    inputFormLayout.addRow("Vector Field image: ", self.vfMRMLSelector)

    # variables
    self.minJacobianValue = 1
    self.maxJacobianValue = 1

    # vf image (directory input)
    self.vfInputDirectory = ctk.ctkDirectoryButton()
    self.vfInputDirectory.directory = qt.QDir.homePath()
    inputFormLayout.addRow("Input Directory:", self.vfInputDirectory)

    # Fixed image (for geometry info)
    self.fixedImage = slicer.qMRMLNodeComboBox()
    self.fixedImage.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.fixedImage.setMRMLScene( slicer.mrmlScene )
    self.fixedImage.selectNodeUponCreation = True
    self.fixedImage.addEnabled = False
    self.fixedImage.renameEnabled = True
    self.fixedImage.noneEnabled = True
    self.fixedImage.setToolTip( "Output image of Jacobian matrix.vtkSlicerPlastimatchModuleLogicPython" )
    inputFormLayout.addRow("Fixed image (for geometry info): ", self.fixedImage)

    # Apply Button
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = True
    self.layout.addWidget(self.applyButton)
    
    ### Output Area
    outputCollapsibleButton = ctk.ctkCollapsibleButton()
    outputCollapsibleButton.text = "Output"
    self.layout.addWidget(outputCollapsibleButton)

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

    # Jacobian image (mrml output)
    self.outputJacobian = slicer.qMRMLNodeComboBox()
    self.outputJacobian.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.outputJacobian.setMRMLScene( slicer.mrmlScene )
    self.outputJacobian.addEnabled = True
    self.outputJacobian.renameEnabled = True
    #self.outputJacobian.layout().addWidget(self.outputSelector)
    self.outputJacobian.setToolTip( "Output image of Jacobian matrix.vtkSlicerPlastimatchModuleLogicPython" )
    outputFormLayout.addRow("Jacobian image: ", self.outputJacobian)

    # output directory selector
#    self.outputDirectory = ctk.ctkDirectoryButton()
#    self.outputDirectory.directory = qt.QDir.homePath()
#    outputFormLayout.addRow("Output Directory: ", self.outputDirectory)
    
    # output statistics
    buttonLayout = qt.QHBoxLayout()
    self.minJacobian = qt.QLineEdit()
    self.minJacobian.setToolTip( "Minimum value of Jacobian matrix" ) 
    buttonLayout.addWidget(self.minJacobian)
    outputFormLayout.addRow("Minimum Jacobian:", buttonLayout)

    buttonLayout = qt.QHBoxLayout()
    self.maxJacobian = qt.QLineEdit()
    self.maxJacobian.setToolTip( "Maximum value of Jacobian matrix" ) 
    buttonLayout.addWidget(self.maxJacobian)
    outputFormLayout.addRow("Maximum Jacobian:", buttonLayout)    

    # connections
    self.applyButton.connect('clicked(bool)', self.onJacobianApply)
    self.outputJacobian.connect("currentNodeChanged(vtkMRMLNode*)", self.onOutputJacobianSelect)
    self.fixedImage.connect("currentNodeChanged(vtkMRMLNode*)", self.onFixedImageSelect)
    self.vfMRMLSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onvfMRMLSelect)

    # Add vertical spacer
    self.layout.addStretch(1)
コード例 #31
0
    def setup(self):
        """Init the widget """
        # self.firstLoad = True
        ScriptedLoadableModuleWidget.setup(self)

        # Create objects that can be used anywhere in the module. Example: in most cases there should be just one
        # object of the logic class
        self._initLogic_()

        ##########
        # Main area
        self.mainAreaCollapsibleButton = ctk.ctkCollapsibleButton()
        self.mainAreaCollapsibleButton.text = "Main area"
        self.layout.addWidget(self.mainAreaCollapsibleButton,
                              SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.mainLayout = qt.QGridLayout(self.mainAreaCollapsibleButton)

        # Node selector
        volumeLabel = qt.QLabel("Active volume: ")
        volumeLabel.setStyleSheet("margin-left:5px")
        self.mainLayout.addWidget(volumeLabel, 0, 0)
        self.volumeSelector = slicer.qMRMLNodeComboBox()
        self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.volumeSelector.selectNodeUponCreation = True
        self.volumeSelector.autoFillBackground = True
        self.volumeSelector.addEnabled = False
        self.volumeSelector.noneEnabled = False
        self.volumeSelector.removeEnabled = False
        self.volumeSelector.showHidden = False
        self.volumeSelector.showChildNodeTypes = False
        self.volumeSelector.setMRMLScene(slicer.mrmlScene)
        self.volumeSelector.setMinimumWidth(150)
        self.volumeSelector.setStyleSheet("margin: 15px 0")
        # self.volumeSelector.selectNodeUponCreation = False
        self.mainLayout.addWidget(self.volumeSelector, 0, 1, 1, 2)
        self.volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                    self._onMainVolumeChanged_)

        ### Radio buttons frame
        self.radioButtonsFrame = qt.QFrame()
        self.radioButtonsLayout = qt.QHBoxLayout(self.radioButtonsFrame)
        self.typesFrame = qt.QFrame()
        self.radioButtonsLayout.addWidget(self.typesFrame)
        self.typesLayout = qt.QVBoxLayout(self.typesFrame)

        labelsStyle = "font-weight: bold; margin: 0 0 10px 0px;"
        # Types Radio Buttons
        typesLabel = qt.QLabel("Select type")
        typesLabel.setStyleSheet(labelsStyle)
        self.typesLayout.addWidget(typesLabel)
        self.typesRadioButtonGroup = qt.QButtonGroup()
        for key in self.logic.params.mainTypes.keys():
            rbitem = qt.QRadioButton(self.logic.params.getMainTypeLabel(key))
            self.typesRadioButtonGroup.addButton(rbitem, key)
            self.typesLayout.addWidget(rbitem)
        self.typesRadioButtonGroup.buttons()[0].setChecked(True)

        # Subtypes Radio buttons
        # The content will be loaded dynamically every time the main type is modified
        self.subtypesFrame = qt.QFrame()
        self.radioButtonsLayout.addWidget(self.subtypesFrame)
        self.subtypesLayout = qt.QVBoxLayout(self.subtypesFrame)
        subtypesLabel = qt.QLabel("Select subtype")
        subtypesLabel.setStyleSheet(labelsStyle)
        self.subtypesLayout.addWidget(subtypesLabel)
        self.subtypesLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.subtypesRadioButtonGroup = qt.QButtonGroup()
        # Add all the subtypes (we will filter later in "updateState" function)
        for key in self.logic.params.subtypes.keys():
            # Build the description
            rbitem = qt.QRadioButton(self.logic.params.getSubtypeLabel(key))
            self.subtypesRadioButtonGroup.addButton(rbitem, key)
            self.subtypesLayout.addWidget(rbitem,
                                          SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.subtypesLayout.addStretch()

        # Region radio buttons
        self.regionsFrame = qt.QFrame()
        self.radioButtonsLayout.addWidget(self.regionsFrame)
        self.regionsLayout = qt.QVBoxLayout(self.regionsFrame)
        regionsLabel = qt.QLabel("Select region")
        regionsLabel.setStyleSheet(labelsStyle)
        self.regionsLayout.addWidget(regionsLabel)
        self.regionsLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.regionsLayout.setStretch(0, 0)
        self.regionsRadioButtonGroup = qt.QButtonGroup()
        self.regionsFrame = qt.QFrame()
        # Add all the regions
        for key in self.logic.params.regions.keys():
            # Build the description
            rbitem = qt.QRadioButton(self.logic.params.getRegionLabel(key))
            self.regionsRadioButtonGroup.addButton(rbitem, key)
            self.regionsLayout.addWidget(rbitem,
                                         SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.regionsLayout.addStretch()
        self.regionsRadioButtonGroup.buttons()[0].setChecked(True)

        # Artifact radio buttons (Add them to the same layout as the type)
        # self.separatorLabel = qt.QLabel("------------")
        # labelsStyle = "margin: 5px 0 5px 0;"
        # self.separatorLabel.setStyleSheet(labelsStyle)
        # self.typesLayout.addWidget(self.separatorLabel)
        # self.artifactsLabel = qt.QLabel("Select artifact")
        # labelsStyle = "font-weight: bold; margin: 15px 0 10px 0;"
        # self.artifactsLabel.setStyleSheet(labelsStyle)
        # self.typesLayout.addWidget(self.artifactsLabel)
        # self.artifactsRadioButtonGroup = qt.QButtonGroup()
        # for artifactId in self.logic.params.artifacts.iterkeys():
        #     rbitem = qt.QRadioButton(self.logic.params.getArtifactLabel(artifactId))
        #     self.artifactsRadioButtonGroup.addButton(rbitem, artifactId)
        #     self.typesLayout.addWidget(rbitem)
        # self.artifactsRadioButtonGroup.buttons()[0].setChecked(True)
        #
        self.typesLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.typesLayout.addStretch()

        # Connections
        self.typesRadioButtonGroup.connect("buttonClicked (QAbstractButton*)",
                                           self.__onTypesRadioButtonClicked__)
        self.subtypesRadioButtonGroup.connect(
            "buttonClicked (QAbstractButton*)",
            self.__onSecondaryRadioButtonClicked__)
        self.regionsRadioButtonGroup.connect(
            "buttonClicked (QAbstractButton*)",
            self.__onSecondaryRadioButtonClicked__)
        # self.artifactsRadioButtonGroup.connect("buttonClicked (QAbstractButton*)", self.__onTypesRadioButtonClicked__)

        self.mainLayout.addWidget(self.radioButtonsFrame, 2, 0, 1, 3,
                                  SlicerUtil.ALIGNMENT_VERTICAL_TOP)

        # Save results button
        self.saveResultsButton = ctk.ctkPushButton()
        self.saveResultsButton.setText("Save results")
        self.saveResultsButton.toolTip = "Save the results labelmap in the specified directory"
        self.saveResultsButton.setIcon(
            qt.QIcon("{0}/Save.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.saveResultsButton.setIconSize(qt.QSize(20, 20))
        self.saveResultsButton.setFixedWidth(135)
        self.mainLayout.addWidget(self.saveResultsButton, 4, 0)
        self.saveResultsButton.connect('clicked()',
                                       self._onSaveResultsButtonClicked_)

        # Save results directory button
        defaultPath = os.path.join(
            SlicerUtil.getSettingsDataFolder(self.moduleName),
            "results")  # Assign a default path for the results
        path = SlicerUtil.settingGetOrSetDefault(self.moduleName,
                                                 "SaveResultsDirectory",
                                                 defaultPath)
        self.saveResultsDirectoryButton = ctk.ctkDirectoryButton()
        self.saveResultsDirectoryButton.directory = path
        self.saveResultsDirectoryButton.setMaximumWidth(440)
        self.mainLayout.addWidget(self.saveResultsDirectoryButton, 4, 1, 1, 2)
        self.saveResultsDirectoryButton.connect(
            "directoryChanged (QString)", self._onSaveResultsDirectoryChanged_)

        self._createSegmentEditorWidget_()

        # MIP viewer (by default it will be hidden)
        self.mipCollapsibleButton = ctk.ctkCollapsibleButton()
        self.mipCollapsibleButton.text = "MIP viewer"
        mipLayout = qt.QVBoxLayout(self.mipCollapsibleButton)
        self.mainLayout.addWidget(self.mipCollapsibleButton)
        self.mipViewer = CIPUI.MIPViewerWidget(mipLayout)
        self.mipCollapsibleButton.setVisible(False)
        self.mipViewer.setup()
        self.mipViewer.isCrosshairEnabled = False
        self.mipCollapsibleButton.collapsed = True

        #####
        # Case navigator
        self.caseNavigatorWidget = None
        if SlicerUtil.isSlicerACILLoaded():
            caseNavigatorAreaCollapsibleButton = ctk.ctkCollapsibleButton()
            caseNavigatorAreaCollapsibleButton.text = "Case navigator"
            self.layout.addWidget(caseNavigatorAreaCollapsibleButton, 0x0020)
            # caseNavigatorLayout = qt.QVBoxLayout(caseNavigatorAreaCollapsibleButton)

            # Add a case list navigator
            from ACIL.ui import CaseNavigatorWidget
            self.caseNavigatorWidget = CaseNavigatorWidget(
                self.moduleName, caseNavigatorAreaCollapsibleButton)
            self.caseNavigatorWidget.setup()
            # Listen for event in order to save the current labelmap before moving to the next case
            self.caseNavigatorWidget.addObservable(
                self.caseNavigatorWidget.EVENT_PRE_NEXT,
                self._checkSaveChanges_)
            self.caseNavigatorWidget.addObservable(
                self.caseNavigatorWidget.EVENT_PRE_PREVIOUS,
                self._checkSaveChanges_)
            self.caseNavigatorWidget.addObservable(
                self.caseNavigatorWidget.EVENT_PRE_LABELMAP_LOAD,
                self._onPreNavigatorLabelmapLoaded_)
            self.caseNavigatorWidget.addObservable(
                self.caseNavigatorWidget.EVENT_LABELMAP_LOADED,
                self._onNavigatorLabelmapLoaded_)

        self.layout.addStretch()

        # Extra Connections
        self._createSceneObservers_()

        self.disableEvents = False
        self.setMainTypeGUIProperties()
コード例 #32
0
    def setup(self):

        self.detailsPopup = None
        self.setDetailsPopup(self.getSavedDICOMDetailsWidgetType()())

        # XXX Slicer 4.5 - Remove these. Here only for backward compatibility.
        self.dicomBrowser = self.detailsPopup.dicomBrowser
        self.tables = self.detailsPopup.tables

        layoutManager = slicer.app.layoutManager()
        if layoutManager is not None:
            layoutManager.layoutChanged.connect(self.onLayoutChanged)

        # connect to the 'Show DICOM Browser' button
        self.showBrowserButton = qt.QPushButton('Show DICOM database browser')
        self.showBrowserButton.setCheckable(True)
        self.layout.addWidget(self.showBrowserButton)
        self.showBrowserButton.setStyleSheet("font:Bold;" "font-size:12px")
        self.showBrowserButton.connect('clicked()', self.toggleDetailsPopup)

        self.loadedDataLabel = qt.QLabel("Loaded data")
        self.loadedDataLabel.setSizePolicy(qt.QSizePolicy.Expanding,
                                           qt.QSizePolicy.Fixed)
        self.layout.addWidget(self.loadedDataLabel)
        font = qt.QFont()
        font.setBold(True)
        font.setPointSize(12)
        self.loadedDataLabel.setFont(font)
        self.layout.addWidget(self.loadedDataLabel)

        self.subjectHierarchyTree = slicer.qMRMLSubjectHierarchyTreeView()
        self.layout.addWidget(self.subjectHierarchyTree)
        self.subjectHierarchyTree.setMRMLScene(slicer.mrmlScene)
        self.subjectHierarchyTree.currentItemChanged.connect(
            self.onCurrentItemChanged)
        self.subjectHierarchyTree.currentItemModified.connect(
            self.onCurrentItemModified)
        self.subjectHierarchyCurrentVisibility = False
        self.subjectHierarchyTree.setColumnHidden(
            self.subjectHierarchyTree.model().idColumn, True)

        self.browserSettingsWidget = ctk.ctkCollapsibleGroupBox()
        self.browserSettingsWidget.title = "Browser settings"
        self.layout.addWidget(self.browserSettingsWidget)
        self.browserSettingsWidget.collapsed = True
        self.browserSettingsWidget.setLayout(qt.QFormLayout())

        self.directoryButton = ctk.ctkDirectoryButton()
        self.browserSettingsWidget.layout().addRow("Local database:",
                                                   self.directoryButton)
        self.directoryButton.directoryChanged.connect(
            self.onDatabaseDirectoryButtonChanged)
        self.onDatabaseDirectoryDetailsPopupChanged(
            self.detailsPopup.dicomBrowser.databaseDirectory)

        self.tableDensityComboBox = qt.QComboBox()
        self.browserSettingsWidget.layout().addRow("Table density:",
                                                   self.tableDensityComboBox)
        self.tableDensityComboBox.currentIndexChanged.connect(
            self.onTableDensityChanged)
        self.updateTableDensityComboBox()

        self.horizontalCheckBox = qt.QCheckBox()
        self.horizontalCheckBox.checked = settingsValue(
            'DICOM/horizontalTables', 0, converter=int)
        self.horizontalCheckBox.stateChanged.connect(
            self.onHorizontalStateChanged)
        self.browserSettingsWidget.layout().addRow("Horizontal:",
                                                   self.horizontalCheckBox)

        self.browserPersistentCheckBox = qt.QCheckBox()
        self.browserPersistentCheckBox.checked = settingsValue(
            'DICOM/BrowserPersistent', False, converter=toBool)
        self.browserPersistentCheckBox.stateChanged.connect(
            self.onBrowserPersistentStateChanged)
        self.browserSettingsWidget.layout().addRow(
            "Browser persistent:", self.browserPersistentCheckBox)

        self.additionalSettingsLayout = qt.QHBoxLayout()

        #
        # servers
        #

        # testing server - not exposed (used for development)
        self.localFrame = ctk.ctkCollapsibleButton(self.parent)
        self.localFrame.setLayout(qt.QVBoxLayout())
        self.localFrame.setText("Servers")
        self.layout.addWidget(self.localFrame)
        self.localFrame.collapsed = True

        self.toggleServer = qt.QPushButton("Start Testing Server")
        self.localFrame.layout().addWidget(self.toggleServer)
        self.toggleServer.connect('clicked()', self.onToggleServer)

        self.verboseServer = qt.QCheckBox("Verbose")
        self.localFrame.layout().addWidget(self.verboseServer)

        # advanced options - not exposed to end users
        # developers can uncomment these lines to access testing server
        self.toggleServer.hide()
        self.verboseServer.hide()

        # Listener

        settings = qt.QSettings()
        self.toggleListener = qt.QPushButton()
        self.toggleListener.checkable = True
        if hasattr(slicer, 'dicomListener'):
            self.toggleListener.text = "Stop Listener"
            slicer.dicomListener.process.connect(
                'stateChanged(QProcess::ProcessState)',
                self.onListenerStateChanged)
        else:
            self.toggleListener.text = "Start Listener"
        self.localFrame.layout().addWidget(self.toggleListener)
        self.toggleListener.connect('clicked()', self.onToggleListener)

        self.runListenerAtStart = qt.QCheckBox(
            "Start Listener when Slicer Starts")
        self.localFrame.layout().addWidget(self.runListenerAtStart)
        self.runListenerAtStart.checked = settingsValue(
            'DICOM/RunListenerAtStart', False, converter=toBool)
        self.runListenerAtStart.connect('clicked()', self.onRunListenerAtStart)

        # connect to the main window's dicom button
        mw = slicer.util.mainWindow()
        if mw:
            try:
                action = slicer.util.findChildren(mw,
                                                  name='LoadDICOMAction')[0]
                action.connect('triggered()', self.onOpenDetailsPopup)
            except IndexError:
                logging.error(
                    'Could not connect to the main window DICOM button')

        if hasattr(slicer, 'dicomListener'):
            slicer.dicomListener.fileToBeAddedCallback = self.onListenerToAddFile
            slicer.dicomListener.fileAddedCallback = self.onListenerAddedFile

        slicer.dicomDatabase.connect('databaseChanged()',
                                     self.onDatabaseChanged)

        # the recent activity frame
        self.activityFrame = ctk.ctkCollapsibleButton(self.parent)
        self.activityFrame.collapsed = True
        self.activityFrame.setLayout(qt.QVBoxLayout())
        self.activityFrame.setText("Recent DICOM Activity")
        self.layout.addWidget(self.activityFrame)

        self.recentActivity = DICOMLib.DICOMRecentActivityWidget(
            self.activityFrame, detailsPopup=self.detailsPopup)
        self.activityFrame.layout().addWidget(self.recentActivity)
        self.requestUpdateRecentActivity()
コード例 #33
0
    def setup(self):

        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

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

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

        # fixed landmarks (mrml input)
        self.fixedLandmarks = slicer.qMRMLNodeComboBox()
        self.fixedLandmarks.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
        self.fixedLandmarks.selectNodeUponCreation = True
        self.fixedLandmarks.addEnabled = False
        self.fixedLandmarks.removeEnabled = False
        self.fixedLandmarks.noneEnabled = True
        self.fixedLandmarks.showHidden = False
        self.fixedLandmarks.renameEnabled = True
        self.fixedLandmarks.setMRMLScene(slicer.mrmlScene)
        self.fixedLandmarks.setToolTip("Landmarks on fixed image.")
        inputFormLayout.addRow("Fixed landmarks: ", self.fixedLandmarks)

        # fixed landmarks (directory input)
        self.fixedLandmarksDirectory = ctk.ctkDirectoryButton()
        self.fixedLandmarksDirectory.directory = qt.QDir.homePath()
        inputFormLayout.addRow("", self.fixedLandmarksDirectory)

        # moving landmarks (mrml input)
        self.movingLandmarks = slicer.qMRMLNodeComboBox()
        self.movingLandmarks.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
        self.movingLandmarks.selectNodeUponCreation = True
        self.movingLandmarks.addEnabled = False
        self.movingLandmarks.removeEnabled = False
        self.movingLandmarks.noneEnabled = True
        self.movingLandmarks.showHidden = False
        self.movingLandmarks.showChildNodeTypes = False
        self.movingLandmarks.setMRMLScene(slicer.mrmlScene)
        self.movingLandmarks.setToolTip("Landmarks on moving image.")
        inputFormLayout.addRow("Moving landmarks: ", self.movingLandmarks)

        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        self.parent.layout().addWidget(self.view)

        # moving landmarks (directory input)
        self.movingLandmarksDirectory = ctk.ctkDirectoryButton()
        self.movingLandmarksDirectory.directory = qt.QDir.homePath()
        inputFormLayout.addRow("", self.movingLandmarksDirectory)

        # Apply Button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = True
        self.layout.addWidget(self.applyButton)

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

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

        # output statistics
        buttonLayout = qt.QHBoxLayout()
        self.averageError = qt.QLineEdit()
        self.averageErrorValue = 1
        self.averageError.setToolTip("Average landmark separation")
        buttonLayout.addWidget(self.averageError)
        outputFormLayout.addRow("Average error:", buttonLayout)

        buttonLayout = qt.QHBoxLayout()
        self.Variance = qt.QLineEdit()
        self.VarianceValue = 1
        self.Variance.setToolTip("Variance")
        buttonLayout.addWidget(self.Variance)
        outputFormLayout.addRow("Variance:", buttonLayout)

        buttonLayout = qt.QHBoxLayout()
        self.stDev = qt.QLineEdit()
        self.stDevValue = 1
        self.stDev.setToolTip("Standard deviation")
        buttonLayout.addWidget(self.stDev)
        outputFormLayout.addRow("Standard deviation:", buttonLayout)

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

        # connections
        self.fixedLandmarks.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onFixedLandmarksSelect)
        self.movingLandmarks.connect("currentNodeChanged(vtkMRMLNode*)",
                                     self.onMovingLandmarksSelect)
        self.applyButton.connect('clicked(bool)', self.onMismatchErrorApply)
コード例 #34
0
    def setup(self):

        ####################IMPORTAR VOLUMEN 4D#################################################3

        ### Se crea la sección para importar
        importDataCollapsibleButton = ctk.ctkCollapsibleButton()
        importDataCollapsibleButton.text = "Import Volume"
        self.layout.addWidget(importDataCollapsibleButton)
        importDataFormLayout = qt.QFormLayout(importDataCollapsibleButton)
        #### Crear desplegable para seleccionar dirección del volumen
        self.__fDialog = ctk.ctkDirectoryButton()
        self.__fDialog.caption = 'Input directory'
        importDataFormLayout.addRow('Input directory:', self.__fDialog)
        #### Crear desplegable para seleccionar dirección del volumen
        self.inputImportSelector = slicer.qMRMLNodeComboBox()
        self.inputImportSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.inputImportSelector.addEnabled = True  # Se habilita la posibildad al usuario de crear un nuevo nodo con este widget
        self.inputImportSelector.removeEnabled = True  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        self.inputImportSelector.setMRMLScene(slicer.mrmlScene)
        importDataFormLayout.addRow("Input node:", self.inputImportSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.inputImportSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        self.__nameFrame = qt.QLineEdit()
        self.__nameFrame.text = 'NA'
        importDataFormLayout.addRow('Volume Name', self.__nameFrame)

        # Botón de importar
        self.buttonImport = qt.QPushButton("Import")
        self.buttonImport.toolTip = "Run the algorithm."
        importDataFormLayout.addRow("", self.buttonImport)
        self.buttonImport.connect('clicked(bool)', self.importFunction)

        #Por medio de esta función se crean los widgets de interacción con el usuario del modulo
        #La sección Parameters tendrá disponible un desplegable en el cual se encuentran los multivoumenes importadps
        #También poseerá un desplegable de tipo de registro los cuales serán: "Rigido", "BSpline", "Afín", "Rigido-BSpline" y "Rigido-Afin"
        #Finalemente dispondrá de un botón "Registrar" con el cual se da inicio al registro seleccionado del multivolumen cargado
        ScriptedLoadableModuleWidget.setup(self)
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Volume registration"
        self.layout.addWidget(parametersCollapsibleButton)

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

        self.inputSelector = slicer.qMRMLNodeComboBox(
        )  #permite crear un desplegable con opcioneas a elegir, en este caso será el de multivolumen
        self.inputSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.inputSelector.addEnabled = True  # Se habilita la posibildad al usuario de crear un nuevo nodo con este widget
        self.inputSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("MultiVolume Node:", self.inputSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.inputSelector, 'setMRMLScene(vtkMRMLScene*)')

        self.typeComboBox = ctk.ctkComboBox(
        )  #permite crear un desplegable con opcioneas a elegir, en este caso será el de tipo de registro
        self.typeComboBox.addItem(
            'Rigid'
        )  #opción que de tipo de registro que puede elegir el usuario
        self.typeComboBox.addItem(
            'BSpline'
        )  #opción que de tipo de registro que puede elegir el usuario
        self.typeComboBox.addItem(
            'Affine'
        )  #opción que de tipo de registro que puede elegir el usuario
        self.typeComboBox.addItem(
            'Rigid-BSpline'
        )  #opción que de tipo de registro que puede elegir el usuario
        self.typeComboBox.addItem(
            'Rigid-Affine'
        )  #opción que de tipo de registro que puede elegir el usuario
        parametersFormLayout.addRow(
            'Registration Type:',
            self.typeComboBox)  #añade el desplegable al Layout de parameter

        #    self.buttonRegister = qt.QPushButton("Registrar") #creación del botón con nombre registrar
        #    self.buttonRegister.toolTip = "Run the algorithm."
        #    self.buttonRegister.enabled = True
        #    parametersFormLayout.addRow(self.buttonRegister)#añade el boton al layout de parameter

        #    self.buttonRegister.connect('clicked(bool)', self.registrarButton)#conecta el boton con la función registrarButto
        #    self.layout.addStretch(1)
        #Boton ajustar
        self.buttonRegister = qt.QPushButton(u"Register")
        self.buttonRegister.toolTip = u"ajustar imágenes para facilitar el registro"
        parametersFormLayout.addWidget(self.buttonRegister)
        self.buttonRegister.connect('clicked(bool)', self.registrarButton)
        self.buttonRegister.enabled = True
        self.layout.addStretch(1)

        ##CURVAS
        ScriptedLoadableModuleWidget.setup(self)
        SmoothCollapsibleButton = ctk.ctkCollapsibleButton()
        SmoothCollapsibleButton.text = "Plot curves"
        self.layout.addWidget(SmoothCollapsibleButton)
        SmoothFormLayout = qt.QFormLayout(SmoothCollapsibleButton)

        self.inputSmoothSelector = slicer.qMRMLNodeComboBox(
        )  #permite crear un desplegable con opcioneas a elegir, en este caso será el de multivolumen
        self.inputSmoothSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.inputSmoothSelector.addEnabled = True  # Se habilita la posibildad al usuario de crear un nuevo nodo con este widget
        self.inputSmoothSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        self.inputSmoothSelector.setMRMLScene(slicer.mrmlScene)
        SmoothFormLayout.addRow("MultiVolume Node: ", self.inputSmoothSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.inputSmoothSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        self.imagenMultuply = slicer.qMRMLNodeComboBox()
        self.imagenMultuply.objectName = 'imagenMovilSelector'
        self.imagenMultuply.toolTip = u'Seleccione la imagen móvil'
        self.imagenMultuply.nodeTypes = ['vtkMRMLLabelMapVolumeNode']
        self.imagenMultuply.noneEnabled = True
        self.imagenMultuply.addEnabled = False  # Se quita la posibilidad al usuario de crear un nuevo nodo con este widget
        self.imagenMultuply.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        ##        self.imagenMovilSelector.connect('currentNodeChanged(bool)', self.enableOrDisableRegistrarButton)
        self.imagenMultuply.setMRMLScene(slicer.mrmlScene)
        SmoothFormLayout.addRow(u"Label Mask:", self.imagenMultuply)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.imagenMultuply, 'setMRMLScene(vtkMRMLScene*)')

        self.buttoncCurve = qt.QPushButton(u"Plot")
        self.buttoncCurve.toolTip = u"Suavizar imágenes dinámicas"
        SmoothFormLayout.addWidget(self.buttoncCurve)
        self.buttoncCurve.connect('clicked(bool)', self.OnCurveButton)
        self.buttoncCurve.enabled = True
        self.layout.addStretch(1)
コード例 #35
0
ファイル: RunNeuralNet.py プロジェクト: qitsweauca/aigt
    def setup(self):

        ScriptedLoadableModuleWidget.setup(self)

        self.logic = RunNeuralNetLogic()
        self.moduleDir = os.path.dirname(slicer.modules.runneuralnet.path)

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

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

        self.modelDirectoryFilePathSelector = ctk.ctkDirectoryButton()
        self.modelDirectoryFilePath = os.path.join(self.moduleDir, os.pardir,
                                                   "Networks")
        self.modelDirectoryFilePathSelector.directory = self.modelDirectoryFilePath
        parametersFormLayout.addRow(self.modelDirectoryFilePathSelector)

        self.networkTypeSelector = qt.QComboBox()
        self.networkTypeSelector.addItems(["Select network type"])
        networks = os.listdir(self.modelDirectoryFilePath)
        networks = [x for x in networks if not '.' in x]
        self.networkTypeSelector.addItems(networks)
        self.networkType = "Select network type"
        parametersFormLayout.addRow(self.networkTypeSelector)

        self.modelSelector = qt.QComboBox()
        self.modelSelector.addItems(["Select model"])
        self.modelName = "Select model"
        parametersFormLayout.addRow(self.modelSelector)

        #self.modelNameLineEdit = qt.QLineEdit()
        #self.modelNameLineEdit.text = 'Model Name'
        #parametersFormLayout.addRow(self.modelNameLineEdit)

        self.outputTypeSelector = qt.QComboBox()
        self.outputTypeSelector.addItems(
            ["Select network output type", "IMAGE", "TRANSFORM", "STRING"])
        self.outputType = "Select network output type"
        parametersFormLayout.addRow(self.outputTypeSelector)

        self.inputNodeSelector = slicer.qMRMLNodeComboBox()
        self.inputNodeSelector.selectNodeUponCreation = True
        self.inputNodeSelector.nodeTypes = (("vtkMRMLScalarVolumeNode",
                                             "vtkMRMLVectorVolumeNode",
                                             "vtkMRMLStreamingVolumeNode"))
        self.inputNodeSelector.addEnabled = True
        self.inputNodeSelector.removeEnabled = False
        self.inputNodeSelector.editEnabled = True
        self.inputNodeSelector.renameEnabled = True
        self.inputNodeSelector.noneEnabled = False
        self.inputNodeSelector.showHidden = False
        self.inputNodeSelector.showChildNodeTypes = False
        self.inputNodeSelector.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("Image Node: ", self.inputNodeSelector)

        self.outputNodeSelector = slicer.qMRMLNodeComboBox()
        self.outputNodeSelector.selectNodeUponCreation = True
        self.outputNodeSelector.nodeTypes = ((), "")
        self.outputNodeSelector.addEnabled = True
        self.outputNodeSelector.removeEnabled = False
        self.outputNodeSelector.editEnabled = True
        self.outputNodeSelector.renameEnabled = True
        self.outputNodeSelector.noneEnabled = False
        self.outputNodeSelector.showHidden = False
        self.outputNodeSelector.showChildNodeTypes = False
        self.outputNodeSelector.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("Label Node: ", self.outputNodeSelector)

        self.plusServerIncomingHostNameLineEdit = qt.QLineEdit("localhost")
        self.hostnameLabel = qt.QLabel()
        self.hostnameLabel.setText("Incoming Hostname: ")
        self.plusServerIncomingPortLineEdit = qt.QLineEdit()
        self.plusServerIncomingPortLineEdit.setText("18944")
        self.portLabel = qt.QLabel()
        self.portLabel.setText("Port: ")
        incominghbox = qt.QHBoxLayout()
        incominghbox.addWidget(self.hostnameLabel)
        incominghbox.addWidget(self.plusServerIncomingHostNameLineEdit)
        incominghbox.addWidget(self.portLabel)
        incominghbox.addWidget(self.plusServerIncomingPortLineEdit)
        parametersFormLayout.addRow(incominghbox)

        self.plusServerOutgoingHostNameLineEdit = qt.QLineEdit("localhost")
        self.outgoinghostnameLabel = qt.QLabel()
        self.outgoinghostnameLabel.setText("Outgoing Hostname: ")
        self.plusServerOutgoingPortLineEdit = qt.QLineEdit()
        self.plusServerOutgoingPortLineEdit.setText("18946")
        self.outgoingportLabel = qt.QLabel()
        self.outgoingportLabel.setText("Port: ")
        outgoinghbox = qt.QHBoxLayout()
        outgoinghbox.addWidget(self.outgoinghostnameLabel)
        outgoinghbox.addWidget(self.plusServerOutgoingHostNameLineEdit)
        outgoinghbox.addWidget(self.outgoingportLabel)
        outgoinghbox.addWidget(self.plusServerOutgoingPortLineEdit)
        parametersFormLayout.addRow(outgoinghbox)

        self.runNeuralNetworkButton = qt.QPushButton("Start Network")
        self.runNeuralNetworkButton.enabled = False
        self.networkRunning = False
        parametersFormLayout.addRow(self.runNeuralNetworkButton)

        condaSettingsCollapsibleButton = ctk.ctkCollapsibleButton()
        condaSettingsCollapsibleButton.text = "Conda settings"
        parametersFormLayout.addRow(condaSettingsCollapsibleButton)
        condaSettingsLayout = qt.QFormLayout(condaSettingsCollapsibleButton)
        condaSettingsCollapsibleButton.collapsed = True

        self.condaDirectoryPathSelector = ctk.ctkDirectoryButton()
        self.condaDirectoryPath = self.getCondaPath()
        self.logic.setPathToCondaExecutable(self.condaDirectoryPath)
        self.condaDirectoryPathSelector.directory = self.condaDirectoryPath
        condaSettingsLayout.addRow(self.condaDirectoryPathSelector)

        self.environmentNameLineEdit = qt.QLineEdit("EnvironmentName")
        self.environmentName = "kerasGPUEnv2"
        condaSettingsLayout.addRow(self.environmentNameLineEdit)

        createNewModelCollapsibleButton = ctk.ctkCollapsibleButton()
        createNewModelCollapsibleButton.text = "Create New Model"
        parametersFormLayout.addRow(createNewModelCollapsibleButton)
        newModelSettingsLayout = qt.QFormLayout(
            createNewModelCollapsibleButton)
        createNewModelCollapsibleButton.collapsed = True

        self.newModelNameLineEdit = qt.QLineEdit()
        self.newModelNameLineEdit.setText("Model Name")
        newModelSettingsLayout.addRow(self.newModelNameLineEdit)

        self.createNewModelButton = qt.QPushButton("Create")
        self.createNewModelButton.enabled = False
        newModelSettingsLayout.addRow(self.createNewModelButton)

        self.modelDirectoryFilePathSelector.connect(
            'directorySelected(QString)', self.onNetworkDirectorySelected)
        self.condaDirectoryPathSelector.connect('directorySelected(QString)',
                                                self.onCondaDirectorySelected)
        self.environmentNameLineEdit.connect(
            'textChanged(QString)', self.onCondaEnvironmentNameChanged)
        self.networkTypeSelector.connect('currentIndexChanged(int)',
                                         self.onNetworkTypeSelected)
        self.modelSelector.connect('currentIndexChanged(int)',
                                   self.onModelSelected)
        self.outputTypeSelector.connect('currentIndexChanged(int)',
                                        self.onOutputTypeSelected)
        self.inputNodeSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                       self.onSelect)
        self.outputNodeSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                        self.onSelect)
        self.runNeuralNetworkButton.connect('clicked(bool)',
                                            self.onStartNetworkClicked)
        self.newModelNameLineEdit.connect('textChanged(QString)',
                                          self.onNewModelNameChanged)
        self.createNewModelButton.connect('clicked(bool)',
                                          self.onCreateModelClicked)
コード例 #36
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        #
        # Data Area
        #
        dataGroupBox = ctk.ctkCollapsibleGroupBox()
        dataGroupBox.setTitle('Data')
        self.layout.addWidget(dataGroupBox)

        dataGridLayout = qt.QGridLayout(dataGroupBox)
        self.dirButton = ctk.ctkDirectoryButton()
        dirButtonLabel = qt.QLabel('DICOM Directory: ')
        dataGridLayout.addWidget(dirButtonLabel, 1, 1, 1, 1)
        dataGridLayout.addWidget(self.dirButton, 1, 2, 1, 3)
        self.dirButton.setMaximumWidth(500)
        orLabel = qt.QLabel('        - or - ')
        dataGridLayout.addWidget(orLabel, 2, 1, 1, 1)
        collectionsComboBoxLabel = qt.QLabel('TCIA Collection: ')
        dataGridLayout.addWidget(collectionsComboBoxLabel, 3, 1, 1, 1)

        try:
            m = slicer.modules.tciabrowser
            self.tcia = slicer.modules.tciabrowser.widgetRepresentation().self(
            )
            self.connectTCIAButton = qt.QPushButton('Connect')
            self.connectTCIAButton.toolTip = "Connect to TCIA Server."
            dataGridLayout.addWidget(self.connectTCIAButton, 3, 2, 1, 1)
            self.collectionsComboBox = qt.QComboBox()
            dataGridLayout.addWidget(self.collectionsComboBox, 3, 3, 1, 2)
            # connections
            self.connectTCIAButton.connect('clicked(bool)',
                                           self.getTCIACollectionValues)
            # TODO disable scrolling event for collectionsComboBox
            self.collectionsComboBox.connect('currentIndexChanged(QString)',
                                             self.onTCIACollectionChanged)
        except AttributeError:
            # TODO add button to open Extensions Manager
            noConnectionLabel = qt.QLabel('TCIA Browser not installed.')
            dataGridLayout.addWidget(noConnectionLabel, 3, 2, 1, 1)

        #
        # Patient Table Area
        #
        self.patientGroupBox = ctk.ctkCollapsibleGroupBox()
        self.patientGroupBox.setTitle('Patient Selection')
        self.layout.addWidget(self.patientGroupBox)
        self.patientGroupBoxLayout = qt.QGridLayout(self.patientGroupBox)

        self.patientsTable = qt.QTableWidget()
        self.patientsTableHeaderLabels = [
            'ID', 'Name', 'BirthDate', 'Sex', 'Modalities'
        ]
        self.patientsTable.setColumnCount(5)
        self.patientsTable.sortingEnabled = True
        self.patientsTable.setHorizontalHeaderLabels(
            self.patientsTableHeaderLabels)
        self.patientsTableHeader = self.patientsTable.horizontalHeader()
        self.patientsTableHeader.setStretchLastSection(True)
        self.patientGroupBoxLayout.addWidget(self.patientsTable, 1, 1, 1, 5)
        abstractItemView = qt.QAbstractItemView()
        self.patientsTable.setSelectionBehavior(abstractItemView.SelectRows)

        self.examinePatientButton = qt.QPushButton('Examine')
        self.examinePatientButton.setEnabled(False)
        self.patientGroupBoxLayout.addWidget(self.examinePatientButton, 2, 4,
                                             1, 2)

        #
        # Other Connections
        #
        self.dirButton.connect('directoryChanged(const QString &)',
                               self.onDICOMDirectoryChanged)