class Dialog(QDialog): def __init__(self, names, values, message='', title=''): assert len(names) == len(values) super(Dialog, self).__init__() if title: self.setWindowTitle(title) self.names = names self.values = values self.message_label = QLabel(message) self.buttons_layout = QVBoxLayout() self.button_group = QButtonGroup(self) for i, button_name in enumerate(self.names, start=1): button = QPushButton(button_name) self.button_group.addButton(button, i) self.buttons_layout.addWidget(button) self.layout = QVBoxLayout() self.layout.addWidget(self.message_label) self.layout.addLayout(self.buttons_layout) self.setLayout(self.layout) self.button_group.buttonClicked.connect(self.button_clicked_slot) def button_clicked_slot(self, button): self.done(self.button_group.id(button)) def get_button_name(self, button_id): return self.names[button_id - 1] def get_button_value(self, button_id): return self.values[button_id - 1]
def insert(self, boton): """Añade un boton. Redefine la clase base""" QButtonGroup.insert(self, boton) self.layout.addWidget(boton, self.__row, self.__col) if self.__col == 0: self.__col = 1 else: self.__row += 1 self.__col = 0
def __init__(self, parent): QButtonGroup.__init__(self, parent, "SeleccionMultiple") self.setGeometry(QRect(110, 80, 170, 121)) self.setColumnLayout(0, Qt.Vertical) self.layout().setSpacing(6) self.layout().setMargin(11) self.layout = QGridLayout(self.layout(), 2) self.__row = 0 self.__col = 0
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)