def __init__(self, parent, nombre, args): """Recibe la lista de elementos""" QHButtonGroup.__init__(self, parent, "SeleccionSimple") ElementoWidgetOpciones.__init__(self) self.nombre = nombre self.setTitle(nombre) self.setExclusive(True) for elemento in args: boton = QRadioButton(self) boton.setText(elemento) self.insert(boton) self.diccionario[elemento] = boton self.find(0).setOn(True)
def __init__(self, kongs, deferred): KDialogIgnoringEscape.__init__(self) decorateWindow(self) self.setButtons(0) self.kongs = kongs self.selectedKong = None self.deferred = deferred layout = QVBoxLayout() label = QLabel(i18n('Which kong do you want to declare?')) layout.addWidget(label) layout.setAlignment(label, Qt.AlignHCenter) self.buttons = [] for kong in kongs: button = QRadioButton((kong[0].name()), self) self.buttons.append(button) layout.addWidget(button) button.toggled.connect(self.toggled) widget = QWidget(self) widget.setLayout(layout) self.setMainWidget(widget)
def __init__(self, chows, propose, deferred): KDialogIgnoringEscape.__init__(self) decorateWindow(self) self.setButtons(KDialog.NoButton) self.chows = chows self.selectedChow = None self.deferred = deferred layout = QVBoxLayout() label = QLabel(i18n('Which chow do you want to expose?')) layout.addWidget(label) layout.setAlignment(label, Qt.AlignHCenter) self.buttons = [] for chow in chows: button = QRadioButton('{}-{}-{}'.format(*(x.value for x in chow))) self.buttons.append(button) layout.addWidget(button) layout.setAlignment(button, Qt.AlignHCenter) button.toggled.connect(self.toggled) widget = QWidget(self) widget.setLayout(layout) self.setMainWidget(widget) for idx, chow in enumerate(chows): if chow == propose: self.buttons[idx].setFocus()
def setupPlotSettingsFrame(self): self.plotSettingsFrame = ctk.ctkCollapsibleButton() self.plotSettingsFrame.text = "Plotting Settings" self.plotSettingsFrame.collapsed = 1 plotSettingsFrameLayout = QFormLayout(self.plotSettingsFrame) self.layout.addWidget(self.plotSettingsFrame) # label map for probing self.labelMapSelector = slicer.qMRMLNodeComboBox() self.labelMapSelector.nodeTypes = ['vtkMRMLLabelMapVolumeNode'] self.labelMapSelector.toolTip = 'Label map to be probed' self.labelMapSelector.setMRMLScene(slicer.mrmlScene) self.labelMapSelector.addEnabled = 0 self.chartButton = QPushButton('Chart') self.chartButton.setEnabled(False) hbox = QHBoxLayout() hbox.addWidget(QLabel('Probed label volume')) hbox.addWidget(self.labelMapSelector) hbox.addWidget(self.chartButton) plotSettingsFrameLayout.addRow(hbox) self.iCharting = QCheckBox('Interactive charting') self.iCharting.setChecked(True) plotSettingsFrameLayout.addRow(self.iCharting) self.iChartingMode = QButtonGroup() self.iChartingIntensity = QRadioButton('Signal intensity') self.iChartingIntensityFixedAxes = QRadioButton( 'Fixed range intensity') self.iChartingPercent = QRadioButton('Percentage change') self.iChartingIntensity.setChecked(1) self.iChartingMode.addButton(self.iChartingIntensity) self.iChartingMode.addButton(self.iChartingIntensityFixedAxes) self.iChartingMode.addButton(self.iChartingPercent) hbox = QHBoxLayout() self.plottingModeGroupBox = QGroupBox('Plotting mode:') plottingModeLayout = QVBoxLayout() self.plottingModeGroupBox.setLayout(plottingModeLayout) plottingModeLayout.addWidget(self.iChartingIntensity) plottingModeLayout.addWidget(self.iChartingIntensityFixedAxes) plottingModeLayout.addWidget(self.iChartingPercent) hbox.addWidget(self.plottingModeGroupBox) self.showLegendCheckBox = QCheckBox('Display legend') self.showLegendCheckBox.setChecked(0) self.xLogScaleCheckBox = QCheckBox('Use log scale for X axis') self.xLogScaleCheckBox.setChecked(0) self.yLogScaleCheckBox = QCheckBox('Use log scale for Y axis') self.yLogScaleCheckBox.setChecked(0) self.plotGeneralSettingsGroupBox = QGroupBox('General Plot options:') plotGeneralSettingsLayout = QVBoxLayout() self.plotGeneralSettingsGroupBox.setLayout(plotGeneralSettingsLayout) plotGeneralSettingsLayout.addWidget(self.showLegendCheckBox) plotGeneralSettingsLayout.addWidget(self.xLogScaleCheckBox) plotGeneralSettingsLayout.addWidget(self.yLogScaleCheckBox) hbox.addWidget(self.plotGeneralSettingsGroupBox) plotSettingsFrameLayout.addRow(hbox) self.nFramesBaselineCalculation = QSpinBox() self.nFramesBaselineCalculation.minimum = 1 hbox = QHBoxLayout() hbox.addWidget(QLabel('Frame count(baseline calculation):')) hbox.addWidget(self.nFramesBaselineCalculation) plotSettingsFrameLayout.addRow(hbox)
class qSlicerMultiVolumeExplorerModuleWidget( qSlicerMultiVolumeExplorerSimplifiedModuleWidget): def __init__(self, parent=None): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.__init__(self, parent) def setupAdditionalFrames(self): self.setupPlotSettingsFrame() def setupInputFrame(self, parent=None): self.inputFrame = ctk.ctkCollapsibleButton() self.inputFrame.text = "Input" self.inputFrame.collapsed = 0 inputFrameCollapsibleLayout = QFormLayout(self.inputFrame) qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupInputFrame( self, parent=inputFrameCollapsibleLayout) self.layout.addWidget(self.inputFrame) self.fgMultiVolumeSelector = slicer.qMRMLNodeComboBox() self.fgMultiVolumeSelector.nodeTypes = ['vtkMRMLMultiVolumeNode'] self.fgMultiVolumeSelector.setMRMLScene(slicer.mrmlScene) self.fgMultiVolumeSelector.addEnabled = 0 self.fgMultiVolumeSelector.noneEnabled = 1 self.fgMultiVolumeSelector.toolTip = "Secondary multivolume will be used for the secondary \ plot in interactive charting. As an example, this can be used to overlay the \ curve obtained by fitting a model to the data" self.inputFrameLayout.addRow(QLabel('Input secondary multivolume'), self.fgMultiVolumeSelector) def setupFrameControlFrame(self): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupFrameControlFrame( self) self.frameCopySelector = slicer.qMRMLNodeComboBox() self.frameCopySelector.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred) self.frameCopySelector.nodeTypes = ['vtkMRMLScalarVolumeNode'] self.frameCopySelector.setMRMLScene(slicer.mrmlScene) self.frameCopySelector.addEnabled = 1 self.frameCopySelector.enabled = 0 # do not show "children" of vtkMRMLScalarVolumeNode self.frameCopySelector.hideChildNodeTypes = [ "vtkMRMLDiffusionWeightedVolumeNode", "vtkMRMLDiffusionTensorVolumeNode", "vtkMRMLVectorVolumeNode" ] self.extractFrameCopy = False self.extractFrameCheckBox = QCheckBox('Enable copying') hbox = QHBoxLayout() hbox.addWidget(QLabel('Current frame copy')) hbox.addWidget(self.frameCopySelector) hbox.addWidget(self.extractFrameCheckBox) self.inputFrameLayout.addRow(hbox) def setupPlotSettingsFrame(self): self.plotSettingsFrame = ctk.ctkCollapsibleButton() self.plotSettingsFrame.text = "Plotting Settings" self.plotSettingsFrame.collapsed = 1 plotSettingsFrameLayout = QFormLayout(self.plotSettingsFrame) self.layout.addWidget(self.plotSettingsFrame) # label map for probing self.labelMapSelector = slicer.qMRMLNodeComboBox() self.labelMapSelector.nodeTypes = ['vtkMRMLLabelMapVolumeNode'] self.labelMapSelector.toolTip = 'Label map to be probed' self.labelMapSelector.setMRMLScene(slicer.mrmlScene) self.labelMapSelector.addEnabled = 0 self.chartButton = QPushButton('Chart') self.chartButton.setEnabled(False) hbox = QHBoxLayout() hbox.addWidget(QLabel('Probed label volume')) hbox.addWidget(self.labelMapSelector) hbox.addWidget(self.chartButton) plotSettingsFrameLayout.addRow(hbox) self.iCharting = QCheckBox('Interactive charting') self.iCharting.setChecked(True) plotSettingsFrameLayout.addRow(self.iCharting) self.iChartingMode = QButtonGroup() self.iChartingIntensity = QRadioButton('Signal intensity') self.iChartingIntensityFixedAxes = QRadioButton( 'Fixed range intensity') self.iChartingPercent = QRadioButton('Percentage change') self.iChartingIntensity.setChecked(1) self.iChartingMode.addButton(self.iChartingIntensity) self.iChartingMode.addButton(self.iChartingIntensityFixedAxes) self.iChartingMode.addButton(self.iChartingPercent) hbox = QHBoxLayout() self.plottingModeGroupBox = QGroupBox('Plotting mode:') plottingModeLayout = QVBoxLayout() self.plottingModeGroupBox.setLayout(plottingModeLayout) plottingModeLayout.addWidget(self.iChartingIntensity) plottingModeLayout.addWidget(self.iChartingIntensityFixedAxes) plottingModeLayout.addWidget(self.iChartingPercent) hbox.addWidget(self.plottingModeGroupBox) self.showLegendCheckBox = QCheckBox('Display legend') self.showLegendCheckBox.setChecked(0) self.xLogScaleCheckBox = QCheckBox('Use log scale for X axis') self.xLogScaleCheckBox.setChecked(0) self.yLogScaleCheckBox = QCheckBox('Use log scale for Y axis') self.yLogScaleCheckBox.setChecked(0) self.plotGeneralSettingsGroupBox = QGroupBox('General Plot options:') plotGeneralSettingsLayout = QVBoxLayout() self.plotGeneralSettingsGroupBox.setLayout(plotGeneralSettingsLayout) plotGeneralSettingsLayout.addWidget(self.showLegendCheckBox) plotGeneralSettingsLayout.addWidget(self.xLogScaleCheckBox) plotGeneralSettingsLayout.addWidget(self.yLogScaleCheckBox) hbox.addWidget(self.plotGeneralSettingsGroupBox) plotSettingsFrameLayout.addRow(hbox) self.nFramesBaselineCalculation = QSpinBox() self.nFramesBaselineCalculation.minimum = 1 hbox = QHBoxLayout() hbox.addWidget(QLabel('Frame count(baseline calculation):')) hbox.addWidget(self.nFramesBaselineCalculation) plotSettingsFrameLayout.addRow(hbox) def setupPlottingFrame(self, parent=None): self.plotFrame = ctk.ctkCollapsibleButton() self.plotFrame.text = "Plotting" self.plotFrame.collapsed = 0 plotFrameLayout = QGridLayout(self.plotFrame) self.layout.addWidget(self.plotFrame) qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupPlottingFrame( self, parent=plotFrameLayout) def onDockChartViewToggled(self, checked): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.onDockChartViewToggled( self, checked) if checked: self.layout.removeWidget(self.plotFrame) self.plotFrame.hide() def dockChartView(self): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.dockChartView(self) self.layout.addWidget(self.plotFrame) self.plotFrame.show() def setFramesEnabled(self, enabled): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setFramesEnabled( self, enabled) self.plotSettingsFrame.setEnabled(enabled) self.plotFrame.setEnabled(enabled) self.plotFrame.collapsed = 0 if enabled else 1 def setupConnections(self): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupConnections(self) self.labelMapSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onLabelNodeChanged) self.chartButton.connect('clicked()', self.onLabeledChartRequested) self.xLogScaleCheckBox.connect('stateChanged(int)', self.onXLogScaleRequested) self.yLogScaleCheckBox.connect('stateChanged(int)', self.onYLogScaleRequested) self.nFramesBaselineCalculation.valueChanged.connect( self.onFrameCountBaselineCalculationChanged) self.iChartingMode.buttonClicked.connect(self.onChartingModeChanged) self.showLegendCheckBox.connect('stateChanged(int)', self.onShowLegendChanged) self.fgMultiVolumeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onForegroundInputChanged) self.extractFrameCheckBox.connect('stateChanged(int)', self.onExtractFrameChanged) self.frameCopySelector.connect('mrmlSceneChanged(vtkMRMLScene*)', self.onVFMRMLSceneChanged) def onFrameCountBaselineCalculationChanged(self, value): self._multiVolumeIntensityChart.nFramesForBaselineCalculation = value def onChartingModeChanged(self, button): if button is self.iChartingIntensity: self._multiVolumeIntensityChart.activateSignalIntensityMode() elif button is self.iChartingIntensityFixedAxes: self._multiVolumeIntensityChart.activateFixedRangeIntensityMode() elif button is self.iChartingPercent: self._multiVolumeIntensityChart.activatePercentageChangeMode() def onShowLegendChanged(self, checked): self._multiVolumeIntensityChart.showLegend = True if checked == 2 else False def onXLogScaleRequested(self, checked): self._multiVolumeIntensityChart.showXLogScale = True if checked == 2 else False def onYLogScaleRequested(self, checked): self._multiVolumeIntensityChart.showYLogScale = True if checked == 2 else False def onLVMRMLSceneChanged(self, mrmlScene): self.labelMapSelector.setMRMLScene(slicer.mrmlScene) def onVFMRMLSceneChanged(self, mrmlScene): self.frameCopySelector.setMRMLScene(slicer.mrmlScene) def onLabelNodeChanged(self): labelNode = self.labelMapSelector.currentNode() self.chartButton.setEnabled(labelNode is not None and self._bgMultiVolumeNode is not None) def onForegroundInputChanged(self): logging.info( "qSlicerMultiVolumeExplorerModuleWidget:ForegroundInputChanged") self._fgMultiVolumeNode = self.fgMultiVolumeSelector.currentNode() self._multiVolumeIntensityChart.fgMultiVolumeNode = self.fgMultiVolumeSelector.currentNode( ) self.refreshGUIForNewBackgroundImage() def onBackgroundInputChanged(self): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.onBackgroundInputChanged( self) if self._bgMultiVolumeNode is not None: self.frameCopySelector.setCurrentNode(None) self.nFramesBaselineCalculation.maximum = self._bgMultiVolumeNode.GetNumberOfFrames( ) self.onLabelNodeChanged() ''' If extract button is checked, will copy the current frame to the selected volume node on each event from frame slider ''' def onExtractFrameChanged(self, checked): if checked: self.extractFrameCopy = True self.onSliderChanged(self.frameSlider.value) else: self.extractFrameCopy = False def onSliderChanged(self, frameId): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.onSliderChanged( self, frameId) frameId = int(frameId) if self.extractFrameCopy: frameVolume = self.frameCopySelector.currentNode() frameVolumeCopy = Helper.extractFrame(frameVolume, self._bgMultiVolumeNode, frameId) if not frameVolume: self.frameCopySelector.setCurrentNode(frameVolumeCopy) frameName = '%s frame %d' % (self._bgMultiVolumeNode.GetName(), frameId) frameVolumeCopy.SetName(frameName) def onLabeledChartRequested(self): labelNode = self.labelMapSelector.currentNode() mvNode = self._bgMultiVolumeNode mvLabels = MultiVolumeIntensityChartView.getMultiVolumeLabels( self._bgMultiVolumeNode) chartViewNode = LabeledImageChartView( labelNode=labelNode, multiVolumeNode=mvNode, multiVolumeLabels=mvLabels, baselineFrames=self.nFramesBaselineCalculation, displayPercentageChange=self.iChartingPercent.checked) chartViewNode.requestChartCreation() def processEvent(self, observee, event): if not self.iCharting.checked: return qSlicerMultiVolumeExplorerSimplifiedModuleWidget.processEvent( self, observee, event)
def setupPlotSettingsFrame(self): self.plotSettingsFrame = ctk.ctkCollapsibleButton() self.plotSettingsFrame.text = "Plotting Settings" self.plotSettingsFrame.collapsed = 1 plotSettingsFrameLayout = QFormLayout(self.plotSettingsFrame) self.layout.addWidget(self.plotSettingsFrame) # label map for probing self.labelMapSelector = slicer.qMRMLNodeComboBox() self.labelMapSelector.nodeTypes = ['vtkMRMLLabelMapVolumeNode'] self.labelMapSelector.toolTip = 'Label map to be probed' self.labelMapSelector.setMRMLScene(slicer.mrmlScene) self.labelMapSelector.addEnabled = 0 self.chartButton = QPushButton('Chart') self.chartButton.setEnabled(False) hbox = QHBoxLayout() hbox.addWidget(QLabel('Probed label volume')) hbox.addWidget(self.labelMapSelector) hbox.addWidget(self.chartButton) plotSettingsFrameLayout.addRow(hbox) self.iCharting = QCheckBox('Interactive charting') self.iCharting.setChecked(True) plotSettingsFrameLayout.addRow(self.iCharting) self.iChartingMode = QButtonGroup() self.iChartingIntensity = QRadioButton('Signal intensity') self.iChartingIntensityFixedAxes = QRadioButton('Fixed range intensity') self.iChartingPercent = QRadioButton('Percentage change') self.iChartingIntensity.setChecked(1) self.iChartingMode.addButton(self.iChartingIntensity) self.iChartingMode.addButton(self.iChartingIntensityFixedAxes) self.iChartingMode.addButton(self.iChartingPercent) hbox = QHBoxLayout() self.plottingModeGroupBox = QGroupBox('Plotting mode:') plottingModeLayout = QVBoxLayout() self.plottingModeGroupBox.setLayout(plottingModeLayout) plottingModeLayout.addWidget(self.iChartingIntensity) plottingModeLayout.addWidget(self.iChartingIntensityFixedAxes) plottingModeLayout.addWidget(self.iChartingPercent) hbox.addWidget(self.plottingModeGroupBox) self.showLegendCheckBox = QCheckBox('Display legend') self.showLegendCheckBox.setChecked(0) self.xLogScaleCheckBox = QCheckBox('Use log scale for X axis') self.xLogScaleCheckBox.setChecked(0) self.yLogScaleCheckBox = QCheckBox('Use log scale for Y axis') self.yLogScaleCheckBox.setChecked(0) self.plotGeneralSettingsGroupBox = QGroupBox('General Plot options:') plotGeneralSettingsLayout = QVBoxLayout() self.plotGeneralSettingsGroupBox.setLayout(plotGeneralSettingsLayout) plotGeneralSettingsLayout.addWidget(self.showLegendCheckBox) plotGeneralSettingsLayout.addWidget(self.xLogScaleCheckBox) plotGeneralSettingsLayout.addWidget(self.yLogScaleCheckBox) hbox.addWidget(self.plotGeneralSettingsGroupBox) plotSettingsFrameLayout.addRow(hbox) self.nFramesBaselineCalculation = QSpinBox() self.nFramesBaselineCalculation.minimum = 1 hbox = QHBoxLayout() hbox.addWidget(QLabel('Frame count(baseline calculation):')) hbox.addWidget(self.nFramesBaselineCalculation) plotSettingsFrameLayout.addRow(hbox)
class qSlicerMultiVolumeExplorerModuleWidget(qSlicerMultiVolumeExplorerSimplifiedModuleWidget): def __init__(self, parent=None): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.__init__(self, parent) def setupAdditionalFrames(self): self.setupPlotSettingsFrame() def setupInputFrame(self, parent=None): self.inputFrame = ctk.ctkCollapsibleButton() self.inputFrame.text = "Input" self.inputFrame.collapsed = 0 inputFrameCollapsibleLayout = QFormLayout(self.inputFrame) qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupInputFrame(self, parent=inputFrameCollapsibleLayout) self.layout.addWidget(self.inputFrame) self.fgMultiVolumeSelector = slicer.qMRMLNodeComboBox() self.fgMultiVolumeSelector.nodeTypes = ['vtkMRMLMultiVolumeNode'] self.fgMultiVolumeSelector.setMRMLScene(slicer.mrmlScene) self.fgMultiVolumeSelector.addEnabled = 0 self.fgMultiVolumeSelector.noneEnabled = 1 self.fgMultiVolumeSelector.toolTip = "Secondary multivolume will be used for the secondary \ plot in interactive charting. As an example, this can be used to overlay the \ curve obtained by fitting a model to the data" self.inputFrameLayout.addRow(QLabel('Input secondary multivolume'), self.fgMultiVolumeSelector) def setupFrameControlFrame(self): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupFrameControlFrame(self) self.frameCopySelector = slicer.qMRMLNodeComboBox() self.frameCopySelector.nodeTypes = ['vtkMRMLScalarVolumeNode'] self.frameCopySelector.setMRMLScene(slicer.mrmlScene) self.frameCopySelector.addEnabled = 1 self.frameCopySelector.enabled = 0 # do not show "children" of vtkMRMLScalarVolumeNode self.frameCopySelector.hideChildNodeTypes = ["vtkMRMLDiffusionWeightedVolumeNode", "vtkMRMLDiffusionTensorVolumeNode", "vtkMRMLVectorVolumeNode"] self.extractFrameCopy = False self.extractFrameCheckBox = QCheckBox('Enable copying') hbox = QHBoxLayout() hbox.addWidget(QLabel('Current frame copy')) hbox.addWidget(self.frameCopySelector) hbox.addWidget(self.extractFrameCheckBox) self.inputFrameLayout.addRow(hbox) def setupPlotSettingsFrame(self): self.plotSettingsFrame = ctk.ctkCollapsibleButton() self.plotSettingsFrame.text = "Plotting Settings" self.plotSettingsFrame.collapsed = 1 plotSettingsFrameLayout = QFormLayout(self.plotSettingsFrame) self.layout.addWidget(self.plotSettingsFrame) # label map for probing self.labelMapSelector = slicer.qMRMLNodeComboBox() self.labelMapSelector.nodeTypes = ['vtkMRMLLabelMapVolumeNode'] self.labelMapSelector.toolTip = 'Label map to be probed' self.labelMapSelector.setMRMLScene(slicer.mrmlScene) self.labelMapSelector.addEnabled = 0 self.chartButton = QPushButton('Chart') self.chartButton.setEnabled(False) hbox = QHBoxLayout() hbox.addWidget(QLabel('Probed label volume')) hbox.addWidget(self.labelMapSelector) hbox.addWidget(self.chartButton) plotSettingsFrameLayout.addRow(hbox) self.iCharting = QCheckBox('Interactive charting') self.iCharting.setChecked(True) plotSettingsFrameLayout.addRow(self.iCharting) self.iChartingMode = QButtonGroup() self.iChartingIntensity = QRadioButton('Signal intensity') self.iChartingIntensityFixedAxes = QRadioButton('Fixed range intensity') self.iChartingPercent = QRadioButton('Percentage change') self.iChartingIntensity.setChecked(1) self.iChartingMode.addButton(self.iChartingIntensity) self.iChartingMode.addButton(self.iChartingIntensityFixedAxes) self.iChartingMode.addButton(self.iChartingPercent) hbox = QHBoxLayout() self.plottingModeGroupBox = QGroupBox('Plotting mode:') plottingModeLayout = QVBoxLayout() self.plottingModeGroupBox.setLayout(plottingModeLayout) plottingModeLayout.addWidget(self.iChartingIntensity) plottingModeLayout.addWidget(self.iChartingIntensityFixedAxes) plottingModeLayout.addWidget(self.iChartingPercent) hbox.addWidget(self.plottingModeGroupBox) self.showLegendCheckBox = QCheckBox('Display legend') self.showLegendCheckBox.setChecked(0) self.xLogScaleCheckBox = QCheckBox('Use log scale for X axis') self.xLogScaleCheckBox.setChecked(0) self.yLogScaleCheckBox = QCheckBox('Use log scale for Y axis') self.yLogScaleCheckBox.setChecked(0) self.plotGeneralSettingsGroupBox = QGroupBox('General Plot options:') plotGeneralSettingsLayout = QVBoxLayout() self.plotGeneralSettingsGroupBox.setLayout(plotGeneralSettingsLayout) plotGeneralSettingsLayout.addWidget(self.showLegendCheckBox) plotGeneralSettingsLayout.addWidget(self.xLogScaleCheckBox) plotGeneralSettingsLayout.addWidget(self.yLogScaleCheckBox) hbox.addWidget(self.plotGeneralSettingsGroupBox) plotSettingsFrameLayout.addRow(hbox) self.nFramesBaselineCalculation = QSpinBox() self.nFramesBaselineCalculation.minimum = 1 hbox = QHBoxLayout() hbox.addWidget(QLabel('Frame count(baseline calculation):')) hbox.addWidget(self.nFramesBaselineCalculation) plotSettingsFrameLayout.addRow(hbox) def setupPlottingFrame(self, parent=None): self.plotFrame = ctk.ctkCollapsibleButton() self.plotFrame.text = "Plotting" self.plotFrame.collapsed = 0 plotFrameLayout = QGridLayout(self.plotFrame) self.layout.addWidget(self.plotFrame) qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupPlottingFrame(self, parent=plotFrameLayout) def onDockChartViewToggled(self, checked): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.onDockChartViewToggled(self, checked) if checked: self.layout.removeWidget(self.plotFrame) self.plotFrame.hide() def dockChartView(self): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.dockChartView(self) self.layout.addWidget(self.plotFrame) self.plotFrame.show() def setFramesEnabled(self, enabled): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setFramesEnabled(self, enabled) self.plotSettingsFrame.setEnabled(enabled) self.plotFrame.setEnabled(enabled) self.plotFrame.collapsed = 0 if enabled else 1 def setupConnections(self): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupConnections(self) self.labelMapSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onLabelNodeChanged) self.chartButton.connect('clicked()', self.onLabeledChartRequested) self.xLogScaleCheckBox.connect('stateChanged(int)', self.onXLogScaleRequested) self.yLogScaleCheckBox.connect('stateChanged(int)', self.onYLogScaleRequested) self.nFramesBaselineCalculation.valueChanged.connect(self.onFrameCountBaselineCalculationChanged) self.iChartingMode.buttonClicked.connect(self.onChartingModeChanged) self.showLegendCheckBox.connect('stateChanged(int)', self.onShowLegendChanged) self.fgMultiVolumeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onForegroundInputChanged) self.extractFrameCheckBox.connect('stateChanged(int)', self.onExtractFrameChanged) self.frameCopySelector.connect('mrmlSceneChanged(vtkMRMLScene*)', self.onVFMRMLSceneChanged) def onFrameCountBaselineCalculationChanged(self, value): self._multiVolumeIntensityChart.nFramesForBaselineCalculation = value def onChartingModeChanged(self, button): if button is self.iChartingIntensity: self._multiVolumeIntensityChart.activateSignalIntensityMode() elif button is self.iChartingIntensityFixedAxes: self._multiVolumeIntensityChart.activateFixedRangeIntensityMode() elif button is self.iChartingPercent: self._multiVolumeIntensityChart.activatePercentageChangeMode() def onShowLegendChanged(self, checked): self._multiVolumeIntensityChart.showLegend = True if checked == 2 else False def onXLogScaleRequested(self, checked): self._multiVolumeIntensityChart.showXLogScale = True if checked == 2 else False def onYLogScaleRequested(self, checked): self._multiVolumeIntensityChart.showYLogScale = True if checked == 2 else False def onLVMRMLSceneChanged(self, mrmlScene): self.labelMapSelector.setMRMLScene(slicer.mrmlScene) def onVFMRMLSceneChanged(self, mrmlScene): self.frameCopySelector.setMRMLScene(slicer.mrmlScene) def onLabelNodeChanged(self): labelNode = self.labelMapSelector.currentNode() self.chartButton.setEnabled(labelNode is not None and self._bgMultiVolumeNode is not None) def onForegroundInputChanged(self): logging.info("qSlicerMultiVolumeExplorerModuleWidget:ForegroundInputChanged") self._fgMultiVolumeNode = self.fgMultiVolumeSelector.currentNode() self._multiVolumeIntensityChart.fgMultiVolumeNode = self.fgMultiVolumeSelector.currentNode() self.refreshGUIForNewBackgroundImage() def onBackgroundInputChanged(self): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.onBackgroundInputChanged(self) if self._bgMultiVolumeNode is not None: self.frameCopySelector.setCurrentNode(None) self.nFramesBaselineCalculation.maximum = self._bgMultiVolumeNode.GetNumberOfFrames() self.onLabelNodeChanged() ''' If extract button is checked, will copy the current frame to the selected volume node on each event from frame slider ''' def onExtractFrameChanged(self, checked): if checked: self.extractFrameCopy = True self.onSliderChanged(self.frameSlider.value) else: self.extractFrameCopy = False def onSliderChanged(self, frameId): qSlicerMultiVolumeExplorerSimplifiedModuleWidget.onSliderChanged(self, frameId) frameId = int(frameId) if self.extractFrameCopy: frameVolume = self.frameCopySelector.currentNode() frameVolumeCopy = Helper.extractFrame(frameVolume, self._bgMultiVolumeNode, frameId) if not frameVolume: self.frameCopySelector.setCurrentNode(frameVolumeCopy) frameName = '%s frame %d' % (self._bgMultiVolumeNode.GetName(), frameId) frameVolumeCopy.SetName(frameName) def onLabeledChartRequested(self): labelNode = self.labelMapSelector.currentNode() mvNode = self._bgMultiVolumeNode mvLabels = MultiVolumeIntensityChartView.getMultiVolumeLabels(self._bgMultiVolumeNode) chartViewNode = LabeledImageChartView(labelNode=labelNode, multiVolumeNode=mvNode, multiVolumeLabels=mvLabels, baselineFrames=self.nFramesBaselineCalculation, displayPercentageChange=self.iChartingPercent.checked) chartViewNode.requestChartCreation() def processEvent(self, observee, event): if not self.iCharting.checked: return qSlicerMultiVolumeExplorerSimplifiedModuleWidget.processEvent(self, observee, event)