Esempio n. 1
0
    def create(self, widgetType='window', showHeader=False, showPreview=False):
        """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific 
    extra widgets
    """

        # find internals of widget for reference and repacking
        self.toolBar = slicer.util.findChildren(self.dicomApp, 'ToolBar')[0]
        self.databaseNameLabel = slicer.util.findChildren(
            self.dicomApp, 'DatabaseNameLabel')[0]
        self.databaseDirectoryButton = slicer.util.findChildren(
            self.dicomApp, 'DirectoryButton')[0]
        self.tree = slicer.util.findChildren(self.dicomApp, 'TreeView')[0]
        self.userFrame = slicer.util.findChildren(self.dicomApp,
                                                  'UserFrame')[0]
        self.thumbs = slicer.util.findChildren(self.dicomApp,
                                               'ThumbnailsWidget')[0]
        self.widthSlider = slicer.util.findChildren(self.dicomApp,
                                                    'ThumbnailWidthSlider')[0]
        self.preview = slicer.util.findChildren(self.dicomApp,
                                                'PreviewFrame')[0]

        self.widgetType = widgetType
        if widgetType == 'dialog':
            self.window = qt.QDialog(self.dicomApp)
        elif widgetType == 'window':
            self.window = qt.QWidget()
        elif widgetType == 'popup':
            self.window = ctk.ctkPopupWidget(self.dicomApp)
            self.window.orientation = 1
            self.window.horizontalDirection = 0
            self.window.alignment = 0x82
        elif widgetType == 'dock':
            self.dock = qt.QDockWidget(slicer.util.mainWindow())
            self.dock.setFeatures(qt.QDockWidget.DockWidgetFloatable
                                  | qt.QDockWidget.DockWidgetMovable
                                  | qt.QDockWidget.DockWidgetClosable)
            slicer.util.mainWindow().addDockWidget(0x15, self.dock)
            self.window = qt.QFrame()
            self.dock.setWidget(self.window)
        else:
            raise "Unknown widget type - should be dialog, window, dock or popup"

        self.window.setWindowTitle('DICOM Details')

        self.layout = qt.QGridLayout()
        self.window.setLayout(self.layout)

        # overall layout - tree on top, preview and selection below
        toolRow = 0
        treeRow = 1
        selectionRow = 2

        # tool row at top, with commands and database
        self.toolLayout = qt.QHBoxLayout()
        self.layout.addLayout(self.toolLayout, toolRow, 0, 1, 2)
        self.toolLayout.addWidget(self.toolBar)
        self.toolLayout.addWidget(self.databaseNameLabel)
        self.toolLayout.addWidget(self.databaseDirectoryButton)

        # tree goes next, spread across 1 row, 2 columns
        self.layout.addWidget(self.tree, treeRow, 0, 1, 2)

        #
        # preview related column
        #
        self.previewLayout = qt.QVBoxLayout()
        self.layout.addLayout(self.previewLayout, selectionRow, 0)

        self.previewLayout.addWidget(self.thumbs)
        self.previewLayout.addWidget(self.widthSlider)
        if showPreview:
            self.previewLayout.addWidget(self.preview)
        else:
            self.preview.hide()

        #
        # action related column (interacting with slicer)
        #
        self.actionLayout = qt.QVBoxLayout()
        self.layout.addLayout(self.actionLayout, selectionRow, 1)
        self.actionLayout.addWidget(self.userFrame)

        tableWidth = 350 if showHeader else 700
        self.loadableTable = DICOMLoadableTable(self.userFrame,
                                                width=tableWidth)
        self.actionLayout.addWidget(self.loadableTable.widget)

        #
        # button row for action column
        #
        self.actionButtonLayout = qt.QHBoxLayout()
        self.actionLayout.addLayout(self.actionButtonLayout)

        self.uncheckAllButton = qt.QPushButton('Uncheck All')
        self.actionButtonLayout.addWidget(self.uncheckAllButton)
        self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables)

        self.loadButton = qt.QPushButton('Load Selection to Slicer')
        self.loadButton.enabled = False
        self.actionButtonLayout.addWidget(self.loadButton)
        self.loadButton.connect('clicked()', self.loadCheckedLoadables)

        self.closeButton = qt.QPushButton('Close')
        self.actionButtonLayout.addWidget(self.closeButton)
        self.closeButton.connect('clicked()', self.close)

        if self.setBrowserPersistence:
            self.browserPersistentButton = qt.QCheckBox(
                'Make DICOM Browser Persistent')
            self.browserPersistentButton.toolTip = 'When enabled, DICOM Broswer remains open and usable after leaving DICOM module'
            self.actionLayout.addWidget(self.browserPersistentButton)
            self.browserPersistentButton.connect('stateChanged(int)',
                                                 self.setBrowserPersistence)

        #
        # header related column (more details about the selected file)
        #
        if showHeader:
            self.headerLayout = qt.QVBoxLayout()
            self.layout.addLayout(self.headerLayout, selectionRow, 2)
            self.header = DICOMHeaderWidget(self.window)
            self.headerLayout.addWidget(self.header.widget)
Esempio n. 2
0
    def create(self, widgetType="window", showHeader=False, showPreview=False):
        """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific
    extra widgets
    """

        # find internals of widget for reference and repacking
        self.toolBar = slicer.util.findChildren(self.dicomBrowser, "ToolBar")[0]
        self.databaseNameLabel = slicer.util.findChildren(self.dicomBrowser, "DatabaseNameLabel")[0]
        self.databaseDirectoryButton = slicer.util.findChildren(self.dicomBrowser, "DirectoryButton")[0]
        # self.tables = self.dicomBrowser.tableManager
        self.tables = slicer.util.findChildren(self.dicomBrowser, "dicomTableManager")[0]

        # self.userFrame = slicer.util.findChildren(self.dicomBrowser, 'UserFrame')[0]
        self.userFrame = qt.QWidget()
        # self.thumbs = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailsWidget')[0]
        # self.widthSlider = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailWidthSlider')[0]
        self.preview = qt.QWidget()

        self.widgetType = widgetType
        if widgetType == "dialog":
            self.window = qt.QDialog(self.dicomBrowser)
        elif widgetType == "window":
            self.window = qt.QWidget()
        elif widgetType == "popup":
            self.window = ctk.ctkPopupWidget(self.dicomBrowser)
            self.window.orientation = 1
            self.window.horizontalDirection = 0
            self.window.alignment = 0x82
        elif widgetType == "dock":
            self.dock = qt.QDockWidget(slicer.util.mainWindow())
            self.dock.setFeatures(
                qt.QDockWidget.DockWidgetFloatable
                | qt.QDockWidget.DockWidgetMovable
                | qt.QDockWidget.DockWidgetClosable
            )
            slicer.util.mainWindow().addDockWidget(0x15, self.dock)
            self.window = qt.QFrame()
            self.dock.setWidget(self.window)
        else:
            raise "Unknown widget type - should be dialog, window, dock or popup"

        self.window.setWindowTitle("DICOM Browser")

        self.layout = qt.QVBoxLayout()
        self.window.setLayout(self.layout)

        # tool row at top, with commands and database
        self.toolFrame = qt.QWidget()
        self.toolLayout = qt.QHBoxLayout(self.toolFrame)
        self.layout.addWidget(self.toolFrame)
        self.toolLayout.addWidget(self.toolBar)
        self.toolLayout.addWidget(self.databaseNameLabel)
        self.toolLayout.addWidget(self.databaseDirectoryButton)

        # tables goes next, spread across 1 row, 2 columns
        self.tables.tableOrientation = self.tableOrientation
        self.tables.dynamicTableLayout = False
        self.tablesExpandableWidget = ctk.ctkExpandableWidget()
        self.layout.addWidget(self.tablesExpandableWidget)
        self.tablesLayout = qt.QVBoxLayout(self.tablesExpandableWidget)

        self.tablesLayout.addWidget(self.tables)

        #
        # preview related column
        #
        self.previewLayout = qt.QVBoxLayout()
        # self.layout.addLayout(self.previewLayout,selectionRow,0)

        # self.previewLayout.addWidget(self.thumbs)
        # self.previewLayout.addWidget(self.widthSlider)
        if showPreview:
            self.previewLayout.addWidget(self.preview)
        else:
            self.preview.hide()

        #
        # action related column (interacting with slicer)
        #
        self.loadableTableFrame = qt.QWidget()
        self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame)
        self.layout.addWidget(self.loadableTableFrame)

        self.loadableTableLayout.addWidget(self.userFrame)
        self.userFrame.hide()

        tableWidth = 350 if showHeader else 700
        self.loadableTable = DICOMLoadableTable(self.userFrame, width=tableWidth)
        # self.loadableTableLayout.addWidget(self.loadableTable.widget)
        # self.loadableTable.widget.hide()

        #
        # button row for action column
        #
        self.actionButtonsFrame = qt.QWidget()
        self.layout.addWidget(self.actionButtonsFrame)
        self.layout.addStretch(1)
        self.actionButtonLayout = qt.QHBoxLayout()
        self.actionButtonsFrame.setLayout(self.actionButtonLayout)

        self.loadButton = qt.QPushButton("Load")
        self.loadButton.enabled = True
        self.loadButton.toolTip = "Load Selection to Slicer"
        self.actionButtonLayout.addWidget(self.loadButton)
        self.loadButton.connect("clicked()", self.loadCheckedLoadables)

        self.headerPopup = DICOMLib.DICOMHeaderPopup()

        self.viewMetadataButton = qt.QPushButton("Metadata")
        self.viewMetadataButton.toolTip = "Display Metadata of the Selected Series"
        self.viewMetadataButton.enabled = False
        self.actionButtonLayout.addWidget(self.viewMetadataButton)
        self.viewMetadataButton.connect("clicked()", self.onViewHeaderButton)
        self.viewMetadataButton.connect("clicked()", self.headerPopup.open)
        self.actionButtonLayout.addStretch(1)

        self.examineButton = qt.QPushButton("Examine")
        self.actionButtonLayout.addWidget(self.examineButton)
        self.examineButton.enabled = False
        self.examineButton.connect("clicked()", self.examineForLoading)

        self.uncheckAllButton = qt.QPushButton("Uncheck All")
        self.actionButtonLayout.addWidget(self.uncheckAllButton)
        self.uncheckAllButton.connect("clicked()", self.uncheckAllLoadables)
        self.actionButtonLayout.addStretch(1)

        self.closeButton = qt.QPushButton("Close")
        # self.actionButtonLayout.addWidget(self.closeButton)
        self.closeButton.connect("clicked()", self.close)

        self.advancedViewButton = qt.QCheckBox("Advanced")
        self.actionButtonLayout.addWidget(self.advancedViewButton)
        self.advancedViewButton.enabled = True
        self.advancedViewButton.checked = self.advancedViewCheckState
        self.advancedViewButton.connect("stateChanged(int)", self.onAdvanedViewButton)

        self.horizontalViewCheckBox = qt.QCheckBox("Horizontal Tables")
        self.toolLayout.addWidget(self.horizontalViewCheckBox)
        self.horizontalViewCheckBox.enabled = True
        if self.tableOrientation == 1:
            self.horizontalViewCheckBox.checked = True
        self.horizontalViewCheckBox.connect("stateChanged(int)", self.onHorizontalViewCheckBox)

        if self.setBrowserPersistence:
            self.browserPersistentButton = qt.QCheckBox("Browser Persistent")
            self.browserPersistentButton.toolTip = (
                "When enabled, DICOM Broswer remains open and usable after leaving DICOM module"
            )
            self.actionButtonLayout.addWidget(self.browserPersistentButton)
            self.browserPersistentButton.connect("stateChanged(int)", self.setBrowserPersistence)

        if self.advancedViewCheckState == True:
            self.loadableTableFrame.show()
        else:
            self.examineButton.hide()
            self.uncheckAllButton.hide()
            self.loadableTableFrame.hide()
        #
        # header related column (more details about the selected file)
        #
        if showHeader:
            self.headerLayout = qt.QVBoxLayout()
            self.layout.addLayout(self.headerLayout, selectionRow, 2)
            self.header = DICOMHeaderWidget(self.window)
            self.headerLayout.addWidget(self.header.widget)

        #
        # Plugin selection widget
        #
        self.pluginSelector = DICOMPluginSelector(self.window)
        self.loadableTableLayout.addRow(self.pluginSelector.widget, self.loadableTable.widget)
        self.checkBoxByPlugins = []

        for pluginClass in slicer.modules.dicomPlugins:
            self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass]
            self.checkBox.connect("stateChanged(int)", self.onPluginStateChanged)
            self.checkBoxByPlugins.append(self.checkBox)
