Пример #1
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        #
        #  Interface
        #
        loader = qt.QUiLoader()
        self.moduleName = 'RigidAlignmentModule'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            '%s.ui' % self.moduleName)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        # Global variables of the Interface
        # Directories
        self.CollapsibleButton_Directories = self.getWidget(
            'CollapsibleButton_Directories')
        self.RigidAlignmentInputModelsDirectory = self.getWidget(
            'DirectoryButton_RigidAlignmentInputModelsDirectory')
        self.RigidAlignmentInputFiducialFilesDirectory = self.getWidget(
            'DirectoryButton_RigidAlignmentInputFiducialFilesDirectory')
        self.RigidAlignmentCommonSphereDirectory = self.getWidget(
            'DirectoryButton_RigidAlignmentCommonSphereDirectory')
        self.RigidAlignmentOutputSphericalModelsDirectory = self.getWidget(
            'DirectoryButton_RigidAlignmentOutputSphericalModelsDirectory')
        self.RigidAlignmentOutputModelsDirectory = self.getWidget(
            'DirectoryButton_RigidAlignmentOutputModelsDirectory')
        #   Apply CLIs
        self.ApplyButton = self.getWidget('pushButton_RigidAlignment')

        # Connections
        # Directories
        self.CollapsibleButton_Directories.connect(
            'clicked()', lambda: self.onSelectedCollapsibleButtonOpen(
                self.CollapsibleButton_Directories))
        self.RigidAlignmentInputModelsDirectory.connect(
            'directoryChanged(const QString &)', self.onSelect)
        self.RigidAlignmentInputFiducialFilesDirectory.connect(
            'directoryChanged(const QString &)', self.onSelect)
        self.RigidAlignmentCommonSphereDirectory.connect(
            'directoryChanged(const QString &)', self.onSelect)
        self.RigidAlignmentOutputSphericalModelsDirectory.connect(
            'directoryChanged(const QString &)', self.onSelect)
        self.RigidAlignmentOutputModelsDirectory.connect(
            'directoryChanged(const QString &)', self.onSelect)
        #   Apply CLIs
        self.ApplyButton.connect('clicked(bool)', self.onApplyButton)

        # Refresh Apply button state
        self.onSelect()
    def __init__(self):
        self.widget = qt.QWidget()
        self.widget.setLayout(qt.QVBoxLayout())

        uiloader = qt.QUiLoader()
        qfile = qt.QFile(
            '/Users/dmwelch/Development/src/extensions/SlicerDerivedImageEval/Resources/UI/simple.ui'
        )
        qfile.open(qt.QFile.ReadOnly)
        self.simple = uiloader.load(qfile)
        self.widget.layout().addWidget(self.simple)
        qfile.close()

        self.widget.show()
Пример #3
0
def loadUI(path):
  """ Load UI file ``path`` and return the corresponding widget.
  Raises a ``RuntimeError`` exception if the UI file is not found or if no
  widget was instantiated.
  """
  import qt
  qfile = qt.QFile(path)
  qfile.open(qt.QFile.ReadOnly)
  loader = qt.QUiLoader()
  widget = loader.load(qfile)
  if not widget:
    errorMessage = "Could not load UI file: " + str(path) + "\n\n"
    raise RuntimeError(errorMessage)
  return widget
Пример #4
0
    def setup(self):

        loader = qt.QUiLoader()
        moduleName = 'ScenePerformance'
        scriptedModulesPath = os.path.dirname(
            slicer.util.modulePath(moduleName))
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            'ScenePerformance.ui')

        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.layout.addWidget(widget)

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

        self.runTestsButton = qt.QPushButton("Run tests")
        self.runTestsButton.toolTip = "Run all the tests."
        self.runTestsButton.name = "Run tests"
        self.layout.addWidget(self.runTestsButton)
        self.runTestsButton.connect('clicked()', self.runTests)

        self.TimePushButton = self.findWidget(self.parent, 'TimePushButton')
        self.ActionComboBox = self.findWidget(self.parent, 'ActionComboBox')
        self.ActionPathLineEdit = self.findWidget(self.parent,
                                                  'ActionPathLineEdit')
        self.ResultsTextEdit = self.findWidget(self.parent, 'ResultsTextEdit')
        self.URLLineEdit = self.findWidget(self.parent, 'URLLineEdit')
        self.URLFileNameLineEdit = self.findWidget(self.parent,
                                                   'URLFileNameLineEdit')
        self.SceneViewSpinBox = self.findWidget(self.parent,
                                                'SceneViewSpinBox')
        self.LayoutSpinBox = self.findWidget(self.parent, 'LayoutSpinBox')
        self.MRMLNodeComboBox = self.findWidget(self.parent,
                                                'MRMLNodeComboBox')
        self.RepeatSpinBox = self.findWidget(self.parent, 'RepeatSpinBox')

        widget.setMRMLScene(slicer.mrmlScene)
        #self.MRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)

        self.TimePushButton.connect('clicked()', self.timeAction)
        self.ActionComboBox.connect('currentIndexChanged(int)',
                                    self.updateActionProperties)
        self.updateActionProperties()
Пример #5
0
 def downloadFromSource(self,source,attemptCount=0):
   """Given an instance of SampleDataSource, downloads the data
   if needed and loads the results in slicer"""
   nodes = []
   for uri,fileName,nodeName,loadFileType in zip(source.uris,source.fileNames,source.nodeNames,source.loadFileType):
     filePath = self.downloadFileIntoCache(uri, fileName)
     if nodeName:
       loadedNode = self.loadNode(filePath, nodeName, loadFileType, source.loadFileProperties)
       if loadedNode is None and attemptCount < 5:
         attemptCount += 1
         self.logMessage('<b>Load failed! Trying to download again...</b>', logging.ERROR)
         file = qt.QFile(filePath)
         if not file.remove():
           self.logMessage('<b>Load failed! Unable to delete and try again loading %s!</b>' % filePath, logging.ERROR)
           return None
         return self.downloadFromSource(source,attemptCount)
       nodes.append(loadedNode)
   return nodes
Пример #6
0
  def setup(self):

    # UI setup
    loader = qt.QUiLoader()
    moduleName = 'BenderSampleData'
    scriptedModulesPath = eval('slicer.modules.%s.path' % moduleName.lower())
    scriptedModulesPath = os.path.dirname(scriptedModulesPath)
    path = os.path.join(scriptedModulesPath, 'Resources', 'UI', '%s.ui' %moduleName)

    qfile = qt.QFile(path)
    qfile.open(qt.QFile.ReadOnly)
    widget = loader.load(qfile, self.parent)
    self.layout = self.parent.layout()
    self.widget = widget;
    self.layout.addWidget(widget)

    # widget setup
    self.log = self.get('BenderSampleDataLog')
    self.logic = BenderSampleDataLogic(self.logMessage)
    self.dataTree = self.get('BenderSampleDataTree')
    self.dataTree.expandAll()
    self.downloadDirectoryPathLineEdit = self.get('DownloadDirectoryPathLineEdit')
    self.downloadDirectoryPathLineEdit.currentPath = qt.QDir.homePath()
    self.get('BenderSampleDataDownloadPushButton').connect('clicked()', self.downloadCheckedItems)
