Beispiel #1
0
    def __init__(self, parent, nombre, lista):
        """el ultimo parametro es la lista de posibles valores"""
        ElementoWidgetOpciones.__init__(self)
        QGroupBox.__init__(self, parent, "ListaSimple")
        self.nombre = nombre
        self.setTitle(nombre)
        self.setColumnLayout(0, Qt.Vertical)
        self.layout().setSpacing(6)
        self.layout().setMargin(11)
        llayout = QVBoxLayout(self.layout())
        llayout.setAlignment(Qt.AlignTop)
        layout12 = QHBoxLayout(None, 0, 6, "layout12")
        label = QLabel(self, "label")
        layout12.addWidget(label)
        spacer7 = QSpacerItem(51, 31, QSizePolicy.Expanding, QSizePolicy.Minimum)
        layout12.addItem(spacer7)
        
        self.combo1 = QComboBox(0, self, "comboBox1")
        layout12.addWidget(self.combo1)
        spacer8 = QSpacerItem(131, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        layout12.addItem(spacer8)
        llayout.addLayout(layout12)


        for elemento in lista:
            self.combo1.insertItem(elemento)    
    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)
Beispiel #4
0
    def __init__(self, parent=None):
        super(InfoWidget, self).__init__()

        empty_str = "__________"

        beam_group = QGroupBox(" Beam ")
        bm_v_layout = QVBoxLayout()

        bm_v_layout.addLayout(get_spacebox(130))

        xb_label = QLabel("  X (mm) ")
        yb_label = QLabel("  Y (mm) ")

        bm_label_a_layout = QHBoxLayout()
        bm_label_a_layout.addWidget(xb_label)
        bm_label_a_layout.addWidget(yb_label)

        bm_v_layout.addLayout(bm_label_a_layout)

        self.xb_data = QLabel(empty_str)
        self.yb_data = QLabel(empty_str)
        bm_data_layout = QHBoxLayout()
        bm_data_layout.addWidget(self.xb_data)
        bm_data_layout.addWidget(self.yb_data)
        bm_v_layout.addLayout(bm_data_layout)

        bm_v_layout.addWidget(QLabel("  "))

        tmp_str = "  Wavelength (" + u"\u212B" + ") "

        w_lambda_label = QLabel(tmp_str)
        bm_v_layout.addWidget(w_lambda_label)
        self.w_lambda_data = QLabel(empty_str)
        bm_v_layout.addWidget(self.w_lambda_data)
        # bm_v_layout.addWidget(QLabel("  "))

        # bm_v_layout.addStretch()
        beam_group.setLayout(bm_v_layout)

        cell_group = QGroupBox(" Crystal ")
        cell_v_layout = QVBoxLayout()
        cell_v_layout.addLayout(get_spacebox(160))

        a_label = QLabel("    a ")
        b_label = QLabel("    b ")
        c_label = QLabel("    c ")
        cell_label_d_layout = QHBoxLayout()
        cell_label_d_layout.addWidget(a_label)
        cell_label_d_layout.addWidget(b_label)
        cell_label_d_layout.addWidget(c_label)
        cell_v_layout.addLayout(cell_label_d_layout)

        self.a_data = QLabel(empty_str)
        self.b_data = QLabel(empty_str)
        self.c_data = QLabel(empty_str)
        cell_data_layout = QHBoxLayout()
        cell_data_layout.addWidget(self.a_data)
        cell_data_layout.addWidget(self.b_data)
        cell_data_layout.addWidget(self.c_data)
        cell_v_layout.addLayout(cell_data_layout)
        cell_v_layout.addWidget(QLabel("  "))

        left_margin_str = "    "
        alpha_str = left_margin_str + u"\u03B1"
        beta_str = left_margin_str + u"\u03B2"
        gamma_str = left_margin_str + u"\u03B3"

        alpha_label = QLabel(alpha_str)
        beta_label = QLabel(beta_str)
        gamma_label = QLabel(gamma_str)

        cell_label_a_layout = QHBoxLayout()
        cell_label_a_layout.addWidget(alpha_label)
        cell_label_a_layout.addWidget(beta_label)
        cell_label_a_layout.addWidget(gamma_label)
        cell_v_layout.addLayout(cell_label_a_layout)

        self.alpha_data = QLabel(empty_str)
        self.beta_data = QLabel(empty_str)
        self.gamma_data = QLabel(empty_str)
        cell_data_layout = QHBoxLayout()
        cell_data_layout.addWidget(self.alpha_data)
        cell_data_layout.addWidget(self.beta_data)
        cell_data_layout.addWidget(self.gamma_data)
        cell_v_layout.addLayout(cell_data_layout)

        cell_v_layout.addWidget(QLabel("  "))

        spgrp_label = QLabel(" Space Group")
        self.spgrp_data = QLabel(empty_str)
        spgrp_hbox = QHBoxLayout()
        spgrp_hbox.addWidget(spgrp_label)
        spgrp_hbox.addWidget(self.spgrp_data)
        cell_v_layout.addLayout(spgrp_hbox)

        r_layout = QVBoxLayout()
        r_layout.addWidget(QLabel("  "))
        r_layout.addWidget(QLabel(" Orientation (deg) "))

        r_label_layout = QHBoxLayout()
        r1_label = QLabel(" rot X")
        r2_label = QLabel(" rot Y")
        r3_label = QLabel(" rot Z")
        r_label_layout.addWidget(r1_label)
        r_label_layout.addWidget(r2_label)
        r_label_layout.addWidget(r3_label)

        r_data_layout = QHBoxLayout()
        self.r1_data = QLabel(empty_str)
        self.r2_data = QLabel(empty_str)
        self.r3_data = QLabel(empty_str)
        r_data_layout.addWidget(self.r1_data)
        r_data_layout.addWidget(self.r2_data)
        r_data_layout.addWidget(self.r3_data)

        r_layout.addLayout(r_label_layout)
        r_layout.addLayout(r_data_layout)

        crys_v_layout = QVBoxLayout()
        crys_v_layout.addLayout(cell_v_layout)
        crys_v_layout.addLayout(r_layout)
        # crys_v_layout.addStretch()
        cell_group.setLayout(crys_v_layout)

        scan_group = QGroupBox(" Scan ")

        scan_v_layout = QVBoxLayout()
        scan_v_layout.addLayout(get_spacebox(180))
        scan_v_layout.addWidget(QLabel(" Image Range "))

        img_ran_h_layout = QHBoxLayout()
        img_ran1_v_layout = QVBoxLayout()
        # img_ran1_label = QLabel(" from")
        self.img_ran1_data = QLabel(empty_str)
        # img_ran1_v_layout.addWidget(img_ran1_label)
        img_ran1_v_layout.addWidget(self.img_ran1_data)

        img_ran2_v_layout = QVBoxLayout()
        # img_ran2_label = QLabel(" to")
        self.img_ran2_data = QLabel(empty_str)
        # img_ran2_v_layout.addWidget(img_ran2_label)
        img_ran2_v_layout.addWidget(self.img_ran2_data)

        img_ran_h_layout.addLayout(img_ran1_v_layout)
        img_ran_h_layout.addLayout(img_ran2_v_layout)

        scan_v_layout.addLayout(img_ran_h_layout)

        scan_v_layout.addWidget(QLabel("  "))

        oscil_h_layout = QHBoxLayout()
        oscil1_v_layout = QVBoxLayout()
        oscil_h_layout.addWidget(QLabel("Oscillation "))

        oscil2_v_layout = QVBoxLayout()
        # oscil2_label = QLabel(" to ")
        self.oscil2_data = QLabel(empty_str)
        # oscil2_v_layout.addWidget(oscil2_label)
        oscil2_v_layout.addWidget(self.oscil2_data)

        oscil_h_layout.addLayout(oscil1_v_layout)
        oscil_h_layout.addLayout(oscil2_v_layout)
        scan_v_layout.addLayout(oscil_h_layout)

        e_time_label = QLabel("Exposure Time")
        self.e_time_data = QLabel(empty_str)
        e_time_hbox = QHBoxLayout()
        e_time_hbox.addWidget(e_time_label)
        e_time_hbox.addWidget(self.e_time_data)
        scan_v_layout.addLayout(e_time_hbox)

        scan_v_layout.addWidget(QLabel("  "))
        strn_sp_label = QLabel("Strong Spots")
        self.strn_sp_data = QLabel(empty_str)
        strn_hbox = QHBoxLayout()
        strn_hbox.addWidget(strn_sp_label)
        strn_hbox.addWidget(self.strn_sp_data)
        scan_v_layout.addLayout(strn_hbox)

        # scan_v_layout.addWidget(QLabel("  "))
        indx_sp_label = QLabel("Indexed Spots")
        self.indx_sp_data = QLabel(empty_str)
        indx_hbox = QHBoxLayout()
        indx_hbox.addWidget(indx_sp_label)
        indx_hbox.addWidget(self.indx_sp_data)
        scan_v_layout.addLayout(indx_hbox)

        # scan_v_layout.addWidget(QLabel("  "))
        refn_sp_label = QLabel("Refined Spots")
        self.refn_sp_data = QLabel(empty_str)
        refn_hbox = QHBoxLayout()
        refn_hbox.addWidget(refn_sp_label)
        refn_hbox.addWidget(self.refn_sp_data)
        scan_v_layout.addLayout(refn_hbox)

        # scan_v_layout.addWidget(QLabel("  "))
        itgr_prf_label = QLabel("Prof int Spots")
        self.itgr_prf_data = QLabel(empty_str)
        itgr_prf_hbox = QHBoxLayout()
        itgr_prf_hbox.addWidget(itgr_prf_label)
        itgr_prf_hbox.addWidget(self.itgr_prf_data)
        scan_v_layout.addLayout(itgr_prf_hbox)

        # scan_v_layout.addWidget(QLabel("  "))
        itgr_sum_label = QLabel("Sum int Spots")
        self.itgr_sum_data = QLabel(empty_str)
        itgr_sum_hbox = QHBoxLayout()
        itgr_sum_hbox.addWidget(itgr_sum_label)
        itgr_sum_hbox.addWidget(self.itgr_sum_data)
        scan_v_layout.addLayout(itgr_sum_hbox)

        scan_v_layout.addStretch()
        scan_group.setLayout(scan_v_layout)

        detec_group = QGroupBox(" Detector ")
        detec_v_layout = QVBoxLayout()
        detec_v_layout.addLayout(get_spacebox(160))

        # detec_v_layout.addWidget(QLabel("  "))
        d_dist_label = QLabel(" Distance (mm)")

        self.d_dist_data = QLabel(empty_str)
        d_dist_hbox = QHBoxLayout()
        d_dist_hbox.addWidget(d_dist_label)
        d_dist_hbox.addWidget(self.d_dist_data)
        detec_v_layout.addLayout(d_dist_hbox)

        # detec_v_layout.addWidget(QLabel("  "))
        n_pans_label = QLabel(" Number of Panels ")
        self.n_pans_data = QLabel(empty_str)
        n_pans_hbox = QHBoxLayout()
        n_pans_hbox.addWidget(n_pans_label)
        n_pans_hbox.addWidget(self.n_pans_data)
        detec_v_layout.addLayout(n_pans_hbox)

        # detec_v_layout.addWidget(QLabel("  "))
        gain_label = QLabel(" Gain ")
        self.gain_data = QLabel(empty_str)
        gain_hbox = QHBoxLayout()
        gain_hbox.addWidget(gain_label)
        gain_hbox.addWidget(self.gain_data)
        detec_v_layout.addLayout(gain_hbox)

        # detec_v_layout.addWidget(QLabel("  "))
        max_res_label = QLabel(" Max res (" + u"\u212B" + ")")
        self.max_res_data = QLabel(empty_str)
        max_res_hbox = QHBoxLayout()
        max_res_hbox.addWidget(max_res_label)
        max_res_hbox.addWidget(self.max_res_data)
        detec_v_layout.addLayout(max_res_hbox)

        detec_v_layout.addWidget(QLabel("  "))
        pix_size_label = QLabel(" Pixel Size ")
        detec_v_layout.addWidget(pix_size_label)

        px_h_layout = QHBoxLayout()

        px_x_v_layout = QVBoxLayout()
        x_px_size_label = QLabel(" X (mm)")
        self.x_px_size_data = QLabel(empty_str)
        px_x_v_layout.addWidget(x_px_size_label)
        px_x_v_layout.addWidget(self.x_px_size_data)

        px_y_v_layout = QVBoxLayout()
        y_px_size_label = QLabel(" Y (mm)")
        self.y_px_size_data = QLabel(empty_str)
        px_y_v_layout.addWidget(y_px_size_label)
        px_y_v_layout.addWidget(self.y_px_size_data)

        px_h_layout.addLayout(px_x_v_layout)
        px_h_layout.addLayout(px_y_v_layout)

        detec_v_layout.addLayout(px_h_layout)

        # detec_v_layout.addWidget(QLabel("  "))
        # detec_v_layout.addStretch()
        detec_group.setLayout(detec_v_layout)

        left_big_box = QHBoxLayout()
        left_big_box.addWidget(beam_group)
        left_big_box.addWidget(cell_group)
        left_big_box.addStretch()

        right_big_box = QHBoxLayout()
        right_big_box.addWidget(detec_group)
        right_big_box.addWidget(scan_group)
        right_big_box.addStretch()

        inner_main_h_box = QVBoxLayout()
        inner_main_h_box.addLayout(left_big_box)
        inner_main_h_box.addLayout(right_big_box)

        self.my_json_path = None
        self.my_pikl_path = None

        self.update_data(exp_json_path=self.my_json_path,
                         refl_pikl_path=self.my_pikl_path)

        self.my_scrollable = QScrollArea()
        tmp_widget = QWidget()
        tmp_widget.setLayout(inner_main_h_box)
        self.my_scrollable.setWidget(tmp_widget)

        main_v_box = QVBoxLayout()
        main_v_box.addWidget(self.my_scrollable)

        self.setLayout(main_v_box)
    def new_stuff(self):
        # fullscreen group
        self.fullscreen_groupbox = VerticalGroupBox(self, 'Fullscreen Options')
        self.fullscreen_groupbox.setColumns(2)
        self.grid.addWidget(self.fullscreen_groupbox, 0, 0)
        self.fullscreen_check = QCheckBox(self.fullscreen_groupbox)
        self.fullscreen_check.setText('fullscreen')
        self.tooltips.add(self.fullscreen_check, "Run dosbox in fullscreen")
        self.fulldouble_check = QCheckBox(self.fullscreen_groupbox)
        self.fulldouble_check.setText('full&double')
        self.tooltips.add(self.fulldouble_check, "Use double buffering in fullscreen")
        
        # resolution group
        self.resolution_groupbox = VerticalGroupBox(self, 'Resolution Options')
        self.resolution_groupbox.setColumns(4)
        self.grid.addWidget(self.resolution_groupbox, 0, 1)
        self.fullresolution_box = ConfigComboBoxWidget(self.resolution_groupbox,
                                                       'fullscreen resolution', self._default_resolutions)
        self.tooltips.add(self.fullresolution_box, "Resolution when running in fullscreen")

        self.windowresolution_box = ConfigComboBoxWidget(self.resolution_groupbox,
                                                         'windowed resolution', self._default_resolutions)
        self.tooltips.add(self.windowresolution_box, "Resolution when running in a window")
        
        # misc group
        self.misc_groupbox = VerticalGroupBox(self, 'Misc. Options')
        self.misc_groupbox.setColumns(3)
        self.grid.addWidget(self.misc_groupbox, 1, 0)
        self.output_box = ConfigComboBoxWidget(self.misc_groupbox,
                                               'Output', self._default_outputs)
        self.waitonerror_check = QCheckBox(self.misc_groupbox)
        self.waitonerror_check.setText('Wait on error')
        self.tooltips.add(self.waitonerror_check,
                          "Wait before closing window if dosbox has an error")
        
        # mouse group
        self.mouse_groupbox = VerticalGroupBox(self, 'Mouse Options')
        self.mouse_groupbox.setColumns(3)
        self.grid.addWidget(self.mouse_groupbox, 1, 1)
        self.autolock_check = QCheckBox(self.mouse_groupbox)
        self.autolock_check.setText('autolock')
        self.tooltips.add(self.autolock_check,
                          "Clicking in the dosbox window automatically locks mouse")
        self.sensitivity_box = ConfigSpinWidget(self.mouse_groupbox,
                                                'Mouse sensitivity', min=1, max=100,
                                                suffix='%')
        self.tooltips.add(self.sensitivity_box, "How sensitive the mouse is")

        # keyboard group
        self.keyboard_groupbox = VerticalGroupBox(self, 'Keyboard Options')
        self.keyboard_groupbox.setColumns(3)
        # add to row 2, first two columns
        self.grid.addMultiCellWidget(self.keyboard_groupbox, 2, 2, 0, 1)
        self.usescancodes_check = QCheckBox(self.keyboard_groupbox)
        self.usescancodes_check.setText('usescancodes')
        self.tooltips.add(self.usescancodes_check,
                          "Avoid use of symkeys")
        self.mapper_entry = ConfigKURLSelectWidget(self.keyboard_groupbox,
                                                   'mapperfile (File used for key mappings)')
        self.tooltips.add(self.mapper_entry, "File used for key mappings")


        # priority group
        self.priority_groupbox = QGroupBox(self)
        self.priority_groupbox.setTitle('Priority Options')
        self.priority_groupbox.setColumns(2)
        #self.grid.addWidget(self.priority_groupbox, 3, 0)
        # add to row 3 first two columns
        self.grid.addMultiCellWidget(self.priority_groupbox, 3, 3, 0, 1)
        self.focused_box = ConfigComboBoxWidget(self.priority_groupbox,
                                                'focused', self._default_priorities)
        self.tooltips.add(self.focused_box, "Priority level for dosbox when focused")
        self.unfocused_box = ConfigComboBoxWidget(self.priority_groupbox,
                                                  'unfocused', self._default_priorities)
        self.tooltips.add(self.unfocused_box,
                          "Priority level for dosbox when unfocused or minimized")