Esempio n. 3
0
    def create(self):
        super(InteractiveConnectedComponentsUsingParzenPDFsOptions,
              self).create()

        ioCollapsibleButton = ctk.ctkCollapsibleGroupBox()
        ioCollapsibleButton.title = "IO"
        ioCollapsibleButton.collapsed = 0
        self.frame.layout().addWidget(ioCollapsibleButton)

        # Layout within the io collapsible button
        ioFormLayout = qt.QFormLayout(ioCollapsibleButton)
        self.additionalInputNodeSelectors = []
        for i in range(0, 2):
            self.additionalInputNodeSelectors.append(
                self.addInputNodeSelector(i, ioFormLayout))
        self.additionalInputNodeSelectors[
            0].toolTip = "Select the 1st additional input volume to be segmented"
        self.additionalInputNodeSelectors[
            1].toolTip = "Select the 2nd additional input volume to be segmented"

        # Objects
        objectCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
        objectCollapsibleGroupBox.title = "Objects"
        self.frame.layout().addWidget(objectCollapsibleGroupBox)

        # Layout within the io collapsible button
        objectFormLayout = qt.QFormLayout(objectCollapsibleGroupBox)
        foregroundLayout = qt.QHBoxLayout()
        foregroundLabel = slicer.qMRMLLabelComboBox()
        foregroundLabel.objectName = 'Foreground label'
        foregroundLabel.setMRMLScene(slicer.mrmlScene)
        foregroundLabel.setMRMLColorNode(self.editUtil.getColorNode())
        foregroundLabel.labelValueVisible = True
        foregroundLabel.currentColor = 1
        self.foregroundLabel = foregroundLabel
        self.connections.append(
            (self.foregroundLabel, 'currentColorChanged(int)',
             self.updateMRMLFromGUI))
        foregroundWeightSpinBox = qt.QDoubleSpinBox(foregroundLabel)
        self.foregroundWeightSpinBox = foregroundWeightSpinBox
        foregroundWeightSpinBox.setRange(0.0, 1.0)
        foregroundWeightSpinBox.setSingleStep(0.1)
        foregroundWeightSpinBox.value = 1.0
        foregroundPopup = ctk.ctkPopupWidget(foregroundWeightSpinBox)
        foregroundPopupLayout = qt.QHBoxLayout(foregroundPopup)
        foregroundPopupSlider = ctk.ctkDoubleSlider(foregroundPopup)
        self.foregroundPopupSlider = foregroundPopupSlider
        foregroundPopupSlider.maximum = 1.0
        foregroundPopupSlider.minimum = 0.0
        foregroundPopupSlider.singleStep = 0.1
        foregroundPopupSlider.connect('valueChanged(double)',
                                      self.foregroundWeightSpinBox.setValue)
        foregroundWeightSpinBox.connect('valueChanged(double)',
                                        self.foregroundPopupSlider.setValue)
        self.connections.append(
            (self.foregroundWeightSpinBox, 'valueChanged(double)',
             self.updateMRMLFromGUI))
        foregroundLayout.addWidget(foregroundLabel)
        foregroundLayout.addWidget(foregroundWeightSpinBox)
        foregroundPopupLayout.addWidget(foregroundPopupSlider)
        objectFormLayout.addRow("Foreground Label:", foregroundLayout)
        self.objectLabel = foregroundLabel
        # http://qt-project.org/doc/qt-4.7/qt.html
        foregroundPopup.alignment = 0x0082  # Qt::AlignVCenter | Qt::AlignRight
        foregroundPopup.horizontalDirection = 0  # Qt::LeftToRight
        foregroundPopup.verticalDirection = 0  # Qt::TopToBottom
        foregroundPopup.animationEffect = 1  # Qt::ScrollEffect

        backgroundLayout = qt.QHBoxLayout()
        backgroundLabel = slicer.qMRMLLabelComboBox()
        backgroundLabel.objectName = 'Background label'
        backgroundLabel.setMRMLScene(slicer.mrmlScene)
        backgroundLabel.setMRMLColorNode(self.editUtil.getColorNode())
        backgroundLabel.labelValueVisible = True
        backgroundLabel.currentColor = 2
        self.backgroundLabel = backgroundLabel
        self.connections.append(
            (self.backgroundLabel, 'currentColorChanged(int)',
             self.updateMRMLFromGUI))
        backgroundWeightSpinBox = qt.QDoubleSpinBox(backgroundLabel)
        self.backgroundWeightSpinBox = backgroundWeightSpinBox
        backgroundWeightSpinBox.setRange(0.0, 1.0)
        backgroundWeightSpinBox.setSingleStep(0.1)
        backgroundWeightSpinBox.value = 1.0
        backgroundPopup = ctk.ctkPopupWidget(backgroundWeightSpinBox)
        backgroundPopupLayout = qt.QHBoxLayout(backgroundPopup)
        backgroundPopupSlider = ctk.ctkDoubleSlider(backgroundPopup)
        self.backgroundPopupSlider = backgroundPopupSlider
        backgroundPopupSlider.maximum = 1.0
        backgroundPopupSlider.minimum = 0.0
        backgroundPopupSlider.singleStep = 0.1
        backgroundPopupSlider.connect('valueChanged(double)',
                                      self.backgroundWeightSpinBox.setValue)
        backgroundWeightSpinBox.connect('valueChanged(double)',
                                        self.backgroundPopupSlider.setValue)
        self.connections.append(
            (self.backgroundWeightSpinBox, 'valueChanged(double)',
             self.updateMRMLFromGUI))
        backgroundLayout.addWidget(backgroundLabel)
        backgroundLayout.addWidget(backgroundWeightSpinBox)
        backgroundPopupLayout.addWidget(backgroundPopupSlider)
        objectFormLayout.addRow("Background Label:", backgroundLayout)
        self.backgroundLabel = backgroundLabel
        # http://qt-project.org/doc/qt-4.7/qt.html
        backgroundPopup.alignment = 0x0082  # Qt::AlignVCenter | Qt::AlignRight
        backgroundPopup.horizontalDirection = 0  # Qt::LeftToRight
        backgroundPopup.verticalDirection = 0  # Qt::TopToBottom
        backgroundPopup.animationEffect = 1  # Qt::ScrollEffect

        # Presets
        # Placeholder
        presetsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
        presetsCollapsibleGroupBox.title = "Preset"
        self.frame.layout().addWidget(presetsCollapsibleGroupBox)
        presetComboBox = slicer.qSlicerPresetComboBox()

        # Advanced Parameters
        paramsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
        paramsCollapsibleGroupBox.title = "Advanced Parameters"
        paramsCollapsibleGroupBox.collapsed = 1
        self.frame.layout().addWidget(paramsCollapsibleGroupBox)

        # Layout within the io collapsible button
        paramsFormLayout = qt.QFormLayout(paramsCollapsibleGroupBox)

        erosionSpinBox = qt.QSpinBox()
        erosionSpinBox.objectName = 'erosionSpinBox'
        erosionSpinBox.toolTip = "Set the erosion radius."
        erosionSpinBox.setMinimum(0)
        erosionSpinBox.setValue(5)  # Default
        paramsFormLayout.addRow("Erosion Radius:", erosionSpinBox)
        self.erosionSpinBox = erosionSpinBox
        self.connections.append(
            (self.erosionSpinBox, "valueChanged(int)", self.updateMRMLFromGUI))

        holeFillSpinBox = qt.QSpinBox()
        holeFillSpinBox.objectName = 'holeFillSpinBox'
        holeFillSpinBox.toolTip = "Set the hole fill iterations."
        holeFillSpinBox.setMinimum(0)
        holeFillSpinBox.setValue(5)  #Default
        paramsFormLayout.addRow("Hole Fill Iterations:", holeFillSpinBox)
        self.holeFillSpinBox = holeFillSpinBox
        self.connections.append((self.holeFillSpinBox, "valueChanged(int)",
                                 self.updateMRMLFromGUI))

        # probabilitySmoothingStandardDeviation spin box
        probabilitySmoothingStdDevSpinBox = qt.QDoubleSpinBox()
        probabilitySmoothingStdDevSpinBox.objectName = 'probabilitySmoothingStdDevSpinBox'
        probabilitySmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to probability images prior to computing maximum likelihood of each class at each pixel."
        probabilitySmoothingStdDevSpinBox.setMinimum(0.0)
        probabilitySmoothingStdDevSpinBox.setValue(1.0)  # Default
        probabilitySmoothingStdDevSpinBox.setSingleStep(0.5)
        paramsFormLayout.addRow("Probability Smoothing Standard Deviation:",
                                probabilitySmoothingStdDevSpinBox)
        self.probabilitySmoothingStdDevSpinBox = probabilitySmoothingStdDevSpinBox
        self.connections.append(
            (self.probabilitySmoothingStdDevSpinBox, "valueChanged(double)",
             self.updateMRMLFromGUI))

        # histogramSmoothingStandardDeviation spin box
        histogramSmoothingStdDevSpinBox = qt.QDoubleSpinBox()
        histogramSmoothingStdDevSpinBox.objectName = 'histogramSmoothingStdDevSpinBox'
        histogramSmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to histograms to convert them to probability density function estimates."
        histogramSmoothingStdDevSpinBox.setMinimum(0.0)
        histogramSmoothingStdDevSpinBox.setValue(5.0)  # Default
        histogramSmoothingStdDevSpinBox.setSingleStep(0.5)
        paramsFormLayout.addRow("Probability Smoothing Standard Deviation:",
                                histogramSmoothingStdDevSpinBox)
        self.histogramSmoothingStdDevSpinBox = histogramSmoothingStdDevSpinBox
        self.connections.append(
            (self.histogramSmoothingStdDevSpinBox, "valueChanged(double)",
             self.updateMRMLFromGUI))

        # draft check box
        draftCheckBox = qt.QCheckBox()
        draftCheckBox.objectName = 'draftCheckBox'
        draftCheckBox.toolTip = "Downsamples results by a factor of 4."
        paramsFormLayout.addRow("Draft Mode:", draftCheckBox)
        self.draftCheckBox = draftCheckBox
        self.connections.append(
            (self.draftCheckBox, "stateChanged(int)", self.updateMRMLFromGUI))

        # force classification check box
        forceClassificationCheckBox = qt.QCheckBox()
        forceClassificationCheckBox.objectName = 'forceClassificationCheckBox'
        forceClassificationCheckBox.toolTip = "Perform the classification of all voxels?"
        forceClassificationCheckBox.setChecked(False)
        paramsFormLayout.addRow("Classify all voxels: ",
                                forceClassificationCheckBox)
        self.forceClassificationCheckBox = forceClassificationCheckBox
        self.connections.append((self.forceClassificationCheckBox,
                                 "stateChanged(int)", self.updateMRMLFromGUI))

        # dilate first check box
        dilateFirstCheckBox = qt.QCheckBox()
        dilateFirstCheckBox.objectName = 'dilateFirstCheckBox'
        dilateFirstCheckBox.toolTip = "Dilate and then erode so as to fill-in holes?"
        dilateFirstCheckBox.setChecked(False)
        paramsFormLayout.addRow("Dilate First: ", dilateFirstCheckBox)
        self.dilateFirstCheckBox = dilateFirstCheckBox
        self.connections.append((self.dilateFirstCheckBox, "stateChanged(int)",
                                 self.updateMRMLFromGUI))

        self.helpLabel = qt.QLabel(
            "Run the PDF Segmentation on the current label map.", self.frame)
        self.frame.layout().addWidget(self.helpLabel)

        self.apply = qt.QPushButton("Apply", self.frame)
        self.apply.setToolTip(
            "Apply to run segmentation.\nCreates a new label volume using the current volume as input"
        )
        self.frame.layout().addWidget(self.apply)
        self.widgets.append(self.apply)

        EditorLib.HelpButton(
            self.frame,
            "Use this tool to apply segmentation using Parzen windowed PDFs.\n\n Select different label colors and paint on the foreground or background voxels using the paint effect.\nTo run segmentation correctly, you need to supply a minimum or two class labels."
        )

        self.connections.append((self.apply, 'clicked()', self.onApply))