Пример #7
0
  def create(self):
    # Instantiate and connect widgets ...
    loader = qt.QUiLoader()
    path = os.path.join(os.path.dirname(__file__), 'Resources', 'UI','settings.ui')
    qfile = qt.QFile(path)
    qfile.open(qt.QFile.ReadOnly)
    self.window = loader.load(qfile)
    window = self.window

    find = slicer.util.findChildren
    self.cornerTextParametersCollapsibleButton = find(window, 'cornerTextParametersCollapsibleButton')[0]
    self.sliceViewAnnotationsCheckBox = find(window,'sliceViewAnnotationsCheckBox')[0]
    self.sliceViewAnnotationsCheckBox.checked = self.sliceViewAnnotationsEnabled

    self.activateCornersGroupBox = find(window,'activateCornersGroupBox')[0]
    self.topLeftCheckBox = find(window,'topLeftCheckBox')[0]
    self.topLeftCheckBox.checked = self.topLeft
    self.topRightCheckBox = find(window,'topRightCheckBox')[0]
    self.topRightCheckBox.toolTip = "Top right corner annotation is only enabled when the scalarBar is off."
    self.topRightCheckBox.checked = self.topRight
    self.topRightCheckBox.enabled = not(self.scalarBarEnabled)

    self.bottomLeftCheckBox = find(window, 'bottomLeftCheckBox')[0]
    self.bottomLeftCheckBox.checked = self.bottomLeft

    self.level1RadioButton = find(window,'level1RadioButton')[0]
    self.level2RadioButton = find(window,'level2RadioButton')[0]
    self.level3RadioButton = find(window,'level3RadioButton')[0]

    self.fontPropertiesGroupBox = find(window,'fontPropertiesGroupBox')[0]
    self.timesFontRadioButton = find(window,'timesFontRadioButton')[0]
    self.arialFontRadioButton = find(window,'arialFontRadioButton')[0]
    if self.fontFamily == 'Times':
      self.timesFontRadioButton.checked = True
    else:
      self.arialFontRadioButton.checked = True

    self.fontSizeSpinBox = find(window,'fontSizeSpinBox')[0]
    self.fontSizeSpinBox.value = self.fontSize

    self.backgroundPersistenceCheckBox = find(window,'backgroundPersistenceCheckBox')[0]
    self.backgroundPersistenceCheckBox.checked = self.backgroundDICOMAnnotationsPersistence

    self.annotationsAmountGroupBox = find(window,'annotationsAmountGroupBox')[0]

    self.scalarBarCollapsibleButton = find(window,'scalarBarCollapsibleButton')[0]
    self.scalarBarEnalbeCheckBox = find(window,'scalarBarEnableCheckBox')[0]
    self.scalarBarEnalbeCheckBox.checked = self.scalarBarEnabled
    self.scalarBarLayerSelectionGroupBox = find(window,'scalarBarLayerSelectionGroupBox')[0]

    self.backgroundRadioButton = find(window, 'backgroundRadioButton')[0]
    self.backgroundRadioButton.checked = True
    self.foregroundRadioButton = find(window, 'foregroundRadioButton')[0]
    self.rangeLabelFormatLineEdit = find(window,'rangeLabelFormatLineEdit')[0]
    self.rangeLabelFormatLineEdit.text = self.rangeLabelFormat

    self.restoreDefaultsButton = find(window, 'restoreDefaultsButton')[0]

    # connections
    self.sliceViewAnnotationsCheckBox.connect('clicked()', self.onSliceViewAnnotationsCheckBox)

    self.topLeftCheckBox.connect('clicked()', self.onCornerTextsActivationCheckBox)
    self.topRightCheckBox.connect('clicked()', self.onCornerTextsActivationCheckBox)
    self.bottomLeftCheckBox.connect('clicked()', self.onCornerTextsActivationCheckBox)
    self.timesFontRadioButton.connect('clicked()', self.onFontFamilyRadioButton)
    self.arialFontRadioButton.connect('clicked()', self.onFontFamilyRadioButton)
    self.fontSizeSpinBox.connect('valueChanged(int)', self.onFontSizeSpinBox)

    self.level1RadioButton.connect('clicked()', self.updateSliceViewFromGUI)
    self.level2RadioButton.connect('clicked()', self.updateSliceViewFromGUI)
    self.level3RadioButton.connect('clicked()', self.updateSliceViewFromGUI)

    self.backgroundPersistenceCheckBox.connect('clicked()', self.onBackgroundLayerPersistenceCheckBox)

    self.scalarBarEnalbeCheckBox.connect('clicked()', self.onScalarBarCheckBox)
    self.backgroundRadioButton.connect('clicked()',self.onLayerSelectionRadioButton)
    self.foregroundRadioButton.connect('clicked()',self.onLayerSelectionRadioButton)
    self.rangeLabelFormatLineEdit.connect('editingFinished()',self.onRangeLabelFormatLineEdit)
    self.rangeLabelFormatLineEdit.connect('returnPressed()',self.onRangeLabelFormatLineEdit)

    self.restoreDefaultsButton.connect('clicked()', self.restoreDefaultValues)
Пример #8
0
    def create(self):
        # Instantiate and connect widgets ...
        loader = qt.QUiLoader()
        path = os.path.join(os.path.dirname(__file__), 'Resources', 'UI',
                            'settings.ui')
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        self.window = loader.load(qfile)
        window = self.window

        find = slicer.util.findChildren
        self.cornerTextParametersCollapsibleButton = find(
            window, 'cornerTextParametersCollapsibleButton')[0]
        self.sliceViewAnnotationsCheckBox = find(
            window, 'sliceViewAnnotationsCheckBox')[0]
        self.sliceViewAnnotationsCheckBox.checked = self.sliceViewAnnotationsEnabled

        self.activateCornersGroupBox = find(window,
                                            'activateCornersGroupBox')[0]
        self.topLeftCheckBox = find(window, 'topLeftCheckBox')[0]
        self.topLeftCheckBox.checked = self.topLeft
        self.topRightCheckBox = find(window, 'topRightCheckBox')[0]
        self.topRightCheckBox.checked = self.topRight

        self.bottomLeftCheckBox = find(window, 'bottomLeftCheckBox')[0]
        self.bottomLeftCheckBox.checked = self.bottomLeft

        self.level1RadioButton = find(window, 'level1RadioButton')[0]
        self.level2RadioButton = find(window, 'level2RadioButton')[0]
        self.level3RadioButton = find(window, 'level3RadioButton')[0]

        self.fontPropertiesGroupBox = find(window, 'fontPropertiesGroupBox')[0]
        self.timesFontRadioButton = find(window, 'timesFontRadioButton')[0]
        self.arialFontRadioButton = find(window, 'arialFontRadioButton')[0]
        if self.fontFamily == 'Times':
            self.timesFontRadioButton.checked = True
        else:
            self.arialFontRadioButton.checked = True

        self.fontSizeSpinBox = find(window, 'fontSizeSpinBox')[0]
        self.fontSizeSpinBox.value = self.fontSize

        self.backgroundPersistenceCheckBox = find(
            window, 'backgroundPersistenceCheckBox')[0]
        self.backgroundPersistenceCheckBox.checked = self.backgroundDICOMAnnotationsPersistence

        self.annotationsAmountGroupBox = find(window,
                                              'annotationsAmountGroupBox')[0]

        self.restoreDefaultsButton = find(window, 'restoreDefaultsButton')[0]

        self.updateEnabledButtons()

        # connections
        self.sliceViewAnnotationsCheckBox.connect(
            'clicked()', self.onSliceViewAnnotationsCheckBox)

        self.topLeftCheckBox.connect('clicked()',
                                     self.onCornerTextsActivationCheckBox)
        self.topRightCheckBox.connect('clicked()',
                                      self.onCornerTextsActivationCheckBox)
        self.bottomLeftCheckBox.connect('clicked()',
                                        self.onCornerTextsActivationCheckBox)
        self.timesFontRadioButton.connect('clicked()',
                                          self.onFontFamilyRadioButton)
        self.arialFontRadioButton.connect('clicked()',
                                          self.onFontFamilyRadioButton)
        self.fontSizeSpinBox.connect('valueChanged(int)',
                                     self.onFontSizeSpinBox)

        self.level1RadioButton.connect('clicked()',
                                       self.updateSliceViewFromGUI)
        self.level2RadioButton.connect('clicked()',
                                       self.updateSliceViewFromGUI)
        self.level3RadioButton.connect('clicked()',
                                       self.updateSliceViewFromGUI)

        self.backgroundPersistenceCheckBox.connect(
            'clicked()', self.onBackgroundLayerPersistenceCheckBox)

        self.restoreDefaultsButton.connect('clicked()',
                                           self.restoreDefaultValues)