class SDLConfigWidget(BaseDosboxConfigWidget):
    def __init__(self, parent, name='SDLConfigWidget'):
        BaseDosboxConfigWidget.__init__(self, parent, name=name)
        numrows = 2
        numcols = 2
        margin = 0
        space = 1
        self.grid = QGridLayout(self, numrows, numcols,
                                margin, space, 'SDLConfigWidgetLayout')
        self.myconfig = self.app.myconfig
        res = self.myconfig.get('dosbox_profiles', 'default_resolutions')
        resolutions = [r.strip() for r in res.split(',')]
        self._default_resolutions = ['original'] + resolutions
        self._default_outputs = ['surface', 'overlay', 'opengl', 'openglnb', 'ddraw']
        self._default_priorities = ['lowest', 'lower', 'normal', 'higher', 'highest']
        self.new_stuff()
        self.localconfig.add_section('sdl')
        
    def new_stuff(self):
        # fullscreen group
        self.fullscreen_groupbox = VerticalGroupBox(self, 'Fullscreen Options')
        self.fullscreen_groupbox.setColumns(2)
        self.grid.addWidget(self.fullscreen_groupbox, 0, 0)
        self.fullscreen_check = QCheckBox(self.fullscreen_groupbox)
        self.fullscreen_check.setText('fullscreen')
        self.tooltips.add(self.fullscreen_check, "Run dosbox in fullscreen")
        self.fulldouble_check = QCheckBox(self.fullscreen_groupbox)
        self.fulldouble_check.setText('full&double')
        self.tooltips.add(self.fulldouble_check, "Use double buffering in fullscreen")
        
        # resolution group
        self.resolution_groupbox = VerticalGroupBox(self, 'Resolution Options')
        self.resolution_groupbox.setColumns(4)
        self.grid.addWidget(self.resolution_groupbox, 0, 1)
        self.fullresolution_box = ConfigComboBoxWidget(self.resolution_groupbox,
                                                       'fullscreen resolution', self._default_resolutions)
        self.tooltips.add(self.fullresolution_box, "Resolution when running in fullscreen")

        self.windowresolution_box = ConfigComboBoxWidget(self.resolution_groupbox,
                                                         'windowed resolution', self._default_resolutions)
        self.tooltips.add(self.windowresolution_box, "Resolution when running in a window")
        
        # misc group
        self.misc_groupbox = VerticalGroupBox(self, 'Misc. Options')
        self.misc_groupbox.setColumns(3)
        self.grid.addWidget(self.misc_groupbox, 1, 0)
        self.output_box = ConfigComboBoxWidget(self.misc_groupbox,
                                               'Output', self._default_outputs)
        self.waitonerror_check = QCheckBox(self.misc_groupbox)
        self.waitonerror_check.setText('Wait on error')
        self.tooltips.add(self.waitonerror_check,
                          "Wait before closing window if dosbox has an error")
        
        # mouse group
        self.mouse_groupbox = VerticalGroupBox(self, 'Mouse Options')
        self.mouse_groupbox.setColumns(3)
        self.grid.addWidget(self.mouse_groupbox, 1, 1)
        self.autolock_check = QCheckBox(self.mouse_groupbox)
        self.autolock_check.setText('autolock')
        self.tooltips.add(self.autolock_check,
                          "Clicking in the dosbox window automatically locks mouse")
        self.sensitivity_box = ConfigSpinWidget(self.mouse_groupbox,
                                                'Mouse sensitivity', min=1, max=100,
                                                suffix='%')
        self.tooltips.add(self.sensitivity_box, "How sensitive the mouse is")

        # keyboard group
        self.keyboard_groupbox = VerticalGroupBox(self, 'Keyboard Options')
        self.keyboard_groupbox.setColumns(3)
        # add to row 2, first two columns
        self.grid.addMultiCellWidget(self.keyboard_groupbox, 2, 2, 0, 1)
        self.usescancodes_check = QCheckBox(self.keyboard_groupbox)
        self.usescancodes_check.setText('usescancodes')
        self.tooltips.add(self.usescancodes_check,
                          "Avoid use of symkeys")
        self.mapper_entry = ConfigKURLSelectWidget(self.keyboard_groupbox,
                                                   'mapperfile (File used for key mappings)')
        self.tooltips.add(self.mapper_entry, "File used for key mappings")


        # priority group
        self.priority_groupbox = QGroupBox(self)
        self.priority_groupbox.setTitle('Priority Options')
        self.priority_groupbox.setColumns(2)
        #self.grid.addWidget(self.priority_groupbox, 3, 0)
        # add to row 3 first two columns
        self.grid.addMultiCellWidget(self.priority_groupbox, 3, 3, 0, 1)
        self.focused_box = ConfigComboBoxWidget(self.priority_groupbox,
                                                'focused', self._default_priorities)
        self.tooltips.add(self.focused_box, "Priority level for dosbox when focused")
        self.unfocused_box = ConfigComboBoxWidget(self.priority_groupbox,
                                                  'unfocused', self._default_priorities)
        self.tooltips.add(self.unfocused_box,
                          "Priority level for dosbox when unfocused or minimized")
        
    def set_config(self, configobj):
        self.mainconfig = configobj
        # some assignments to help with typing
        sdl = 'sdl'
        cfg = self.mainconfig
        # set the various config widgets
        fullscreen = cfg.getboolean(sdl, 'fullscreen')
        self.fullscreen_check.setChecked(fullscreen)
        fulldouble = cfg.getboolean(sdl, 'fulldouble')
        self.fulldouble_check.setChecked(fulldouble)
        fullresolution = cfg.get(sdl, 'fullresolution')
        self.fullresolution_box.set_config_option(fullresolution)
        windowresolution = cfg.get(sdl, 'windowresolution')
        self.windowresolution_box.set_config_option(windowresolution)
        output = cfg.get(sdl, 'output')
        self.output_box.set_config_option(output)
        waitonerror = cfg.getboolean(sdl, 'waitonerror')
        self.waitonerror_check.setChecked(waitonerror)
        autolock = cfg.getboolean(sdl, 'autolock')
        self.autolock_check.setChecked(autolock)
        sensitivity = cfg.getint(sdl, 'sensitivity')
        self.sensitivity_box.set_config_option(sensitivity)
        usescancodes = cfg.getboolean(sdl, 'usescancodes')
        self.usescancodes_check.setChecked(usescancodes)
        mapperfile = cfg.get(sdl, 'mapperfile')
        self.mapper_entry.set_config_option(mapperfile)
        priorities = cfg.get(sdl, 'priority')
        focused, unfocused = [p.strip() for p in priorities.split(',')]
        self.focused_box.set_config_option(focused)
        self.unfocused_box.set_config_option(unfocused)

    def get_config(self):
        # some assignments to help with typing
        sdl = 'sdl'
        cfg = self.localconfig
        # get config values from the various widgets
        fullscreen = self._get_bool_for_config(self.fullscreen_check)
        cfg.set(sdl, 'fullscreen', fullscreen)
        fulldouble = self._get_bool_for_config(self.fulldouble_check)
        cfg.set(sdl, 'fulldouble', fulldouble)
        fullresolution = self.fullresolution_box.get_config_option()
        cfg.set(sdl, 'fullresolution', fullresolution)
        windowresolution = self.windowresolution_box.get_config_option()
        cfg.set(sdl, 'windowresolution', windowresolution)
        output = self.output_box.get_config_option()
        cfg.set(sdl, 'output', output)
        waitonerror = self._get_bool_for_config(self.waitonerror_check)
        cfg.set(sdl, 'waitonerror', waitonerror)
        autolock = self._get_bool_for_config(self.autolock_check)
        cfg.set(sdl, 'autolock', autolock)
        sensitivity = self.sensitivity_box.get_config_option()
        cfg.set(sdl, 'sensitivity', sensitivity)
        usescancodes = self._get_bool_for_config(self.usescancodes_check)
        cfg.set(sdl, 'usescancodes', usescancodes)
        mapperfile = self.mapper_entry.get_config_option()
        cfg.set(sdl, 'mapperfile', mapperfile)
        # priorities part
        focused = self.focused_box.get_config_option()
        unfocused = self.unfocused_box.get_config_option()
        priority = ','.join([focused, unfocused])
        cfg.set(sdl, 'priority', priority)
        return self.localconfig
  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)
 def __init__(self, parent, title):
     QGroupBox.__init__(self, parent)
     self.setTitle(title)
     self.setOrientation(self.Vertical)