Esempio n. 4
0
  def create(self,widgetType='window',showHeader=False,showPreview=False):
    """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific
    extra widgets
    """

    # find internals of widget for reference and repacking
    self.toolBar = slicer.util.findChildren(self.dicomApp, 'ToolBar')[0]
    self.databaseNameLabel = slicer.util.findChildren(self.dicomApp, 'DatabaseNameLabel')[0]
    self.databaseDirectoryButton = slicer.util.findChildren(self.dicomApp, 'DirectoryButton')[0]
    self.tree = slicer.util.findChildren(self.dicomApp, 'TreeView')[0]
    self.userFrame = slicer.util.findChildren(self.dicomApp, 'UserFrame')[0]
    self.thumbs = slicer.util.findChildren(self.dicomApp, 'ThumbnailsWidget')[0]
    self.widthSlider = slicer.util.findChildren(self.dicomApp, 'ThumbnailWidthSlider')[0]
    self.preview = slicer.util.findChildren(self.dicomApp, 'PreviewFrame')[0]

    self.widgetType = widgetType
    if widgetType == 'dialog':
      self.window = qt.QDialog(self.dicomApp)
    elif widgetType == 'window':
      self.window = qt.QWidget()
    elif widgetType == 'popup':
      self.window = ctk.ctkPopupWidget(self.dicomApp)
      self.window.orientation = 1
      self.window.horizontalDirection = 0
      self.window.alignment = 0x82
    elif widgetType == 'dock':
      self.dock = qt.QDockWidget(slicer.util.mainWindow())
      self.dock.setFeatures( qt.QDockWidget.DockWidgetFloatable |
                                qt.QDockWidget.DockWidgetMovable |
                                qt.QDockWidget.DockWidgetClosable )
      slicer.util.mainWindow().addDockWidget(0x15, self.dock)
      self.window = qt.QFrame()
      self.dock.setWidget(self.window)
    else:
      raise "Unknown widget type - should be dialog, window, dock or popup"

    self.window.setWindowTitle('DICOM Details')

    self.layout = qt.QGridLayout()
    self.window.setLayout(self.layout)

    # overall layout - tree on top, preview and selection below
    toolRow = 0
    treeRow = 1
    selectionRow = 2

    # tool row at top, with commands and database
    self.toolLayout = qt.QHBoxLayout()
    self.layout.addLayout(self.toolLayout,toolRow,0,1,2)
    self.toolLayout.addWidget(self.toolBar)
    self.toolLayout.addWidget(self.databaseNameLabel)
    self.toolLayout.addWidget(self.databaseDirectoryButton)

    # tree goes next, spread across 1 row, 2 columns
    self.layout.addWidget(self.tree,treeRow,0,1,2)

    #
    # preview related column
    #
    self.previewLayout = qt.QVBoxLayout()
    self.layout.addLayout(self.previewLayout,selectionRow,0)

    self.previewLayout.addWidget(self.thumbs)
    self.previewLayout.addWidget(self.widthSlider)
    if showPreview:
      self.previewLayout.addWidget(self.preview)
    else:
      self.preview.hide()

    #
    # action related column (interacting with slicer)
    #
    self.actionLayout = qt.QVBoxLayout()
    self.layout.addLayout(self.actionLayout,selectionRow,1)
    self.actionLayout.addWidget(self.userFrame)

    tableWidth = 350 if showHeader else 700
    self.loadableTable = DICOMLoadableTable(self.userFrame,width=tableWidth)
    self.actionLayout.addWidget(self.loadableTable.widget)

    #
    # button row for action column
    #
    self.actionButtonLayout = qt.QHBoxLayout()
    self.actionLayout.addLayout(self.actionButtonLayout)

    self.uncheckAllButton = qt.QPushButton('Uncheck All')
    self.actionButtonLayout.addWidget(self.uncheckAllButton)
    self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables)

    self.loadButton = qt.QPushButton('Load Selection to Slicer')
    self.loadButton.enabled = False
    self.actionButtonLayout.addWidget(self.loadButton)
    self.loadButton.connect('clicked()', self.loadCheckedLoadables)

    self.closeButton = qt.QPushButton('Close')
    self.actionButtonLayout.addWidget(self.closeButton)
    self.closeButton.connect('clicked()', self.close)

    if self.setBrowserPersistence:
      self.browserPersistentButton = qt.QCheckBox('Make DICOM Browser Persistent')
      self.browserPersistentButton.toolTip = 'When enabled, DICOM Broswer remains open and usable after leaving DICOM module'
      self.actionLayout.addWidget(self.browserPersistentButton)
      self.browserPersistentButton.connect('stateChanged(int)', self.setBrowserPersistence)


    #
    # header related column (more details about the selected file)
    #
    if showHeader:
      self.headerLayout = qt.QVBoxLayout()
      self.layout.addLayout(self.headerLayout,selectionRow,2)
      self.header = DICOMHeaderWidget(self.window)
      self.headerLayout.addWidget(self.header.widget)
  def create(self):
    super(InteractiveConnectedComponentsUsingParzenPDFsOptions,self).create()

    ioCollapsibleButton = ctk.ctkCollapsibleGroupBox()
    ioCollapsibleButton.title = "IO"
    ioCollapsibleButton.collapsed = 0
    self.frame.layout().addWidget(ioCollapsibleButton)

    # Layout within the io collapsible button
    ioFormLayout = qt.QFormLayout(ioCollapsibleButton)
    self.additionalInputNodeSelectors = []
    for i in range(0,2):
      self.additionalInputNodeSelectors.append(self.addInputNodeSelector(i, ioFormLayout))
    self.additionalInputNodeSelectors[0].toolTip = "Select the 1st additional input volume to be segmented"
    self.additionalInputNodeSelectors[1].toolTip = "Select the 2nd additional input volume to be segmented"

    # Objects
    objectCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
    objectCollapsibleGroupBox.title = "Objects"
    self.frame.layout().addWidget(objectCollapsibleGroupBox)

    # Layout within the io collapsible button
    objectFormLayout = qt.QFormLayout(objectCollapsibleGroupBox)
    foregroundLayout = qt.QHBoxLayout()
    foregroundLabel = slicer.qMRMLLabelComboBox()
    foregroundLabel.objectName = 'Foreground label'
    foregroundLabel.setMRMLScene(slicer.mrmlScene)
    foregroundLabel.setMRMLColorNode(self.editUtil.getColorNode())
    foregroundLabel.labelValueVisible = True
    foregroundLabel.currentColor = 1
    self.foregroundLabel = foregroundLabel
    self.connections.append( (self.foregroundLabel, 'currentColorChanged(int)', self.updateMRMLFromGUI ) )
    foregroundWeightSpinBox = qt.QDoubleSpinBox(foregroundLabel)
    self.foregroundWeightSpinBox = foregroundWeightSpinBox
    foregroundWeightSpinBox.setRange(0.0, 1.0)
    foregroundWeightSpinBox.setSingleStep(0.1)
    foregroundWeightSpinBox.value = 1.0
    foregroundPopup = ctk.ctkPopupWidget( foregroundWeightSpinBox )
    foregroundPopupLayout = qt.QHBoxLayout( foregroundPopup )
    foregroundPopupSlider = ctk.ctkDoubleSlider( foregroundPopup )
    self.foregroundPopupSlider = foregroundPopupSlider
    foregroundPopupSlider.maximum = 1.0
    foregroundPopupSlider.minimum = 0.0
    foregroundPopupSlider.singleStep = 0.1
    foregroundPopupSlider.connect('valueChanged(double)', self.foregroundWeightSpinBox.setValue)
    foregroundWeightSpinBox.connect('valueChanged(double)', self.foregroundPopupSlider.setValue)
    self.connections.append( (self.foregroundWeightSpinBox, 'valueChanged(double)', self.updateMRMLFromGUI ) )
    foregroundLayout.addWidget( foregroundLabel )
    foregroundLayout.addWidget( foregroundWeightSpinBox )
    foregroundPopupLayout.addWidget( foregroundPopupSlider )
    objectFormLayout.addRow("Foreground Label:", foregroundLayout )
    self.objectLabel = foregroundLabel
    # http://qt-project.org/doc/qt-4.7/qt.html
    foregroundPopup.alignment = 0x0082 # Qt::AlignVCenter | Qt::AlignRight
    foregroundPopup.horizontalDirection = 0 # Qt::LeftToRight
    foregroundPopup.verticalDirection = 0 # Qt::TopToBottom
    foregroundPopup.animationEffect = 1 # Qt::ScrollEffect

    backgroundLayout = qt.QHBoxLayout()
    backgroundLabel = slicer.qMRMLLabelComboBox()
    backgroundLabel.objectName = 'Background label'
    backgroundLabel.setMRMLScene(slicer.mrmlScene)
    backgroundLabel.setMRMLColorNode(self.editUtil.getColorNode())
    backgroundLabel.labelValueVisible = True
    backgroundLabel.currentColor = 2
    self.backgroundLabel = backgroundLabel
    self.connections.append( (self.backgroundLabel, 'currentColorChanged(int)', self.updateMRMLFromGUI ) )
    backgroundWeightSpinBox = qt.QDoubleSpinBox(backgroundLabel)
    self.backgroundWeightSpinBox = backgroundWeightSpinBox
    backgroundWeightSpinBox.setRange(0.0, 1.0)
    backgroundWeightSpinBox.setSingleStep(0.1)
    backgroundWeightSpinBox.value = 1.0
    backgroundPopup = ctk.ctkPopupWidget( backgroundWeightSpinBox )
    backgroundPopupLayout = qt.QHBoxLayout( backgroundPopup )
    backgroundPopupSlider = ctk.ctkDoubleSlider( backgroundPopup )
    self.backgroundPopupSlider = backgroundPopupSlider
    backgroundPopupSlider.maximum = 1.0
    backgroundPopupSlider.minimum = 0.0
    backgroundPopupSlider.singleStep = 0.1
    backgroundPopupSlider.connect('valueChanged(double)', self.backgroundWeightSpinBox.setValue)
    backgroundWeightSpinBox.connect('valueChanged(double)', self.backgroundPopupSlider.setValue)
    self.connections.append( (self.backgroundWeightSpinBox, 'valueChanged(double)', self.updateMRMLFromGUI ) )
    backgroundLayout.addWidget( backgroundLabel )
    backgroundLayout.addWidget( backgroundWeightSpinBox )
    backgroundPopupLayout.addWidget( backgroundPopupSlider )
    objectFormLayout.addRow("Background Label:", backgroundLayout)
    self.backgroundLabel = backgroundLabel
    # http://qt-project.org/doc/qt-4.7/qt.html
    backgroundPopup.alignment = 0x0082 # Qt::AlignVCenter | Qt::AlignRight
    backgroundPopup.horizontalDirection = 0 # Qt::LeftToRight
    backgroundPopup.verticalDirection = 0 # Qt::TopToBottom
    backgroundPopup.animationEffect = 1 # Qt::ScrollEffect

    # Presets
    # Placeholder
    presetsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
    presetsCollapsibleGroupBox.title = "Preset"
    self.frame.layout().addWidget(presetsCollapsibleGroupBox)
    presetComboBox = slicer.qSlicerPresetComboBox()

    # Advanced Parameters
    paramsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
    paramsCollapsibleGroupBox.title = "Advanced Parameters"
    paramsCollapsibleGroupBox.collapsed = 1
    self.frame.layout().addWidget(paramsCollapsibleGroupBox)

    # Layout within the io collapsible button
    paramsFormLayout = qt.QFormLayout(paramsCollapsibleGroupBox)

    erosionSpinBox = qt.QSpinBox()
    erosionSpinBox.objectName = 'erosionSpinBox'
    erosionSpinBox.toolTip = "Set the erosion radius."
    erosionSpinBox.setMinimum(0)
    erosionSpinBox.setValue(5) # Default
    paramsFormLayout.addRow("Erosion Radius:", erosionSpinBox)
    self.erosionSpinBox = erosionSpinBox
    self.connections.append( (self.erosionSpinBox, "valueChanged(int)", self.updateMRMLFromGUI ) )

    holeFillSpinBox = qt.QSpinBox()
    holeFillSpinBox.objectName = 'holeFillSpinBox'
    holeFillSpinBox.toolTip = "Set the hole fill iterations."
    holeFillSpinBox.setMinimum(0)
    holeFillSpinBox.setValue(5) #Default
    paramsFormLayout.addRow("Hole Fill Iterations:", holeFillSpinBox)
    self.holeFillSpinBox = holeFillSpinBox
    self.connections.append( (self.holeFillSpinBox, "valueChanged(int)", self.updateMRMLFromGUI ) )

    # probabilitySmoothingStandardDeviation spin box
    probabilitySmoothingStdDevSpinBox = qt.QDoubleSpinBox()
    probabilitySmoothingStdDevSpinBox.objectName = 'probabilitySmoothingStdDevSpinBox'
    probabilitySmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to probability images prior to computing maximum likelihood of each class at each pixel."
    probabilitySmoothingStdDevSpinBox.setMinimum(0.0)
    probabilitySmoothingStdDevSpinBox.setValue(1.0) # Default
    probabilitySmoothingStdDevSpinBox.setSingleStep(0.5)
    paramsFormLayout.addRow("Probability Smoothing Standard Deviation:", probabilitySmoothingStdDevSpinBox)
    self.probabilitySmoothingStdDevSpinBox = probabilitySmoothingStdDevSpinBox
    self.connections.append( (self.probabilitySmoothingStdDevSpinBox, "valueChanged(double)", self.updateMRMLFromGUI ) )

    # histogramSmoothingStandardDeviation spin box
    histogramSmoothingStdDevSpinBox = qt.QDoubleSpinBox()
    histogramSmoothingStdDevSpinBox.objectName = 'histogramSmoothingStdDevSpinBox'
    histogramSmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to histograms to convert them to probability density function estimates."
    histogramSmoothingStdDevSpinBox.setMinimum(0.0)
    histogramSmoothingStdDevSpinBox.setValue(5.0) # Default
    histogramSmoothingStdDevSpinBox.setSingleStep(0.5)
    paramsFormLayout.addRow("Probability Smoothing Standard Deviation:", histogramSmoothingStdDevSpinBox)
    self.histogramSmoothingStdDevSpinBox = histogramSmoothingStdDevSpinBox
    self.connections.append( (self.histogramSmoothingStdDevSpinBox, "valueChanged(double)", self.updateMRMLFromGUI ) )

    # draft check box
    draftCheckBox = qt.QCheckBox()
    draftCheckBox.objectName = 'draftCheckBox'
    draftCheckBox.toolTip = "Downsamples results by a factor of 4."
    paramsFormLayout.addRow("Draft Mode:", draftCheckBox)
    self.draftCheckBox = draftCheckBox
    self.connections.append( (self.draftCheckBox, "stateChanged(int)", self.updateMRMLFromGUI ) )

    # force classification check box
    forceClassificationCheckBox = qt.QCheckBox()
    forceClassificationCheckBox.objectName = 'forceClassificationCheckBox'
    forceClassificationCheckBox.toolTip = "Perform the classification of all voxels?"
    forceClassificationCheckBox.setChecked(False)
    paramsFormLayout.addRow("Classify all voxels: ", forceClassificationCheckBox)
    self.forceClassificationCheckBox = forceClassificationCheckBox
    self.connections.append( (self.forceClassificationCheckBox, "stateChanged(int)", self.updateMRMLFromGUI ) )

    # dilate first check box
    dilateFirstCheckBox = qt.QCheckBox()
    dilateFirstCheckBox.objectName = 'dilateFirstCheckBox'
    dilateFirstCheckBox.toolTip = "Dilate and then erode so as to fill-in holes?"
    dilateFirstCheckBox.setChecked(False)
    paramsFormLayout.addRow("Dilate First: ", dilateFirstCheckBox)
    self.dilateFirstCheckBox = dilateFirstCheckBox
    self.connections.append( (self.dilateFirstCheckBox, "stateChanged(int)", self.updateMRMLFromGUI ) )

    self.helpLabel = qt.QLabel("Run the PDF Segmentation on the current label map.", self.frame)
    self.frame.layout().addWidget(self.helpLabel)

    self.apply = qt.QPushButton("Apply", self.frame)
    self.apply.setToolTip("Apply to run segmentation.\nCreates a new label volume using the current volume as input")
    self.frame.layout().addWidget(self.apply)
    self.widgets.append(self.apply)

    EditorLib.HelpButton(self.frame, "Use this tool to apply segmentation using Parzen windowed PDFs.\n\n Select different label colors and paint on the foreground or background voxels using the paint effect.\nTo run segmentation correctly, you need to supply a minimum or two class labels.")

    self.connections.append( (self.apply, 'clicked()', self.onApply) )