Пример #9
0
  def setupEditionTab(self):
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #                                UI FILES LOADING                                   #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    loader = qt.QUiLoader()
    self.EditionTabName = 'TraficMultiEditionTab'
    scriptedModulesPath = eval('slicer.modules.%s.path' % self.moduleName.lower())
    scriptedModulesPath = os.path.dirname(scriptedModulesPath)
    path = os.path.join(scriptedModulesPath, 'Resources', 'UI', '%s.ui' % self.EditionTabName)
    qfile = qt.QFile(path)
    qfile.open(qt.QFile.ReadOnly)
    widget = loader.load(qfile, self.editionTabWidget)

    self.editionLayout = qt.QVBoxLayout(self.editionTabWidget)
    self.editionWidget = widget


    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #                                 FIBER DISPLAY AREA                                #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    displayFibersCollapsibleButton = ctk.ctkCollapsibleButton()
    displayFibersCollapsibleButton.text = "Fiber Bundle"
    self.editionLayout.addWidget(displayFibersCollapsibleButton)

    # Layout within the dummy collapsible button
    displayFibersFormLayout = qt.QFormLayout(displayFibersCollapsibleButton)

    #
    # Fibers Tree View
    #
    # self.inputFiber = slicer.qMRMLTractographyDisplayTreeView()
    self.inputFiber = slicer.qMRMLNodeComboBox()
    self.inputFiber.nodeTypes = ["vtkMRMLFiberBundleNode"]
    self.inputFiber.addEnabled = False
    self.inputFiber.removeEnabled = True
    self.inputFiber.noneEnabled = True
    self.inputFiber.showHidden = True
    self.inputFiber.showChildNodeTypes = False
    self.inputFiber.setMRMLScene(slicer.mrmlScene)
    displayFibersFormLayout.addRow("Input Fiber", self.inputFiber)

    # self.progress = qt.QProgressDialog()
    # self.progress.setValue(0)
    # self.progress.show()

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #                                 FIBER SELECTION AREA                              #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    selectionFibersCollapsibleButton = ctk.ctkCollapsibleButton()
    selectionFibersCollapsibleButton.text = "Fiber Selection"
    self.editionLayout.addWidget(selectionFibersCollapsibleButton)

    # Layout within the dummy collapsible button
    selectionFibersFormLayout = qt.QFormLayout(selectionFibersCollapsibleButton)

    self.selectionFiber = self.getWidget('qSlicerTractographyEditorROIWidget', index_tab=0)
    self.ROISelectorDisplay = self.getWidget('ROIForFiberSelectionMRMLNodeSelector', index_tab=0)
    self.ROISelectorDisplay.setMRMLScene(slicer.mrmlScene)
    self.fiberList = self.getWidget('fiberList', index_tab=0)
    name_labels = ['Select a type of fiber','0','Arc_L_FT','Arc_L_FrontoParietal','Arc_L_TemporoParietal','Arc_R_FT','Arc_R_FrontoParietal','Arc_R_TemporoParietal','CGC_L','CGC_R','CGH_L','CGH_R','CorpusCallosum_Genu',
               'CorpusCallosum_Motor','CorpusCallosum_Parietal','CorpusCallosum_PreMotor','CorpusCallosum_Rostrum','CorpusCallosum_Splenium','CorpusCallosum_Tapetum','CorticoFugal-Left_Motor',
               'CorticoFugal-Left_Parietal','CorticoFugal-Left_PreFrontal','CorticoFugal-Left_PreMotor','CorticoFugal-Right_Motor','CorticoFugal-Right_Parietal','CorticoFugal-Right_PreFrontal',
               'CorticoFugal-Right_PreMotor','CorticoRecticular-Left','CorticoRecticular-Right','CorticoSpinal-Left','CorticoSpinal-Right','CorticoThalamic_L_PreFrontal','CorticoThalamic_L_SUPERIOR',
               'CorticoThalamic_Left_Motor','CorticoThalamic_Left_Parietal','CorticoThalamic_Left_PreMotor','CorticoThalamic_R_PreFrontal','CorticoThalamic_R_SUPERIOR',
               'CorticoThalamic_Right_Motor','CorticoThalamic_Right_Parietal','CorticoThalamic_Right_PreMotor','Fornix_L','Fornix_R','IFOF_L','IFOF_R','ILF_L','ILF_R',
               'OpticRadiation_Left','OpticRadiation_Right','Optic_Tract_L','Optic_Tract_R','SLF_II_L','SLF_II_R','UNC_L','UNC_R']
    self.fiberList.addItems(name_labels)
    self.fiberList.setMaxVisibleItems(5)
    # selectionFibersFormLayout.addRow(self.selectionFiber)
    selectionFibersFormLayout.addRow(self.selectionFiber)

    self.disROI = self.getWidget('DisableROI', index_tab=0)
    self.posROI = self.getWidget('PositiveROI', index_tab=0)
    self.negROI = self.getWidget('NegativeROI', index_tab=0)
    self.interROI = self.getWidget('InteractiveROI', index_tab=0)
    self.showROI = self.getWidget('ROIVisibility', index_tab=0)

    # self.accEditOn = self.getWidget('EnableAccurateEdit')
    self.extractFiber = self.getWidget('CreateNewFiberBundle', index_tab=0)

    self.ROISelector = slicer.qSlicerTractographyEditorROIWidget()
    self.ROISelector.setFiberBundleNode(self.inputFiber.currentNode())
    self.ROISelector.setMRMLScene(slicer.mrmlScene)
    self.ROISelector.setAnnotationMRMLNodeForFiberSelection(self.ROISelectorDisplay.currentNode())
    self.ROISelector.setAnnotationROIMRMLNodeToFiberBundleEnvelope(self.ROISelectorDisplay.currentNode())


    # self.editionLayout.addWidget(self.ROISelector)


    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #                                 FIBER REVIEW AREA                                 #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    reviewsCollapsibleButton = ctk.ctkCollapsibleButton()
    reviewsCollapsibleButton.text = "Reviews"
    self.editionLayout.addWidget(reviewsCollapsibleButton)

    self.reviewsFormLayout = qt.QFormLayout(reviewsCollapsibleButton)
    self.reviewsList = slicer.qMRMLTractographyDisplayTreeView()
    self.reviewsList.setMRMLScene(slicer.mrmlScene)
    self.reviewsFormLayout.addRow(self.reviewsList)


    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #                                 CLEAR AND SAVE AREA                               #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    
    self.dFPath = qt.QLineEdit("")
    self.outputDirEdit = qt.QLineEdit("")
    # self.dFPath.setEnabled(False)

    self.dFSelector = qt.QPushButton("Browse")
    self.outputDirEditSelector = qt.QPushButton("Browse")
    self.clearButton = qt.QPushButton("CLEAR")
    self.clearButton.toolTip = "Clear everything."
    self.clearButton.enabled = True
    self.saveButton = qt.QPushButton("SAVE")
    self.saveButton.toolTip = "Save and update Trafic database."
    self.saveButton.enabled = True

        # self.editionLayout.addWidget(self.ROISelector)
    gridLayoutdF = qt.QGridLayout()
    gridLayoutClearSave = qt.QGridLayout()

    gridLayoutdF.addWidget(qt.QLabel("Displacement field"), 0, 0)
    gridLayoutdF.addWidget(self.dFPath, 0, 1)
    gridLayoutdF.addWidget(self.dFSelector, 0, 2)
    gridLayoutdF.addWidget(qt.QLabel("Output Directory"), 1, 0)
    gridLayoutdF.addWidget(self.outputDirEdit, 1, 1)
    gridLayoutdF.addWidget(self.outputDirEditSelector, 1, 2)

    gridLayoutClearSave.addWidget(self.clearButton, 0, 0)
    gridLayoutClearSave.addWidget(self.saveButton, 0, 2)
    self.editionLayout.addLayout(gridLayoutdF)
    self.editionLayout.addLayout(gridLayoutClearSave)



    self.nodeDict = {}

    # Initialization of the dictionnary that will contains the Node ID and their type
    for i in xrange(1, len(name_labels)):
      self.nodeDict[name_labels[i]] = []


    self.editionLayout.addStretch(1)

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #                                 CONNECTIONS                                       #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    self.inputFiber.connect("currentNodeChanged(vtkMRMLNode*)", self.onChangeCurrentNode)
    self.disROI.connect("toggled(bool)", self.onDisROI)
    self.posROI.connect("toggled(bool)", self.onPosROI)
    self.negROI.connect("toggled(bool)", self.onNegROI)
    self.interROI.connect("toggled(bool)", self.onInterROI)
    self.showROI.connect("toggled(bool)", self.onShowROI)
    # self.accEditOn.connect("toggled(bool)", self.onAccEditOn)

    self.ROISelectorDisplay.connect("currentNodeChanged(vtkMRMLNode*)", self.onChangeCurrentNode)
    self.ROISelectorDisplay.connect("nodeAddedByUser(vtkMRMLNode*)", self.onAddNode)
    self.saveButton.connect("clicked(bool)", self.onSaveButton)
    self.clearButton.connect("clicked(bool)", self.onClearButton)

    self.extractFiber.connect("clicked(bool)", self.OnExtractFiber)
    self.dFSelector.connect("clicked(bool)", self.OndFSelector)
    self.dFPath.connect("editingFinished()", self.checkdFPath)
    self.outputDirEditSelector.connect("clicked(bool)", self.OnOutputDirEditSelector)
    self.outputDirEdit.connect("editingFinished()", self.CheckOutputDirEdit)

    return
