def __init__(self): ''' Constructor ''' qt.QWidget.__init__(self) self.propertiesMenuWidget=qt.QFrame() self.propertiesMenuWidget.setLayout(qt.QVBoxLayout()) #self.checkBoxVisible2D = qt.QCheckBox() #self.checkBoxVisible2D.setTristate(False) self.checkBoxVisible3D = qt.QCheckBox() self.checkBoxVisible3D.setTristate(False) #self.propertiesMenuWidget.setCellWidget(0,0,qt.QLabel("Visible2D")) #self.propertiesMenuWidget.setCellWidget(0,1,self.checkBoxVisible2D) self.visible3DFrame=qt.QFrame() self.visible3DFrame.setLayout(qt.QHBoxLayout()) self.visible3DFrame.layout().addWidget(qt.QLabel("Visible in 3D")) self.visible3DFrame.layout().addWidget(self.checkBoxVisible3D) self.thresholdFrame=qt.QFrame() self.thresholdFrame.setLayout(qt.QHBoxLayout()) self.thresholdLabel = qt.QLabel("Opacity Range:") self.thresholdLabel.setToolTip("Set the opacity range.") self.thresholdFrame.layout().addWidget(self.thresholdLabel) self.threshold = ctk.ctkRangeWidget() self.threshold.spinBoxAlignment = 0xff # put enties on top self.threshold.minimum = 0. self.threshold.maximum = 255. self.threshold.singleStep = 1. # set min/max based on current range self.thresholdFrame.layout().addWidget(self.threshold) self.colorFrame=qt.QFrame() self.colorFrame.setLayout(qt.QHBoxLayout()) self.colorLabel = qt.QLabel("Color Range:") self.colorLabel.setToolTip("Set the color range.") self.colorFrame.layout().addWidget(self.colorLabel) self.colorRangeSlider = ctk.ctkRangeWidget() self.colorRangeSlider.spinBoxAlignment = 0xff # put enties on top self.colorRangeSlider.singleStep = 0.01 self.colorRangeSlider.minimum = 0. self.colorRangeSlider.maximum = 255. # set min/max based on current range self.colorFrame.layout().addWidget(self.colorRangeSlider) #success, lo, hi = self.getBackgroundScalarRange() #if success: # self.threshold.minimum, self.threshold.maximum = lo, hi # self.threshold.singleStep = (hi - lo) / 1000. #self.thresholdFrame.layout().addWidget(self.threshold) self.propertiesMenuWidget.layout().addWidget(self.visible3DFrame) self.propertiesMenuWidget.layout().addWidget(self.thresholdFrame ) self.propertiesMenuWidget.layout().addWidget(self.colorFrame )
def __init__(self): ''' Constructor ''' qt.QWidget.__init__(self) self.propertiesMenuWidget=qt.QFrame() self.propertiesMenuWidget.setLayout(qt.QVBoxLayout()) #self.checkBoxVisible2D = qt.QCheckBox() #self.checkBoxVisible2D.setTristate(False) self.checkBoxVisible3D = qt.QCheckBox() self.checkBoxVisible3D.setTristate(False) #self.propertiesMenuWidget.setCellWidget(0,0,qt.QLabel("Visible2D")) #self.propertiesMenuWidget.setCellWidget(0,1,self.checkBoxVisible2D) self.visible3DFrame=qt.QFrame() self.visible3DFrame.setLayout(qt.QHBoxLayout()) self.visible3DFrame.layout().addWidget(qt.QLabel("Visible in 3D")) self.visible3DFrame.layout().addWidget(self.checkBoxVisible3D) self.thresholdFrame=qt.QFrame() self.thresholdFrame.setLayout(qt.QHBoxLayout()) self.thresholdLabel = qt.QLabel("Opacity Range:") self.thresholdLabel.setToolTip("Set the opacity range.") self.thresholdFrame.layout().addWidget(self.thresholdLabel) self.threshold = ctk.ctkRangeWidget() self.threshold.spinBoxAlignment = 0xff # put enties on top self.threshold.minimum = 0. self.threshold.maximum = 255. self.threshold.singleStep = 1. # set min/max based on current range self.thresholdFrame.layout().addWidget(self.threshold) self.colorFrame=qt.QFrame() self.colorFrame.setLayout(qt.QHBoxLayout()) self.colorLabel = qt.QLabel("Color Range:") self.colorLabel.setToolTip("Set the color range.") self.colorFrame.layout().addWidget(self.colorLabel) self.colorRangeSlider = ctk.ctkRangeWidget() self.colorRangeSlider.spinBoxAlignment = 0xff # put enties on top self.colorRangeSlider.singleStep = 0.01 self.colorRangeSlider.minimum = 0. self.colorRangeSlider.maximum = 255. # set min/max based on current range self.colorFrame.layout().addWidget(self.colorRangeSlider) #success, lo, hi = self.getBackgroundScalarRange() #if success: # self.threshold.minimum, self.threshold.maximum = lo, hi # self.threshold.singleStep = (hi - lo) / 1000. #self.thresholdFrame.layout().addWidget(self.threshold) self.propertiesMenuWidget.layout().addWidget(self.visible3DFrame) self.propertiesMenuWidget.layout().addWidget(self.thresholdFrame )
def create(self): super(DoubleThresholdEffectOptions,self).create() self.thresholdLabel = qt.QLabel("DoubleThreshold Inner Range:", self.frame) self.thresholdLabel.setToolTip("Set the range of the background values that should will labeled.") self.threshold = ctk.ctkRangeWidget(self.frame) self.threshold.spinBoxAlignment = 0xff # put enties on top self.threshold.singleStep = 0.01 self.outerThresholdLabel = qt.QLabel("DoubleThreshold Outter Range:", self.frame) self.outerThresholdLabel.setToolTip("Set the range of the background values that must be connected to the inner range to be labeled.") self.outerThreshold = ctk.ctkRangeWidget(self.frame) self.outerThreshold.spinBoxAlignment = 0xff # put enties on top self.outerThreshold.singleStep = 0.01 # set min/max based on current range success, lo, hi = self.getBackgroundScalarRange() if success: self.threshold.minimum, self.threshold.maximum = lo, hi self.threshold.singleStep = (hi - lo) / 1000. self.outerThreshold.minimum, self.outerThreshold.maximum = lo, hi self.outerThreshold.singleStep = (hi - lo) / 1000. self.frame.layout().addWidget(self.thresholdLabel) self.widgets.append(self.thresholdLabel) self.frame.layout().addWidget(self.threshold) self.widgets.append(self.threshold) self.frame.layout().addWidget(self.outerThresholdLabel) self.widgets.append(self.outerThresholdLabel) self.frame.layout().addWidget(self.outerThreshold) self.widgets.append(self.outerThreshold) self.apply = qt.QPushButton("Apply", self.frame) self.apply.setToolTip("Apply current threshold settings to the label map.") self.frame.layout().addWidget(self.apply) self.widgets.append(self.apply) self.timer = qt.QTimer() self.previewState = 0 self.previewStep = 1 self.previewSteps = 5 self.timer.start(200) self.connections.append( (self.timer, 'timeout()', self.preview) ) self.connections.append( (self.threshold, 'valuesChanged(double,double)', self.onThresholdValuesChanged) ) self.connections.append( (self.outerThreshold, 'valuesChanged(double,double)', self.onThresholdValuesChanged) ) self.connections.append( (self.apply, 'clicked()', self.onApply) ) EditorLib.HelpButton(self.frame, "TODO: describe double threshold") # Add vertical spacer self.frame.layout().addStretch(1)
def create(self): super(LabelEffectOptions, self).create() self.paintOver = qt.QCheckBox("Paint Over", self.frame) self.paintOver.setToolTip("Allow effect to overwrite non-zero labels.") self.frame.layout().addWidget(self.paintOver) self.widgets.append(self.paintOver) self.thresholdPaint = qt.QCheckBox("Threshold Paint", self.frame) self.thresholdPaint.setToolTip( "Enable/Disable threshold mode for labeling.") self.frame.layout().addWidget(self.thresholdPaint) self.widgets.append(self.thresholdPaint) self.thresholdLabel = qt.QLabel("Threshold", self.frame) self.thresholdLabel.setToolTip( "In threshold mode, the label will only be set if the background value is within this range." ) self.frame.layout().addWidget(self.thresholdLabel) self.widgets.append(self.thresholdLabel) self.threshold = ctk.ctkRangeWidget(self.frame) self.threshold.spinBoxAlignment = 0xff # put enties on top self.threshold.singleStep = 0.01 self.setRangeWidgetToBackgroundRange(self.threshold) self.frame.layout().addWidget(self.threshold) self.widgets.append(self.threshold) self.connections.append( (self.paintOver, "clicked()", self.updateMRMLFromGUI)) self.connections.append( (self.thresholdPaint, "clicked()", self.updateMRMLFromGUI)) self.connections.append( (self.threshold, "valuesChanged(double,double)", self.onThresholdValuesChange))
def create(self): super(LabelEffectOptions,self).create() self.paintOver = qt.QCheckBox("Paint Over", self.frame) self.paintOver.setToolTip("Allow effect to overwrite non-zero labels.") self.frame.layout().addWidget(self.paintOver) self.widgets.append(self.paintOver) self.thresholdPaint = qt.QCheckBox("Threshold Paint", self.frame) self.thresholdPaint.setToolTip("Enable/Disable threshold mode for labeling.") self.frame.layout().addWidget(self.thresholdPaint) self.widgets.append(self.thresholdPaint) self.thresholdLabel = qt.QLabel("Threshold", self.frame) self.thresholdLabel.setToolTip("In threshold mode, the label will only be set if the background value is within this range.") self.frame.layout().addWidget(self.thresholdLabel) self.widgets.append(self.thresholdLabel) self.threshold = ctk.ctkRangeWidget(self.frame) self.threshold.spinBoxAlignment = 0xff # put enties on top self.threshold.singleStep = 0.01 self.setRangeWidgetToBackgroundRange(self.threshold) self.frame.layout().addWidget(self.threshold) self.widgets.append(self.threshold) if not self.usesPaintOver: self.paintOver.hide() if not self.usesThreshold: self.thresholdPaint.hide() self.thresholdLabel.hide() self.threshold.hide() self.connections.append( (self.paintOver, "clicked()", self.updateMRMLFromGUI ) ) self.connections.append( (self.thresholdPaint, "clicked()", self.updateMRMLFromGUI ) ) self.connections.append( (self.threshold, "valuesChanged(double,double)", self.onThresholdValuesChange ) )
def makeThresholdsWidgets(self): self.thresholdsTab = qt.QWidget() self.parametersTabWidget.addTab(self.thresholdsTab, 'Thresholds') self.thresholdsLayout = qt.QFormLayout(self.thresholdsTab) self.referenceThresholdSlider = ctk.ctkRangeWidget() self.referenceThresholdSlider.decimals = 0 self.referenceThresholdSlider.valuesChanged.connect( self.onReferenceThresholdSlider) self.thresholdsLayout.addRow('Reference: ', self.referenceThresholdSlider) self.floatingThresholdSlider = ctk.ctkRangeWidget() self.floatingThresholdSlider.decimals = 0 self.floatingThresholdSlider.valuesChanged.connect( self.onFloatingThresholdSlider) self.thresholdsLayout.addRow('Floating: ', self.floatingThresholdSlider)
def create(self): super(ThresholdEffectOptions, self).create() self.thresholdLabel = qt.QLabel("Threshold Range:", self.frame) self.thresholdLabel.setToolTip( "Set the range of the background values that should be labeled.") self.frame.layout().addWidget(self.thresholdLabel) self.widgets.append(self.thresholdLabel) self.threshold = ctk.ctkRangeWidget(self.frame) self.threshold.spinBoxAlignment = 0xff # put enties on top self.threshold.singleStep = 0.01 # set min/max based on current range success, lo, hi = self.getBackgroundScalarRange() if success: self.threshold.minimum, self.threshold.maximum = lo, hi self.threshold.singleStep = (hi - lo) / 1000. self.frame.layout().addWidget(self.threshold) self.widgets.append(self.threshold) self.useForPainting = qt.QPushButton("Use For Paint", self.frame) self.useForPainting.setToolTip( "Transfer the current threshold settings to be used for labeling operations such as Paint and Draw." ) self.frame.layout().addWidget(self.useForPainting) self.widgets.append(self.useForPainting) self.apply = qt.QPushButton("Apply", self.frame) self.apply.objectName = self.__class__.__name__ + 'Apply' self.apply.setToolTip( "Apply current threshold settings to the label map.") self.frame.layout().addWidget(self.apply) self.widgets.append(self.apply) self.timer = qt.QTimer() self.previewState = 0 self.previewStep = 1 self.previewSteps = 5 self.timer.start(200) self.connections.append((self.timer, 'timeout()', self.preview)) self.connections.append( (self.useForPainting, 'clicked()', self.onUseForPainting)) self.connections.append( (self.threshold, 'valuesChanged(double,double)', self.onThresholdValuesChanged)) self.connections.append((self.apply, 'clicked()', self.onApply)) EditorLib.HelpButton( self.frame, "Set labels based on threshold range. Note: this replaces the current label map values." ) # Add vertical spacer self.frame.layout().addStretch(1)
def create(self): super(ThresholdEffectOptions, self).create() self.thresholdLabel = qt.QLabel("Threshold Range:", self.frame) self.thresholdLabel.setToolTip("Set the range of the background values that should be labeled.") self.frame.layout().addWidget(self.thresholdLabel) self.widgets.append(self.thresholdLabel) self.threshold = ctk.ctkRangeWidget(self.frame) self.threshold.spinBoxAlignment = 0xFF # put enties on top self.threshold.singleStep = 0.01 # set min/max based on current range success, lo, hi = self.getBackgroundScalarRange() if success: self.threshold.minimum, self.threshold.maximum = lo, hi self.threshold.singleStep = (hi - lo) / 1000.0 self.frame.layout().addWidget(self.threshold) self.widgets.append(self.threshold) self.useForPainting = qt.QPushButton("Use For Paint", self.frame) self.useForPainting.setToolTip( "Transfer the current threshold settings to be used for labeling operations such as Paint and Draw." ) self.frame.layout().addWidget(self.useForPainting) self.widgets.append(self.useForPainting) self.apply = qt.QPushButton("Apply", self.frame) self.apply.setToolTip("Apply current threshold settings to the label map.") self.frame.layout().addWidget(self.apply) self.widgets.append(self.apply) self.timer = qt.QTimer() self.previewState = 0 self.previewStep = 1 self.previewSteps = 5 self.timer.start(200) self.connections.append((self.timer, "timeout()", self.preview)) self.connections.append((self.useForPainting, "clicked()", self.onUseForPainting)) self.connections.append((self.threshold, "valuesChanged(double,double)", self.onThresholdValuesChanged)) self.connections.append((self.apply, "clicked()", self.onApply)) EditorLib.HelpButton( self.frame, "Set labels based on threshold range. Note: this replaces the current label map values." ) # Add vertical spacer self.frame.layout().addStretch(1)
def setup(self): # Input/Output collapsible button collapsibleButton = ctk.ctkCollapsibleButton() collapsibleButton.text = "IO" self.layout.addWidget(collapsibleButton) # Layout within the dummy collapsible button formLayout = qt.QFormLayout(collapsibleButton) # The input volume selector self.inputVolumeFrame = qt.QFrame(collapsibleButton) self.inputVolumeFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.inputVolumeFrame) self.inputVolumeSelector = qt.QLabel("Input Image Volume: ", self.inputVolumeFrame) self.inputVolumeFrame.layout().addWidget(self.inputVolumeSelector) self.inputVolumeSelector = slicer.qMRMLNodeComboBox(self.inputVolumeFrame) self.inputVolumeSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" ) self.inputVolumeSelector.addEnabled = False self.inputVolumeSelector.removeEnabled = True self.inputVolumeSelector.renameEnabled = True self.inputVolumeSelector.setMRMLScene( slicer.mrmlScene ) self.inputVolumeFrame.layout().addWidget(self.inputVolumeSelector) # The endo segmentation selector self.endoLabelFrame = qt.QFrame(collapsibleButton) self.endoLabelFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.endoLabelFrame) self.endoLabelSelector = qt.QLabel("Endo Label Map: ", self.endoLabelFrame) self.endoLabelFrame.layout().addWidget(self.endoLabelSelector) self.endoLabelSelector = slicer.qMRMLNodeComboBox(self.endoLabelFrame) self.endoLabelSelector.nodeTypes = ( ("vtkMRMLLabelMapVolumeNode"), "" ) self.endoLabelSelector.addEnabled = False self.endoLabelSelector.removeEnabled = True self.endoLabelSelector.renameEnabled = True self.endoLabelSelector.setMRMLScene( slicer.mrmlScene ) self.endoLabelFrame.layout().addWidget(self.endoLabelSelector) # The wall segmentation selector self.wallLabelFrame = qt.QFrame(collapsibleButton) self.wallLabelFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.wallLabelFrame) self.wallLabelSelector = qt.QLabel("Wall Label Map: ", self.wallLabelFrame) self.wallLabelFrame.layout().addWidget(self.wallLabelSelector) self.wallLabelSelector = slicer.qMRMLNodeComboBox(self.wallLabelFrame) self.wallLabelSelector.nodeTypes = ( ("vtkMRMLLabelMapVolumeNode"), "" ) self.wallLabelSelector.addEnabled = False self.wallLabelSelector.removeEnabled = True self.wallLabelSelector.renameEnabled = True self.wallLabelSelector.setMRMLScene( slicer.mrmlScene ) self.wallLabelFrame.layout().addWidget(self.wallLabelSelector) # Add vertical spacer self.layout.addStretch(1) # Create model button createModelButton = qt.QPushButton("Create Endo and Wall Models") createModelButton.toolTip = "Create models from the LA endo and wall segmentations." formLayout.addWidget(createModelButton) createModelButton.connect('clicked(bool)', self.onCreateModelButtonClicked) # The model selector self.inputModelFrame = qt.QFrame(collapsibleButton) self.inputModelFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.inputModelFrame) self.inputModelSelector = qt.QLabel("Input Wall Model: ", self.inputModelFrame) self.inputModelFrame.layout().addWidget(self.inputModelSelector) self.inputModelSelector = slicer.qMRMLNodeComboBox(self.inputModelFrame) self.inputModelSelector.nodeTypes = ( ("vtkMRMLModelNode"), "" ) self.inputModelSelector.addEnabled = False self.inputModelSelector.removeEnabled = False self.inputModelSelector.renameEnabled = True self.inputModelSelector.setMRMLScene( slicer.mrmlScene ) self.inputModelFrame.layout().addWidget(self.inputModelSelector) # Probe volume button probeVolumeButton = qt.QPushButton("Probe Input Image With Wall Model") probeVolumeButton.toolTip = "Probe the input image volume with the wall model to map the image volume intensities to the model. The wall model will be deleted and replaced by the new output wall model." formLayout.addWidget(probeVolumeButton) probeVolumeButton.connect('clicked(bool)', self.onProbeVolumeButtonClicked) # The threshold slider self.thresholdFrame = qt.QFrame(collapsibleButton) self.thresholdFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.thresholdFrame) self.thresholdLabel = qt.QLabel("Threshold Range:", self.thresholdFrame) self.thresholdLabel.setToolTip("Set the lower and upper intensity thresholds for the model.") self.thresholdFrame.layout().addWidget(self.thresholdLabel) self.threshold = ctk.ctkRangeWidget(self.thresholdFrame) self.threshold.spinBoxAlignment = 0xff # Put entries on top self.threshold.singleStep = 0.01 # Set a temporary minimum and maximum threshold value self.threshold.minimum = 0 self.threshold.maximum = 1000 self.threshold.singleStep = 1 self.thresholdFrame.layout().addWidget(self.threshold) # Connect threshold slider to method self.threshold.connect( 'valuesChanged(double,double)', self.onThresholdValuesChanged ) # Set local var as instance attribute self.createModelButton = createModelButton self.probeVolumeButton = probeVolumeButton
def setup(self): QCLib.genericPanel.setup(self) self.label = ctk.ctkCollapsibleButton(self.frame) self.label.setText("ROI") self.framelayout.addWidget(self.label) parametersFormLayout=qt.QFormLayout(self.label) self.overrideROI = ctk.ctkCheckBox() self.overrideROI.setText('Override ROI if exists') self.overrideROI.enabled=False self.overrideROI.checked=True parametersFormLayout.addRow(self.overrideROI) self.sliceslider = slicer.qMRMLSliceControllerWidget() self.sliceslider.enabled=False parametersFormLayout.addRow("Rods Slice", self.sliceslider) self.autothr = ctk.ctkCheckBox() self.autothr.setText('Automatic Threashold Range') self.autothr.enabled=False self.autothr.checked=True parametersFormLayout.addRow(self.autothr) self.thr = ctk.ctkRangeWidget() self.thr.decimals = 0 self.thr.minimum = 0 self.thr.maximum = 0 self.thr.enabled = False parametersFormLayout.addRow("Threashold Range",self.thr) self.dgp = ctk.ctkCollapsibleButton(self.frame) self.dgp.setText("GDP (Double Click a row to chart measured distances)") self.dgp.enabled=False self.framelayout.addWidget(self.dgp) self.dgp.setLayout(qt.QVBoxLayout()) self.chartButton = qt.QPushButton("Chart") self.chartButton.toolTip = "Chart distances frequency" self.chartButton.enabled=False self.dgp.layout().addWidget(self.chartButton) self.resultTable=qt.QTableWidget(2,5) #self.resultTable=qt.QTableView() labels=['','Minimum(mm)','GDP(%) of Minumum','Maximum(mm)','GDP(%) of Maximum'] self.resultTable.setHorizontalHeaderLabels(labels) self.resultTable.verticalHeader().setVisible(False) self.items=[] self.items.append(qt.QTableWidgetItem('Side')) self.items.append(qt.QTableWidgetItem('Diagonal')) self.resultTable.setItem(0,0,self.items[0]) self.resultTable.setItem(1,0,self.items[1]) for n in range(8): self.items.append(qt.QTableWidgetItem()) self.resultTable.setItem(n/4,(n%4)+1,self.items[n+2]) for n in range(len(self.items)): self.items[n].setFlags(33) self.resultTable.resizeColumnsToContents() self.dgp.layout().addWidget(self.resultTable) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Estimate GDP." self.applyButton.enabled = False self.framelayout.addWidget(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.chartButton.connect('clicked(bool)', self.onChart) self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelectMaster) self.autothr.connect("toggled(bool)",self.autothreshold) self.resultTable.connect('cellDoubleClicked(int,int)',self.ChartThem) # Add vertical spacer self.layout.addStretch(1)
def setup(self): self.conoProbeConnectorLogic = ConoProbeConnectorLogic() self.firstInitColouring = True ScriptedLoadableModuleWidget.setup(self) # Icons stuff self.conoProbeConnectorModuleDirectoryPath = slicer.modules.conoprobeconnector.path.replace("ConoProbeConnector.py","") self.playIcon = qt.QIcon(self.conoProbeConnectorModuleDirectoryPath + '/Resources/Icons/playIcon.png') self.stopIcon = qt.QIcon(self.conoProbeConnectorModuleDirectoryPath + '/Resources/Icons/stopIcon.png') self.recordIcon = qt.QIcon(self.conoProbeConnectorModuleDirectoryPath + '/Resources/Icons/recordIcon.png') self.restartIcon = qt.QIcon(self.conoProbeConnectorModuleDirectoryPath + '/Resources/Icons/restartIcon.png') self.saveIcon = qt.QIcon(self.conoProbeConnectorModuleDirectoryPath + '/Resources/Icons/saveIcon.png') self.errorStyleSheet = "QLabel { color : #FF0000; \ font: bold 14px}" self.defaultStyleSheet = "QLabel { color : #000000; \ font: bold 14px}" ######################################################## Recorder recorderCollapsibleButton = ctk.ctkCollapsibleButton() recorderCollapsibleButton.text = "ConoProbe Connector" recorderCollapsibleButton.collapsed = False self.layout.addWidget(recorderCollapsibleButton) recorderFormLayout = qt.QFormLayout(recorderCollapsibleButton) # Output self.recorderOutputGroupBox = ctk.ctkCollapsibleGroupBox() self.recorderOutputGroupBox.setTitle("Output") recorderOutputFormLayout = qt.QFormLayout(self.recorderOutputGroupBox) recorderFormLayout.addRow(self.recorderOutputGroupBox) self.lensMinLabel = qt.QLabel('-') self.lensMinLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel10 = qt.QLabel('Lens Min. Dist. (mm): ') self.QFormLayoutLeftLabel10.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel10, self.lensMinLabel) self.distanceLabel = qt.QLabel('-') self.distanceLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel1 = qt.QLabel('Distance (mm): ') self.QFormLayoutLeftLabel1.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel1, self.distanceLabel) self.lensMaxLabel = qt.QLabel('-') self.lensMaxLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel11 = qt.QLabel('Lens Max. Dist. (mm): ') self.QFormLayoutLeftLabel11.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel11, self.lensMaxLabel) dummyLabel1 = qt.QLabel('') recorderOutputFormLayout.addRow('', dummyLabel1) self.powerLabel = qt.QLabel('-') self.powerLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel8 = qt.QLabel('Laser Power (arb. unit): ') self.QFormLayoutLeftLabel8.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel8, self.powerLabel) self.frequencyLabel = qt.QLabel('-') self.frequencyLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel9 = qt.QLabel('Laser Frequency (Hz): ') self.QFormLayoutLeftLabel9.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel9, self.frequencyLabel) self.nbrOfPointsRecordedLabel = qt.QLabel('0') self.nbrOfPointsRecordedLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel2 = qt.QLabel('Nbr. of Points Recorded: ') self.QFormLayoutLeftLabel2.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel2, self.nbrOfPointsRecordedLabel) self.positionLabel = qt.QLabel('-') self.positionLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel3 = qt.QLabel('Position ([r, a, s]): ') self.QFormLayoutLeftLabel3.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel3, self.positionLabel) self.timeLabel = qt.QLabel('-') self.timeLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel4 = qt.QLabel('Recording Time (s): ') self.QFormLayoutLeftLabel4.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel4, self.timeLabel) self.snrLabel = qt.QLabel('-') self.snrLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel5 = qt.QLabel('SNR (%): ') self.QFormLayoutLeftLabel5.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel5, self.snrLabel) self.totalLabel = qt.QLabel('-') self.totalLabel.setStyleSheet(self.defaultStyleSheet) self.QFormLayoutLeftLabel6 = qt.QLabel('Total: ') self.QFormLayoutLeftLabel6.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel6, self.totalLabel) dummyLabel2 = qt.QLabel('') recorderOutputFormLayout.addRow('', dummyLabel2) self.infoLabel = qt.QLabel('Make sure Plus is running') self.infoLabel.setWordWrap(True) self.infoLabel.setStyleSheet(self.errorStyleSheet) self.QFormLayoutLeftLabel7 = qt.QLabel('INFO: ') self.QFormLayoutLeftLabel7.setStyleSheet(self.defaultStyleSheet) recorderOutputFormLayout.addRow(self.QFormLayoutLeftLabel7, self.infoLabel) # Live Filtering self.recorderFilteringGroupBox = ctk.ctkCollapsibleGroupBox() self.recorderFilteringGroupBox.setTitle("Live Filtering") recorderFilteringFormLayout = qt.QFormLayout(self.recorderFilteringGroupBox) recorderFormLayout.addRow(self.recorderFilteringGroupBox) self.snrFilteringSlider = ctk.ctkSliderWidget() self.snrFilteringSlider.setDecimals(0) self.snrFilteringSlider.singleStep = 1 self.snrFilteringSlider.minimum = 0 self.snrFilteringSlider.maximum = 100 self.snrFilteringSlider.value = 40 recorderFilteringFormLayout.addRow('SNR (%): ', self.snrFilteringSlider) self.distanceFilteringSlider = ctk.ctkRangeWidget() self.distanceFilteringSlider.minimum = 0 self.distanceFilteringSlider.maximum = 500 self.distanceFilteringSlider.setValues(0, 500) recorderFilteringFormLayout.addRow('Distance (mm): ', self.distanceFilteringSlider) # Intuitive Colouring self.colouringGroupBox = ctk.ctkCollapsibleGroupBox() self.colouringGroupBox.setTitle("Intuitive Colouring") colouringFormLayout = qt.QFormLayout(self.colouringGroupBox) recorderFormLayout.addRow(self.colouringGroupBox) hBoxLayoutColouring = qt.QHBoxLayout() colouringFormLayout.addRow(hBoxLayoutColouring) self.rasLabel = qt.QLabel('Direction: ') hBoxLayoutColouring.addWidget(self.rasLabel) self.rasComboBox = qt.QComboBox() self.rasComboBox.addItem('R') self.rasComboBox.addItem('A') self.rasComboBox.addItem('S') hBoxLayoutColouring.addWidget(self.rasComboBox) self.minLabel = qt.QLabel(' Minimum: ') hBoxLayoutColouring.addWidget(self.minLabel) self.minSpinBox = qt.QDoubleSpinBox () self.minSpinBox.setMinimum(-500) self.minSpinBox.setMaximum(500) self.minSpinBox.setSingleStep(0.1) self.minSpinBox.setValue(0.0) hBoxLayoutColouring.addWidget(self.minSpinBox) self.maxLabel = qt.QLabel(' Maximum: ') hBoxLayoutColouring.addWidget(self.maxLabel) self.maxSpinBox = qt.QDoubleSpinBox () self.maxSpinBox.setMinimum(-500) self.maxSpinBox.setMaximum(500) self.maxSpinBox.setSingleStep(0.1) self.maxSpinBox.setValue(0.0) hBoxLayoutColouring.addWidget(self.maxSpinBox) hBoxLayoutColouring.addStretch() # Controls self.controlsGroupBox = ctk.ctkCollapsibleGroupBox() self.controlsGroupBox.setTitle("Controls") controlsFormLayout = qt.QFormLayout(self.controlsGroupBox) recorderFormLayout.addRow(self.controlsGroupBox) hBoxLayoutControls = qt.QHBoxLayout() controlsFormLayout.addRow(hBoxLayoutControls) self.initButton = qt.QPushButton(" Init") self.initButton.setIcon(self.playIcon) self.initButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.initButton.enabled = True hBoxLayoutControls.addWidget(self.initButton) self.recordButton = qt.QPushButton(" Record") self.recordButton.setIcon(self.recordIcon) self.recordButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.recordButton.enabled = False self.recordButton.checkable = True hBoxLayoutControls.addWidget(self.recordButton) self.probeDialogButton = qt.QPushButton("ProbeDialog") self.probeDialogButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.probeDialogButton.enabled = False hBoxLayoutControls.addWidget(self.probeDialogButton) self.saveButton = qt.QPushButton(" Save") self.saveButton.setIcon(self.saveIcon) self.saveButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.saveButton.enabled = False hBoxLayoutControls.addWidget(self.saveButton) self.resetButton = qt.QPushButton(" Reset") self.resetButton.setIcon(self.restartIcon) self.resetButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.resetButton.enabled = False hBoxLayoutControls.addWidget(self.resetButton) hBoxCheckBoxes = qt.QHBoxLayout() controlsFormLayout.addRow(hBoxCheckBoxes) self.viewpointCheckBox = qt.QCheckBox('Enable Viewpoint') self.viewpointCheckBox.checked = True self.viewpointCheckBox.enabled = False hBoxCheckBoxes.addWidget(self.viewpointCheckBox) self.singlePointCheckBox = qt.QCheckBox('Single Measurements') self.singlePointCheckBox.checked = False self.singlePointCheckBox.enabled = False hBoxCheckBoxes.addWidget(self.singlePointCheckBox) self.plusRemoteCheckBox = qt.QCheckBox('Record PLUS Data Stream') self.plusRemoteCheckBox.checked = False self.plusRemoteCheckBox.enabled = False hBoxCheckBoxes.addWidget(self.plusRemoteCheckBox) # Post-Processing self.postProcessingGroupBox = ctk.ctkCollapsibleGroupBox() self.postProcessingGroupBox.setTitle("Post-Processing") postProcessingFormLayout = qt.QFormLayout(self.postProcessingGroupBox) recorderFormLayout.addRow(self.postProcessingGroupBox) self.snrPostProcessingSlider = ctk.ctkSliderWidget() self.snrPostProcessingSlider.setDecimals(0) self.snrPostProcessingSlider.singleStep = 1 self.snrPostProcessingSlider.minimum = 0 self.snrPostProcessingSlider.maximum = 100 self.snrPostProcessingSlider.value = 0 postProcessingFormLayout.addRow('SNR (%): ', self.snrPostProcessingSlider) self.distancePostProcessingSlider = ctk.ctkRangeWidget() self.distancePostProcessingSlider.minimum = 0 self.distancePostProcessingSlider.maximum = 500 self.distancePostProcessingSlider.setValues(0, 500) postProcessingFormLayout.addRow('Distance (mm): ', self.distancePostProcessingSlider) hBoxLayoutPostProcessing = qt.QHBoxLayout() postProcessingFormLayout.addRow(hBoxLayoutPostProcessing) self.undoButton = qt.QPushButton("Undo") self.undoButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.undoButton.enabled = False hBoxLayoutPostProcessing.addWidget(self.undoButton) self.applyButton = qt.QPushButton("Apply") self.applyButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.applyButton.enabled = False hBoxLayoutPostProcessing.addWidget(self.applyButton) ######################################################## Connections self.snrFilteringSlider.connect('valueChanged(double)', self.onSnrFilteringValueChanged) self.distanceFilteringSlider.connect('maximumValueChanged(double)', self.onDistanceFilteringMaximumValueChanged) self.distanceFilteringSlider.connect('minimumValueChanged(double)', self.onDistanceFilteringMinimumValueChanged) self.initButton.connect('clicked(bool)', self.onInitClicked) self.recordButton.connect('clicked(bool)', self.onRecordClicked) self.resetButton.connect('clicked(bool)', self.onResetClicked) self.probeDialogButton.connect('clicked(bool)', self.onProbeDialogClicked) self.saveButton.connect('clicked(bool)', self.onSaveClicked) self.undoButton.connect('clicked(bool)', self.onUndoClicked) self.applyButton.connect('clicked(bool)', self.onApplyClicked) self.viewpointCheckBox.connect('stateChanged(int)', self.onViewpointChecked) self.plusRemoteCheckBox.connect('stateChanged(int)', self.onPlusRemoteChecked) # Add vertical spacer self.layout.addStretch(1) # Create Plus connector and activate it self.conoProbeConnectorLogic.setupPlus()
def setup(self): # Instantiate and connect widgets ... self.RingOff = None self.RingOn = None # Tags to manage event observers self.tagSourceNode = None self.tagDestinationNode = None ##################### ## For debugging ## ## Reload and Test area reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) ## reload button ## (use this during development, but remove it when delivering ## your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "CurveMaker Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) ## ##################### # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Source points (vtkMRMLMarkupsFiducialNode) # self.SourceSelector = slicer.qMRMLNodeComboBox() self.SourceSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "") self.SourceSelector.addEnabled = True self.SourceSelector.removeEnabled = False self.SourceSelector.noneEnabled = True self.SourceSelector.showHidden = False self.SourceSelector.renameEnabled = True self.SourceSelector.showChildNodeTypes = False self.SourceSelector.setMRMLScene(slicer.mrmlScene) self.SourceSelector.setToolTip( "Pick up a Markups node listing fiducials.") parametersFormLayout.addRow("Source points: ", self.SourceSelector) # # Target point (vtkMRMLMarkupsFiducialNode) # self.DestinationSelector = slicer.qMRMLNodeComboBox() self.DestinationSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.DestinationSelector.addEnabled = True self.DestinationSelector.removeEnabled = False self.DestinationSelector.noneEnabled = True self.DestinationSelector.showHidden = False self.DestinationSelector.renameEnabled = True self.DestinationSelector.selectNodeUponCreation = True self.DestinationSelector.showChildNodeTypes = False self.DestinationSelector.setMRMLScene(slicer.mrmlScene) self.DestinationSelector.setToolTip("Pick up or create a Model node.") parametersFormLayout.addRow("Curve model: ", self.DestinationSelector) # # Radius for the tube # self.RadiusSliderWidget = ctk.ctkSliderWidget() self.RadiusSliderWidget.singleStep = 1.0 self.RadiusSliderWidget.minimum = 1.0 self.RadiusSliderWidget.maximum = 50.0 self.RadiusSliderWidget.value = 5.0 self.RadiusSliderWidget.setToolTip("Set the raidus of the tube.") parametersFormLayout.addRow("Radius (mm): ", self.RadiusSliderWidget) # # Radio button to select interpolation method # self.InterpolationLayout = qt.QHBoxLayout() self.InterpolationNone = qt.QRadioButton("None") self.InterpolationCardinalSpline = qt.QRadioButton("Cardinal Spline") self.InterpolationHermiteSpline = qt.QRadioButton( "Hermite Spline (for Endoscopy)") self.InterpolationLayout.addWidget(self.InterpolationNone) self.InterpolationLayout.addWidget(self.InterpolationCardinalSpline) self.InterpolationLayout.addWidget(self.InterpolationHermiteSpline) self.InterpolationGroup = qt.QButtonGroup() self.InterpolationGroup.addButton(self.InterpolationNone) self.InterpolationGroup.addButton(self.InterpolationCardinalSpline) self.InterpolationGroup.addButton(self.InterpolationHermiteSpline) parametersFormLayout.addRow("Interpolation: ", self.InterpolationLayout) # # Interpolation Resolution # self.InterpResolutionSliderWidget = ctk.ctkSliderWidget() self.InterpResolutionSliderWidget.singleStep = 1.0 self.InterpResolutionSliderWidget.minimum = 3.0 self.InterpResolutionSliderWidget.maximum = 50.0 self.InterpResolutionSliderWidget.value = 25.0 self.InterpResolutionSliderWidget.setToolTip( "Number of interpolation points between control points. Default is 25." ) parametersFormLayout.addRow("Resolution: ", self.InterpResolutionSliderWidget) # # Radio button for ring mode # self.RingLayout = qt.QHBoxLayout() self.RingOff = qt.QRadioButton("Off") self.RingOn = qt.QRadioButton("On") self.RingLayout.addWidget(self.RingOff) self.RingLayout.addWidget(self.RingOn) self.RingGroup = qt.QButtonGroup() self.RingGroup.addButton(self.RingOff) self.RingGroup.addButton(self.RingOn) parametersFormLayout.addRow("Ring mode: ", self.RingLayout) # # Check box to start curve visualization # self.EnableAutoUpdateCheckBox = qt.QCheckBox() self.EnableAutoUpdateCheckBox.checked = 0 self.EnableAutoUpdateCheckBox.setToolTip( "If checked, the CurveMaker module keeps updating the model as the points are updated." ) parametersFormLayout.addRow("Auto update:", self.EnableAutoUpdateCheckBox) # # Button to generate a curve # self.GenerateButton = qt.QPushButton("Generate Curve") self.GenerateButton.toolTip = "Generate Curve" self.GenerateButton.enabled = True parametersFormLayout.addRow("", self.GenerateButton) # Connections self.InterpolationNone.connect('clicked(bool)', self.onSelectInterpolationNone) self.InterpolationCardinalSpline.connect( 'clicked(bool)', self.onSelectInterpolationCardinalSpline) self.InterpolationHermiteSpline.connect( 'clicked(bool)', self.onSelectInterpolationHermiteSpline) self.RingOff.connect('clicked(bool)', self.onRingOff) self.RingOn.connect('clicked(bool)', self.onRingOn) self.EnableAutoUpdateCheckBox.connect('toggled(bool)', self.onEnableAutoUpdate) self.SourceSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSourceSelected) self.DestinationSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onDestinationSelected) self.RadiusSliderWidget.connect("valueChanged(double)", self.onTubeUpdated) self.InterpResolutionSliderWidget.connect( "valueChanged(double)", self.onInterpResolutionUpdated) self.GenerateButton.connect('clicked(bool)', self.onGenerateCurve) # Set default ## default interpolation method self.InterpolationCardinalSpline.setChecked(True) self.onSelectInterpolationCardinalSpline(True) ## default ring mode self.RingOff.setChecked(True) self.onRingOff(True) # # Curve Length area # lengthCollapsibleButton = ctk.ctkCollapsibleButton() lengthCollapsibleButton.text = "Length" self.layout.addWidget(lengthCollapsibleButton) lengthFormLayout = qt.QFormLayout(lengthCollapsibleButton) lengthCollapsibleButton.collapsed = True #-- Curve length self.lengthLineEdit = qt.QLineEdit() self.lengthLineEdit.text = '--' self.lengthLineEdit.readOnly = True self.lengthLineEdit.frame = True self.lengthLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.lengthLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) lengthFormLayout.addRow("Curve Length (mm):", self.lengthLineEdit) # # Distance Area # distanceCollapsibleButton = ctk.ctkCollapsibleButton() distanceCollapsibleButton.text = "Distance" distanceCollapsibleButton.collapsed = True self.layout.addWidget(distanceCollapsibleButton) distanceFormLayout = qt.QFormLayout(distanceCollapsibleButton) #-- Point-to-curve distance # - Markups selector for input points distanceLayout = qt.QVBoxLayout() self.targetFiducialsSelector = slicer.qMRMLNodeComboBox() self.targetFiducialsSelector.nodeTypes = (( "vtkMRMLMarkupsFiducialNode"), "") self.targetFiducialsSelector.selectNodeUponCreation = True self.targetFiducialsSelector.addEnabled = True self.targetFiducialsSelector.removeEnabled = True self.targetFiducialsSelector.noneEnabled = True self.targetFiducialsSelector.showHidden = False self.targetFiducialsSelector.showChildNodeTypes = False self.targetFiducialsSelector.setMRMLScene(slicer.mrmlScene) self.targetFiducialsSelector.setToolTip("Select Markups for targets") distanceLayout.addWidget(self.targetFiducialsSelector) self.targetFiducialsNode = None self.tagDestinationDispNode = None self.targetFiducialsSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onTargetFiducialsSelected) self.fiducialsTable = qt.QTableWidget(1, 3) self.fiducialsTable.setSelectionBehavior( qt.QAbstractItemView.SelectRows) self.fiducialsTable.setSelectionMode( qt.QAbstractItemView.SingleSelection) self.fiducialsTableHeaders = ["Name", "Position (mm)", "Distance (mm)"] self.fiducialsTable.setHorizontalHeaderLabels( self.fiducialsTableHeaders) self.fiducialsTable.horizontalHeader().setStretchLastSection(True) distanceLayout.addWidget(self.fiducialsTable) self.extrapolateCheckBox = qt.QCheckBox() self.extrapolateCheckBox.checked = 0 self.extrapolateCheckBox.setToolTip( "Extrapolate the first and last segment to calculate the distance") self.extrapolateCheckBox.connect('toggled(bool)', self.updateTargetFiducialsTable) self.extrapolateCheckBox.text = 'Extrapolate curves to measure the distances' self.showErrorVectorCheckBox = qt.QCheckBox() self.showErrorVectorCheckBox.checked = 0 self.showErrorVectorCheckBox.setToolTip( "Show error vectors, which is defined by the target point and the closest point on the curve. The vector is perpendicular to the curve, unless the closest point is one end of the curve." ) self.showErrorVectorCheckBox.connect('toggled(bool)', self.updateTargetFiducialsTable) self.showErrorVectorCheckBox.text = 'Show error vectors' distanceLayout.addWidget(self.extrapolateCheckBox) distanceLayout.addWidget(self.showErrorVectorCheckBox) distanceFormLayout.addRow("Distance from:", distanceLayout) # # Curvature Area # curvatureCollapsibleButton = ctk.ctkCollapsibleButton() curvatureCollapsibleButton.text = "Curvature" curvatureCollapsibleButton.collapsed = True self.layout.addWidget(curvatureCollapsibleButton) curvatureFormLayout = qt.QFormLayout(curvatureCollapsibleButton) #-- Curvature self.curvatureLayout = qt.QHBoxLayout() self.curvatureOff = qt.QRadioButton("Off") self.curvatureOff.connect('clicked(bool)', self.onCurvatureOff) self.curvatureOn = qt.QRadioButton("On") self.curvatureOn.connect('clicked(bool)', self.onCurvatureOn) self.curvatureLayout.addWidget(self.curvatureOff) self.curvatureLayout.addWidget(self.curvatureOn) self.curvatureGroup = qt.QButtonGroup() self.curvatureGroup.addButton(self.curvatureOff) self.curvatureGroup.addButton(self.curvatureOn) curvatureFormLayout.addRow("Curvature mode:", self.curvatureLayout) autoCurvatureRangeFormLayout = qt.QFormLayout( curvatureCollapsibleButton) self.autoCurvatureRangeLayout = qt.QHBoxLayout() self.autoCurvatureRangeOff = qt.QRadioButton("Manual") self.autoCurvatureRangeOff.connect('clicked(bool)', self.onAutoCurvatureRangeOff) self.autoCurvatureRangeOn = qt.QRadioButton("Auto") self.autoCurvatureRangeOn.connect('clicked(bool)', self.onAutoCurvatureRangeOn) self.autoCurvatureRangeLayout.addWidget(self.autoCurvatureRangeOff) self.autoCurvatureRangeLayout.addWidget(self.autoCurvatureRangeOn) self.autoCurvatureRangeGroup = qt.QButtonGroup() self.autoCurvatureRangeGroup.addButton(self.autoCurvatureRangeOff) self.autoCurvatureRangeGroup.addButton(self.autoCurvatureRangeOn) curvatureFormLayout.addRow("Color range:", self.autoCurvatureRangeLayout) #-- Color range self.curvatureColorRangeWidget = ctk.ctkRangeWidget() self.curvatureColorRangeWidget.setToolTip("Set color range") self.curvatureColorRangeWidget.setDecimals(3) self.curvatureColorRangeWidget.singleStep = 0.001 self.curvatureColorRangeWidget.minimumValue = 0.0 self.curvatureColorRangeWidget.maximumValue = 0.5 self.curvatureColorRangeWidget.minimum = 0.0 self.curvatureColorRangeWidget.maximum = 1.0 curvatureFormLayout.addRow("Color range: ", self.curvatureColorRangeWidget) self.curvatureColorRangeWidget.connect( 'valuesChanged(double, double)', self.onUpdateCurvatureColorRange) #-- Curvature data self.meanCurvatureLineEdit = qt.QLineEdit() self.meanCurvatureLineEdit.text = '--' self.meanCurvatureLineEdit.readOnly = True self.meanCurvatureLineEdit.frame = True self.meanCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.meanCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.meanCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Mean (mm^-1):", self.meanCurvatureLineEdit) self.minCurvatureLineEdit = qt.QLineEdit() self.minCurvatureLineEdit.text = '--' self.minCurvatureLineEdit.readOnly = True self.minCurvatureLineEdit.frame = True self.minCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.minCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.minCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Minimum (mm^-1):", self.minCurvatureLineEdit) self.maxCurvatureLineEdit = qt.QLineEdit() self.maxCurvatureLineEdit.text = '--' self.maxCurvatureLineEdit.readOnly = True self.maxCurvatureLineEdit.frame = True self.maxCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.maxCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.maxCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Maximum (mm^-1):", self.maxCurvatureLineEdit) ## Create a scale for curvature self.scalarBarWidget = vtk.vtkScalarBarWidget() actor = self.scalarBarWidget.GetScalarBarActor() actor.SetOrientationToVertical() actor.SetNumberOfLabels(11) actor.SetTitle("Curvature (mm^-1)") actor.SetLabelFormat(" %#8.3f") actor.SetPosition(0.1, 0.1) actor.SetWidth(0.1) actor.SetHeight(0.8) self.scalarBarWidget.SetEnabled(0) layout = slicer.app.layoutManager() view = layout.threeDWidget(0).threeDView() renderer = layout.activeThreeDRenderer() self.scalarBarWidget.SetInteractor( renderer.GetRenderWindow().GetInteractor()) self.lookupTable = vtk.vtkLookupTable() self.lookupTable.SetRange(0.0, 100.0) self.scalarBarWidget.GetScalarBarActor().SetLookupTable( self.lookupTable) ## default curvature mode: off self.curvatureOff.setChecked(True) self.onCurvatureOff(True) self.autoCurvatureRangeOff.setChecked(True) self.onAutoCurvatureRangeOff(True) # Add vertical spacer self.layout.addStretch(1)
def setup(self): # Instantiate and connect widgets ... # # Reload and Test area # reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "AblationMarginVisualizer Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # # Basic Area # basicCollapsibleButton = ctk.ctkCollapsibleButton() basicCollapsibleButton.text = "Basic" self.layout.addWidget(basicCollapsibleButton) # Layout within the dummy collapsible button basicFormLayout = qt.QFormLayout(basicCollapsibleButton) # # Tumor label selector # self.tumorLabelSelector = slicer.qMRMLNodeComboBox() self.tumorLabelSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "") self.tumorLabelSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", 1) self.tumorLabelSelector.selectNodeUponCreation = True self.tumorLabelSelector.addEnabled = False self.tumorLabelSelector.removeEnabled = False self.tumorLabelSelector.noneEnabled = False self.tumorLabelSelector.showHidden = False self.tumorLabelSelector.showChildNodeTypes = False self.tumorLabelSelector.setMRMLScene(slicer.mrmlScene) self.tumorLabelSelector.setToolTip( "Select label image of the tumor volume") basicFormLayout.addRow("Tumor Volume: ", self.tumorLabelSelector) self.outputModelSelector = slicer.qMRMLNodeComboBox() self.outputModelSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.outputModelSelector.selectNodeUponCreation = False self.outputModelSelector.addEnabled = False self.outputModelSelector.renameEnabled = False self.outputModelSelector.removeEnabled = False self.outputModelSelector.noneEnabled = False self.outputModelSelector.showHidden = False self.outputModelSelector.showChildNodeTypes = False self.outputModelSelector.setMRMLScene(slicer.mrmlScene) self.outputModelSelector.setToolTip( "Select a surface model of the ablation volume") basicFormLayout.addRow("Ablation Volume Model: ", self.outputModelSelector) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True basicFormLayout.addRow(self.applyButton) self.applyButton.connect('clicked(bool)', self.onApplyButton) # # Visualization Area # visualizationCollapsibleButton = ctk.ctkCollapsibleButton() visualizationCollapsibleButton.text = "Visualization" self.layout.addWidget(visualizationCollapsibleButton) # Layout within the dummy collapsible button visualizationFormLayout = qt.QFormLayout( visualizationCollapsibleButton) self.colorMapSelector = slicer.qMRMLColorTableComboBox() self.colorMapSelector.setMRMLScene(slicer.mrmlScene) visualizationFormLayout.addRow("Color Table: ", self.colorMapSelector) self.colorMapSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onColorTableSelect) #self.colorRangeWidget = slicer.qMRMLRangeWidget() self.colorRangeWidget = ctk.ctkRangeWidget() self.colorRangeWidget.setToolTip("Set color range") visualizationFormLayout.addRow("Color Range: ", self.colorRangeWidget) self.colorRangeWidget.connect('valuesChanged(double, double)', self.updateColorRange) self.showScaleButton = qt.QCheckBox() self.showScaleButton.setText('Show Scale') self.showScaleButton.checked = False self.showScaleButton.setToolTip( 'Check to show the scale bar in the 3D viewer') visualizationFormLayout.addRow("Ablation Volume Model: ", self.showScaleButton) self.showScaleButton.connect('clicked(bool)', self.onShowScaleButton) # connections #self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) #self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) # Add vertical spacer self.layout.addStretch(1) ## Create a scale self.scalarBarWidget = vtk.vtkScalarBarWidget() actor = self.scalarBarWidget.GetScalarBarActor() actor.SetOrientationToVertical() actor.SetNumberOfLabels(11) actor.SetTitle("") actor.SetLabelFormat(" %#8.3f") actor.SetPosition(0.1, 0.1) actor.SetWidth(0.1) actor.SetHeight(0.8) self.scalarBarWidget.SetEnabled(0) layout = slicer.app.layoutManager() view = layout.threeDWidget(0).threeDView() renderer = layout.activeThreeDRenderer() self.scalarBarWidget.SetInteractor( renderer.GetRenderWindow().GetInteractor())
def createUserInterface(self): self.__layout = self.__parent.createUserInterface() self.__previewWindow = ctk.ctkVTKSliceView() self.__previewHLayout = qt.QHBoxLayout() self.__previewHLayout.addWidget(self.__previewWindow) self.__spaceLabel = qt.QLabel(" ") self.__previewHLayout.addWidget(self.__spaceLabel) self.__spaceLabel2 = qt.QLabel(" ") self.__previewHLayout.addWidget(self.__spaceLabel2) self.__layout.addRow(self.__previewHLayout) # Frame slider # self.frameSlider = ctk.ctkSliderWidget() # frameSlider.connect('valueChanged(double)', self.frameSliderValueChanged) # self.frameSlider.decimals = 0 # self.__layout.addRow("Preview for one Slicer: ", self.frameSlider) self.__ioAdvancedToggle = qt.QCheckBox("Show Advanced") self.__ioAdvancedToggle.setChecked(False) self.__layout.addRow(self.__ioAdvancedToggle) # # I/O advanced panel # self.__ioAdvancedPanel = qt.QFrame(self) self.__ioAdvancedPanel.hide() print "testss" self.__ioAdvancedPanel.setFrameStyle(6) self.__layout.addRow(self.__ioAdvancedPanel) self.__ioAdvancedToggle.connect("clicked()", self.onIOAdvancedToggle) ioAdvancedFormLayout = qt.QFormLayout(self.__ioAdvancedPanel) # Frame delay slider self.frameDelaySlider = ctk.ctkRangeWidget() # frameDelaySlider.connect('valueChanged(double)', self.frameDelaySliderValueChanged) self.frameDelaySlider.decimals = 0 self.frameDelaySlider.minimum = 1 self.frameDelaySlider.maximum = 70 self.frameDelaySlider.minimumValue = 5 self.frameDelaySlider.maximumValue = 20 self.frameDelaySlider.suffix = " vx" # self.frameDelaySlider.value = 20 ioAdvancedFormLayout.addRow("Diameters [Min-Max]: ", self.frameDelaySlider) # Frame delay slider self.frameDelaySlider = ctk.ctkSliderWidget() # frameDelaySlider.connect('valueChanged(double)', self.frameDelaySliderValueChanged) self.frameDelaySlider.decimals = 0 self.frameDelaySlider.minimum = 5 self.frameDelaySlider.maximum = 100 self.frameDelaySlider.value = 20 ioAdvancedFormLayout.addRow("Input Contrast: ", self.frameDelaySlider) self.__previewButton=qt.QPushButton() self.__previewButton.text="Update preview" # self.__inputVolumeNodeSelector.setMRMLScene(slicer.mrmlScene) self.__previewButtonHLayout = qt.QHBoxLayout() self.__spaceLabel2 = qt.QLabel(" ") self.__previewButtonHLayout.addWidget(self.__spaceLabel2) self.__spaceLabel = qt.QLabel(" ") self.__previewButtonHLayout.addWidget(self.__spaceLabel) self.__previewButtonHLayout.addWidget(self.__previewButton) self.__layout.addRow(self.__previewButtonHLayout) self.__previewButton.connect("clicked()", self.updatePreview)
def setup(self): QCLib.genericPanel.setup(self) # # Output Volume collapsible button # self.output = ctk.ctkCollapsibleButton(self.frame) self.output.setText("Output Volume") self.output.enabled=False self.framelayout.addWidget(self.output) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(self.output) # # output volume selector # self.outputSelector = slicer.qMRMLNodeComboBox() #self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.outputSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] #self.outputSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 1 ) self.outputSelector.selectNodeUponCreation = True self.outputSelector.addEnabled = True self.outputSelector.removeEnabled = True self.outputSelector.noneEnabled = False self.outputSelector.renameEnabled = True self.outputSelector.showHidden = False self.outputSelector.showChildNodeTypes = False self.outputSelector.setMRMLScene(slicer.mrmlScene) self.outputSelector.setToolTip("Output Volume") #self.outputSelector.enabled=False parametersFormLayout.addRow("Output Volume: ", self.outputSelector) #algorithm selector self.algorithmSel = ctk.ctkComboBox() algorithms=["Canny","Sobel","Zero Crossing Based"] self.algorithmSel.addItems(algorithms) #self.algorithmSel.enabled=False self.algorithmSel.editable=False self.algorithmSel.setCurrentIndex(0) parametersFormLayout.addRow("Edge Detection Algorithm", self.algorithmSel) self.optionFrame=qt.QFrame() self.optionFrame.setLayout(qt.QFormLayout()) self.optionFrame.enabled=False self.framelayout.addWidget(self.optionFrame) #variance slider self.varianceSlider = ctk.ctkSliderWidget() self.varianceSlider.minimum = 0 self.varianceSlider.maximum = 100 self.varianceSlider.setValue(2) #self.varianceSlider.enabled = False self.varianceSlider.setToolTip("Variance of the pre gaussian filter") self.optionFrame.layout().addRow("Variance", self.varianceSlider) #threshold slider self.threshSlider=ctk.ctkRangeWidget() self.threshSlider.minimum = 0 self.threshSlider.maximum = 0 self.threshSlider.setValues(0,0) #self.threshSlider.enabled=False self.threshSlider.setToolTip("Threshold of output volume") self.optionFrame.layout().addRow("Threshold", self.threshSlider) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the edge detection algotrithm" self.applyButton.enabled = False self.framelayout.addWidget(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelectInput) self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelectOutput) self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.algorithmSel.connect("currentIndexChanged(int)", self.setOptionEnabled) # Add vertical spacer self.layout.addStretch(1) count = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLSliceCompositeNode') for n in xrange(count): compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLSliceCompositeNode') compNode.SetForegroundOpacity(1.0)
def setup(self): # Instantiate and connect widgets ... self.RingOff = None self.RingOn = None # Tags to manage event observers self.tagSourceNode = None self.tagDestinationNode = None ##################### ## For debugging ## ## Reload and Test area #reloadCollapsibleButton = ctk.ctkCollapsibleButton() #reloadCollapsibleButton.text = "Reload && Test" #self.layout.addWidget(reloadCollapsibleButton) #reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) # ## reload button ## (use this during development, but remove it when delivering ## your module to users) #self.reloadButton = qt.QPushButton("Reload") #self.reloadButton.toolTip = "Reload this module." #self.reloadButton.name = "CurveMaker Reload" #reloadFormLayout.addWidget(self.reloadButton) #self.reloadButton.connect('clicked()', self.onReload) ## ##################### # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Source points (vtkMRMLMarkupsFiducialNode) # self.SourceSelector = slicer.qMRMLNodeComboBox() self.SourceSelector.nodeTypes = ( ("vtkMRMLMarkupsFiducialNode"), "" ) self.SourceSelector.addEnabled = True self.SourceSelector.removeEnabled = False self.SourceSelector.noneEnabled = True self.SourceSelector.showHidden = False self.SourceSelector.renameEnabled = True self.SourceSelector.showChildNodeTypes = False self.SourceSelector.setMRMLScene( slicer.mrmlScene ) self.SourceSelector.setToolTip( "Pick up a Markups node listing fiducials." ) parametersFormLayout.addRow("Source points: ", self.SourceSelector) # # Target point (vtkMRMLMarkupsFiducialNode) # self.DestinationSelector = slicer.qMRMLNodeComboBox() self.DestinationSelector.nodeTypes = ( ("vtkMRMLModelNode"), "" ) self.DestinationSelector.addEnabled = True self.DestinationSelector.removeEnabled = False self.DestinationSelector.noneEnabled = True self.DestinationSelector.showHidden = False self.DestinationSelector.renameEnabled = True self.DestinationSelector.selectNodeUponCreation = True self.DestinationSelector.showChildNodeTypes = False self.DestinationSelector.setMRMLScene( slicer.mrmlScene ) self.DestinationSelector.setToolTip( "Pick up or create a Model node." ) parametersFormLayout.addRow("Curve model: ", self.DestinationSelector) # # Radius for the tube # self.RadiusSliderWidget = ctk.ctkSliderWidget() self.RadiusSliderWidget.singleStep = 1.0 self.RadiusSliderWidget.minimum = 1.0 self.RadiusSliderWidget.maximum = 50.0 self.RadiusSliderWidget.value = 5.0 self.RadiusSliderWidget.setToolTip("Set the raidus of the tube.") parametersFormLayout.addRow("Radius (mm): ", self.RadiusSliderWidget) # # Radio button to select interpolation method # self.InterpolationLayout = qt.QHBoxLayout() self.InterpolationNone = qt.QRadioButton("None") self.InterpolationCardinalSpline = qt.QRadioButton("Cardinal Spline") self.InterpolationHermiteSpline = qt.QRadioButton("Hermite Spline (for Endoscopy)") self.InterpolationLayout.addWidget(self.InterpolationNone) self.InterpolationLayout.addWidget(self.InterpolationCardinalSpline) self.InterpolationLayout.addWidget(self.InterpolationHermiteSpline) self.InterpolationGroup = qt.QButtonGroup() self.InterpolationGroup.addButton(self.InterpolationNone) self.InterpolationGroup.addButton(self.InterpolationCardinalSpline) self.InterpolationGroup.addButton(self.InterpolationHermiteSpline) parametersFormLayout.addRow("Interpolation: ", self.InterpolationLayout) # # Interpolation Resolution # self.InterpResolutionSliderWidget = ctk.ctkSliderWidget() self.InterpResolutionSliderWidget.singleStep = 1.0 self.InterpResolutionSliderWidget.minimum = 5.0 self.InterpResolutionSliderWidget.maximum = 50.0 self.InterpResolutionSliderWidget.value = 25.0 self.InterpResolutionSliderWidget.setToolTip("Number of interpolation points between control points. Default is 25.") parametersFormLayout.addRow("Resolution: ", self.InterpResolutionSliderWidget) # # Radio button for ring mode # self.RingLayout = qt.QHBoxLayout() self.RingOff = qt.QRadioButton("Off") self.RingOn = qt.QRadioButton("On") self.RingLayout.addWidget(self.RingOff) self.RingLayout.addWidget(self.RingOn) self.RingGroup = qt.QButtonGroup() self.RingGroup.addButton(self.RingOff) self.RingGroup.addButton(self.RingOn) parametersFormLayout.addRow("Ring mode: ", self.RingLayout) # # Check box to start curve visualization # self.EnableAutoUpdateCheckBox = qt.QCheckBox() self.EnableAutoUpdateCheckBox.checked = 0 self.EnableAutoUpdateCheckBox.setToolTip("If checked, the CurveMaker module keeps updating the model as the points are updated.") parametersFormLayout.addRow("Auto update:", self.EnableAutoUpdateCheckBox) # # Button to generate a curve # self.GenerateButton = qt.QPushButton("Generate Curve") self.GenerateButton.toolTip = "Generate Curve" self.GenerateButton.enabled = True parametersFormLayout.addRow("", self.GenerateButton) # Connections self.InterpolationNone.connect('clicked(bool)', self.onSelectInterpolationNone) self.InterpolationCardinalSpline.connect('clicked(bool)', self.onSelectInterpolationCardinalSpline) self.InterpolationHermiteSpline.connect('clicked(bool)', self.onSelectInterpolationHermiteSpline) self.RingOff.connect('clicked(bool)', self.onRingOff) self.RingOn.connect('clicked(bool)', self.onRingOn) self.EnableAutoUpdateCheckBox.connect('toggled(bool)', self.onEnableAutoUpdate) self.SourceSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSourceSelected) self.DestinationSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onDestinationSelected) self.RadiusSliderWidget.connect("valueChanged(double)", self.onTubeUpdated) self.InterpResolutionSliderWidget.connect("valueChanged(double)", self.onInterpResolutionUpdated) self.GenerateButton.connect('clicked(bool)', self.onGenerateCurve) # Set default ## default interpolation method self.InterpolationCardinalSpline.setChecked(True) self.onSelectInterpolationCardinalSpline(True) ## default ring mode self.RingOff.setChecked(True) self.onRingOff(True) # # Curve Length area # lengthCollapsibleButton = ctk.ctkCollapsibleButton() lengthCollapsibleButton.text = "Length" self.layout.addWidget(lengthCollapsibleButton) lengthFormLayout = qt.QFormLayout(lengthCollapsibleButton) lengthCollapsibleButton.collapsed = True #-- Curve length self.lengthLineEdit = qt.QLineEdit() self.lengthLineEdit.text = '--' self.lengthLineEdit.readOnly = True self.lengthLineEdit.frame = True self.lengthLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.lengthLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) lengthFormLayout.addRow("Curve Length (mm):", self.lengthLineEdit) # # Distance Area # distanceCollapsibleButton = ctk.ctkCollapsibleButton() distanceCollapsibleButton.text = "Distance" distanceCollapsibleButton.collapsed = True self.layout.addWidget(distanceCollapsibleButton) distanceFormLayout = qt.QFormLayout(distanceCollapsibleButton) #-- Point-to-curve distance # - Markups selector for input points distanceLayout = qt.QVBoxLayout() self.targetFiducialsSelector = slicer.qMRMLNodeComboBox() self.targetFiducialsSelector.nodeTypes = ( ("vtkMRMLMarkupsFiducialNode"), "" ) self.targetFiducialsSelector.selectNodeUponCreation = True self.targetFiducialsSelector.addEnabled = True self.targetFiducialsSelector.removeEnabled = True self.targetFiducialsSelector.noneEnabled = True self.targetFiducialsSelector.showHidden = False self.targetFiducialsSelector.showChildNodeTypes = False self.targetFiducialsSelector.setMRMLScene( slicer.mrmlScene ) self.targetFiducialsSelector.setToolTip( "Select Markups for targets" ) distanceLayout.addWidget(self.targetFiducialsSelector) self.targetFiducialsNode = None self.tagDestinationDispNode = None self.targetFiducialsSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onTargetFiducialsSelected) self.fiducialsTable = qt.QTableWidget(1, 3) self.fiducialsTable.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self.fiducialsTable.setSelectionMode(qt.QAbstractItemView.SingleSelection) self.fiducialsTableHeaders = ["Name", "Position (mm)", "Distance (mm)"] self.fiducialsTable.setHorizontalHeaderLabels(self.fiducialsTableHeaders) self.fiducialsTable.horizontalHeader().setStretchLastSection(True) distanceLayout.addWidget(self.fiducialsTable) self.extrapolateCheckBox = qt.QCheckBox() self.extrapolateCheckBox.checked = 0 self.extrapolateCheckBox.setToolTip("Extrapolate the first and last segment to calculate the distance") self.extrapolateCheckBox.connect('toggled(bool)', self.updateTargetFiducialsTable) self.extrapolateCheckBox.text = 'Extrapolate curves to measure the distances' self.showErrorVectorCheckBox = qt.QCheckBox() self.showErrorVectorCheckBox.checked = 0 self.showErrorVectorCheckBox.setToolTip("Show error vectors, which is defined by the target point and the closest point on the curve. The vector is perpendicular to the curve, unless the closest point is one end of the curve.") self.showErrorVectorCheckBox.connect('toggled(bool)', self.updateTargetFiducialsTable) self.showErrorVectorCheckBox.text = 'Show error vectors' distanceLayout.addWidget(self.extrapolateCheckBox) distanceLayout.addWidget(self.showErrorVectorCheckBox) distanceFormLayout.addRow("Distance from:", distanceLayout) # # Curvature Area # curvatureCollapsibleButton = ctk.ctkCollapsibleButton() curvatureCollapsibleButton.text = "Curvature" curvatureCollapsibleButton.collapsed = True self.layout.addWidget(curvatureCollapsibleButton) curvatureFormLayout = qt.QFormLayout(curvatureCollapsibleButton) #-- Curvature self.curvatureLayout = qt.QHBoxLayout() self.curvatureOff = qt.QRadioButton("Off") self.curvatureOff.connect('clicked(bool)', self.onCurvatureOff) self.curvatureOn = qt.QRadioButton("On") self.curvatureOn.connect('clicked(bool)', self.onCurvatureOn) self.curvatureLayout.addWidget(self.curvatureOff) self.curvatureLayout.addWidget(self.curvatureOn) self.curvatureGroup = qt.QButtonGroup() self.curvatureGroup.addButton(self.curvatureOff) self.curvatureGroup.addButton(self.curvatureOn) curvatureFormLayout.addRow("Curvature mode:", self.curvatureLayout) autoCurvatureRangeFormLayout = qt.QFormLayout(curvatureCollapsibleButton) self.autoCurvatureRangeLayout = qt.QHBoxLayout() self.autoCurvatureRangeOff = qt.QRadioButton("Manual") self.autoCurvatureRangeOff.connect('clicked(bool)', self.onAutoCurvatureRangeOff) self.autoCurvatureRangeOn = qt.QRadioButton("Auto") self.autoCurvatureRangeOn.connect('clicked(bool)', self.onAutoCurvatureRangeOn) self.autoCurvatureRangeLayout.addWidget(self.autoCurvatureRangeOff) self.autoCurvatureRangeLayout.addWidget(self.autoCurvatureRangeOn) self.autoCurvatureRangeGroup = qt.QButtonGroup() self.autoCurvatureRangeGroup.addButton(self.autoCurvatureRangeOff) self.autoCurvatureRangeGroup.addButton(self.autoCurvatureRangeOn) curvatureFormLayout.addRow("Color range:", self.autoCurvatureRangeLayout) #-- Color range self.curvatureColorRangeWidget = ctk.ctkRangeWidget() self.curvatureColorRangeWidget.setToolTip("Set color range") self.curvatureColorRangeWidget.setDecimals(3) self.curvatureColorRangeWidget.singleStep = 0.001 self.curvatureColorRangeWidget.minimumValue = 0.0 self.curvatureColorRangeWidget.maximumValue = 0.5 self.curvatureColorRangeWidget.minimum = 0.0 self.curvatureColorRangeWidget.maximum = 1.0 curvatureFormLayout.addRow("Color range: ", self.curvatureColorRangeWidget) self.curvatureColorRangeWidget.connect('valuesChanged(double, double)', self.onUpdateCurvatureColorRange) #-- Curvature data self.meanCurvatureLineEdit = qt.QLineEdit() self.meanCurvatureLineEdit.text = '--' self.meanCurvatureLineEdit.readOnly = True self.meanCurvatureLineEdit.frame = True self.meanCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.meanCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.meanCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Mean (mm^-1):", self.meanCurvatureLineEdit) self.minCurvatureLineEdit = qt.QLineEdit() self.minCurvatureLineEdit.text = '--' self.minCurvatureLineEdit.readOnly = True self.minCurvatureLineEdit.frame = True self.minCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.minCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.minCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Minimum (mm^-1):", self.minCurvatureLineEdit) self.maxCurvatureLineEdit = qt.QLineEdit() self.maxCurvatureLineEdit.text = '--' self.maxCurvatureLineEdit.readOnly = True self.maxCurvatureLineEdit.frame = True self.maxCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.maxCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.maxCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Maximum (mm^-1):", self.maxCurvatureLineEdit) ## Create a scale for curvature self.scalarBarWidget = vtk.vtkScalarBarWidget() actor = self.scalarBarWidget.GetScalarBarActor() actor.SetOrientationToVertical() actor.SetNumberOfLabels(11) actor.SetTitle("Curvature (mm^-1)") actor.SetLabelFormat(" %#8.3f") actor.SetPosition(0.1, 0.1) actor.SetWidth(0.1) actor.SetHeight(0.8) self.scalarBarWidget.SetEnabled(0) layout = slicer.app.layoutManager() view = layout.threeDWidget(0).threeDView() renderer = layout.activeThreeDRenderer() self.scalarBarWidget.SetInteractor(renderer.GetRenderWindow().GetInteractor()) self.lookupTable = vtk.vtkLookupTable() self.lookupTable.SetRange(0.0, 100.0) self.scalarBarWidget.GetScalarBarActor().SetLookupTable(self.lookupTable) ## default curvature mode: off self.curvatureOff.setChecked(True) self.onCurvatureOff(True) self.autoCurvatureRangeOff.setChecked(True) self.onAutoCurvatureRangeOff(True) # Add vertical spacer self.layout.addStretch(1)
def setup(self): # Instantiate and connect widgets ... # # Reload and Test area # reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "AblationMarginVisualizer Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # # Basic Area # basicCollapsibleButton = ctk.ctkCollapsibleButton() basicCollapsibleButton.text = "Basic" self.layout.addWidget(basicCollapsibleButton) # Layout within the dummy collapsible button basicFormLayout = qt.QFormLayout(basicCollapsibleButton) # # Tumor label selector # self.tumorLabelSelector = slicer.qMRMLNodeComboBox() self.tumorLabelSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" ) self.tumorLabelSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 1 ) self.tumorLabelSelector.selectNodeUponCreation = True self.tumorLabelSelector.addEnabled = False self.tumorLabelSelector.removeEnabled = False self.tumorLabelSelector.noneEnabled = False self.tumorLabelSelector.showHidden = False self.tumorLabelSelector.showChildNodeTypes = False self.tumorLabelSelector.setMRMLScene( slicer.mrmlScene ) self.tumorLabelSelector.setToolTip( "Select label image of the tumor volume" ) basicFormLayout.addRow("Tumor Volume: ", self.tumorLabelSelector) self.outputModelSelector = slicer.qMRMLNodeComboBox() self.outputModelSelector.nodeTypes = ( ("vtkMRMLModelNode"), "" ) self.outputModelSelector.selectNodeUponCreation = False self.outputModelSelector.addEnabled = False self.outputModelSelector.renameEnabled = False self.outputModelSelector.removeEnabled = False self.outputModelSelector.noneEnabled = False self.outputModelSelector.showHidden = False self.outputModelSelector.showChildNodeTypes = False self.outputModelSelector.setMRMLScene( slicer.mrmlScene ) self.outputModelSelector.setToolTip( "Select a surface model of the ablation volume" ) basicFormLayout.addRow("Ablation Volume Model: ", self.outputModelSelector) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True basicFormLayout.addRow(self.applyButton) self.applyButton.connect('clicked(bool)', self.onApplyButton) # # Visualization Area # visualizationCollapsibleButton = ctk.ctkCollapsibleButton() visualizationCollapsibleButton.text = "Visualization" self.layout.addWidget(visualizationCollapsibleButton) # Layout within the dummy collapsible button visualizationFormLayout = qt.QFormLayout(visualizationCollapsibleButton) self.colorMapSelector = slicer.qMRMLColorTableComboBox() self.colorMapSelector.setMRMLScene( slicer.mrmlScene ) visualizationFormLayout.addRow("Color Table: ", self.colorMapSelector) self.colorMapSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onColorTableSelect) #self.colorRangeWidget = slicer.qMRMLRangeWidget() self.colorRangeWidget = ctk.ctkRangeWidget() self.colorRangeWidget.setToolTip("Set color range") visualizationFormLayout.addRow("Color Range: ", self.colorRangeWidget) self.colorRangeWidget.connect('valuesChanged(double, double)', self.updateColorRange) self.showScaleButton = qt.QCheckBox() self.showScaleButton.setText('Show Scale') self.showScaleButton.checked = False self.showScaleButton.setToolTip('Check to show the scale bar in the 3D viewer') visualizationFormLayout.addRow("Ablation Volume Model: ", self.showScaleButton) self.showScaleButton.connect('clicked(bool)', self.onShowScaleButton) # connections #self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) #self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) # Add vertical spacer self.layout.addStretch(1) ## Create a scale self.scalarBarWidget = vtk.vtkScalarBarWidget() actor = self.scalarBarWidget.GetScalarBarActor() actor.SetOrientationToVertical() actor.SetNumberOfLabels(11) actor.SetTitle("") actor.SetLabelFormat(" %#8.3f") actor.SetPosition(0.1, 0.1) actor.SetWidth(0.1) actor.SetHeight(0.8) self.scalarBarWidget.SetEnabled(0) layout = slicer.app.layoutManager() view = layout.threeDWidget(0).threeDView() renderer = layout.activeThreeDRenderer() self.scalarBarWidget.SetInteractor(renderer.GetRenderWindow().GetInteractor())
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersLayout = qt.QFormLayout(parametersCollapsibleButton) # # input volume selector # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "") self.inputSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", 0) self.inputSelector.selectNodeUponCreation = True self.inputSelector.addEnabled = False self.inputSelector.removeEnabled = False self.inputSelector.noneEnabled = True self.inputSelector.showHidden = False self.inputSelector.showChildNodeTypes = False self.inputSelector.setMRMLScene(slicer.mrmlScene) self.inputSelector.setToolTip("Pick the input to the algorithm.") parametersLayout.addRow("Input Volume: ", self.inputSelector) #self.activeVolume = self.inputSelector.currentNode() #self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) #self.labelSelector = slicer.qSlicerLabelMapVolumeDisplayWidget() #parametersLayout.addRow("Label Map: ", self.labelSelector) # # Select Button # self.selectButton = qt.QPushButton("Select") self.selectButton.toolTip = "Select the volume." self.selectButton.enabled = True parametersLayout.addRow(self.selectButton) # # Gradient Button # self.gradientButton = qt.QPushButton( "Gradient - sergio reimplementation") self.gradientButton.toolTip = "re-implementation of sergio's gradient." self.gradientButton.enabled = True parametersLayout.addRow(self.gradientButton) # # Paint Button # self.paintButton = qt.QPushButton("Paint") self.paintButton.toolTip = "Turn on paint." self.paintButton.enabled = True self.paintButton.checkable = True parametersLayout.addRow(self.paintButton) # # Apply mask Button # self.applyButton = qt.QPushButton("Apply mask") self.applyButton.toolTip = "Find area of mask." self.applyButton.enabled = True parametersLayout.addRow(self.applyButton) # # Range for threshold # self.threshold = ctk.ctkRangeWidget() lo, hi = self.getLoHiImageValues() self.threshold.minimum, self.threshold.maximum = lo, hi self.threshold.singleStep = (hi - lo) / 1000. parametersLayout.addRow(self.threshold) # # Grow Button # self.growButton = qt.QPushButton("Grow with Threshold") self.growButton.toolTip = "Grow into 3D with connected threshold." self.growButton.enabled = True parametersLayout.addRow(self.growButton) # # Liver 2D Button # self.liver2DButton = qt.QPushButton("Liver 2D") self.liver2DButton.toolTip = "Grow from mask in 2D, but up down into next slices." self.liver2DButton.enabled = True parametersLayout.addRow(self.liver2DButton) # # Cross remove Button # self.crossButton = qt.QPushButton("Cross remove") self.crossButton.toolTip = "re-implementation of sergio's cross remove." self.crossButton.enabled = True parametersLayout.addRow(self.crossButton) # # Connectivity reduction Button # self.connectivityButton = qt.QPushButton("Connectivity reduction") self.connectivityButton.toolTip = "re-implementation of sergio's connectivity reduction." self.connectivityButton.enabled = True parametersLayout.addRow(self.connectivityButton) # # Paint Button (correction) # self.correctButton = qt.QPushButton("Correct") self.correctButton.toolTip = "Turn on paint for annotating corrections." self.correctButton.enabled = True self.correctButton.checkable = True parametersLayout.addRow(self.correctButton) # # Track centroid under mask # self.trackMaskButton = qt.QPushButton("Track correction") self.trackMaskButton.toolTip = "Try to use correction mask, and track the centroid in has inside it" self.trackMaskButton.enabled = True parametersLayout.addRow(self.trackMaskButton) # # Erase mask (including all under) # self.eraseMaskButton = qt.QPushButton("Erase correction") self.eraseMaskButton.toolTip = "Delete the correction mask to hopefully orphan other areas" self.eraseMaskButton.enabled = True parametersLayout.addRow(self.eraseMaskButton) # # Remove unconnected # self.removeIsolatedButton = qt.QPushButton("Remove unconnected") self.removeIsolatedButton.toolTip = "try to see just the main blob and remove stuff not connected." self.removeIsolatedButton.enabled = True parametersLayout.addRow(self.removeIsolatedButton) # connections #buttons self.selectButton.connect('clicked(bool)', self.onSelectButton) self.gradientButton.connect('clicked(bool)', self.onGradientButton) self.paintButton.connect('clicked(bool)', self.onPaintButton) self.applyButton.connect('clicked(bool)', self.onApplyButton) self.growButton.connect('clicked(bool)', self.onGrowButton) self.liver2DButton.connect('clicked(bool)', self.onliver2DButton) self.crossButton.connect('clicked(bool)', self.onCrossButton) self.connectivityButton.connect('clicked(bool)', self.onConnectivityButton) # correction tools buttons self.correctButton.connect('clicked(bool)', self.onCorrectButton) self.trackMaskButton.connect('clicked(bool)', self.onTrackMaskButton) self.eraseMaskButton.connect('clicked(bool)', self.onEraseMaskButton) self.removeIsolatedButton.connect('clicked(bool)', self.onRemoveIsolatedButton) self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.threshold.connect('valuesChanged(double,double)', self.onThresholdValuesChanged) # Creates and adds the custom Editor Widget to the module #self.localParEditorWidget = ParEditorWidget(parent=self.parent, showVolumesFrame=False) #self.localParEditorWidget.setup() #self.localParEditorWidget.enter() # Add vertical spacer self.layout.addStretch(1) # sets the layout to Red Slice Only layoutManager = slicer.app.layoutManager() layoutManager.setLayout( slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)
def setup(self): # Input/Output collapsible button collapsibleButton = ctk.ctkCollapsibleButton() collapsibleButton.text = "IO" self.layout.addWidget(collapsibleButton) # Layout within the dummy collapsible button formLayout = qt.QFormLayout(collapsibleButton) # The input volume selector self.inputVolumeFrame = qt.QFrame(collapsibleButton) self.inputVolumeFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.inputVolumeFrame) self.inputVolumeSelector = qt.QLabel("Input Image Volume: ", self.inputVolumeFrame) self.inputVolumeFrame.layout().addWidget(self.inputVolumeSelector) self.inputVolumeSelector = slicer.qMRMLNodeComboBox( self.inputVolumeFrame) self.inputVolumeSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "") self.inputVolumeSelector.addEnabled = False self.inputVolumeSelector.removeEnabled = True self.inputVolumeSelector.renameEnabled = True self.inputVolumeSelector.setMRMLScene(slicer.mrmlScene) self.inputVolumeFrame.layout().addWidget(self.inputVolumeSelector) # The endo segmentation selector self.endoLabelFrame = qt.QFrame(collapsibleButton) self.endoLabelFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.endoLabelFrame) self.endoLabelSelector = qt.QLabel("Endo Label Map: ", self.endoLabelFrame) self.endoLabelFrame.layout().addWidget(self.endoLabelSelector) self.endoLabelSelector = slicer.qMRMLNodeComboBox(self.endoLabelFrame) self.endoLabelSelector.nodeTypes = (("vtkMRMLLabelMapVolumeNode"), "") self.endoLabelSelector.addEnabled = False self.endoLabelSelector.removeEnabled = True self.endoLabelSelector.renameEnabled = True self.endoLabelSelector.setMRMLScene(slicer.mrmlScene) self.endoLabelFrame.layout().addWidget(self.endoLabelSelector) # The wall segmentation selector self.wallLabelFrame = qt.QFrame(collapsibleButton) self.wallLabelFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.wallLabelFrame) self.wallLabelSelector = qt.QLabel("Wall Label Map: ", self.wallLabelFrame) self.wallLabelFrame.layout().addWidget(self.wallLabelSelector) self.wallLabelSelector = slicer.qMRMLNodeComboBox(self.wallLabelFrame) self.wallLabelSelector.nodeTypes = (("vtkMRMLLabelMapVolumeNode"), "") self.wallLabelSelector.addEnabled = False self.wallLabelSelector.removeEnabled = True self.wallLabelSelector.renameEnabled = True self.wallLabelSelector.setMRMLScene(slicer.mrmlScene) self.wallLabelFrame.layout().addWidget(self.wallLabelSelector) # Add vertical spacer self.layout.addStretch(1) # Create model button createModelButton = qt.QPushButton("Create Endo and Wall Models") createModelButton.toolTip = "Create models from the LA endo and wall segmentations." formLayout.addWidget(createModelButton) createModelButton.connect('clicked(bool)', self.onCreateModelButtonClicked) # The model selector self.inputModelFrame = qt.QFrame(collapsibleButton) self.inputModelFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.inputModelFrame) self.inputModelSelector = qt.QLabel("Input Wall Model: ", self.inputModelFrame) self.inputModelFrame.layout().addWidget(self.inputModelSelector) self.inputModelSelector = slicer.qMRMLNodeComboBox( self.inputModelFrame) self.inputModelSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.inputModelSelector.addEnabled = False self.inputModelSelector.removeEnabled = False self.inputModelSelector.renameEnabled = True self.inputModelSelector.setMRMLScene(slicer.mrmlScene) self.inputModelFrame.layout().addWidget(self.inputModelSelector) # Probe volume button probeVolumeButton = qt.QPushButton("Probe Input Image With Wall Model") probeVolumeButton.toolTip = "Probe the input image volume with the wall model to map the image volume intensities to the model. The wall model will be deleted and replaced by the new output wall model." formLayout.addWidget(probeVolumeButton) probeVolumeButton.connect('clicked(bool)', self.onProbeVolumeButtonClicked) # The threshold slider self.thresholdFrame = qt.QFrame(collapsibleButton) self.thresholdFrame.setLayout(qt.QHBoxLayout()) formLayout.addWidget(self.thresholdFrame) self.thresholdLabel = qt.QLabel("Threshold Range:", self.thresholdFrame) self.thresholdLabel.setToolTip( "Set the lower and upper intensity thresholds for the model.") self.thresholdFrame.layout().addWidget(self.thresholdLabel) self.threshold = ctk.ctkRangeWidget(self.thresholdFrame) self.threshold.spinBoxAlignment = 0xff # Put entries on top self.threshold.singleStep = 0.01 # Set a temporary minimum and maximum threshold value self.threshold.minimum = 0 self.threshold.maximum = 1000 self.threshold.singleStep = 1 self.thresholdFrame.layout().addWidget(self.threshold) # Connect threshold slider to method self.threshold.connect('valuesChanged(double,double)', self.onThresholdValuesChanged) # Set local var as instance attribute self.createModelButton = createModelButton self.probeVolumeButton = probeVolumeButton
def createUserInterface(self): self.__layout = self.__parent.createUserInterface() self.__previewWindow = ctk.ctkVTKSliceView() self.__previewHLayout = qt.QHBoxLayout() self.__previewHLayout.addWidget(self.__previewWindow) self.__spaceLabel = qt.QLabel(" ") self.__previewHLayout.addWidget(self.__spaceLabel) self.__spaceLabel2 = qt.QLabel(" ") self.__previewHLayout.addWidget(self.__spaceLabel2) self.__layout.addRow(self.__previewHLayout) # Frame slider # self.frameSlider = ctk.ctkSliderWidget() # frameSlider.connect('valueChanged(double)', self.frameSliderValueChanged) # self.frameSlider.decimals = 0 # self.__layout.addRow("Preview for one Slicer: ", self.frameSlider) self.__ioAdvancedToggle = qt.QCheckBox("Show Advanced") self.__ioAdvancedToggle.setChecked(False) self.__layout.addRow(self.__ioAdvancedToggle) # # I/O advanced panel # self.__ioAdvancedPanel = qt.QFrame(self) self.__ioAdvancedPanel.hide() print "testss" self.__ioAdvancedPanel.setFrameStyle(6) self.__layout.addRow(self.__ioAdvancedPanel) self.__ioAdvancedToggle.connect("clicked()", self.onIOAdvancedToggle) ioAdvancedFormLayout = qt.QFormLayout(self.__ioAdvancedPanel) # Frame delay slider self.frameDelaySlider = ctk.ctkRangeWidget() # frameDelaySlider.connect('valueChanged(double)', self.frameDelaySliderValueChanged) self.frameDelaySlider.decimals = 0 self.frameDelaySlider.minimum = 1 self.frameDelaySlider.maximum = 70 self.frameDelaySlider.minimumValue = 5 self.frameDelaySlider.maximumValue = 20 self.frameDelaySlider.suffix = " vx" # self.frameDelaySlider.value = 20 ioAdvancedFormLayout.addRow("Diameters [Min-Max]: ", self.frameDelaySlider) # Frame delay slider self.frameDelaySlider = ctk.ctkSliderWidget() # frameDelaySlider.connect('valueChanged(double)', self.frameDelaySliderValueChanged) self.frameDelaySlider.decimals = 0 self.frameDelaySlider.minimum = 5 self.frameDelaySlider.maximum = 100 self.frameDelaySlider.value = 20 ioAdvancedFormLayout.addRow("Input Contrast: ", self.frameDelaySlider) self.__previewButton = qt.QPushButton() self.__previewButton.text = "Update preview" # self.__inputVolumeNodeSelector.setMRMLScene(slicer.mrmlScene) self.__previewButtonHLayout = qt.QHBoxLayout() self.__spaceLabel2 = qt.QLabel(" ") self.__previewButtonHLayout.addWidget(self.__spaceLabel2) self.__spaceLabel = qt.QLabel(" ") self.__previewButtonHLayout.addWidget(self.__spaceLabel) self.__previewButtonHLayout.addWidget(self.__previewButton) self.__layout.addRow(self.__previewButtonHLayout) self.__previewButton.connect("clicked()", self.updatePreview)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersLayout = qt.QFormLayout(parametersCollapsibleButton) # # input volume selector # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" ) self.inputSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 ) self.inputSelector.selectNodeUponCreation = True self.inputSelector.addEnabled = False self.inputSelector.removeEnabled = False self.inputSelector.noneEnabled = True self.inputSelector.showHidden = False self.inputSelector.showChildNodeTypes = False self.inputSelector.setMRMLScene( slicer.mrmlScene ) self.inputSelector.setToolTip( "Pick the input to the algorithm." ) parametersLayout.addRow("Input Volume: ", self.inputSelector) #self.activeVolume = self.inputSelector.currentNode() #self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) #self.labelSelector = slicer.qSlicerLabelMapVolumeDisplayWidget() #parametersLayout.addRow("Label Map: ", self.labelSelector) # # Select Button # self.selectButton = qt.QPushButton("Select") self.selectButton.toolTip = "Select the volume." self.selectButton.enabled = True parametersLayout.addRow(self.selectButton) # # Gradient Button # self.gradientButton = qt.QPushButton("Gradient - sergio reimplementation") self.gradientButton.toolTip = "re-implementation of sergio's gradient." self.gradientButton.enabled = True parametersLayout.addRow(self.gradientButton) # # Paint Button # self.paintButton = qt.QPushButton("Paint") self.paintButton.toolTip = "Turn on paint." self.paintButton.enabled = True self.paintButton.checkable = True parametersLayout.addRow(self.paintButton) # # Apply mask Button # self.applyButton = qt.QPushButton("Apply mask") self.applyButton.toolTip = "Find area of mask." self.applyButton.enabled = True parametersLayout.addRow(self.applyButton) # # Range for threshold # self.threshold = ctk.ctkRangeWidget() lo, hi = self.getLoHiImageValues() self.threshold.minimum, self.threshold.maximum = lo, hi self.threshold.singleStep = (hi - lo) / 1000. parametersLayout.addRow(self.threshold) # # Grow Button # self.growButton = qt.QPushButton("Grow with Threshold") self.growButton.toolTip = "Grow into 3D with connected threshold." self.growButton.enabled = True parametersLayout.addRow(self.growButton) # # Liver 2D Button # self.liver2DButton = qt.QPushButton("Liver 2D") self.liver2DButton.toolTip = "Grow from mask in 2D, but up down into next slices." self.liver2DButton.enabled = True parametersLayout.addRow(self.liver2DButton) # # Cross remove Button # self.crossButton = qt.QPushButton("Cross remove") self.crossButton.toolTip = "re-implementation of sergio's cross remove." self.crossButton.enabled = True parametersLayout.addRow(self.crossButton) # # Connectivity reduction Button # self.connectivityButton = qt.QPushButton("Connectivity reduction") self.connectivityButton.toolTip = "re-implementation of sergio's connectivity reduction." self.connectivityButton.enabled = True parametersLayout.addRow(self.connectivityButton) # # Paint Button (correction) # self.correctButton = qt.QPushButton("Correct") self.correctButton.toolTip = "Turn on paint for annotating corrections." self.correctButton.enabled = True self.correctButton.checkable = True parametersLayout.addRow(self.correctButton) # # Track centroid under mask # self.trackMaskButton = qt.QPushButton("Track correction") self.trackMaskButton.toolTip = "Try to use correction mask, and track the centroid in has inside it" self.trackMaskButton.enabled = True parametersLayout.addRow(self.trackMaskButton) # # Erase mask (including all under) # self.eraseMaskButton = qt.QPushButton("Erase correction") self.eraseMaskButton.toolTip = "Delete the correction mask to hopefully orphan other areas" self.eraseMaskButton.enabled = True parametersLayout.addRow(self.eraseMaskButton) # # Remove unconnected # self.removeIsolatedButton = qt.QPushButton("Remove unconnected") self.removeIsolatedButton.toolTip = "try to see just the main blob and remove stuff not connected." self.removeIsolatedButton.enabled = True parametersLayout.addRow(self.removeIsolatedButton) # connections #buttons self.selectButton.connect('clicked(bool)', self.onSelectButton) self.gradientButton.connect('clicked(bool)', self.onGradientButton) self.paintButton.connect('clicked(bool)', self.onPaintButton) self.applyButton.connect('clicked(bool)', self.onApplyButton) self.growButton.connect('clicked(bool)', self.onGrowButton) self.liver2DButton.connect('clicked(bool)', self.onliver2DButton) self.crossButton.connect('clicked(bool)', self.onCrossButton) self.connectivityButton.connect('clicked(bool)', self.onConnectivityButton) # correction tools buttons self.correctButton.connect('clicked(bool)', self.onCorrectButton) self.trackMaskButton.connect('clicked(bool)', self.onTrackMaskButton) self.eraseMaskButton.connect('clicked(bool)', self.onEraseMaskButton) self.removeIsolatedButton.connect('clicked(bool)', self.onRemoveIsolatedButton) self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.threshold.connect('valuesChanged(double,double)', self.onThresholdValuesChanged) # Creates and adds the custom Editor Widget to the module #self.localParEditorWidget = ParEditorWidget(parent=self.parent, showVolumesFrame=False) #self.localParEditorWidget.setup() #self.localParEditorWidget.enter() # Add vertical spacer self.layout.addStretch(1) # sets the layout to Red Slice Only layoutManager = slicer.app.layoutManager() layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)
def setup(self): """ Setup of the plugin, Uses ctk, qt and slicer objects. Consists of three sections 1. Reload and testing: Only used for testing and can be removed 2. Watershed: Performs the gradient magnitude filter and watershed filter on the original data 3. Annotation: Allows a user to select out components by using fiducials """ # # ################################################## # # # Reload and testing (only used for development) # # ################################################## # self.reloadCollapsibleButton = ctk.ctkCollapsibleButton() # self.reloadCollapsibleButton.text = "Reload && Test" # self.layout.addWidget(self.reloadCollapsibleButton) # self.reloadFormLayout = qt.QFormLayout(self.reloadCollapsibleButton) # # # reload button # # (use this during development, but remove it when delivering # # your module to users) # self.reloadButton = qt.QPushButton("Reload") # self.reloadButton.toolTip = "Reload this module." # self.reloadButton.name = "test Reload" # self.reloadFormLayout.addWidget(self.reloadButton) # self.reloadButton.connect('clicked()', self.onReload) # # # reload and test button # # (use this during development, but remove it when delivering # # your module to users) # self.reloadAndTestButton = qt.QPushButton("Reload and Test") # self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests." # self.reloadFormLayout.addWidget(self.reloadAndTestButton) # self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest) ################################################## # Watershed ################################################## # Collapsible button self.wsCollapsibleButton = ctk.ctkCollapsibleButton() self.wsCollapsibleButton.text = "Perform watershed" self.layout.addWidget(self.wsCollapsibleButton) # Layout within the collapsible button self.wsFormLayout = qt.QFormLayout(self.wsCollapsibleButton) # Volume setup # make a frame enclosed by a collapsible button self.frame = qt.QFrame(self.wsCollapsibleButton) # Set ANOTHER layout in the frame self.frame.setLayout(qt.QHBoxLayout()) self.wsFormLayout.addRow(self.frame) self.inputSelector = qt.QLabel("Input Volume: ", self.frame) self.frame.layout().addWidget(self.inputSelector) self.inputSelector = slicer.qMRMLNodeComboBox(self.frame) self.inputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" ) self.inputSelector.addEnabled = False self.inputSelector.removeEnabled = False self.inputSelector.setMRMLScene(slicer.mrmlScene) self.frame.layout().addWidget(self.inputSelector) # Gradient magnitude level self.gradLabel = qt.QLabel("Gradient sigma:") self.wsFormLayout.addWidget(self.gradLabel) self.gradSig = qt.QDoubleSpinBox() self.gradSig.minimum = 0.01 self.gradSig.value = 1.20 self.gradSig.setSingleStep(0.01) self.wsFormLayout.addWidget(self.gradSig) # watershed iteration self.wsIterationLabel = qt.QLabel("Watershed iteration steps:") self.wsFormLayout.addRow(self.wsIterationLabel) self.wsIteration = qt.QDoubleSpinBox() self.wsIteration.minimum = 0.1 self.wsIteration.value = 0.1 self.wsIteration.setSingleStep(0.1) self.wsFormLayout.addWidget(self.wsIteration) # filter the output self.filterLabel = qt.QLabel("Filter out segmentations where the total pixel count is less than:") self.wsFormLayout.addRow(self.filterLabel) self.filterBy = qt.QLineEdit("10") self.filterBy = qt.QSpinBox() self.filterBy.minimum = 0 self.filterBy.maximum = 1000000 self.filterBy.value = 10 self.filterBy.setSingleStep(1) self.wsFormLayout.addWidget(self.filterBy) # ws level self.wsLevelLabel = qt.QLabel("Watershed level:") self.wsLevelLabel.setToolTip("Set the range for the watershed level") self.wsFormLayout.addRow(self.wsLevelLabel) self.wsLevel = ctk.ctkRangeWidget() self.wsLevel.spinBoxAlignment = 0xff # put enties on top self.wsLevel.singleStep = 0.1 self.wsLevel.maximum = 10 self.wsLevel.maximumValue = 4 self.wsLevel.minimumValue = 0.2 self.wsFormLayout.addRow(self.wsLevel) # Apply button goButton = qt.QPushButton("Go") goButton.toolTip = "Run the ws Operator." self.wsFormLayout.addRow(goButton) goButton.connect('clicked(bool)', self.onApplyWS) # Cancel button self.cancelButtonWS = qt.QPushButton("Cancel") self.cancelButtonWS.toolTip = "Stop Everything!" self.wsFormLayout.addRow(self.cancelButtonWS) self.cancelButtonWS.connect('clicked(bool)', self.onCancelButton) ################################################## # Annotation ################################################## # Collapsible button self.annotationCollapsibleButton = ctk.ctkCollapsibleButton() self.annotationCollapsibleButton.text = "Annotation" self.layout.addWidget(self.annotationCollapsibleButton) # Layout within the collapsible button self.annotationFormLayout = qt.QFormLayout(self.annotationCollapsibleButton) # Fiducial input # make a frame enclosed by a collapsible button self.frame2 = qt.QFrame(self.annotationCollapsibleButton) # Set ANOTHER layout in the frame self.frame2.setLayout(qt.QHBoxLayout()) self.annotationFormLayout.addRow(self.frame2) self.inputFiducialsNodeSelector = qt.QLabel("Input Fiducials: ", self.frame2) self.frame2.layout().addWidget(self.inputFiducialsNodeSelector) self.inputFiducialsNodeSelector = slicer.qMRMLNodeComboBox(self.frame2) self.inputFiducialsNodeSelector.nodeTypes = ['vtkMRMLMarkupsFiducialNode', 'vtkMRMLAnnotationHierarchyNode', 'vtkMRMLFiducialListNode'] self.inputFiducialsNodeSelector.addEnabled = False self.inputFiducialsNodeSelector.removeEnabled = False self.inputFiducialsNodeSelector.setMRMLScene(slicer.mrmlScene) self.frame2.layout().addWidget(self.inputFiducialsNodeSelector) # Output for filtered label map self.outputFrame = qt.QFrame(self.annotationCollapsibleButton) self.outputFrame.setLayout(qt.QHBoxLayout()) self.annotationFormLayout.addWidget(self.outputFrame) self.outputSelector = qt.QLabel("Output Annotated label map: ", self.outputFrame) self.outputFrame.layout().addWidget(self.outputSelector) self.outputSelector = slicer.qMRMLNodeComboBox(self.outputFrame) self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.outputSelector.addEnabled = True self.outputSelector.removeEnabled = True self.outputSelector.renameEnabled = True self.outputSelector.setMRMLScene(slicer.mrmlScene) self.outputFrame.layout().addWidget(self.outputSelector) # reference labels input self.refFrame = qt.QFrame(self.annotationCollapsibleButton) self.refFrame.setLayout(qt.QHBoxLayout()) self.annotationFormLayout.addRow(self.refFrame) self.refLabel = qt.QLabel("Reference label map order [Optional]: ", self.refFrame) self.refFrame.layout().addWidget(self.refLabel) self.refSelector = slicer.qMRMLNodeComboBox(self.refFrame) self.refSelector.nodeTypes = ['vtkMRMLColorNode'] # Dont know a node type for just .txt self.refSelector.addEnabled = False self.refSelector.noneEnabled = True self.refSelector.removeEnabled = False self.refSelector.setMRMLScene(slicer.mrmlScene) self.refSelector.toolTip = "OPTIONAL:" \ "Can reorder the naming of the labels. " \ "Requires at a text file where the first column is a number and the second column " \ "is the label used for the fiducial e.g. 1 liver" \ " 2 lung" self.refFrame.layout().addWidget(self.refSelector) # Apply button goButtonAnn = qt.QPushButton("Go") goButtonAnn.toolTip = "Run the Annotation." self.annotationFormLayout.addRow(goButtonAnn) goButtonAnn.connect('clicked(bool)', self.onApplyAnnotation) # Cancel button cancelButtonAnn = qt.QPushButton("Cancel") cancelButtonAnn.toolTip = "Stop Everything!" self.annotationFormLayout.addRow(cancelButtonAnn) cancelButtonAnn.connect('clicked(bool)', self.onCancelButton) ################################################## # Status and Progress ################################################## # Label statusLabel = qt.QLabel("Status: ") self.currentStatusLabel = qt.QLabel("Idle") hlayout = qt.QHBoxLayout() hlayout.addStretch(1) hlayout.addWidget(statusLabel) hlayout.addWidget(self.currentStatusLabel) self.layout.addLayout(hlayout) # Progress bar self.progress = qt.QProgressBar() self.progress.setRange(0, 100) self.progress.setValue(0) self.layout.addWidget(self.progress) self.progress.hide()