Esempio n. 6
0
  def create(self,widgetType='window',showHeader=False,showPreview=False):
    """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific
    extra widgets
    """

    # find internals of widget for reference and repacking
    self.toolBar = slicer.util.findChildren(self.dicomBrowser, 'ToolBar')[0]
    self.databaseNameLabel = slicer.util.findChildren(self.dicomBrowser, 'DatabaseNameLabel')[0]
    self.databaseDirectoryButton = slicer.util.findChildren(self.dicomBrowser, 'DirectoryButton')[0]
    self.tableDensityLabel = qt.QLabel('Density: ')
    self.tableDensityLabel.objectName = 'tablesDensityLabel'
    self.tableDensityComboBox = slicer.util.findChildren(self.dicomBrowser, 'tableDensityComboBox')[0]
    self.tableDensityComboBox.connect('currentIndexChanged(QString)', self.onTableDensityComboBox)
    index = self.tableDensityComboBox.findText(self.tableDensity)
    if  (index != -1) :
      self.tableDensityComboBox.setCurrentIndex(index)

    #
    # create and configure the Slicer browser widget - this involves
    # reaching inside and manipulating the widget hierarchy
    # - TODO: this configurability should be exposed more natively
    #   in the CTK code to avoid the findChildren calls
    #
    self.tables = slicer.util.findChildren(self.dicomBrowser, 'dicomTableManager')[0]
    patientTable = slicer.util.findChildren(self.tables, 'patientsTable')[0]
    patientTableView = slicer.util.findChildren(patientTable, 'tblDicomDatabaseView')[0]
    patientSearchBox = slicer.util.findChildren(patientTable, 'leSearchBox')[0]
    studyTable = slicer.util.findChildren(self.tables, 'studiesTable')[0]
    studyTableView = slicer.util.findChildren(studyTable, 'tblDicomDatabaseView')[0]
    studySearchBox = slicer.util.findChildren(studyTable, 'leSearchBox')[0]
    seriesTable = slicer.util.findChildren(self.tables, 'seriesTable')[0]
    seriesTableView = slicer.util.findChildren(seriesTable, 'tblDicomDatabaseView')[0]
    seriesSearchBox = slicer.util.findChildren(seriesTable, 'leSearchBox')[0]
    self.tableSplitter = qt.QSplitter()
    self.tableSplitter.addWidget(patientTableView)
    self.tableSplitter.addWidget(studyTableView)
    self.tableSplitter.addWidget(seriesTableView)

    # TODO: Move to this part to CTK
    patientTableView.resizeColumnsToContents()
    studyTableView.resizeColumnsToContents()
    seriesTableView.resizeColumnsToContents()

    self.userFrame = qt.QWidget()
    self.preview = qt.QWidget()

    self.widgetType = widgetType
    if widgetType == 'dialog':
      self.window = qt.QDialog(self.dicomBrowser)
    elif widgetType == 'window':
      self.window = qt.QWidget()
    elif widgetType == 'popup':
      self.window = ctk.ctkPopupWidget(self.dicomBrowser)
      self.window.orientation = 1
      self.window.horizontalDirection = 0
      self.window.alignment = 0x82
    elif widgetType == 'dock':
      self.dock = qt.QDockWidget(slicer.util.mainWindow())
      self.dock.setFeatures( qt.QDockWidget.DockWidgetFloatable |
                                qt.QDockWidget.DockWidgetMovable |
                                qt.QDockWidget.DockWidgetClosable )
      slicer.util.mainWindow().addDockWidget(0x15, self.dock)
      self.window = qt.QFrame()
      self.dock.setWidget(self.window)
    else:
      raise "Unknown widget type - should be dialog, window, dock or popup"

    self.window.objectName = 'SlicerDICOMBrowser'

    self.setModality(not self.browserPersistent)

    self.window.setWindowTitle('DICOM Browser')

    self.layout = qt.QVBoxLayout(self.window)

    # tool row at top, with commands and database
    self.toolFrame = qt.QWidget()
    self.toolFrame.setMaximumHeight(40)
    self.toolFrame.setContentsMargins(-5,-5,-5,-5)
    self.toolLayout = qt.QHBoxLayout(self.toolFrame)
    self.layout.addWidget(self.toolFrame)
    self.toolLayout.addWidget(self.toolBar)
    self.settingsButton = ctk.ctkExpandButton()
    self.toolLayout.addWidget(self.settingsButton)
    self.toolLayout.addWidget(self.databaseNameLabel)
    self.databaseNameLabel.visible = False
    self.toolLayout.addWidget(self.databaseDirectoryButton)
    self.databaseDirectoryButton.visible = False
    self.toolLayout.addWidget(self.tableDensityLabel)
    self.tableDensityLabel.visible = False
    self.toolLayout.addWidget(self.tableDensityComboBox)
    self.tableDensityComboBox.visible = False
    self.settingsButton.connect('toggled(bool)', self.onSettingsButton)

    # enable export button and make new connection
    self.actionExport = self.dicomBrowser.findChildren('QAction', 'ActionExport')[0]
    self.actionExport.enabled = 1
    self.actionExport.connect('triggered()', self.onExportAction)

    # search row
    self.searchFrame = qt.QWidget()
    self.searchFrame.setMaximumHeight(40)
    self.searchLayout = qt.QHBoxLayout(self.searchFrame)
    self.layout.addWidget(self.searchFrame)
    patinetsLabel = qt.QLabel('Patients: ')
    self.searchLayout.addWidget(patinetsLabel)
    self.searchLayout.addWidget(patientSearchBox)
    studiesLabel = qt.QLabel('Studies: ')
    self.searchLayout.addWidget(studiesLabel)
    self.searchLayout.addWidget(studySearchBox)
    seriesLabel = qt.QLabel('Series: ')
    self.searchLayout.addWidget(seriesLabel)
    self.searchLayout.addWidget(seriesSearchBox)

    # tables goes next, spread across 1 row, 2 columns
    if self.horizontalTables:
      self.tableSplitter.setOrientation(1)
    else:
      self.tableSplitter.setOrientation(0)
    self.layout.addWidget(self.tableSplitter)

    #
    # preview related column
    #
    self.previewLayout = qt.QVBoxLayout()
    if showPreview:
      self.previewLayout.addWidget(self.preview)
    else:
      self.preview.hide()

    #
    # action related column (interacting with slicer)
    #
    self.loadableTableFrame = qt.QWidget()
    self.loadableTableFrame.setMaximumHeight(200)
    self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame)
    self.layout.addWidget(self.loadableTableFrame)

    self.loadableTableLayout.addWidget(self.userFrame)
    self.userFrame.hide()

    tableWidth = 350 if showHeader else 600
    self.loadableTable = DICOMLoadableTable(self.userFrame,width=tableWidth)

    #
    # button row for action column
    #
    self.actionButtonsFrame = qt.QWidget()
    self.actionButtonsFrame.setMaximumHeight(40)
    self.actionButtonsFrame.objectName = 'ActionButtonsFrame'
    self.layout.addWidget(self.actionButtonsFrame)

    self.actionButtonLayout = qt.QHBoxLayout()
    self.actionButtonsFrame.setLayout(self.actionButtonLayout)

    self.loadButton = qt.QPushButton('Load')
    self.loadButton.enabled = True
    self.loadButton.toolTip = 'Load Selection to Slicer'
    self.actionButtonLayout.addWidget(self.loadButton)
    self.loadButton.connect('clicked()', self.loadCheckedLoadables)

    self.headerPopup = DICOMLib.DICOMHeaderPopup()

    self.viewMetadataButton = qt.QPushButton('Metadata')
    self.viewMetadataButton.objectName = 'ActionViewMetadata'
    self.viewMetadataButton.toolTip = 'Display Metadata of the Selected Series'
    self.viewMetadataButton.enabled = False
    self.actionButtonLayout.addWidget(self.viewMetadataButton)
    self.viewMetadataButton.connect('clicked()', self.onViewHeaderButton)
    self.viewMetadataButton.connect('clicked()', self.headerPopup.open)
    self.actionButtonLayout.addStretch(1)

    self.examineButton = qt.QPushButton('Examine')
    self.actionButtonLayout.addWidget(self.examineButton)
    self.examineButton.enabled = False
    self.examineButton.connect('clicked()', self.examineForLoading)

    self.uncheckAllButton = qt.QPushButton('Uncheck All')
    self.actionButtonLayout.addWidget(self.uncheckAllButton)
    self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables)
    self.actionButtonLayout.addStretch(1)

    self.advancedViewButton = qt.QCheckBox('Advanced')
    self.advancedViewButton.objectName = 'AdvancedViewCheckBox'
    self.actionButtonLayout.addWidget(self.advancedViewButton)
    self.advancedViewButton.enabled = True
    self.advancedViewButton.checked = self.advancedView
    self.advancedViewButton.connect('clicked()', self.onAdvanedViewButton)

    self.horizontalViewCheckBox = qt.QCheckBox('Horizontal')
    self.horizontalViewCheckBox.objectName = 'HorizontalViewCheckBox'
    self.horizontalViewCheckBox.checked = self.horizontalTables
    self.horizontalViewCheckBox.connect('clicked()', self.onHorizontalViewCheckBox)
    self.actionButtonLayout.addWidget(self.horizontalViewCheckBox)
    self.toolLayout.addStretch(1)

    self.browserPersistentButton = qt.QCheckBox('Browser Persistent')
    self.browserPersistentButton.objectName = 'BrowserPersistentCheckBox'
    self.browserPersistentButton.toolTip = 'When enabled, DICOM Browser remains open after loading data or switching to another module'
    self.browserPersistentButton.checked = self.browserPersistent
    self.actionButtonLayout.addWidget(self.browserPersistentButton)
    self.browserPersistentButton.connect('stateChanged(int)', self.setBrowserPersistence)

    if self.advancedView:
      self.loadableTableFrame.visible = True
    else:
      self.loadableTableFrame.visible = False
      self.examineButton.visible = False
      self.uncheckAllButton.visible = False
    #
    # header related column (more details about the selected file)
    #
    if showHeader:
      self.headerLayout = qt.QVBoxLayout()
      self.layout.addLayout(self.headerLayout,selectionRow,2)
      self.header = DICOMHeaderWidget(self.window)
      self.headerLayout.addWidget(self.header.widget)

    #
    # Series selection
    #
    self.tables.connect('seriesSelectionChanged(QStringList)', self.onSeriesSelected)

    #
    # Plugin selection widget
    #
    self.pluginSelector = DICOMPluginSelector(self.window)
    self.loadableTableLayout.addRow(self.pluginSelector.widget,self.loadableTable.widget)
    self.checkBoxByPlugins = []

    for pluginClass in slicer.modules.dicomPlugins:
      self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass]
      self.checkBox.connect('stateChanged(int)', self.onPluginStateChanged)
      self.checkBoxByPlugins.append(self.checkBox)
