コード例 #1
0
ファイル: LabelCreateDialog.py プロジェクト: BRAINSia/Slicer
  def __init__(self, parent):
    vLayout = qt.QVBoxLayout(parent)

    self.colorPromptLabel = qt.QLabel()
    vLayout.addWidget( self.colorPromptLabel )

    self.colorSelectorFrame = qt.QFrame()
    self.colorSelectorFrame.objectName = 'ColorSelectorFrame'
    self.colorSelectorFrame.setLayout( qt.QHBoxLayout() )
    vLayout.addWidget( self.colorSelectorFrame )

    self.colorSelectorLabel = qt.QLabel()
    self.colorSelectorFrame.layout().addWidget( self.colorSelectorLabel )

    self.colorSelector = slicer.qMRMLColorTableComboBox()
    self.colorSelector.nodeTypes = ["vtkMRMLColorNode"]
    self.colorSelector.hideChildNodeTypes = ("vtkMRMLDiffusionTensorDisplayPropertiesNode", "vtkMRMLProceduralColorNode", "")
    self.colorSelector.addEnabled = False
    self.colorSelector.removeEnabled = False
    self.colorSelector.noneEnabled = False
    self.colorSelector.selectNodeUponCreation = True
    self.colorSelector.showHidden = True
    self.colorSelector.showChildNodeTypes = True
    self.colorSelector.setMRMLScene( slicer.mrmlScene )
    self.colorSelector.setToolTip( "Pick the table of structures you wish to edit" )
    vLayout.addWidget( self.colorSelector )

    self.buttonBox = qt.QDialogButtonBox()
    self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok |
                                      qt.QDialogButtonBox.Cancel)
    vLayout.addWidget(self.buttonBox)

    self.buttonBox.button(qt.QDialogButtonBox.Ok).setToolTip("Use currently selected color node.")
    self.buttonBox.button(qt.QDialogButtonBox.Cancel).setToolTip("Cancel current operation.")
コード例 #2
0
 def makeColorsButton(self):
     self.logic.removeColorMaps()
     self.colorSelector = slicer.qMRMLColorTableComboBox()
     self.colorSelector.nodeTypes = ["vtkMRMLColorNode"]
     self.colorSelector.hideChildNodeTypes = (
         "vtkMRMLDiffusionTensorDisplayPropertiesNode",
         "vtkMRMLProceduralColorNode",
     )
     self.colorSelector.addEnabled = False
     self.colorSelector.removeEnabled = False
     self.colorSelector.noneEnabled = False
     self.colorSelector.selectNodeUponCreation = True
     self.colorSelector.showHidden = True
     self.colorSelector.showChildNodeTypes = True
     self.colorSelector.setMRMLScene(slicer.mrmlScene)
     self.colorSelector.setToolTip("Choose a colormap")
     self.colorSelector.currentNodeID = 'vtkMRMLColorTableNodeFileCividis.txt'
     self.colorSelector.currentNodeID = None
     self.colorSelector.currentNodeChanged.connect(self.onAutoUpdateButton)
     self.settingsLayout.addRow('Colormap: ', self.colorSelector)
コード例 #3
0
    def __init__(self, parent):
        vLayout = qt.QVBoxLayout(parent)

        self.colorPromptLabel = qt.QLabel()
        vLayout.addWidget(self.colorPromptLabel)

        self.colorSelectorFrame = qt.QFrame()
        self.colorSelectorFrame.objectName = 'ColorSelectorFrame'
        self.colorSelectorFrame.setLayout(qt.QHBoxLayout())
        vLayout.addWidget(self.colorSelectorFrame)

        self.colorSelectorLabel = qt.QLabel()
        self.colorSelectorFrame.layout().addWidget(self.colorSelectorLabel)

        self.colorSelector = slicer.qMRMLColorTableComboBox()
        self.colorSelector.nodeTypes = ["vtkMRMLColorNode"]
        self.colorSelector.hideChildNodeTypes = (
            "vtkMRMLDiffusionTensorDisplayPropertiesNode",
            "vtkMRMLProceduralColorNode", "")
        self.colorSelector.addEnabled = False
        self.colorSelector.removeEnabled = False
        self.colorSelector.noneEnabled = False
        self.colorSelector.selectNodeUponCreation = True
        self.colorSelector.showHidden = True
        self.colorSelector.showChildNodeTypes = True
        self.colorSelector.setMRMLScene(slicer.mrmlScene)
        self.colorSelector.setToolTip(
            "Pick the table of structures you wish to edit")
        vLayout.addWidget(self.colorSelector)

        self.buttonBox = qt.QDialogButtonBox()
        self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok
                                          | qt.QDialogButtonBox.Cancel)
        vLayout.addWidget(self.buttonBox)

        self.buttonBox.button(qt.QDialogButtonBox.Ok).setToolTip(
            "Use currently selected color node.")
        self.buttonBox.button(
            qt.QDialogButtonBox.Cancel).setToolTip("Cancel current operation.")