Пример #10
0
    def downloadFromSource(self, source, attemptCount=0):
        """Given an instance of AstroSampleDataSource, downloads the associated data and
    load them into Slicer if it applies.
    The function always returns a list.
    Based on the fileType(s), nodeName(s) and loadFile(s) associated with
    the source, different values may be appended to the returned list:
      - if nodeName is specified, appends loaded nodes but if ``loadFile`` is False appends downloaded filepath
      - if fileType is ``SceneFile``, appends downloaded filepath
      - if fileType is ``ZipFile``, appends directory of extracted archive but if ``loadFile`` is False appends downloaded filepath
    If no ``nodeNames`` and no ``fileTypes`` are specified or if ``loadFiles`` are all False,
    returns the list of all downloaded filepaths.
    """
        nodes = []
        filePaths = []

        for uri, fileName, nodeName, loadFile, loadFileType in zip(
                source.uris, source.fileNames, source.nodeNames,
                source.loadFiles, source.loadFileType):

            current_source = AstroSampleDataSource(
                uris=uri,
                fileNames=fileName,
                nodeNames=nodeName,
                loadFiles=loadFile,
                loadFileType=loadFileType,
                loadFileProperties=source.loadFileProperties)
            filePath = self.downloadFileIntoCache(uri, fileName)
            filePaths.append(filePath)

            if loadFileType == 'ZipFile':
                if loadFile == False:
                    nodes.append(filePath)
                    continue
                outputDir = slicer.mrmlScene.GetCacheManager(
                ).GetRemoteCacheDirectory() + "/" + os.path.splitext(
                    os.path.basename(filePath))[0]
                qt.QDir().mkpath(outputDir)
                success = slicer.util.extractArchive(filePath, outputDir)
                if not success and attemptCount < 5:
                    file = qt.QFile(filePath)
                    if not file.remove():
                        self.logMessage(
                            '<b>Load failed! Unable to delete and try again loading %s!</b>'
                            % filePath, logging.ERROR)
                        nodes.append(None)
                        break
                    attemptCount += 1
                    self.logMessage(
                        '<b>Load failed! Trying to download again (%d of 5 attempts)...</b>'
                        % (attemptCount), logging.ERROR)
                    outputDir = self.downloadFromSource(
                        current_source, attemptCount)[0]
                nodes.append(outputDir)

            elif loadFileType == 'SceneFile':
                if not loadFile:
                    nodes.append(filePath)
                    continue
                success = self.loadScene(filePath, source.loadFileProperties)
                if not success and attemptCount < 5:
                    file = qt.QFile(filePath)
                    if not file.remove():
                        self.logMessage(
                            '<b>Load failed! Unable to delete and try again loading %s!</b>'
                            % filePath, logging.ERROR)
                        nodes.append(None)
                        break
                    attemptCount += 1
                    self.logMessage(
                        '<b>Load failed! Trying to download again (%d of 5 attempts)...</b>'
                        % (attemptCount), logging.ERROR)
                    filePath = self.downloadFromSource(current_source,
                                                       attemptCount)[0]
                nodes.append(filePath)

            elif nodeName:
                if loadFile == False:
                    nodes.append(filePath)
                    continue
                loadedNode = self.loadNode(filePath, nodeName, loadFileType,
                                           source.loadFileProperties)
                if loadedNode is None and attemptCount < 5:
                    file = qt.QFile(filePath)
                    if not file.remove():
                        self.logMessage(
                            '<b>Load failed! Unable to delete and try again loading %s!</b>'
                            % filePath, logging.ERROR)
                        nodes.append(None)
                        break
                    attemptCount += 1
                    self.logMessage(
                        '<b>Load failed! Trying to download again (%d of 5 attempts)...</b>'
                        % (attemptCount), logging.ERROR)
                    loadedNode = self.downloadFromSource(
                        current_source, attemptCount)[0]
                nodes.append(loadedNode)

        if nodes:
            return nodes
        else:
            return filePaths
Пример #11
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        print "-------Pick And Paint Widget Setup--------"
        self.moduleName = 'PickAndPaint'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)

        libPath = os.path.join(scriptedModulesPath)
        sys.path.insert(0, libPath)

        # import the external library that contain the functions comon to all DCBIA modules
        import ShapeQuantifierCore
        reload(ShapeQuantifierCore)

        #reload the logic if there is any change
        self.ShapeQuantifierCore = ShapeQuantifierCore.ShapeQuantifierCore(
            interface=self)
        self.logic = PickAndPaintLogic(
            interface=self, ShapeQuantifierCore=self.ShapeQuantifierCore)
        self.interactionNode = slicer.mrmlScene.GetNodeByID(
            "vtkMRMLInteractionNodeSingleton")

        # UI setup
        loader = qt.QUiLoader()
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            '%s.ui' % self.moduleName)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        self.inputModelLabel = self.ShapeQuantifierCore.get(
            "inputModelLabel"
        )  # this atribute is usefull for Shape Quantifier extension
        self.inputLandmarksLabel = self.ShapeQuantifierCore.get(
            "inputLandmarksLabel"
        )  # this atribute is usefull for Shape Quantifier extension
        self.inputModelSelector = self.ShapeQuantifierCore.get(
            "inputModelSelector")
        self.inputModelSelector.setMRMLScene(slicer.mrmlScene)
        self.inputLandmarksSelector = self.ShapeQuantifierCore.get(
            "inputLandmarksSelector")
        self.inputLandmarksSelector.setMRMLScene(slicer.mrmlScene)
        self.inputLandmarksSelector.setEnabled(
            False
        )  # The "enable" property seems to not be imported from the .ui
        self.loadLandmarksOnSurfacCheckBox = self.ShapeQuantifierCore.get(
            "loadLandmarksOnSurfacCheckBox")
        self.landmarksScaleWidget = self.ShapeQuantifierCore.get(
            "landmarksScaleWidget")
        self.addLandmarksButton = self.ShapeQuantifierCore.get(
            "addLandmarksButton")
        self.surfaceDeplacementCheckBox = self.ShapeQuantifierCore.get(
            "surfaceDeplacementCheckBox")
        self.landmarkComboBox = self.ShapeQuantifierCore.get(
            "landmarkComboBox")
        self.radiusDefinitionWidget = self.ShapeQuantifierCore.get(
            "radiusDefinitionWidget")
        self.cleanerButton = self.ShapeQuantifierCore.get("cleanerButton")
        self.correspondentShapes = self.ShapeQuantifierCore.get(
            "correspondentShapes")
        self.nonCorrespondentShapes = self.ShapeQuantifierCore.get(
            "nonCorrespondentShapes")
        self.propagationInputComboBox = self.ShapeQuantifierCore.get(
            "propagationInputComboBox")
        self.propagationInputComboBox.setMRMLScene(slicer.mrmlScene)
        self.propagateButton = self.ShapeQuantifierCore.get("propagateButton")

        # ------------------------------------------------------------------------------------
        #                                   CONNECTIONS
        # ------------------------------------------------------------------------------------
        self.inputModelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                        self.onModelChanged)
        self.inputLandmarksSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                            self.onLandmarksChanged)
        self.addLandmarksButton.connect('clicked()', self.onAddButton)
        self.cleanerButton.connect('clicked()', self.onCleanButton)
        self.landmarksScaleWidget.connect('valueChanged(double)',
                                          self.onLandmarksScaleChanged)
        self.surfaceDeplacementCheckBox.connect(
            'stateChanged(int)', self.onSurfaceDeplacementStateChanged)
        self.landmarkComboBox.connect('currentIndexChanged(QString)',
                                      self.onLandmarkComboBoxChanged)
        self.radiusDefinitionWidget.connect('valueChanged(double)',
                                            self.onRadiusValueChanged)
        self.propagateButton.connect('clicked()', self.onPropagateButton)

        slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent,
                                     self.onCloseScene)
Пример #12
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        #
        #   Global variables
        # TODO: add the logic
        self.logic = DataImporterLogic()

        #
        #  Interface
        #
        loader = qt.QUiLoader()
        self.moduleName = 'DataImporter'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)
        path = os.path.join(scriptedModulesPath, 'Resources',
                            '%s.ui' % self.moduleName)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        self.CSVFileBrowsePushButton = self.getWidget(
            'CSVFileBrowsePushButton')
        self.CSVFileBrowsePushButton.connect('clicked(bool)',
                                             self.onCSVFileBrowsePushButton)
        self.ImportButton = self.getWidget('ImportButton')
        self.ImportButton.connect('clicked(bool)', self.onImportButton)
        self.CSVFileNameLineEdit = self.getWidget('CSVFileNameLineEdit')
        self.DataInputTypeGroupBox = self.getWidget('DataInputTypeGroupBox')
        self.AutoSegInputType = self.getWidget('AutoSegInputType')
        self.AutoSegInputType.toggled.connect(
            lambda: self.onInputType_chosen(self.AutoSegInputType))
        self.FSLInputType = self.getWidget('FSLInputType')
        self.FSLInputType.toggled.connect(
            lambda: self.onInputType_chosen(self.FSLInputType))
        self.FreeSurferInputType = self.getWidget('FreeSurferInputType')
        self.FreeSurferInputType.toggled.connect(
            lambda: self.onInputType_chosen(self.FreeSurferInputType))
        self.GeneralInputType = self.getWidget('GeneralInputType')
        self.GeneralInputType.toggled.connect(
            lambda: self.onInputType_chosen(self.GeneralInputType))
        self.SubjectsTableWidget = self.getWidget('SubjectsTableWidget')
        self.StructuresSliderWidget = self.getWidget('StructuresSliderWidget')
        self.CurrentStructureTopologyLineEdit = self.getWidget(
            'CurrentStructureTopologyLineEdit')
        self.CohortTopologyLineEdit = self.getWidget('CohortTopologyLineEdit')
        self.SaveCleanDataCheckBox = self.getWidget('checkBoxSaveCleanData')
        self.SaveCleanDataCheckBox.setChecked(True)
        self.SaveCleanDataCheckBox.connect('toggled(bool)',
                                           self.onSaveCleanDataCheckBoxToggled)

        self.SubjectsTableWidget.connect('cellClicked(int, int)',
                                         self.onSubjectTableWidgetClicked)
        self.StructuresSliderWidget.connect(
            'valueChanged(double)', self.onStructuresSliderWidgetChanged)
        self.StructuresSliderWidget.minimum = 0
        self.StructuresSliderWidget.maximum = 0

        # Initialize the beginning input type.
        self.onInputType_chosen(self.AutoSegInputType)
        self.onInputType_chosen(self.FSLInputType)
        self.onInputType_chosen(self.FreeSurferInputType)
        self.onInputType_chosen(self.GeneralInputType)
        self.onSaveCleanDataCheckBoxToggled()