Esempio n. 7
0
    def create(self, widgetType='window', showHeader=False, showPreview=False):
        """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific
    extra widgets
    """

        # find internals of widget for reference and repacking
        self.toolBar = slicer.util.findChildren(self.dicomBrowser,
                                                'ToolBar')[0]
        self.databaseNameLabel = slicer.util.findChildren(
            self.dicomBrowser, 'DatabaseNameLabel')[0]
        self.databaseDirectoryButton = slicer.util.findChildren(
            self.dicomBrowser, 'DirectoryButton')[0]
        #self.tables = self.dicomBrowser.tableManager
        self.tables = slicer.util.findChildren(self.dicomBrowser,
                                               'dicomTableManager')[0]

        #self.userFrame = slicer.util.findChildren(self.dicomBrowser, 'UserFrame')[0]
        self.userFrame = qt.QWidget()
        #self.thumbs = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailsWidget')[0]
        #self.widthSlider = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailWidthSlider')[0]
        self.preview = qt.QWidget()

        self.widgetType = widgetType
        if widgetType == 'dialog':
            self.window = qt.QDialog(self.dicomBrowser)
        elif widgetType == 'window':
            self.window = qt.QWidget()
        elif widgetType == 'popup':
            self.window = ctk.ctkPopupWidget(self.dicomBrowser)
            self.window.orientation = 1
            self.window.horizontalDirection = 0
            self.window.alignment = 0x82
        elif widgetType == 'dock':
            self.dock = qt.QDockWidget(slicer.util.mainWindow())
            self.dock.setFeatures(qt.QDockWidget.DockWidgetFloatable
                                  | qt.QDockWidget.DockWidgetMovable
                                  | qt.QDockWidget.DockWidgetClosable)
            slicer.util.mainWindow().addDockWidget(0x15, self.dock)
            self.window = qt.QFrame()
            self.dock.setWidget(self.window)
        else:
            raise "Unknown widget type - should be dialog, window, dock or popup"

        self.window.setWindowTitle('DICOM Browser')

        self.layout = qt.QVBoxLayout(self.window)

        # tool row at top, with commands and database
        self.toolFrame = qt.QWidget()
        self.toolFrame.setMaximumHeight(40)
        self.toolLayout = qt.QHBoxLayout(self.toolFrame)
        self.layout.addWidget(self.toolFrame)
        self.toolLayout.addWidget(self.toolBar)
        self.toolLayout.addWidget(self.databaseNameLabel)
        self.databaseNameLabel.visible = False
        self.toolLayout.addWidget(self.databaseDirectoryButton)
        self.databaseDirectoryButton.visible = False
        self.settingsButton = ctk.ctkExpandButton()
        self.toolBar.addWidget(self.settingsButton)
        self.settingsButton.connect('toggled(bool)', self.onSettingsButton)

        # tables goes next, spread across 1 row, 2 columns
        self.tables.tableOrientation = self.tableOrientation
        self.tables.dynamicTableLayout = False
        self.tablesExpandableWidget = ctk.ctkExpandableWidget()
        self.tablesLayout = qt.QVBoxLayout(self.tablesExpandableWidget)
        self.tablesLayout.addWidget(self.tables)
        self.tablesExpandableWidget.setMinimumHeight(400)
        self.layout.addWidget(self.tablesExpandableWidget)

        #
        # preview related column
        #
        self.previewLayout = qt.QVBoxLayout()
        #self.layout.addLayout(self.previewLayout,selectionRow,0)

        #self.previewLayout.addWidget(self.thumbs)
        #self.previewLayout.addWidget(self.widthSlider)
        if showPreview:
            self.previewLayout.addWidget(self.preview)
        else:
            self.preview.hide()

        #
        # action related column (interacting with slicer)
        #
        self.loadableTableFrame = qt.QWidget()
        self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame)
        self.layout.addWidget(self.loadableTableFrame)

        self.loadableTableLayout.addWidget(self.userFrame)
        self.userFrame.hide()

        tableWidth = 350 if showHeader else 600
        self.loadableTable = DICOMLoadableTable(self.userFrame,
                                                width=tableWidth)
        #self.loadableTableLayout.addWidget(self.loadableTable.widget)
        #self.loadableTable.widget.hide()

        #
        # button row for action column
        #
        self.actionButtonsFrame = qt.QWidget()
        self.actionButtonsFrame.setMaximumHeight(40)
        self.layout.addWidget(self.actionButtonsFrame)
        #self.layout.addStretch(1)
        self.actionButtonLayout = qt.QHBoxLayout()
        self.actionButtonsFrame.setLayout(self.actionButtonLayout)

        self.loadButton = qt.QPushButton('Load')
        self.loadButton.enabled = True
        self.loadButton.toolTip = 'Load Selection to Slicer'
        self.actionButtonLayout.addWidget(self.loadButton)
        self.loadButton.connect('clicked()', self.loadCheckedLoadables)

        self.headerPopup = DICOMLib.DICOMHeaderPopup()

        self.viewMetadataButton = qt.QPushButton('Metadata')
        self.viewMetadataButton.toolTip = 'Display Metadata of the Selected Series'
        self.viewMetadataButton.enabled = False
        self.actionButtonLayout.addWidget(self.viewMetadataButton)
        self.viewMetadataButton.connect('clicked()', self.onViewHeaderButton)
        self.viewMetadataButton.connect('clicked()', self.headerPopup.open)
        self.actionButtonLayout.addStretch(1)

        self.examineButton = qt.QPushButton('Examine')
        self.actionButtonLayout.addWidget(self.examineButton)
        self.examineButton.enabled = False
        self.examineButton.connect('clicked()', self.examineForLoading)

        self.uncheckAllButton = qt.QPushButton('Uncheck All')
        self.actionButtonLayout.addWidget(self.uncheckAllButton)
        self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables)
        self.actionButtonLayout.addStretch(1)

        self.closeButton = qt.QPushButton('Close')
        #self.actionButtonLayout.addWidget(self.closeButton)
        self.closeButton.connect('clicked()', self.close)

        self.advancedViewButton = qt.QCheckBox('Advanced')
        self.actionButtonLayout.addWidget(self.advancedViewButton)
        self.advancedViewButton.enabled = True
        self.advancedViewButton.checked = self.advancedViewCheckState
        self.advancedViewButton.connect('clicked()', self.onAdvanedViewButton)

        self.horizontalViewCheckBox = qt.QCheckBox('Horizontal Tables')
        self.horizontalViewCheckBox.visible = False
        self.toolLayout.addWidget(self.horizontalViewCheckBox)
        self.horizontalViewCheckBox.enabled = True
        if self.tableOrientation == 1:
            self.horizontalViewCheckBox.checked = True
        self.horizontalViewCheckBox.connect('stateChanged(int)',
                                            self.onHorizontalViewCheckBox)

        if self.setBrowserPersistence:
            self.browserPersistentButton = qt.QCheckBox('Browser Persistent')
            self.browserPersistentButton.toolTip = 'When enabled, DICOM Broswer remains open and usable after leaving DICOM module'
            self.actionButtonLayout.addWidget(self.browserPersistentButton)
            self.browserPersistentButton.connect('stateChanged(int)',
                                                 self.setBrowserPersistence)

        if self.advancedViewCheckState == True:
            self.loadableTableFrame.show()
            self.window.adjustSize()
        else:
            self.examineButton.hide()
            self.uncheckAllButton.hide()
            self.loadableTableFrame.hide()
            self.window.adjustSize()
        #
        # header related column (more details about the selected file)
        #
        if showHeader:
            self.headerLayout = qt.QVBoxLayout()
            self.layout.addLayout(self.headerLayout, selectionRow, 2)
            self.header = DICOMHeaderWidget(self.window)
            self.headerLayout.addWidget(self.header.widget)

        #
        # Plugin selection widget
        #
        self.pluginSelector = DICOMPluginSelector(self.window)
        self.loadableTableLayout.addRow(self.pluginSelector.widget,
                                        self.loadableTable.widget)
        self.checkBoxByPlugins = []

        for pluginClass in slicer.modules.dicomPlugins:
            self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass]
            self.checkBox.connect('stateChanged(int)',
                                  self.onPluginStateChanged)
            self.checkBoxByPlugins.append(self.checkBox)