コード例 #4
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        ###################################
        # Import node graph json file Area
        ###################################
        self.fileCollapsibleButton = ctk.ctkCollapsibleButton()
        self.fileCollapsibleButton.text = "Import Node Graph Json File"
        self.layout.addWidget(self.fileCollapsibleButton)
        self.fileImportFormLayout = qt.QFormLayout(self.fileCollapsibleButton)

        self.fileImport = ctk.ctkPathLineEdit()
        self.fileImport.filters = ctk.ctkPathLineEdit.Files
        self.fileImport.settingKey = 'JsonInputFile'
        self.fileImport.currentPath = os.path.normpath(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         './Resources/nodeGraph_3D.json'))
        self.fileImportFormLayout.addRow("Input Json File:", self.fileImport)

        self.fileImportButton = qt.QPushButton('Load File')
        self.fileImportFormLayout.addRow(self.fileImportButton)

        ###################################
        # Node Table Area
        ###################################
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Node Table"
        self.layout.addWidget(parametersCollapsibleButton)
        # Layout within the collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # Checkbox to see whether or not the input table has a header
        #
        self.headerCheckBox = qt.QCheckBox()
        self.headerCheckBox.checked = 0
        self.headerCheckBox.setToolTip(
            "If checked, it means that the input node table contains a header."
        )
        parametersFormLayout.addRow("Header in Node Table",
                                    self.headerCheckBox)

        #
        # input table selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLTableNode"]
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = False
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip(
            "The input file loaded trough the import Data module should be a one line table (with or without header)."
        )
        parametersFormLayout.addRow("Input Table: ", self.inputSelector)

        #
        # Table start column spinBox
        #
        self.min_column = 1
        self.tableStartSpinBox = qt.QDoubleSpinBox()
        self.tableStartSpinBox.singleStep = 1
        self.tableStartSpinBox.setValue(self.min_column)
        self.tableStartSpinBox.setDecimals(0)
        self.tableStartSpinBox.setToolTip(
            "Set start column, if the first column contains a string of characters(ex: subject name) then this column should be skipped and the start column is thus 1. This should be an integer (int)"
        )
        parametersFormLayout.addRow("Start Column:", self.tableStartSpinBox)

        ###################################
        # Region Selector Area
        ###################################
        self.nodeselectCollapsibleButton = ctk.ctkCollapsibleButton()
        self.nodeselectCollapsibleButton.text = "Selection of Node Region"
        self.layout.addWidget(self.nodeselectCollapsibleButton)
        # Layout within the collapsible button
        self.nodeselectFormLayout = qt.QFormLayout(
            self.nodeselectCollapsibleButton)

        # Search Box to filter regions to display
        self.searchLayout = qt.QHBoxLayout()
        self.nodeselectFormLayout.addRow('Search:', self.searchLayout)
        self.regionSearchBox = ctk.ctkSearchBox()
        self.regionSearchBox.placeholderText = "search region"
        self.regionSearchBox.searchIcon
        self.searchLayout.addWidget(self.regionSearchBox)

        self.logic = visuThreeDLogic()
        self.regionsLayout = qt.QHBoxLayout()
        self.nodeselectFormLayout.addRow('Regions:', self.regionsLayout)
        self.regionButtons = ctk.ctkCheckableComboBox()
        self.regionsLayout.addWidget(self.regionButtons)

        # Add buttons to select all or no region
        self.buttonsLayout = qt.QHBoxLayout()
        self.nodeselectFormLayout.addRow('Select:', self.buttonsLayout)
        self.calculateAllregionsButton = qt.QPushButton('Select All')
        self.calculateAllregionsButton.toolTip = 'Select all regions.'
        self.calculateAllregionsButton.enabled = True
        self.buttonsLayout.addWidget(self.calculateAllregionsButton)
        self.calculateAllFilteredregionsButton = qt.QPushButton(
            'Select Filtered')
        self.calculateAllFilteredregionsButton.toolTip = 'Select all  filtered regions.'
        self.calculateAllFilteredregionsButton.enabled = True
        self.buttonsLayout.addWidget(self.calculateAllFilteredregionsButton)

        self.deselectButtonsLayout = qt.QHBoxLayout()
        self.nodeselectFormLayout.addRow('Deselect:',
                                         self.deselectButtonsLayout)
        self.calculateNoregionsButton = qt.QPushButton('Deselect All')
        self.calculateNoregionsButton.toolTip = 'Deselect all regions.'
        self.calculateNoregionsButton.enabled = True
        self.deselectButtonsLayout.addWidget(self.calculateNoregionsButton)
        self.calculateNoFilteredregionsButton = qt.QPushButton(
            'Deselect Filtered')
        self.calculateNoFilteredregionsButton.toolTip = 'Deselect all filtered regions.'
        self.calculateNoFilteredregionsButton.enabled = True
        self.deselectButtonsLayout.addWidget(
            self.calculateNoFilteredregionsButton)

        ###################################
        # Node Size and colorbar thresholding Area
        ###################################
        self.colorbarCollapsibleButton = ctk.ctkCollapsibleButton()
        self.colorbarCollapsibleButton.text = "Node Size and Color Thresholding"
        self.layout.addWidget(self.colorbarCollapsibleButton)
        # Layout within the collapsible button
        self.regioncheckFormLayout = qt.QFormLayout(
            self.colorbarCollapsibleButton)

        self.ColorTable = slicer.qMRMLColorTableComboBox()
        self.ColorTable.nodeTypes = ["vtkMRMLColorTableNode"]
        self.ColorTable.addEnabled = True
        self.ColorTable.removeEnabled = True
        self.ColorTable.noneEnabled = True
        self.ColorTable.showHidden = True
        self.ColorTable.setMRMLScene(slicer.mrmlScene)
        self.regioncheckFormLayout.addRow("Input Color Map: ", self.ColorTable)

        #
        # Threshold node value
        #
        # default values
        self.minVal = 0.0
        self.maxVal = 1.0
        self.nodeThresholdSliderWidget = ctk.ctkRangeWidget()
        self.nodeThresholdSliderWidget.singleStep = 0.01
        self.nodeThresholdSliderWidget.setValues(self.minVal, self.maxVal)
        self.nodeThresholdSliderWidget.setMaximumValue(self.maxVal)
        self.nodeThresholdSliderWidget.setMinimumValue(self.minVal)
        self.nodeThresholdSliderWidget.setRange(self.minVal, self.maxVal)
        self.nodeThresholdSliderWidget.setMouseTracking(True)
        self.nodeThresholdSliderWidget.setEnabled(True)
        self.nodeThresholdSliderWidget.setToolTip(
            "Set threshold node value for computing the node value.")
        self.regioncheckFormLayout.addRow("Plot Property Range:",
                                          self.nodeThresholdSliderWidget)

        #
        # Node size min spinBox
        #
        # default value for min size (l: lowest , h: highest)
        self.minSize_l = 0.0
        self.minSize_h = 100.0
        self.nodeMinSizeSpinBox = qt.QDoubleSpinBox()
        self.nodeMinSizeSpinBox.singleStep = 0.01
        self.nodeMinSizeSpinBox.setRange(self.minSize_l, self.minSize_h)
        self.nodeMinSizeSpinBox.setToolTip("Set minimum node size.")
        self.regioncheckFormLayout.addRow("Min Size:", self.nodeMinSizeSpinBox)

        #
        # Node size max spinBox
        #
        # default value for max size (l: lowest , h: highest)
        self.maxSize_l = 0.0
        self.maxSize_h = 100.0
        self.nodeMaxSizeSpinBox = qt.QDoubleSpinBox()
        self.nodeMaxSizeSpinBox.singleStep = 0.01
        self.nodeMaxSizeSpinBox.setRange(self.maxSize_l, self.maxSize_h)
        self.nodeMaxSizeSpinBox.setToolTip("Set maximum node size.")
        self.regioncheckFormLayout.addRow("Max Size:", self.nodeMaxSizeSpinBox)

        ###################################
        # Connections line/tube Area
        ###################################
        self.lineCollapsibleButton = ctk.ctkCollapsibleButton()
        self.lineCollapsibleButton.text = "Connection Size and Color Thresholding"
        self.layout.addWidget(self.lineCollapsibleButton)
        # Layout within the collapsible button
        self.lineconnectFormLayout = qt.QFormLayout(self.lineCollapsibleButton)

        #
        # input connection matrix selector
        #
        self.matrixConnectSelector = slicer.qMRMLNodeComboBox()
        self.matrixConnectSelector.nodeTypes = ["vtkMRMLTableNode"]
        self.matrixConnectSelector.selectNodeUponCreation = True
        self.matrixConnectSelector.addEnabled = False
        self.matrixConnectSelector.removeEnabled = False
        self.matrixConnectSelector.noneEnabled = False
        self.matrixConnectSelector.showHidden = False
        self.matrixConnectSelector.showChildNodeTypes = False
        self.matrixConnectSelector.setMRMLScene(slicer.mrmlScene)
        self.matrixConnectSelector.setToolTip(
            "Pick the connection matrix input to the algorithm.")
        self.lineconnectFormLayout.addRow("Input Connection Table: ",
                                          self.matrixConnectSelector)

        #
        # Checkbox to choose whether or not the connection distribution follows a log scale or else a linear distribution
        #
        self.connectionDistCheckBox = qt.QCheckBox()
        self.connectionDistCheckBox.checked = 0
        self.connectionDistCheckBox.setToolTip(
            "If checked, it means that the connection distribution follows a log scale."
        )
        self.lineconnectFormLayout.addRow("Log Distribution",
                                          self.connectionDistCheckBox)

        self.connectionColorTable = slicer.qMRMLColorTableComboBox()
        self.connectionColorTable.nodeTypes = ["vtkMRMLColorTableNode"]
        self.connectionColorTable.addEnabled = True
        self.connectionColorTable.removeEnabled = True
        self.connectionColorTable.noneEnabled = True
        self.connectionColorTable.showHidden = True
        self.connectionColorTable.setMRMLScene(slicer.mrmlScene)
        self.lineconnectFormLayout.addRow("Input Color Map: ",
                                          self.connectionColorTable)

        #
        # Threshold node connection strength
        #
        # default values
        self.logic = visuThreeDLogic()
        self.min_strength = 0.0
        self.max_strength = 1.0
        self.connectionThresholdSliderWidget = ctk.ctkRangeWidget()
        self.connectionThresholdSliderWidget.singleStep = 0.01
        self.connectionThresholdSliderWidget.setValues(self.min_strength,
                                                       self.max_strength)
        self.connectionThresholdSliderWidget.setMaximumValue(self.max_strength)
        self.connectionThresholdSliderWidget.setMinimumValue(self.min_strength)
        self.connectionThresholdSliderWidget.setRange(self.minVal,
                                                      self.max_strength)
        self.connectionThresholdSliderWidget.setMouseTracking(True)
        self.connectionThresholdSliderWidget.setEnabled(True)
        self.connectionThresholdSliderWidget.setToolTip(
            "Set threshold node value for computing the node value.")
        self.lineconnectFormLayout.addRow("Plot Strength Range:",
                                          self.connectionThresholdSliderWidget)

        #
        # Connection min strength spinBox
        #
        # default value for min strength (l: lowest , h: highest)
        self.minStrength_l = 0.0
        self.minStrength_h = 50.0
        self.minConnectionSpinBox = qt.QDoubleSpinBox()
        self.minConnectionSpinBox.singleStep = 0.01
        self.minConnectionSpinBox.setRange(self.minStrength_l,
                                           self.minStrength_h)
        self.minConnectionSpinBox.setToolTip(
            "Set minimum connection strength.")
        self.lineconnectFormLayout.addRow("Min Strength:",
                                          self.minConnectionSpinBox)

        #
        # Node size max spinBox
        #
        # default value for max size (l: lowest , h: highest)
        self.maxStrength_l = 0.0
        self.maxStrength_h = 100.0
        self.maxConnectionSpinBox = qt.QDoubleSpinBox()
        self.maxConnectionSpinBox.singleStep = 0.01
        self.maxConnectionSpinBox.setRange(self.maxStrength_l,
                                           self.maxStrength_h)
        self.maxConnectionSpinBox.setToolTip(
            "Set maximum connection strength.")
        self.lineconnectFormLayout.addRow("Max Strenght:",
                                          self.maxConnectionSpinBox)

        ###################################
        # Advanced Connections scale factors Area
        ###################################
        self.scaleCollapsibleButton = ctk.ctkCollapsibleButton()
        self.scaleCollapsibleButton.text = "Advanced Connection Scale Factors"
        self.layout.addWidget(self.scaleCollapsibleButton)
        # Layout within the collapsible button
        self.scaleconnectFormLayout = qt.QFormLayout(
            self.scaleCollapsibleButton)

        #Double SpinBox for default scale factor "f" :
        #computation of value in matrix by the number of connexions * f factor
        self.fscaleDoubleSpinBox = ctk.ctkDoubleSpinBox()
        self.fscaleDoubleSpinBox.setValue(0.000033)
        self.fscaleDoubleSpinBox.setDecimals(6)
        self.fscaleDoubleSpinBox.enabled = True
        self.scaleconnectFormLayout.addWidget(self.fscaleDoubleSpinBox)
        self.scaleconnectFormLayout.addRow("f Scale:",
                                           self.fscaleDoubleSpinBox)

        #Double SpinBox for log scale factor "C" :
        self.logScaleDoubleSpinBox = ctk.ctkDoubleSpinBox()
        self.logScaleDoubleSpinBox.setValue(10)
        self.logScaleDoubleSpinBox.setDecimals(0.)
        self.logScaleDoubleSpinBox.enabled = False
        self.scaleconnectFormLayout.addWidget(self.logScaleDoubleSpinBox)
        self.scaleconnectFormLayout.addRow("C Log Scale:",
                                           self.logScaleDoubleSpinBox)

        ###################################
        # Connections
        ###################################
        self.coord = []
        self.index = []
        self.position = []
        self.visu = []
        self.fileImportButton.connect('clicked(bool)',
                                      self.on_node_graph_json_load)
        self.inputSelector.connect("nodeActivated(vtkMRMLNode*)",
                                   self.on_select)
        self.regionButtons.connect('checkedIndexesChanged()',
                                   self.on_regions_checked)
        self.calculateAllFilteredregionsButton.connect(
            'clicked(bool)', self.on_select_all_filtered_regionButtons)
        self.calculateAllregionsButton.connect(
            'clicked(bool)', self.on_select_all_regionButtons)
        self.calculateNoregionsButton.connect(
            'clicked(bool)', self.on_deselect_all_regionButtons)
        self.calculateNoFilteredregionsButton.connect(
            'clicked(bool)', self.on_deselect_all_filtered_regionButtons)
        self.regionSearchBox.connect("textChanged(QString)", self.on_search)
        self.ColorTable.connect("currentNodeChanged(vtkMRMLNode*)",
                                self.on_node_color_clicked)
        self.nodeThresholdSliderWidget.connect("valuesChanged(double, double)",
                                               self.sliderbar_changed)
        self.nodeMinSizeSpinBox.connect("valueChanged(double)",
                                        self.min_nodesize_changed)
        self.nodeMaxSizeSpinBox.connect("valueChanged(double)",
                                        self.max_nodesize_changed)
        self.tableStartSpinBox.connect("valueChanged(double)",
                                       self.table_start_changed)
        self.matrixConnectSelector.connect("nodeActivated(vtkMRMLNode*)",
                                           self.on_select_matrix)
        self.connectionThresholdSliderWidget.connect(
            "valuesChanged(double, double)", self.sliderbar2_changed)
        self.maxConnectionSpinBox.connect("valueChanged(double)",
                                          self.max_connection_changed)
        self.connectionColorTable.connect("currentNodeChanged(vtkMRMLNode*)",
                                          self.on_connect_color_clicked)
        self.fscaleDoubleSpinBox.connect("valueChanged(double)",
                                         self.on_fscale_changed)
        self.logScaleDoubleSpinBox.connect("valueChanged(double)",
                                           self.on_logscale_changed)

        # Add vertical spacer
        self.layout.addStretch(1)
        self.header = None
        self.connection_d = None
        self.value = 'None'
        self.on_node_graph_json_load()