Пример #13
0
    def __init__(self, workflow_configuration, parent=None):
        if not parent:
            self.parent = qt.QWidget()
            self.parent.setLayout(qt.QVBoxLayout())
        else:
            self.parent = parent

        self.workflow_configuration = workflow_configuration

        parent.connect(parent, 'mrmlSceneChanged(vtkMRMLScene*)',
                       self.workflow_configuration.setMRMLScene)
        self.workflow_configuration.setMRMLScene(slicer.mrmlScene)

        loader = qt.QUiLoader()

        self.steps = []

        def onEntryCallback(actual_step, comingFrom, transitionType):
            data = self.extract_data()

            method_name = 'on_entry_' + actual_step.id()
            if hasattr(self.workflow_configuration, method_name):
                on_entry = getattr(self.workflow_configuration, method_name)
                on_entry(actual_step, comingFrom, transitionType, data)
                self.update_data(data)

        def onExitCallback(actual_step, comingFrom, transitionType):
            data = self.extract_data()

            method_name = 'on_exit_' + actual_step.id()
            if hasattr(self.workflow_configuration, method_name):
                on_exit = getattr(self.workflow_configuration, method_name)
                on_exit(actual_step, comingFrom, transitionType, data)
                self.update_data(data)

        def validateCallback(actual_step, desiredBranchId):
            data = self.extract_data()

            method_name = 'validate_' + actual_step.id()
            if hasattr(self.workflow_configuration, method_name):
                validate = getattr(self.workflow_configuration, method_name)
                return validate(actual_step, data)
            else:
                return True

        self.callbacks = {
            'onEntryCallback': onEntryCallback,
            'onExitCallback': onExitCallback,
            'validateCallback': validateCallback
        }

        for step_widget_file in self.workflow_configuration.step_widget_files:
            path = os.path.join(os.path.dirname(__file__), 'Resources', 'UI',
                                step_widget_file + '.ui')

            qfile = qt.QFile(path)
            qfile.open(qt.QFile.ReadOnly)
            widget = loader.load(qfile)

            if hasattr(widget, 'setMRMLScene'):
                widget.connect(parent, 'mrmlSceneChanged(vtkMRMLScene*)',
                               widget.setMRMLScene)
                widget.setMRMLScene(slicer.mrmlScene)

            if hasattr(self.workflow_configuration, 'post_widget_init'):
                self.workflow_configuration.post_widget_init(
                    step_widget_file, widget)

            step = GeneralizedStep(step_widget_file,
                                   widget,
                                   onEntryCallback=onEntryCallback,
                                   onExitCallback=onExitCallback,
                                   validateCallback=validateCallback)

            self.steps.append((step_widget_file, step))

        self.workflow = ctk.ctkWorkflow(self.parent)
        self.workflowWidget = ctk.ctkWorkflowStackedWidget()

        self.workflowWidget.setWorkflow(self.workflow)
        self.parent.layout().addWidget(self.workflowWidget)

        for i in xrange(len(self.steps) - 1):
            self.workflow.addTransition(self.steps[i][1], self.steps[i + 1][1])

        self.workflow.start()
Пример #14
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        print("-----  Bone Texture widget setup -----")
        self.moduleName = 'BoneTexture'
        scriptedModulesPath = eval('slicer.modules.%s.path' % self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)

        # - Initialisation of Bone Texture and its logic - #

        self.logic = BoneTextureLogic(self)

        # -------------------------------------------------------------------- #
        # ----------------- Definition of the UI interface ------------------- #
        # -------------------------------------------------------------------- #

        # -------------------- Loading of the .ui file ----------------------- #

        loader = qt.QUiLoader()
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI', '%s.ui' % self.moduleName)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        # ---------------- Input Data Collapsible Button --------------------- #

        self.inputDataCollapsibleButton = self.logic.get("InputDataCollapsibleButton")
        self.singleCaseRadioButton = self.logic.get("SingleCaseRadioButton")
        self.multiCaseRadioButton = self.logic.get("MultiCaseRadioButton")
        self.singleCaseGroupBox = self.logic.get("SingleCaseGroupBox")
        self.multiCaseGroupBox = self.logic.get("MultiCaseGroupBox")
        self.inputScanMRMLNodeComboBox = self.logic.get("InputScanMRMLNodeComboBox")
        self.inputSegmentationMRMLNodeComboBox = self.logic.get("InputSegmentationMRMLNodeComboBox")
        self.inputScansPathLineEdit = self.logic.get("InputScansPathLineEdit")
        self.inputSegmentationsPathLineEdit = self.logic.get("InputSegmentationsPathLineEdit")


        # ---------------- Computation Collapsible Button -------------------- #

        self.computationCollapsibleButton = self.logic.get("ComputationCollapsibleButton")
        self.featureChoiceCollapsibleGroupBox = self.logic.get("FeatureChoiceCollapsibleGroupBox")
        self.gLCMFeaturesCheckableComboBox = self.logic.get("GLCMFeaturesCheckableComboBox")
        self.gLRLMFeaturesCheckableComboBox = self.logic.get("GLRLMFeaturesCheckableComboBox")
        self.computeFeaturesPushButton = self.logic.get("ComputeFeaturesPushButton")
        self.computeColormapsPushButton = self.logic.get("ComputeColormapsPushButton")
        self.advancedOptionsCollapsibleGroupBox = self.logic.get("AdvancedOptionsCollapsibleGroupBox")

        # ----------------- Results Collapsible Button ----------------------- #

        self.resultsCollapsibleButton = self.logic.get("ResultsCollapsibleButton")
        self.featuresTableCollapsibleGroupBox = self.logic.get("FeaturesTableCollapsibleGroupBox")
        self.featuresableWidget = self.logic.get("FeaturesableWidget")
        self.displayColormapsCollapsibleGroupBox = self.logic.get("DisplayColormapsCollapsibleGroupBox")
        self.displayColormapsMRMLTreeView = self.logic.get("DisplayColormapsMRMLTreeView")

        # ---------------- Exportation Collapsible Button -------------------- #

        self.exportationCollapsibleButton = self.logic.get("ExportationCollapsibleButton")
        self.outputPathLineEdit = self.logic.get("OutputPathLineEdit")
        self.saveFeaturesPushButton = self.logic.get("SaveFeaturesPushButton")
        self.saveColormapsPushButton = self.logic.get("SaveColormapsPushButton")

        # -------------------------------------------------------------------- #
        # ---------------------------- Connections --------------------------- #
        # -------------------------------------------------------------------- #

        self.singleCaseRadioButton.connect('clicked()', self.onSingleCaseComputationSelected)
        self.multiCaseRadioButton.connect('clicked()', self.onMultiCaseComputationSelected)

        # -------------------------------------------------------------------- #
        # -------------------------- Initialisation -------------------------- #
        # -------------------------------------------------------------------- #

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

    #
    #   Global variables
    #
    self.Logic = RegressionComputationLogic(self)

    #
    #  Interface
    #
    loader = qt.QUiLoader()
    self.moduleName = 'RegressionComputation'
    scriptedModulesPath = eval('slicer.modules.%s.path' % self.moduleName.lower())
    scriptedModulesPath = os.path.dirname(scriptedModulesPath)
    path = os.path.join(scriptedModulesPath, 'Resources', 'UI', '%s.ui' % self.moduleName)
    qfile = qt.QFile(path)
    qfile.open(qt.QFile.ReadOnly)
    widget = loader.load(qfile, self.parent)
    self.layout = self.parent.layout()
    self.widget = widget
    self.layout.addWidget(widget)

    # Global variables of the Interface
    # Input Shapes
    self.CollapsibleButton_RegressionComputationInput = self.getWidget('CollapsibleButton_RegressionComputationInput')
    self.tabWidget_InputShapes = self.getWidget('tabWidget_InputShapes')
    self.shapeInputDirectory = self.getWidget('DirectoryButton_ShapeInput')
    self.tableWidget_inputShapeParameters = self.getWidget('tableWidget_inputShapeParameters')
    self.PathLineEdit_ShapeInputsCSV = self.getWidget('PathLineEdit_ShapeInputsCSV')

    # Times Parameters
    self.CollapsibleButton_TimeParemeters = self.getWidget('CollapsibleButton_TimeParemeters')
    self.t0 = self.getWidget('spinBox_StartingTimePoint')
    self.tn = self.getWidget('spinBox_EndingTimePoint')
    self.T = self.getWidget('spinBox_NumberOfTimepoints')
    self.t0.enabled = True
    self.tn.enabled = True
    self.defaultTimePointRange = self.getWidget('checkBox_defaultTimePointRange')
    self.defaultTimePointRange.visible = False
    
    self.T.setMinimum(10)
    self.T.setMaximum(9999999)
        
    # Deformation Parameters
    self.CollapsibleButton_DeformationParameters = self.getWidget('CollapsibleButton_DeformationParameters')
    self.defKernelWidth = self.getWidget('spinBox_DeformationKernelWidh')
    self.kernelType = self.getWidget('ComboBox_KernelType')
    self.regularityWeight = self.getWidget('doubleSpinBox_RegularityWeight')
    
    self.defKernelWidth.setMinimum(0)
    self.defKernelWidth.setMaximum(9999999)
    self.regularityWeight.value = 0.01    

    # Output Parameters
    self.CollapsibleButton_OutputParameters = self.getWidget('CollapsibleButton_OutputParameters')
    self.outputDirectory = self.getWidget('DirectoryButton_OutputDirectory')
    self.outputPrefix = self.getWidget('lineEdit_OutputRootname')
    self.saveEveryN = self.getWidget('spinBox_SaveEveryNIterations')
    
    self.outputPrefix.text = 'Regression_output_'
    self.saveEveryN.value = 50

    # Optional Parameters
    self.CollapsibleButton_OptionalParameters = self.getWidget('CollapsibleButton_OptionalParameters')
    self.estimateBaseline = self.getWidget('checkBox_EstimateBaselineShape')
    self.optimMethod = self.getWidget('ComboBox_OptimizationMethod')
    self.breakRatio = self.getWidget('doubleSpinBox_BreakRatio')
    self.maxIters = self.getWidget('spinBox_MaxIterations')

    # Run Shape4D
    self.applyButton = self.getWidget('pushButton_RunShape4D')
    self.CLIProgressBar_shape4D = self.getWidget('CLIProgressBar_shape4D')

    # Connect Functions
    self.CollapsibleButton_RegressionComputationInput.connect('clicked()',
                                                        lambda: self.onSelectedCollapsibleButtonOpen(
                                                          self.CollapsibleButton_RegressionComputationInput))
    self.shapeInputDirectory.connect('directoryChanged(const QString &)', self.onInputShapesDirectoryChanged)

    self.CollapsibleButton_TimeParemeters.connect('clicked()',
                                                        lambda: self.onSelectedCollapsibleButtonOpen(
                                                          self.CollapsibleButton_TimeParemeters))

    #self.t0.connect('valueChanged(int)', self.onSetMaximumStartingTimePoint)
    #self.tn.connect('valueChanged(int)', self.onSetMinimumEndingTimePoint)
    #self.defaultTimePointRange.connect('clicked(bool)', self.onEnableTimePointRange)
    

    self.CollapsibleButton_DeformationParameters.connect('clicked()',
                                                        lambda: self.onSelectedCollapsibleButtonOpen(
                                                          self.CollapsibleButton_DeformationParameters))
    self.CollapsibleButton_OutputParameters.connect('clicked()',
                                                        lambda: self.onSelectedCollapsibleButtonOpen(
                                                          self.CollapsibleButton_OutputParameters))
    self.CollapsibleButton_OptionalParameters.connect('clicked()',
                                                        lambda: self.onSelectedCollapsibleButtonOpen(
                                                          self.CollapsibleButton_OptionalParameters))
    self.applyButton.connect('clicked(bool)', self.onApplyButton)



    slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent, self.onCloseScene)

    # Widget Configuration
    #   Input Parameters Table Configuration
    self.tableWidget_inputShapeParameters.setColumnCount(5)
    self.tableWidget_inputShapeParameters.setHorizontalHeaderLabels([' Input Shapes ', ' Time Point ', ' Kernel Width ', ' Shape Index ', ' Weight '])
    self.tableWidget_inputShapeParameters.setColumnWidth(0, 400)
    horizontalHeader = self.tableWidget_inputShapeParameters.horizontalHeader()
    horizontalHeader.setStretchLastSection(False)
    horizontalHeader.setResizeMode(0, qt.QHeaderView.Stretch)
    horizontalHeader.setResizeMode(1, qt.QHeaderView.ResizeToContents)
    horizontalHeader.setResizeMode(2, qt.QHeaderView.ResizeToContents)
    horizontalHeader.setResizeMode(3, qt.QHeaderView.ResizeToContents)
    horizontalHeader.setResizeMode(4, qt.QHeaderView.ResizeToContents)

    #   Shape4D CLI Progress Bar Configuration
    self.CLIProgressBar_shape4D.hide()