Esempio n. 8
0
  def create(self,widgetType='window',showHeader=False,showPreview=False):
    """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific
    extra widgets
    """

    # find internals of widget for reference and repacking
    self.toolBar = slicer.util.findChildren(self.dicomBrowser, 'ToolBar')[0]
    self.databaseNameLabel = slicer.util.findChildren(self.dicomBrowser, 'DatabaseNameLabel')[0]
    self.databaseDirectoryButton = slicer.util.findChildren(self.dicomBrowser, 'DirectoryButton')[0]
    self.tableDensityLabel = qt.QLabel('Density: ')
    self.tableDensityComboBox = slicer.util.findChildren(self.dicomBrowser, 'tableDensityComboBox')[0]
    self.tableDensityComboBox.connect('currentIndexChanged(QString)', self.onTableDensityComboBox)
    index = self.tableDensityComboBox.findText(self.tableDensity)
    if  (index != -1) :
      self.tableDensityComboBox.setCurrentIndex(index)

    #self.tables = self.dicomBrowser.tableManager
    self.tables = slicer.util.findChildren(self.dicomBrowser, 'dicomTableManager')[0]
    patientTable = slicer.util.findChildren(self.tables, 'patientsTable')[0]
    patientTableView = slicer.util.findChildren(patientTable, 'tblDicomDatabaseView')[0]
    patientSearchBox = slicer.util.findChildren(patientTable, 'leSearchBox')[0]
    studyTable = slicer.util.findChildren(self.tables, 'studiesTable')[0]
    studyTableView = slicer.util.findChildren(studyTable, 'tblDicomDatabaseView')[0]
    studySearchBox = slicer.util.findChildren(studyTable, 'leSearchBox')[0]
    seriesTable = slicer.util.findChildren(self.tables, 'seriesTable')[0]
    seriesTableView = slicer.util.findChildren(seriesTable, 'tblDicomDatabaseView')[0]
    seriesSearchBox = slicer.util.findChildren(seriesTable, 'leSearchBox')[0]
    self.tableSplitter = qt.QSplitter()
    self.tableSplitter.addWidget(patientTableView)
    self.tableSplitter.addWidget(studyTableView)
    self.tableSplitter.addWidget(seriesTableView)

    # TODO: Move to this part to CTK
    patientTableView.resizeColumnsToContents()
    studyTableView.resizeColumnsToContents()
    seriesTableView.resizeColumnsToContents()

    #self.userFrame = slicer.util.findChildren(self.dicomBrowser, 'UserFrame')[0]
    self.userFrame = qt.QWidget()
    #self.thumbs = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailsWidget')[0]
    #self.widthSlider = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailWidthSlider')[0]
    self.preview = qt.QWidget()

    self.widgetType = widgetType
    if widgetType == 'dialog':
      self.window = qt.QDialog(self.dicomBrowser)
    elif widgetType == 'window':
      self.window = qt.QWidget()
    elif widgetType == 'popup':
      self.window = ctk.ctkPopupWidget(self.dicomBrowser)
      self.window.orientation = 1
      self.window.horizontalDirection = 0
      self.window.alignment = 0x82
    elif widgetType == 'dock':
      self.dock = qt.QDockWidget(slicer.util.mainWindow())
      self.dock.setFeatures( qt.QDockWidget.DockWidgetFloatable |
                                qt.QDockWidget.DockWidgetMovable |
                                qt.QDockWidget.DockWidgetClosable )
      slicer.util.mainWindow().addDockWidget(0x15, self.dock)
      self.window = qt.QFrame()
      self.dock.setWidget(self.window)
    else:
      raise "Unknown widget type - should be dialog, window, dock or popup"

    self.setModality(not self.browserPersistent)

    self.window.setWindowTitle('DICOM Browser')

    self.layout = qt.QVBoxLayout(self.window)

    # tool row at top, with commands and database
    self.toolFrame = qt.QWidget()
    self.toolFrame.setMaximumHeight(40)
    self.toolFrame.setContentsMargins(-5,-5,-5,-5)
    self.toolLayout = qt.QHBoxLayout(self.toolFrame)
    self.layout.addWidget(self.toolFrame)
    self.toolLayout.addWidget(self.toolBar)
    self.settingsButton = ctk.ctkExpandButton()
    self.toolLayout.addWidget(self.settingsButton)
    self.toolLayout.addWidget(self.databaseNameLabel)
    self.databaseNameLabel.visible = False
    self.toolLayout.addWidget(self.databaseDirectoryButton)
    self.databaseDirectoryButton.visible = False
    self.toolLayout.addWidget(self.tableDensityLabel)
    self.tableDensityLabel.visible = False
    self.toolLayout.addWidget(self.tableDensityComboBox)
    self.tableDensityComboBox.visible = False
    self.settingsButton.connect('toggled(bool)', self.onSettingsButton)

    # enable export button and make new connection
    self.actionExport = self.dicomBrowser.findChildren('QAction', 'ActionExport')[0]
    self.actionExport.enabled = 1
    self.actionExport.connect('triggered()', self.onExportAction)

    # search row
    self.searchFrame = qt.QWidget()
    self.searchFrame.setMaximumHeight(40)
    self.searchLayout = qt.QHBoxLayout(self.searchFrame)
    self.layout.addWidget(self.searchFrame)
    patinetsLabel = qt.QLabel('Patients: ')
    self.searchLayout.addWidget(patinetsLabel)
    self.searchLayout.addWidget(patientSearchBox)
    studiesLabel = qt.QLabel('Studies: ')
    self.searchLayout.addWidget(studiesLabel)
    self.searchLayout.addWidget(studySearchBox)
    seriesLabel = qt.QLabel('Series: ')
    self.searchLayout.addWidget(seriesLabel)
    self.searchLayout.addWidget(seriesSearchBox)

    # tables goes next, spread across 1 row, 2 columns
    if self.horizontalTables:
      self.tableSplitter.setOrientation(1)
    else:
      self.tableSplitter.setOrientation(0)
    self.layout.addWidget(self.tableSplitter)

    #
    # preview related column
    #
    self.previewLayout = qt.QVBoxLayout()
    #self.layout.addLayout(self.previewLayout,selectionRow,0)

    #self.previewLayout.addWidget(self.thumbs)
    #self.previewLayout.addWidget(self.widthSlider)
    if showPreview:
      self.previewLayout.addWidget(self.preview)
    else:
      self.preview.hide()

    #
    # action related column (interacting with slicer)
    #
    self.loadableTableFrame = qt.QWidget()
    self.loadableTableFrame.setMaximumHeight(200)
    self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame)
    self.layout.addWidget(self.loadableTableFrame)

    self.loadableTableLayout.addWidget(self.userFrame)
    self.userFrame.hide()

    tableWidth = 350 if showHeader else 600
    self.loadableTable = DICOMLoadableTable(self.userFrame,width=tableWidth)
    #self.loadableTableLayout.addWidget(self.loadableTable.widget)
    #self.loadableTable.widget.hide()

    #
    # button row for action column
    #
    self.actionButtonsFrame = qt.QWidget()
    self.actionButtonsFrame.setMaximumHeight(40)
    self.layout.addWidget(self.actionButtonsFrame)
    #self.layout.addStretch(1)
    self.actionButtonLayout = qt.QHBoxLayout()
    self.actionButtonsFrame.setLayout(self.actionButtonLayout)

    self.loadButton = qt.QPushButton('Load')
    self.loadButton.enabled = True
    self.loadButton.toolTip = 'Load Selection to Slicer'
    self.actionButtonLayout.addWidget(self.loadButton)
    self.loadButton.connect('clicked()', self.loadCheckedLoadables)

    self.headerPopup = DICOMLib.DICOMHeaderPopup()

    self.viewMetadataButton = qt.QPushButton('Metadata')
    self.viewMetadataButton.toolTip = 'Display Metadata of the Selected Series'
    self.viewMetadataButton.enabled = False
    self.actionButtonLayout.addWidget(self.viewMetadataButton)
    self.viewMetadataButton.connect('clicked()', self.onViewHeaderButton)
    self.viewMetadataButton.connect('clicked()', self.headerPopup.open)
    self.actionButtonLayout.addStretch(1)

    self.examineButton = qt.QPushButton('Examine')
    self.actionButtonLayout.addWidget(self.examineButton)
    self.examineButton.enabled = False
    self.examineButton.connect('clicked()', self.examineForLoading)

    self.uncheckAllButton = qt.QPushButton('Uncheck All')
    self.actionButtonLayout.addWidget(self.uncheckAllButton)
    self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables)
    self.actionButtonLayout.addStretch(1)

    self.closeButton = qt.QPushButton('Close')
    #self.actionButtonLayout.addWidget(self.closeButton)
    self.closeButton.connect('clicked()', self.close)

    self.advancedViewButton = qt.QCheckBox('Advanced')
    self.actionButtonLayout.addWidget(self.advancedViewButton)
    self.advancedViewButton.enabled = True
    self.advancedViewButton.checked = self.advancedView
    self.advancedViewButton.connect('clicked()', self.onAdvanedViewButton)

    self.horizontalViewCheckBox = qt.QCheckBox('Horizontal')
    self.horizontalViewCheckBox.checked = self.horizontalTables
    self.horizontalViewCheckBox.connect('clicked()', self.onHorizontalViewCheckBox)
    self.actionButtonLayout.addWidget(self.horizontalViewCheckBox)
    self.toolLayout.addStretch(1)

    self.browserPersistentButton = qt.QCheckBox('Browser Persistent')
    self.browserPersistentButton.toolTip = 'When enabled, DICOM Browser remains open after loading data or switching to another module'
    self.browserPersistentButton.checked = self.browserPersistent
    self.actionButtonLayout.addWidget(self.browserPersistentButton)
    self.browserPersistentButton.connect('stateChanged(int)', self.setBrowserPersistence)

    if self.advancedView:
      self.loadableTableFrame.visible = True
    else:
      self.loadableTableFrame.visible = False
      self.examineButton.visible = False
      self.uncheckAllButton.visible = False
    #
    # header related column (more details about the selected file)
    #
    if showHeader:
      self.headerLayout = qt.QVBoxLayout()
      self.layout.addLayout(self.headerLayout,selectionRow,2)
      self.header = DICOMHeaderWidget(self.window)
      self.headerLayout.addWidget(self.header.widget)

    #
    # Plugin selection widget
    #
    self.pluginSelector = DICOMPluginSelector(self.window)
    self.loadableTableLayout.addRow(self.pluginSelector.widget,self.loadableTable.widget)
    self.checkBoxByPlugins = []

    for pluginClass in slicer.modules.dicomPlugins:
      self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass]
      self.checkBox.connect('stateChanged(int)', self.onPluginStateChanged)
      self.checkBoxByPlugins.append(self.checkBox)