Пример #16
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        logging.debug("-----  Bone Texture widget setup -----")
        self.moduleName = 'BoneTexture'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)

        # - Init parameters. - #
        # TODO (EASY): a parameter node should be maintained instead of these dictionaries. - #

        self.GLCMFeaturesValueDict = {}
        self.GLCMFeaturesValueDict["insideMask"] = 1
        self.GLCMFeaturesValueDict["binNumber"] = 10
        self.GLCMFeaturesValueDict["pixelIntensityMin"] = 0
        self.GLCMFeaturesValueDict["pixelIntensityMax"] = 4000
        self.GLCMFeaturesValueDict["neighborhoodRadius"] = 4
        self.GLRLMFeaturesValueDict = {}
        self.GLRLMFeaturesValueDict["insideMask"] = 1
        self.GLRLMFeaturesValueDict["binNumber"] = 10
        self.GLRLMFeaturesValueDict["pixelIntensityMin"] = 0
        self.GLRLMFeaturesValueDict["pixelIntensityMax"] = 4000
        self.GLRLMFeaturesValueDict["neighborhoodRadius"] = 4
        self.GLRLMFeaturesValueDict["distanceMin"] = 0.00
        self.GLRLMFeaturesValueDict["distanceMax"] = 1.00
        self.BMFeaturesValueDict = {}
        self.BMFeaturesValueDict["threshold"] = 1
        self.BMFeaturesValueDict["neighborhoodRadius"] = 4

        # -------------------------------------------------------------------- #
        # ----------------- Definition of the UI interface ------------------- #
        # -------------------------------------------------------------------- #

        # -------------------- Loading of the .ui file ----------------------- #

        loader = qt.QUiLoader()
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            '%s.ui' % self.moduleName)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        # ---------------- Input Data Collapsible Button --------------------- #

        self.inputDataCollapsibleButton = self.logic.get(
            "InputDataCollapsibleButton")
        self.inputDataVerticalLayout = self.logic.get(
            "InputDataVerticalLayout")
        self.singleCaseGroupBox = self.logic.get("SingleCaseGroupBox")
        self.inputScanMRMLNodeComboBox = self.logic.get(
            "InputScanMRMLNodeComboBox")
        self.inputScanMRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)
        self.inputSegmentationMRMLNodeComboBox = self.logic.get(
            "InputSegmentationMRMLNodeComboBox")
        self.inputSegmentationMRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)
        # Add a python widget from core slicer scripted module: VectorToScalarModule
        # It works fine, but that module should be written in c++ to be truly reusable with qtdesigner,
        self.vectorToScalarVolumeGroupBox = qt.QGroupBox(
            self.inputDataCollapsibleButton)
        self.vectorToScalarVolumeGroupBox.setTitle(
            "Conversion: Vector Input Scan to Scalar")
        self.vectorToScalarVolumeLayout = qt.QVBoxLayout(
            self.vectorToScalarVolumeGroupBox)
        self.vectorToScalarVolumeConversionWidget = VectorToScalarVolume.VectorToScalarVolumeConversionMethodWidget(
        )
        self.vectorToScalarVolumePushButton = qt.QPushButton(
            self.vectorToScalarVolumeGroupBox)
        self.vectorToScalarVolumePushButton.setText(
            "Convert input scan to scalar")
        self.vectorToScalarVolumeLayout.addWidget(
            self.vectorToScalarVolumeConversionWidget)
        self.vectorToScalarVolumeLayout.addWidget(
            self.vectorToScalarVolumePushButton)
        self.inputDataVerticalLayout.addWidget(
            self.vectorToScalarVolumeGroupBox)
        vectorToScalarIndex = self.vectorToScalarVolumeConversionWidget.methodSelectorComboBox.findData(
            VectorToScalarVolume.VectorToScalarVolumeLogic.LUMINANCE)
        self.vectorToScalarVolumeConversionWidget.methodSelectorComboBox.setCurrentIndex(
            vectorToScalarIndex)
        self.vectorToScalarVolumeGroupBox.enabled = False

        # ---------------- Computation Collapsible Button -------------------- #

        self.computationCollapsibleButton = self.logic.get(
            "ComputationCollapsibleButton")
        self.featureChoiceCollapsibleGroupBox = self.logic.get(
            "FeatureChoiceCollapsibleGroupBox")
        self.gLCMFeaturesCheckBox = self.logic.get("GLCMFeaturesCheckBox")
        self.gLRLMFeaturesCheckBox = self.logic.get("GLRLMFeaturesCheckBox")
        self.bMFeaturesCheckBox = self.logic.get("BMFeaturesCheckBox")
        self.computeFeaturesPushButton = self.logic.get(
            "ComputeFeaturesPushButton")
        self.computeColormapsPushButton = self.logic.get(
            "ComputeColormapsPushButton")
        self.computeParametersBasedOnInputs = self.logic.get(
            "ComputeParametersBasedOnInputsButton")
        self.GLCMparametersCollapsibleGroupBox = self.logic.get(
            "GLCMParametersCollapsibleGroupBox")
        self.GLCMinsideMaskValueSpinBox = self.logic.get(
            "GLCMInsideMaskValueSpinBox")
        self.GLCMnumberOfBinsSpinBox = self.logic.get(
            "GLCMNumberOfBinsSpinBox")
        self.GLCMminVoxelIntensitySpinBox = self.logic.get(
            "GLCMMinVoxelIntensitySpinBox")
        self.GLCMmaxVoxelIntensitySpinBox = self.logic.get(
            "GLCMMaxVoxelIntensitySpinBox")
        self.GLCMneighborhoodRadiusSpinBox = self.logic.get(
            "GLCMNeighborhoodRadiusSpinBox")
        self.GLRLMparametersCollapsibleGroupBox = self.logic.get(
            "GLRLMParametersCollapsibleGroupBox")
        self.GLRLMinsideMaskValueSpinBox = self.logic.get(
            "GLRLMInsideMaskValueSpinBox")
        self.GLRLMnumberOfBinsSpinBox = self.logic.get(
            "GLRLMNumberOfBinsSpinBox")
        self.GLRLMminVoxelIntensitySpinBox = self.logic.get(
            "GLRLMMinVoxelIntensitySpinBox")
        self.GLRLMmaxVoxelIntensitySpinBox = self.logic.get(
            "GLRLMMaxVoxelIntensitySpinBox")
        self.GLRLMminDistanceSpinBox = self.logic.get(
            "GLRLMMinDistanceSpinBox")
        self.GLRLMmaxDistanceSpinBox = self.logic.get(
            "GLRLMMaxDistanceSpinBox")
        self.GLRLMneighborhoodRadiusSpinBox = self.logic.get(
            "GLRLMNeighborhoodRadiusSpinBox")
        self.bMparametersCollapsibleGroupBox = self.logic.get(
            "BMParametersCollapsibleGroupBox")
        self.BMthresholdSpinBox = self.logic.get("BMThresholdSpinBox")
        self.BMneighborhoodRadiusSpinBox = self.logic.get(
            "BMNeighborhoodRadiusSpinBox")

        # ----------------- Results Collapsible Button ----------------------- #

        self.resultsCollapsibleButton = self.logic.get(
            "ResultsCollapsibleButton")
        self.featureSetMRMLNodeComboBox = self.logic.get(
            "featureSetMRMLNodeComboBox")
        self.featureSetMRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)
        self.featureComboBox = self.logic.get("featureComboBox")
        self.displayColormapsCollapsibleGroupBox = self.logic.get(
            "DisplayColormapsCollapsibleGroupBox")
        self.displayFeaturesTableWidget = self.logic.get(
            "displayFeaturesTableWidget")
        self.SaveTablePushButton = self.logic.get("SaveTablePushButton")
        self.CSVPathLineEdit = self.logic.get("CSVPathLineEdit")

        # -------------------------------------------------------------------- #
        # ---------------------------- Connections --------------------------- #
        # -------------------------------------------------------------------- #

        # ------------------------- Input Images ----------------------------- #
        self.inputScanMRMLNodeComboBox.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onInputScanChanged)

        self.vectorToScalarVolumeConversionWidget.methodSelectorComboBox.connect(
            'currentIndexChanged(int)', lambda currentIndex: self.
            vectorToScalarVolumeConversionWidget.setGuiBasedOnOptions(
                self.vectorToScalarVolumeConversionWidget.
                methodSelectorComboBox.itemData(currentIndex),
                self.inputScanMRMLNodeComboBox.currentNode()))
        self.vectorToScalarVolumePushButton.connect(
            'clicked()', self.onVectorToScalarVolumePushButtonClicked)
        # ---------------- Computation Collapsible Button --------------------- #

        self.GLCMinsideMaskValueSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "insideMask", self.GLCMinsideMaskValueSpinBox.value))
        self.GLCMnumberOfBinsSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "binNumber", self.GLCMnumberOfBinsSpinBox.value))
        self.GLCMminVoxelIntensitySpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "pixelIntensityMin", self.GLCMminVoxelIntensitySpinBox.value))
        self.GLCMmaxVoxelIntensitySpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "pixelIntensityMax", self.GLCMmaxVoxelIntensitySpinBox.value))
        self.GLCMneighborhoodRadiusSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "neighborhoodRadius", self.GLCMneighborhoodRadiusSpinBox.value)
        )
        self.GLRLMinsideMaskValueSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "insideMask", self.GLRLMinsideMaskValueSpinBox.value))
        self.GLRLMnumberOfBinsSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "binNumber", self.GLRLMnumberOfBinsSpinBox.value))
        self.GLRLMminVoxelIntensitySpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "pixelIntensityMin", self.GLRLMminVoxelIntensitySpinBox.value))
        self.GLRLMmaxVoxelIntensitySpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "pixelIntensityMax", self.GLRLMmaxVoxelIntensitySpinBox.value))
        self.GLRLMminDistanceSpinBox.connect(
            'valueChanged(double)',
            lambda: self.onGLRLMFeaturesValueDictModified(
                "distanceMin", self.GLRLMminDistanceSpinBox.value))
        self.GLRLMmaxDistanceSpinBox.connect(
            'valueChanged(double)',
            lambda: self.onGLRLMFeaturesValueDictModified(
                "distanceMax", self.GLRLMmaxDistanceSpinBox.value))
        self.GLRLMneighborhoodRadiusSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "neighborhoodRadius", self.GLRLMneighborhoodRadiusSpinBox.value
            ))
        self.BMthresholdSpinBox.connect(
            'valueChanged(int)', lambda: self.onBMFeaturesValueDictModified(
                "threshold", self.BMthresholdSpinBox.value))
        self.BMneighborhoodRadiusSpinBox.connect(
            'valueChanged(int)', lambda: self.onBMFeaturesValueDictModified(
                "neighborhoodRadius", self.BMneighborhoodRadiusSpinBox.value))

        # ----------- Compute Parameters Based on Inputs Button -------------- #
        self.computeParametersBasedOnInputs.connect(
            'clicked()', self.onComputeParametersBasedOnInputs)

        # ---------------- Computation Collapsible Button -------------------- #
        self.computeFeaturesPushButton.connect('clicked()',
                                               self.onComputeFeatures)
        self.computeColormapsPushButton.connect('clicked()',
                                                self.onComputeColormaps)

        # ----------------- Results Collapsible Button ----------------------- #

        self.featureSetMRMLNodeComboBox.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onFeatureSetChanged)
        self.featureComboBox.connect("currentIndexChanged(int)",
                                     self.onFeatureChanged)
        self.SaveTablePushButton.connect('clicked()', self.onSaveTable)
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        print("-----  Bone Texture Serializer widget setup -----")
        self.moduleName = 'BoneTextureSerializer'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)

        # - Initialisation of Bone Texture Serializer and its logic - #

        self.logic = BoneTextureSerializerLogic(self)
        self.caseDict = dict()
        self.GLCMFeaturesValueDict = {}
        self.GLCMFeaturesValueDict["insideMask"] = 1
        self.GLCMFeaturesValueDict["binNumber"] = 10
        self.GLCMFeaturesValueDict["pixelIntensityMin"] = 0
        self.GLCMFeaturesValueDict["pixelIntensityMax"] = 4000
        self.GLCMFeaturesValueDict["neighborhoodRadius"] = 4
        self.GLRLMFeaturesValueDict = {}
        self.GLRLMFeaturesValueDict["insideMask"] = 1
        self.GLRLMFeaturesValueDict["binNumber"] = 10
        self.GLRLMFeaturesValueDict["pixelIntensityMin"] = 0
        self.GLRLMFeaturesValueDict["pixelIntensityMax"] = 4000
        self.GLRLMFeaturesValueDict["neighborhoodRadius"] = 4
        self.GLRLMFeaturesValueDict["distanceMin"] = 0.00
        self.GLRLMFeaturesValueDict["distanceMax"] = 1.00
        self.BMFeaturesValueDict = {}
        self.BMFeaturesValueDict["threshold"] = 1
        self.BMFeaturesValueDict["neighborhoodRadius"] = 4

        # -------------------------------------------------------------------- #
        # ----------------- Definition of the UI interface ------------------- #
        # -------------------------------------------------------------------- #

        # -------------------- Loading of the .ui file ----------------------- #

        loader = qt.QUiLoader()
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            '%s.ui' % self.moduleName)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        # ---------------- Input Data Collapsible Button --------------------- #

        self.inputDataCollapsibleButton = self.logic.get(
            "InputDataCollapsibleButton")
        self.singleCaseGroupBox = self.logic.get("SingleCaseGroupBox")
        self.inputFolderDirectoryButton = self.logic.get(
            "InputFolderDirectoryButton")

        # ---------------- Computation Collapsible Button -------------------- #

        self.computationCollapsibleButton = self.logic.get(
            "ComputationCollapsibleButton")
        self.featureChoiceCollapsibleGroupBox = self.logic.get(
            "FeatureChoiceCollapsibleGroupBox")
        self.gLCMFeaturesCheckBox = self.logic.get("GLCMFeaturesCheckBox")
        self.gLRLMFeaturesCheckBox = self.logic.get("GLRLMFeaturesCheckBox")
        self.bMFeaturesCheckBox = self.logic.get("BMFeaturesCheckBox")
        self.computeFeaturesPushButton = self.logic.get(
            "ComputeFeaturesPushButton")
        self.computeColormapsPushButton = self.logic.get(
            "ComputeColormapsPushButton")
        self.GLCMparametersCollapsibleGroupBox = self.logic.get(
            "GLCMParametersCollapsibleGroupBox")
        self.GLCMinsideMaskValueSpinBox = self.logic.get(
            "GLCMInsideMaskValueSpinBox")
        self.GLCMnumberOfBinsSpinBox = self.logic.get(
            "GLCMNumberOfBinsSpinBox")
        self.GLCMminVoxelIntensitySpinBox = self.logic.get(
            "GLCMMinVoxelIntensitySpinBox")
        self.GLCMmaxVoxelIntensitySpinBox = self.logic.get(
            "GLCMMaxVoxelIntensitySpinBox")
        self.GLCMneighborhoodRadiusSpinBox = self.logic.get(
            "GLCMNeighborhoodRadiusSpinBox")
        self.GLRLMparametersCollapsibleGroupBox = self.logic.get(
            "GLRLMParametersCollapsibleGroupBox")
        self.GLRLMinsideMaskValueSpinBox = self.logic.get(
            "GLRLMInsideMaskValueSpinBox")
        self.GLRLMnumberOfBinsSpinBox = self.logic.get(
            "GLRLMNumberOfBinsSpinBox")
        self.GLRLMminVoxelIntensitySpinBox = self.logic.get(
            "GLRLMMinVoxelIntensitySpinBox")
        self.GLRLMmaxVoxelIntensitySpinBox = self.logic.get(
            "GLRLMMaxVoxelIntensitySpinBox")
        self.GLRLMminDistanceSpinBox = self.logic.get(
            "GLRLMMinDistanceSpinBox")
        self.GLRLMmaxDistanceSpinBox = self.logic.get(
            "GLRLMMaxDistanceSpinBox")
        self.GLRLMneighborhoodRadiusSpinBox = self.logic.get(
            "GLRLMNeighborhoodRadiusSpinBox")
        self.bMparametersCollapsibleGroupBox = self.logic.get(
            "BMParametersCollapsibleGroupBox")
        self.BMthresholdSpinBox = self.logic.get("BMThresholdSpinBox")
        self.BMneighborhoodRadiusSpinBox = self.logic.get(
            "BMNeighborhoodRadiusSpinBox")

        # ---------------- Export Collapsible Button -------------------- #

        self.exportationCollapsibleButton = self.logic.get(
            "ExportCollapsibleButton")
        self.outputFolderDirectoryButton = self.logic.get(
            "OutputFolderDirectoryButton")
        self.separateFeaturesCheckBox = self.logic.get(
            "separateFeaturesCheckBox")
        self.saveAsCSVCheckBox = self.logic.get("saveAsCSVCheckBox")

        # -------------------------------------------------------------------- #
        # ---------------------------- Connections --------------------------- #
        # -------------------------------------------------------------------- #

        # ---------------- Input Data Collapsible Button --------------------- #

        self.inputFolderDirectoryButton.connect(
            'directoryChanged(const QString &)', self.onDirectoryChanged)
        self.GLCMinsideMaskValueSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "insideMask", self.GLCMinsideMaskValueSpinBox.value))
        self.GLCMnumberOfBinsSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "binNumber", self.GLCMnumberOfBinsSpinBox.value))
        self.GLCMminVoxelIntensitySpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "pixelIntensityMin", self.GLCMminVoxelIntensitySpinBox.value))
        self.GLCMmaxVoxelIntensitySpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "pixelIntensityMax", self.GLCMmaxVoxelIntensitySpinBox.value))
        self.GLCMneighborhoodRadiusSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLCMFeaturesValueDictModified(
                "neighborhoodRadius", self.GLCMneighborhoodRadiusSpinBox.value)
        )
        self.GLRLMinsideMaskValueSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "insideMask", self.GLRLMinsideMaskValueSpinBox.value))
        self.GLRLMnumberOfBinsSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "binNumber", self.GLRLMnumberOfBinsSpinBox.value))
        self.GLRLMminVoxelIntensitySpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "pixelIntensityMin", self.GLRLMminVoxelIntensitySpinBox.value))
        self.GLRLMmaxVoxelIntensitySpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "pixelIntensityMax", self.GLRLMmaxVoxelIntensitySpinBox.value))
        self.GLRLMminDistanceSpinBox.connect(
            'valueChanged(double)',
            lambda: self.onGLRLMFeaturesValueDictModified(
                "distanceMin", self.GLRLMminDistanceSpinBox.value))
        self.GLRLMmaxDistanceSpinBox.connect(
            'valueChanged(double)',
            lambda: self.onGLRLMFeaturesValueDictModified(
                "distanceMax", self.GLRLMmaxDistanceSpinBox.value))
        self.GLRLMneighborhoodRadiusSpinBox.connect(
            'valueChanged(int)', lambda: self.onGLRLMFeaturesValueDictModified(
                "neighborhoodRadius", self.GLRLMneighborhoodRadiusSpinBox.value
            ))
        self.BMthresholdSpinBox.connect(
            'valueChanged(int)', lambda: self.onBMFeaturesValueDictModified(
                "threshold", self.BMthresholdSpinBox.value))
        self.BMneighborhoodRadiusSpinBox.connect(
            'valueChanged(int)', lambda: self.onBMFeaturesValueDictModified(
                "neighborhoodRadius", self.BMneighborhoodRadiusSpinBox.value))

        # ---------------- Computation Collapsible Button -------------------- #

        self.computeFeaturesPushButton.connect('clicked()',
                                               self.onComputeFeatures)
        self.computeColormapsPushButton.connect('clicked()',
                                                self.onComputeColormaps)
Пример #18
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        #
        #  Interface
        #
        loader = qt.QUiLoader()
        self.moduleName = 'GroupWiseRegistrationModule'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            '%s.ui' % self.moduleName)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        # Global variables of the Interface
        # Directories
        self.CollapsibleButton_Directories = self.getWidget(
            'CollapsibleButton_Directories')
        self.GroupsInputModelsDirectory = self.getWidget(
            'DirectoryButton_GroupsInputModelsDirectory')
        self.GroupsInputSphericalModelsDirectory = self.getWidget(
            'DirectoryButton_GroupsInputSphericalModelsDirectory')
        self.GroupsOutputCoefficientsDirectory = self.getWidget(
            'DirectoryButton_GroupsOutputCoefficientsDirectory')
        self.GroupsOutputModelsDirectory = self.getWidget(
            'DirectoryButton_GroupsOutputModelsDirectory')
        # Parameters
        self.CollapsibleButton_Parameters = self.getWidget(
            'CollapsibleButton_Parameters')
        self.GroupsLandmarks = self.getWidget('checkBox_Landmarks')
        self.GroupsSpharmDegree = self.getWidget(
            'SliderWidget_SpharmDecomposotion')
        self.GroupsIterations = self.getWidget('spinBox_Iterations')
        self.GroupsProperties = self.getWidget('tableWidget_Properites')
        # Apply CLIs
        self.ApplyButton = self.getWidget('pushButton_RunGroups')

        # Initial Values
        self.Landmarks = False
        self.SpharmDegree = 5
        self.Iterations = 5000
        self.PropertiesNames = []
        self.PropertiesNamesSelected = []
        self.PropertiesWeightsSelected = []

        # Connections
        # Directories
        self.CollapsibleButton_Directories.connect(
            'clicked()', lambda: self.onSelectedCollapsibleButtonOpen(
                self.CollapsibleButton_Directories))
        self.GroupsInputModelsDirectory.connect(
            'directoryChanged(const QString &)', self.onSelectInputModels)
        self.GroupsInputSphericalModelsDirectory.connect(
            'directoryChanged(const QString &)', self.onSelect)
        self.GroupsOutputCoefficientsDirectory.connect(
            'directoryChanged(const QString &)', self.onSelect)
        self.GroupsOutputModelsDirectory.connect(
            'directoryChanged(const QString &)', self.onSelect)
        # Parameters
        self.CollapsibleButton_Parameters.connect(
            'clicked()', lambda: self.onSelectedCollapsibleButtonOpen(
                self.CollapsibleButton_Parameters))
        self.GroupsLandmarks.connect('stateChanged(int)',
                                     self.onSelectLandmarks)
        self.GroupsSpharmDegree.connect('valueChanged(double)',
                                        self.onSelectSpharmDegree)
        self.GroupsIterations.connect('valueChanged(int)',
                                      self.onSelectIterations)
        # Apply CLIs
        self.ApplyButton.connect('clicked(bool)', self.onApplyButton)

        # Widget Configuration
        # Input Properities Table Configuration
        self.GroupsProperties.setColumnCount(2)
        self.GroupsProperties.setHorizontalHeaderLabels(
            [' Properity ', ' Weight '])
        self.GroupsProperties.setColumnWidth(0, 400)
        horizontalHeader = self.GroupsProperties.horizontalHeader()
        horizontalHeader.setStretchLastSection(False)
        _setSectionResizeMode(horizontalHeader, 0, qt.QHeaderView.Stretch)
        _setSectionResizeMode(horizontalHeader, 1,
                              qt.QHeaderView.ResizeToContents)