Esempio n. 9
0
  def create(self,widgetType='window',showHeader=False,showPreview=False):
    """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific
    extra widgets
    """

    # find internals of widget for reference and repacking
    self.toolBar = slicer.util.findChildren(self.dicomBrowser, 'ToolBar')[0]
    self.databaseNameLabel = slicer.util.findChildren(self.dicomBrowser, 'DatabaseNameLabel')[0]
    self.databaseDirectoryButton = slicer.util.findChildren(self.dicomBrowser, 'DirectoryButton')[0]
    #self.tables = self.dicomBrowser.tableManager
    self.tables = slicer.util.findChildren(self.dicomBrowser, 'dicomTableManager')[0]

    #self.userFrame = slicer.util.findChildren(self.dicomBrowser, 'UserFrame')[0]
    self.userFrame = qt.QWidget()
    #self.thumbs = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailsWidget')[0]
    #self.widthSlider = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailWidthSlider')[0]
    self.preview = qt.QWidget()

    self.widgetType = widgetType
    if widgetType == 'dialog':
      self.window = qt.QDialog(self.dicomBrowser)
    elif widgetType == 'window':
      self.window = qt.QWidget()
    elif widgetType == 'popup':
      self.window = ctk.ctkPopupWidget(self.dicomBrowser)
      self.window.orientation = 1
      self.window.horizontalDirection = 0
      self.window.alignment = 0x82
    elif widgetType == 'dock':
      self.dock = qt.QDockWidget(slicer.util.mainWindow())
      self.dock.setFeatures( qt.QDockWidget.DockWidgetFloatable |
                                qt.QDockWidget.DockWidgetMovable |
                                qt.QDockWidget.DockWidgetClosable )
      slicer.util.mainWindow().addDockWidget(0x15, self.dock)
      self.window = qt.QFrame()
      self.dock.setWidget(self.window)
    else:
      raise "Unknown widget type - should be dialog, window, dock or popup"

    self.setModality(not self.browserPersistent)

    self.window.setWindowTitle('DICOM Browser')

    self.layout = qt.QVBoxLayout(self.window)

    # tool row at top, with commands and database
    self.toolFrame = qt.QWidget()
    self.toolFrame.setMaximumHeight(40)
    self.toolLayout = qt.QHBoxLayout(self.toolFrame)
    self.layout.addWidget(self.toolFrame)
    self.toolLayout.addWidget(self.toolBar)
    self.toolLayout.addWidget(self.databaseNameLabel)
    self.databaseNameLabel.visible = False
    self.toolLayout.addWidget(self.databaseDirectoryButton)
    self.databaseDirectoryButton.visible = False
    self.settingsButton = ctk.ctkExpandButton()
    self.toolBar.addWidget(self.settingsButton)
    self.settingsButton.connect('toggled(bool)', self.onSettingsButton)

    # tables goes next, spread across 1 row, 2 columns
    self.tables.tableOrientation = self.tableOrientation
    self.tables.dynamicTableLayout = False
    self.tablesExpandableWidget = ctk.ctkExpandableWidget()
    self.tablesLayout = qt.QVBoxLayout(self.tablesExpandableWidget)
    self.tablesLayout.addWidget(self.tables)
    self.tablesExpandableWidget.setMinimumHeight(400)
    self.layout.addWidget(self.tablesExpandableWidget)

    #
    # preview related column
    #
    self.previewLayout = qt.QVBoxLayout()
    #self.layout.addLayout(self.previewLayout,selectionRow,0)

    #self.previewLayout.addWidget(self.thumbs)
    #self.previewLayout.addWidget(self.widthSlider)
    if showPreview:
      self.previewLayout.addWidget(self.preview)
    else:
      self.preview.hide()

    #
    # action related column (interacting with slicer)
    #
    self.loadableTableFrame = qt.QWidget()
    self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame)
    self.layout.addWidget(self.loadableTableFrame)

    self.loadableTableLayout.addWidget(self.userFrame)
    self.userFrame.hide()

    tableWidth = 350 if showHeader else 600
    self.loadableTable = DICOMLoadableTable(self.userFrame,width=tableWidth)
    #self.loadableTableLayout.addWidget(self.loadableTable.widget)
    #self.loadableTable.widget.hide()

    #
    # button row for action column
    #
    self.actionButtonsFrame = qt.QWidget()
    self.actionButtonsFrame.setMaximumHeight(40)
    self.layout.addWidget(self.actionButtonsFrame)
    #self.layout.addStretch(1)
    self.actionButtonLayout = qt.QHBoxLayout()
    self.actionButtonsFrame.setLayout(self.actionButtonLayout)

    self.loadButton = qt.QPushButton('Load')
    self.loadButton.enabled = True
    self.loadButton.toolTip = 'Load Selection to Slicer'
    self.actionButtonLayout.addWidget(self.loadButton)
    self.loadButton.connect('clicked()', self.loadCheckedLoadables)

    self.headerPopup = DICOMLib.DICOMHeaderPopup()

    self.viewMetadataButton = qt.QPushButton('Metadata')
    self.viewMetadataButton.toolTip = 'Display Metadata of the Selected Series'
    self.viewMetadataButton.enabled = False
    self.actionButtonLayout.addWidget(self.viewMetadataButton)
    self.viewMetadataButton.connect('clicked()', self.onViewHeaderButton)
    self.viewMetadataButton.connect('clicked()', self.headerPopup.open)
    self.actionButtonLayout.addStretch(1)

    self.examineButton = qt.QPushButton('Examine')
    self.actionButtonLayout.addWidget(self.examineButton)
    self.examineButton.enabled = False
    self.examineButton.connect('clicked()', self.examineForLoading)

    self.uncheckAllButton = qt.QPushButton('Uncheck All')
    self.actionButtonLayout.addWidget(self.uncheckAllButton)
    self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables)
    self.actionButtonLayout.addStretch(1)

    self.closeButton = qt.QPushButton('Close')
    #self.actionButtonLayout.addWidget(self.closeButton)
    self.closeButton.connect('clicked()', self.close)

    self.advancedViewButton = qt.QCheckBox('Advanced')
    self.actionButtonLayout.addWidget(self.advancedViewButton)
    self.advancedViewButton.enabled = True
    self.advancedViewButton.checked = self.advancedViewCheckState
    self.advancedViewButton.connect('clicked()', self.onAdvanedViewButton)

    self.horizontalViewCheckBox = qt.QCheckBox('Horizontal Tables')
    self.horizontalViewCheckBox.visible = False
    self.toolLayout.addWidget(self.horizontalViewCheckBox)
    self.horizontalViewCheckBox.enabled = True
    if self.tableOrientation == 1:
      self.horizontalViewCheckBox.checked = True
    self.horizontalViewCheckBox.connect('stateChanged(int)', self.onHorizontalViewCheckBox)

    self.browserPersistentButton = qt.QCheckBox('Browser Persistent')
    self.browserPersistentButton.toolTip = 'When enabled, DICOM Browser remains open after loading data or switching to another module'
    self.browserPersistentButton.checked = self.browserPersistent
    self.actionButtonLayout.addWidget(self.browserPersistentButton)
    self.browserPersistentButton.connect('stateChanged(int)', self.setBrowserPersistence)


    if self.advancedViewCheckState == True:
      self.loadableTableFrame.show()
      self.window.adjustSize()
    else:
      self.examineButton.hide()
      self.uncheckAllButton.hide()
      self.loadableTableFrame.hide()
      self.window.adjustSize()
    #
    # header related column (more details about the selected file)
    #
    if showHeader:
      self.headerLayout = qt.QVBoxLayout()
      self.layout.addLayout(self.headerLayout,selectionRow,2)
      self.header = DICOMHeaderWidget(self.window)
      self.headerLayout.addWidget(self.header.widget)

    #
    # Plugin selection widget
    #
    self.pluginSelector = DICOMPluginSelector(self.window)
    self.loadableTableLayout.addRow(self.pluginSelector.widget,self.loadableTable.widget)
    self.checkBoxByPlugins = []

    for pluginClass in slicer.modules.dicomPlugins:
      self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass]
      self.checkBox.connect('stateChanged(int)', self.onPluginStateChanged)
      self.checkBoxByPlugins.append(self.checkBox)