def setup(self): super(SliceTrackerTargetTablePlugin, self).setup() self.targetTable = qt.QTableView() self.targetTableModel = CustomTargetTableModel(self.logic) # self.targetTableModel.addEventObserver(vtk.vtkCommand.ModifiedEvent, self.updateNeedleModel) self.targetTable.setModel(self.targetTableModel) self.targetTable.setSelectionBehavior(qt.QTableView.SelectItems) self.setTargetTableSizeConstraints() self.targetTable.verticalHeader().hide() self.targetTable.minimumHeight = 150 self.targetTable.setStyleSheet("QTableView::item:selected{background-color: #ff7f7f; color: black};") self.layout().addWidget(self.targetTable)
def setup(self): super(TargetsDefinitionTable, self).setup() self.targetTable = qt.QTableView() self.targetTableModel = CustomTargetTableModel(self.session) self.targetTable.setModel(self.targetTableModel) self.displayCol = self.targetTableModel.getColunmNumForHeaderName(self.targetTableModel.COLUMN_DISPLAY) self.needleTypeCol = self.targetTableModel.getColunmNumForHeaderName(self.targetTableModel.COLUMN_NEEDLETYPE) self.targetTable.setItemDelegateForColumn(self.displayCol, CheckBoxDelegate(self, self.session)) self.targetTable.setItemDelegateForColumn(self.needleTypeCol, ComBoxDelegate(self, self.session)) self.setTargetTableSizeConstraints() self.targetTable.verticalHeader().hide() self.targetTable.minimumHeight = 150 self.targetTable.setStyleSheet("QTableView::item:selected{background-color: #ff7f7f; color: black};") self.layout().addWidget(self.targetTable)
def __init__(self, columnNames): super().__init__() self.addButton = qt.QPushButton('+') self.addButton.clicked.connect(self.onAddButton) self.removeButton = qt.QPushButton('-') self.removeButton.clicked.connect(self.onRemoveButton) self.linkStagesPushButton = qt.QPushButton('Link Across Stages') self.linkStagesPushButton.toolTip = 'When checked, settings will be the same for all stages.' self.linkStagesPushButton.checkable = True self.buttonsFrame = qt.QFrame() self.buttonsFrame.setSizePolicy(qt.QSizePolicy.Preferred, qt.QSizePolicy.Minimum) self.buttonsFrame.setLayout(qt.QHBoxLayout()) self.buttonsFrame.layout().addWidget(self.addButton) self.buttonsFrame.layout().addWidget(self.removeButton) self.buttonsFrame.layout().addWidget(self.linkStagesPushButton) self.model = qt.QStandardItemModel(1, len(columnNames)) for i, columnName in enumerate(columnNames): self.model.setHeaderData(i, qt.Qt.Horizontal, columnName) self.view = qt.QTableView() self.view.setEditTriggers(self.view.CurrentChanged + self.view.DoubleClicked + self.view.SelectedClicked) self.view.setSelectionMode(self.view.SingleSelection) self.view.setSelectionBehavior(self.view.SelectRows) self.view.horizontalHeader().setStretchLastSection(True) self.view.setHorizontalScrollMode(self.view.ScrollPerPixel) self.view.verticalHeader().setMaximumSectionSize(self.RowHeight) self.view.verticalHeader().setMinimumSectionSize(self.RowHeight) self.view.verticalHeader().setDefaultSectionSize(self.RowHeight) self.view.setFixedHeight(65) self.view.setModel(self.model) self.view.setCurrentIndex(self.model.index(0, 0)) self.view.selectionModel().selectionChanged.connect( self.onSelectionChanged) layout = qt.QVBoxLayout(self) layout.addWidget(self.buttonsFrame) layout.addWidget(self.view) return layout
def setupSegmentationSelector(self, Layout, parent): self.segmentationSelector = slicer.qMRMLNodeComboBox() self.segmentationSelector.nodeTypes = ["vtkMRMLSegmentationNode"] self.segmentationSelector.addEnabled = False self.segmentationSelector.removeEnabled = True self.segmentationSelector.renameEnabled = True self.segmentationSelector.setMRMLScene(slicer.mrmlScene) self.segmentationSelector.setToolTip( "Pick the segmentation to compute statistics for") Layout.addRow("Segmentation:", self.segmentationSelector) self.scalarSelector = slicer.qMRMLNodeComboBox() self.scalarSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.scalarSelector.addEnabled = False self.scalarSelector.removeEnabled = True self.scalarSelector.renameEnabled = True self.scalarSelector.noneEnabled = True self.scalarSelector.showChildNodeTypes = False self.scalarSelector.setMRMLScene(slicer.mrmlScene) self.scalarSelector.setToolTip( "Select the scalar volume that you want to get the statistics") Layout.addRow("Scalar Volume 1:", self.scalarSelector) self.scalarSelector2 = slicer.qMRMLNodeComboBox() self.scalarSelector2.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.scalarSelector2.addEnabled = False self.scalarSelector2.removeEnabled = True self.scalarSelector2.renameEnabled = True self.scalarSelector2.noneEnabled = True self.scalarSelector2.showChildNodeTypes = False self.scalarSelector2.setMRMLScene(slicer.mrmlScene) self.scalarSelector2.setToolTip( "Select the scalar volume that you want to get the statistics") Layout.addRow("Scalar Volume 2:", self.scalarSelector2) self.SButton = qt.QPushButton("Get Statistics") self.SButton.toolTip = "Get the statistics for the segmentation selected" self.SButton.enabled = False Layout.addRow(self.SButton) self.table = qt.QTableView() self.table.sortingEnabled = True parent.addWidget(self.table)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # # the inps volume selector # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "IO Volumes" self.parent.layout().addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) parametersFormLayout.setVerticalSpacing(5) self.CTSelector = slicer.qMRMLNodeComboBox() self.CTSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "") self.CTSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", 0) self.CTSelector.selectNodeUponCreation = False self.CTSelector.addEnabled = False self.CTSelector.removeEnabled = False self.CTSelector.noneEnabled = True self.CTSelector.showHidden = False self.CTSelector.showChildNodeTypes = False self.CTSelector.setMRMLScene(slicer.mrmlScene) self.CTSelector.setToolTip("Pick the CT image to work on.") parametersFormLayout.addRow("Input CT Volume: ", self.CTSelector) # # the label map volume selector # self.labelSelector = slicer.qMRMLNodeComboBox() # self.labelSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" ) # self.labelSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 1 ) self.labelSelector.nodeTypes = (("vtkMRMLLabelMapVolumeNode"), "") self.labelSelector.selectNodeUponCreation = True self.labelSelector.addEnabled = False self.labelSelector.removeEnabled = False self.labelSelector.noneEnabled = True self.labelSelector.showHidden = False self.labelSelector.showChildNodeTypes = False self.labelSelector.setMRMLScene(slicer.mrmlScene) self.labelSelector.setToolTip("Pick the label map to the algorithm.") parametersFormLayout.addRow("Label Map Volume: ", self.labelSelector) # Image filtering section self.preProcessingWidget = PreProcessingWidget( self.moduleName, parentWidget=self.parent) self.preProcessingWidget.setup() # # self.splitRadioButton = qt.QRadioButton() # self.splitRadioButton.setText('Split Label Map') # self.splitRadioButton.setChecked(0) # self.parent.layout().addWidget(self.splitRadioButton, 0, 3) # Apply button self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Calculate Parenchyma Phenotypes." self.applyButton.enabled = False self.applyButton.setFixedSize(300, 30) self.parent.layout().addWidget(self.applyButton, 0, 4) # model and view for stats table self.view = qt.QTableView() self.view.sortingEnabled = True self.parent.layout().addWidget(self.view) # model and view for EXP stats table """self.viewexp = qt.QTableView() self.viewexp.sortingEnabled = True self.parent.layout().addWidget(self.viewexp)""" # Histogram Selection self.HistSection = qt.QFrame() self.HistSection.setLayout(qt.QVBoxLayout()) self.parent.layout().addWidget(self.HistSection) self.HistSection.setObjectName('HistSection') self.HistSection.setStyleSheet( '#HistSection {border: 0.5px solid lightGray; }') HistSectionTitle = qt.QLabel() HistSectionTitle.setText('Histogram Section') # HistSectionTitle.setStyleSheet('border: 1px solid white; color: black') self.HistSection.layout().addWidget(HistSectionTitle) self.histogramCheckBoxes = [] self.histFrame = qt.QFrame() # self.histFrame.setStyleSheet('border: 1px solid white') self.histFrame.setLayout(qt.QHBoxLayout()) self.GlobalHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.GlobalHistCheckBox) self.histFrame.layout().addWidget(self.GlobalHistCheckBox) self.RightHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.RightHistCheckBox) self.histFrame.layout().addWidget(self.RightHistCheckBox) self.LeftHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.LeftHistCheckBox) self.histFrame.layout().addWidget(self.LeftHistCheckBox) self.RULHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.RULHistCheckBox) self.histFrame.layout().addWidget(self.RULHistCheckBox) self.RLLHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.RLLHistCheckBox) self.histFrame.layout().addWidget(self.RLLHistCheckBox) self.RMLHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.RMLHistCheckBox) self.histFrame.layout().addWidget(self.RMLHistCheckBox) self.LULHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.LULHistCheckBox) self.histFrame.layout().addWidget(self.LULHistCheckBox) self.LLLHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.LLLHistCheckBox) self.histFrame.layout().addWidget(self.LLLHistCheckBox) self.LUTHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.LUTHistCheckBox) self.histFrame.layout().addWidget(self.LUTHistCheckBox) self.LMTHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.LMTHistCheckBox) self.histFrame.layout().addWidget(self.LMTHistCheckBox) self.LLTHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.LLTHistCheckBox) self.histFrame.layout().addWidget(self.LLTHistCheckBox) self.RUTHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.RUTHistCheckBox) self.histFrame.layout().addWidget(self.RUTHistCheckBox) self.RMTHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.RMTHistCheckBox) self.histFrame.layout().addWidget(self.RMTHistCheckBox) self.RLTHistCheckBox = qt.QCheckBox() self.histogramCheckBoxes.append(self.RLTHistCheckBox) self.histFrame.layout().addWidget(self.RLTHistCheckBox) for i in xrange(len(self.histogramCheckBoxes)): self.histogramCheckBoxes[i].setText(self.rTags[i]) self.histogramCheckBoxes[i].hide() self.HistSection.layout().addWidget(self.histFrame) self.HistSection.enabled = False # Chart button self.chartBox = qt.QFrame() self.chartBox.setObjectName("chartBox") self.chartBox.setStyleSheet( '#chartBox {border: 0.5px solid lightGray;}') self.chartBox.setLayout(qt.QVBoxLayout()) self.parent.layout().addWidget(self.chartBox) chartSectionTitle = qt.QLabel() chartSectionTitle.setText('Chart Section') self.chartBox.layout().addWidget(chartSectionTitle) chartFrame = qt.QFrame() chartFrame.setLayout(qt.QHBoxLayout()) self.chartBox.layout().addWidget(chartFrame) self.chartButton = qt.QPushButton("Chart") self.chartButton.toolTip = "Make a chart from the current statistics." chartFrame.layout().addWidget(self.chartButton) self.chartOption = qt.QComboBox() self.chartOption.addItems(self.chartOptions) chartFrame.layout().addWidget(self.chartOption) self.chartBox.enabled = False self.reportsWidget = CaseReportsWidget(self.moduleName, self.columnsDict, parentWidget=self.parent) self.reportsWidget.setup() self.reportsWidget.showPrintButton(True) # self.reportsWidget.saveButton.enabled = False # self.reportsWidget.openButton.enabled = False # self.reportsWidget.exportButton.enabled = False # self.reportsWidget.removeButton.enabled = False # By default, the Print button is hidden # self.reportsWidget.showPrintButton.enabled = False # Add vertical spacer self.parent.layout().addStretch(1) # connections self.applyButton.connect('clicked()', self.onApply) self.chartButton.connect('clicked()', self.onChart) self.reportsWidget.addObservable( self.reportsWidget.EVENT_SAVE_BUTTON_CLICKED, self.onSaveReport) self.reportsWidget.addObservable( self.reportsWidget.EVENT_PRINT_BUTTON_CLICKED, self.onPrintReport) self.CTSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onCTSelect) self.labelSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onLabelSelect) self.GlobalHistCheckBox.connect('clicked()', self.onHistogram) self.RightHistCheckBox.connect('clicked()', self.onHistogram) self.LeftHistCheckBox.connect('clicked()', self.onHistogram) self.RULHistCheckBox.connect('clicked()', self.onHistogram) self.RLLHistCheckBox.connect('clicked()', self.onHistogram) self.RMLHistCheckBox.connect('clicked()', self.onHistogram) self.LULHistCheckBox.connect('clicked()', self.onHistogram) self.LLLHistCheckBox.connect('clicked()', self.onHistogram) self.LUTHistCheckBox.connect('clicked()', self.onHistogram) self.LMTHistCheckBox.connect('clicked()', self.onHistogram) self.LLTHistCheckBox.connect('clicked()', self.onHistogram) self.RUTHistCheckBox.connect('clicked()', self.onHistogram) self.RMTHistCheckBox.connect('clicked()', self.onHistogram) self.RLTHistCheckBox.connect('clicked()', self.onHistogram)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... ### Parameters Area inputCollapsibleButton = ctk.ctkCollapsibleButton() inputCollapsibleButton.text = "Input" self.layout.addWidget(inputCollapsibleButton) # Layout within the dummy collapsible button inputFormLayout = qt.QFormLayout(inputCollapsibleButton) # fixed landmarks (mrml input) self.fixedLandmarks = slicer.qMRMLNodeComboBox() self.fixedLandmarks.nodeTypes = ["vtkMRMLMarkupsFiducialNode"] self.fixedLandmarks.selectNodeUponCreation = True self.fixedLandmarks.addEnabled = False self.fixedLandmarks.removeEnabled = False self.fixedLandmarks.noneEnabled = True self.fixedLandmarks.showHidden = False self.fixedLandmarks.renameEnabled = True self.fixedLandmarks.setMRMLScene(slicer.mrmlScene) self.fixedLandmarks.setToolTip("Landmarks on fixed image.") inputFormLayout.addRow("Fixed landmarks: ", self.fixedLandmarks) # fixed landmarks (directory input) self.fixedLandmarksDirectory = ctk.ctkDirectoryButton() self.fixedLandmarksDirectory.directory = qt.QDir.homePath() inputFormLayout.addRow("", self.fixedLandmarksDirectory) # moving landmarks (mrml input) self.movingLandmarks = slicer.qMRMLNodeComboBox() self.movingLandmarks.nodeTypes = ["vtkMRMLMarkupsFiducialNode"] self.movingLandmarks.selectNodeUponCreation = True self.movingLandmarks.addEnabled = False self.movingLandmarks.removeEnabled = False self.movingLandmarks.noneEnabled = True self.movingLandmarks.showHidden = False self.movingLandmarks.showChildNodeTypes = False self.movingLandmarks.setMRMLScene(slicer.mrmlScene) self.movingLandmarks.setToolTip("Landmarks on moving image.") inputFormLayout.addRow("Moving landmarks: ", self.movingLandmarks) self.view = qt.QTableView() self.view.sortingEnabled = True self.parent.layout().addWidget(self.view) # moving landmarks (directory input) self.movingLandmarksDirectory = ctk.ctkDirectoryButton() self.movingLandmarksDirectory.directory = qt.QDir.homePath() inputFormLayout.addRow("", self.movingLandmarksDirectory) # Apply Button self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True self.layout.addWidget(self.applyButton) ### Output Area outputCollapsibleButton = ctk.ctkCollapsibleButton() outputCollapsibleButton.text = "Output statistics" self.layout.addWidget(outputCollapsibleButton) # Layout within the dummy collapsible button outputFormLayout = qt.QFormLayout(outputCollapsibleButton) # output statistics buttonLayout = qt.QHBoxLayout() self.averageError = qt.QLineEdit() self.averageErrorValue = 1 self.averageError.setToolTip("Average landmark separation") buttonLayout.addWidget(self.averageError) outputFormLayout.addRow("Average error:", buttonLayout) buttonLayout = qt.QHBoxLayout() self.Variance = qt.QLineEdit() self.VarianceValue = 1 self.Variance.setToolTip("Variance") buttonLayout.addWidget(self.Variance) outputFormLayout.addRow("Variance:", buttonLayout) buttonLayout = qt.QHBoxLayout() self.stDev = qt.QLineEdit() self.stDevValue = 1 self.stDev.setToolTip("Standard deviation") buttonLayout.addWidget(self.stDev) outputFormLayout.addRow("Standard deviation:", buttonLayout) # model and view for stats table self.view = qt.QTableView() self.view.sortingEnabled = True self.parent.layout().addWidget(self.view) # connections self.fixedLandmarks.connect("currentNodeChanged(vtkMRMLNode*)", self.onFixedLandmarksSelect) self.movingLandmarks.connect("currentNodeChanged(vtkMRMLNode*)", self.onMovingLandmarksSelect) self.applyButton.connect('clicked(bool)', self.onMismatchErrorApply)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Input/Export Area # IOCollapsibleButton = ctk.ctkCollapsibleButton() IOCollapsibleButton.text = "Input and Export" self.layout.addWidget(IOCollapsibleButton) # Layout within the dummy collapsible button #IOFormLayout = qt.QFormLayout(IOCollapsibleButton) IOFormLayout = qt.QFormLayout(IOCollapsibleButton) # # Username input # self.userNameInput = qt.QLineEdit() self.userNameInput.setText(slicer.userNameDefault) self.userNameInput.setToolTip("Input MorphoSource account username") IOFormLayout.addRow("MorphSource Username: "******"Input MorphoSource account password") IOFormLayout.addRow("MorphSource Password: "******"Log in") self.loginButton.toolTip = "Log into the Morphosource database" self.loginButton.enabled = False IOFormLayout.addRow(self.loginButton) # # Query parameter area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Query parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Username input # self.orderInput = qt.QLineEdit() self.orderInput.setToolTip( "Input the the specimen order, eg: 'Euprimates' ") parametersFormLayout.addRow("Query order: ", self.orderInput) # # Username input # self.elementInput = qt.QLineEdit() self.elementInput.setToolTip( "Input the speciment element, eg: 'Cranuim' ") parametersFormLayout.addRow("Query element: ", self.elementInput) # # Submit query Button # self.submitQueryButton = qt.QPushButton("Submit query") self.submitQueryButton.toolTip = "Query the MorphoSource database for 3D models. This may take a few minutes." self.submitQueryButton.enabled = False parametersFormLayout.addRow(self.submitQueryButton) # # Query results area # resultsCollapsibleButton = ctk.ctkCollapsibleButton() resultsCollapsibleButton.text = "Query results:" resultsCollapsibleButton.collapsed = False self.layout.addWidget(resultsCollapsibleButton) resultsFormLayout = qt.QFormLayout(resultsCollapsibleButton) self.resultsModel = qt.QStandardItemModel() self.resultsTable = qt.QTableView() self.resultsTable.horizontalHeader().stretchLastSection = True self.resultsTable.horizontalHeader().visible = False self.resultsTable.verticalHeader().visible = False self.resultsTable.setSelectionBehavior( qt.QAbstractItemView().SelectRows) self.resultsTable.setModel(self.resultsModel) resultsFormLayout.addRow(self.resultsTable) self.loadResultsButton = qt.QPushButton("Load selected models") self.loadResultsButton.toolTip = "Load the selected models into the scene." self.loadResultsButton.enabled = False resultsFormLayout.addRow(self.loadResultsButton) # connections self.loginButton.connect('clicked(bool)', self.onLogin) self.userNameInput.connect('textChanged(const QString &)', self.onLoginStringChanged) self.passwordInput.connect('textChanged(const QString &)', self.onLoginStringChanged) self.orderInput.connect('textChanged(const QString &)', self.onQueryStringChanged) self.elementInput.connect('textChanged(const QString &)', self.onQueryStringChanged) self.submitQueryButton.connect('clicked(bool)', self.onSubmitQuery) self.loadResultsButton.connect('clicked(bool)', self.onLoadResults) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onLoginStringChanged() self.onQueryStringChanged()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # File area # filesCollapsibleButton = ctk.ctkCollapsibleButton() filesCollapsibleButton.text = "Files" filesCollapsibleButton.collapsed = False self.layout.addWidget(filesCollapsibleButton) # Layout within the files collapsible button filesFormLayout = qt.QFormLayout(filesCollapsibleButton) self.fileModel = qt.QStandardItemModel() self.fileTable = qt.QTableView() self.fileTable.horizontalHeader().stretchLastSection = True self.fileTable.horizontalHeader().visible = False self.fileTable.setModel(self.fileModel) filesFormLayout.addRow(self.fileTable) buttonLayout = qt.QHBoxLayout() self.addByBrowsingButton = qt.QPushButton("Browse for files") self.clearFilesButton = qt.QPushButton("Clear files") buttonLayout.addWidget(self.addByBrowsingButton) buttonLayout.addWidget(self.clearFilesButton) filesFormLayout.addRow(buttonLayout) # # output area # outputCollapsibleButton = ctk.ctkCollapsibleButton() outputCollapsibleButton.text = "Output" outputCollapsibleButton.collapsed = False self.layout.addWidget(outputCollapsibleButton) outputFormLayout = qt.QFormLayout(outputCollapsibleButton) # # output volume selector # #self.outputSelector = slicer.qMRMLSubjectHierarchyComboBox() self.outputSelector = slicer.qMRMLNodeComboBox() self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode",] #self.outputSelector.setNodeTypes(["vtkMRMLScalarVolumeNode",]) ; TODO: make nodeTypes property for SH box """ TODO: which are supported and needed for SubjectHierarchy combo box. TODO: can we delete/rename/create as with SH self.outputSelector.defaultText = "Create new volume." ; # TODO any way to reset value? """ self.outputSelector.showChildNodeTypes = False self.outputSelector.showHidden = False self.outputSelector.showChildNodeTypes = False self.outputSelector.selectNodeUponCreation = False self.outputSelector.noneEnabled = True self.outputSelector.removeEnabled = True self.outputSelector.renameEnabled = True self.outputSelector.addEnabled = True self.outputSelector.setMRMLScene( slicer.mrmlScene ) self.outputSelector.setToolTip( "Pick the output volume to populate or None to autogenerate." ) outputFormLayout.addRow("Output Volume: ", self.outputSelector) self.spacing = ctk.ctkCoordinatesWidget() self.spacing.coordinates = "1,1,1" self.spacing.toolTip = "Set the colunm, row, slice spacing in mm" outputFormLayout.addRow("Spacing: ", self.spacing) self.loadButton = qt.QPushButton("Load files") outputFormLayout.addRow(self.loadButton) # # Add by name area # addByNameCollapsibleButton = ctk.ctkCollapsibleButton() addByNameCollapsibleButton.text = "Add files by name" addByNameCollapsibleButton.collapsed = True addByNameFormLayout = qt.QFormLayout(addByNameCollapsibleButton) # Don't enable Add by name for now - let's see if it's actually needed # self.layout.addWidget(addByNameCollapsibleButton) forExample = """ directoryPath = '/Volumes/SSD2T/data/SlicerMorph/Sample_for_steve/1326_Rec' pathFormat = '%s/1326__rec%04d.png' start, end = (50, 621) """ self.archetypePathEdit = ctk.ctkPathLineEdit() addByNameFormLayout.addRow("Archetype file", self.archetypePathEdit) self.archetypeFormat = qt.QLineEdit() addByNameFormLayout.addRow("Name format", self.archetypeFormat) self.indexRange = ctk.ctkRangeWidget() self.indexRange.decimals = 0 self.indexRange.maximum = 0 addByNameFormLayout.addRow("Index range", self.indexRange) self.generateNamesButton = qt.QPushButton("Apply") self.generateNamesButton.toolTip = "Run the algorithm." self.generateNamesButton.enabled = False addByNameFormLayout.addRow(self.generateNamesButton) # connections self.addByBrowsingButton.connect('clicked()', self.addByBrowsing) self.clearFilesButton.connect('clicked()', self.fileTable.model().clear) self.archetypePathEdit.connect('currentPathChanged(QString)', self.validateInput) self.archetypePathEdit.connect('currentPathChanged(QString)', self.updateGUIFromArchetype) self.archetypeFormat.connect('textChanged(QString)', self.validateInput) self.generateNamesButton.connect('clicked()', self.onGenerateNames) # self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.validateInput) # TODO - this is missing self.loadButton.connect('clicked()', self.onLoadButton) # refill last selection self.archetypePathEdit.currentPath = slicer.util.settingsValue("ImageStacks/lastArchetypePath", "") # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.validateInput()
def __init__(self): columnNames = ["Include", "Name", "Radius"] self.model = firstColumnCheckableModel(1, len(columnNames)) self.model.updateSelectedFuntion = self.updateSelected for i, columnName in enumerate(columnNames): self.model.setHeaderData(i, qt.Qt.Horizontal, columnName) self.view = qt.QTableView() self.view.setEditTriggers(self.view.DoubleClicked) self.view.setSelectionMode(self.view.SingleSelection) self.view.setSelectionBehavior(self.view.SelectRows) self.view.horizontalHeader().setStretchLastSection(True) self.view.verticalHeader().setDefaultSectionSize( self.view.verticalHeader().defaultSectionSize * 3 / 4) self.view.setHorizontalScrollMode(self.view.ScrollPerPixel) self.view.setModel(self.model) self.view.clicked.connect(self.onSelectionChanged) self.view.setItemDelegateForColumn( 1, TextEditDelegate(self.model, self.renameControlPoints)) self.view.setItemDelegateForColumn( 2, SpinBoxDelegate(self.model, self.updateRadius)) super().__init__() effectPixmap = qt.QPixmap( os.path.join( os.path.split(WarpDrive.__file__)[0], 'Resources', 'Icons', 'SlicerVisible.png')) effectIcon = qt.QIcon(effectPixmap) self.sourceVisibleButton = qt.QToolButton() self.sourceVisibleButton.setToolButtonStyle( qt.Qt.ToolButtonTextUnderIcon) self.sourceVisibleButton.setIcon(effectIcon) self.sourceVisibleButton.setIconSize(effectPixmap.rect().size()) self.sourceVisibleButton.setText('Source') self.sourceVisibleButton.setToolTip( 'Toggle source fiducials visibility') self.sourceVisibleButton.setCheckable(True) self.sourceVisibleButton.setChecked(False) self.sourceVisibleButton.setEnabled(True) self.sourceVisibleButton.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Maximum) self.sourceVisibleButton.toggled.connect(self.onSourceVisibleToggled) effectPixmap = qt.QPixmap( os.path.join( os.path.split(WarpDrive.__file__)[0], 'Resources', 'Icons', 'SlicerVisible.png')) effectIcon = qt.QIcon(effectPixmap) self.targetVisibleButton = qt.QToolButton() self.targetVisibleButton.setToolButtonStyle( qt.Qt.ToolButtonTextUnderIcon) self.targetVisibleButton.setIcon(effectIcon) self.targetVisibleButton.setIconSize(effectPixmap.rect().size()) self.targetVisibleButton.setText('Target') self.targetVisibleButton.setToolTip( 'Toggle target fiducials visibility') self.targetVisibleButton.setCheckable(True) self.targetVisibleButton.setChecked(False) self.targetVisibleButton.setEnabled(True) self.targetVisibleButton.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Maximum) self.targetVisibleButton.toggled.connect(self.onTargetVisibleToggled) self.buttonsFrame.layout().addWidget(self.sourceVisibleButton, 1) self.buttonsFrame.layout().addWidget(self.targetVisibleButton, 1) self.addButton.setText('Fixed point') self.addButton.setToolTip('Add fixed point')
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.chartOptions = ("Count", "Volume mm^3", "Volume cc", "Min", "Max", "Mean", "StdDev") self.logic = None self.grayscaleNode = None self.labelNode = None self.fileName = None self.fileDialog = None # Instantiate and connect widgets ... # # the grayscale volume selector # self.grayscaleSelectorFrame = qt.QFrame(self.parent) self.grayscaleSelectorFrame.setLayout(qt.QHBoxLayout()) self.parent.layout().addWidget(self.grayscaleSelectorFrame) self.grayscaleSelectorLabel = qt.QLabel("Grayscale Volume: ", self.grayscaleSelectorFrame) self.grayscaleSelectorLabel.setToolTip( "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations") self.grayscaleSelectorFrame.layout().addWidget(self.grayscaleSelectorLabel) self.grayscaleSelector = slicer.qMRMLNodeComboBox(self.grayscaleSelectorFrame) self.grayscaleSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.grayscaleSelector.selectNodeUponCreation = False self.grayscaleSelector.addEnabled = False self.grayscaleSelector.removeEnabled = False self.grayscaleSelector.noneEnabled = True self.grayscaleSelector.showHidden = False self.grayscaleSelector.showChildNodeTypes = False self.grayscaleSelector.setMRMLScene( slicer.mrmlScene ) # TODO: need to add a QLabel # self.grayscaleSelector.SetLabelText( "Master Volume:" ) self.grayscaleSelectorFrame.layout().addWidget(self.grayscaleSelector) # # the label volume selector # self.labelSelectorFrame = qt.QFrame() self.labelSelectorFrame.setLayout( qt.QHBoxLayout() ) self.parent.layout().addWidget( self.labelSelectorFrame ) self.labelSelectorLabel = qt.QLabel() self.labelSelectorLabel.setText( "Label Map: " ) self.labelSelectorFrame.layout().addWidget( self.labelSelectorLabel ) self.labelSelector = slicer.qMRMLNodeComboBox() self.labelSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] # todo addAttribute self.labelSelector.selectNodeUponCreation = False self.labelSelector.addEnabled = False self.labelSelector.noneEnabled = True self.labelSelector.removeEnabled = False self.labelSelector.showHidden = False self.labelSelector.showChildNodeTypes = True self.labelSelector.setMRMLScene( slicer.mrmlScene ) self.labelSelector.setToolTip( "Pick the label map to edit" ) self.labelSelectorFrame.layout().addWidget( self.labelSelector ) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Calculate Statistics." self.applyButton.enabled = False self.parent.layout().addWidget(self.applyButton) # model and view for stats table self.view = qt.QTableView() self.view.sortingEnabled = True self.parent.layout().addWidget(self.view) # Chart button self.chartFrame = qt.QFrame() self.chartFrame.setLayout(qt.QHBoxLayout()) self.parent.layout().addWidget(self.chartFrame) self.chartButton = qt.QPushButton("Chart") self.chartButton.toolTip = "Make a chart from the current statistics." self.chartFrame.layout().addWidget(self.chartButton) self.chartOption = qt.QComboBox() self.chartOption.addItems(self.chartOptions) self.chartFrame.layout().addWidget(self.chartOption) self.chartIgnoreZero = qt.QCheckBox() self.chartIgnoreZero.setText('Ignore Zero') self.chartIgnoreZero.checked = False self.chartIgnoreZero.setToolTip('Do not include the zero index in the chart to avoid dwarfing other bars') self.chartFrame.layout().addWidget(self.chartIgnoreZero) self.chartFrame.enabled = False # Save button self.exportToTableButton = qt.QPushButton("Export to table") self.exportToTableButton.toolTip = "Export statistics to table node" self.exportToTableButton.enabled = False self.parent.layout().addWidget(self.exportToTableButton) # Add vertical spacer self.parent.layout().addStretch(1) # connections self.applyButton.connect('clicked()', self.onApply) self.chartButton.connect('clicked()', self.onChart) self.exportToTableButton.connect('clicked()', self.onExportToTable) self.grayscaleSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onGrayscaleSelect) self.labelSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onLabelSelect)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # File area # filesCollapsibleButton = ctk.ctkCollapsibleButton() filesCollapsibleButton.text = "Files" filesCollapsibleButton.collapsed = False self.layout.addWidget(filesCollapsibleButton) # Layout within the files collapsible button filesFormLayout = qt.QFormLayout(filesCollapsibleButton) self.fileModel = qt.QStandardItemModel() self.fileTable = qt.QTableView() self.fileTable.horizontalHeader().stretchLastSection = True self.fileTable.horizontalHeader().visible = False self.fileTable.setModel(self.fileModel) filesFormLayout.addRow(self.fileTable) buttonLayout = qt.QHBoxLayout() self.addByBrowsingButton = qt.QPushButton("Browse for files") self.clearFilesButton = qt.QPushButton("Clear files") buttonLayout.addWidget(self.addByBrowsingButton) buttonLayout.addWidget(self.clearFilesButton) filesFormLayout.addRow(buttonLayout) self.propertiesLabel = qt.QLabel() filesFormLayout.addRow(self.propertiesLabel) # # output area # outputCollapsibleButton = ctk.ctkCollapsibleButton() outputCollapsibleButton.text = "Output" outputCollapsibleButton.collapsed = False self.layout.addWidget(outputCollapsibleButton) outputFormLayout = qt.QFormLayout(outputCollapsibleButton) # # output volume selector # self.outputSelector = slicer.qMRMLNodeComboBox() self.outputSelector.nodeTypes = [ "vtkMRMLScalarVolumeNode", ] self.outputSelector.showChildNodeTypes = False self.outputSelector.showHidden = False self.outputSelector.showChildNodeTypes = False self.outputSelector.selectNodeUponCreation = True self.outputSelector.noneEnabled = True self.outputSelector.removeEnabled = True self.outputSelector.renameEnabled = True self.outputSelector.addEnabled = True self.outputSelector.setMRMLScene(slicer.mrmlScene) self.outputSelector.setToolTip( "Pick the output volume to populate or None to autogenerate.") outputFormLayout.addRow("Output Volume: ", self.outputSelector) self.spacing = ctk.ctkCoordinatesWidget() self.spacing.decimals = 8 self.spacing.coordinates = "1,1,1" self.spacing.toolTip = "Set the colunm, row, slice spacing in mm; original spacing not including downsample" outputFormLayout.addRow("Spacing: ", self.spacing) self.downsample = qt.QCheckBox() self.downsample.toolTip = "Reduces data size by half in each dimension by skipping every other pixel and slice (uses about 1/8 memory)" outputFormLayout.addRow("Downsample: ", self.downsample) self.reverse = qt.QCheckBox() self.reverse.toolTip = "Read the images in reverse order" outputFormLayout.addRow("Reverse: ", self.reverse) self.sliceSkip = ctk.ctkDoubleSpinBox() self.sliceSkip.decimals = 0 self.sliceSkip.minimum = 0 self.sliceSkip.toolTip = "Skips the selected number of slices (use, for example, on long thin samples with more slices than in-plane resolution)" outputFormLayout.addRow("Slice skip: ", self.sliceSkip) self.loadButton = qt.QPushButton("Load files") outputFormLayout.addRow(self.loadButton) # # Add by name area # addByNameCollapsibleButton = ctk.ctkCollapsibleButton() addByNameCollapsibleButton.text = "Add files by name" addByNameCollapsibleButton.collapsed = True addByNameFormLayout = qt.QFormLayout(addByNameCollapsibleButton) # Don't enable Add by name for now - let's see if it's actually needed # self.layout.addWidget(addByNameCollapsibleButton) forExample = """ directoryPath = '/Volumes/SSD2T/data/SlicerMorph/Sample_for_steve/1326_Rec' pathFormat = '%s/1326__rec%04d.png' start, end = (50, 621) """ self.archetypePathEdit = ctk.ctkPathLineEdit() addByNameFormLayout.addRow("Archetype file", self.archetypePathEdit) self.archetypeFormat = qt.QLineEdit() addByNameFormLayout.addRow("Name format", self.archetypeFormat) self.indexRange = ctk.ctkRangeWidget() self.indexRange.decimals = 0 self.indexRange.maximum = 0 addByNameFormLayout.addRow("Index range", self.indexRange) self.generateNamesButton = qt.QPushButton("Apply") self.generateNamesButton.toolTip = "Run the algorithm." self.generateNamesButton.enabled = False addByNameFormLayout.addRow(self.generateNamesButton) # connections self.addByBrowsingButton.connect('clicked()', self.addByBrowsing) self.clearFilesButton.connect('clicked()', self.onClearFiles) self.archetypePathEdit.connect('currentPathChanged(QString)', self.validateInput) self.archetypePathEdit.connect('currentPathChanged(QString)', self.updateGUIFromArchetype) self.archetypeFormat.connect('textChanged(QString)', self.validateInput) self.generateNamesButton.connect('clicked()', self.onGenerateNames) # self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.validateInput) # TODO - this is missing self.loadButton.connect('clicked()', self.onLoadButton) # refill last selection self.archetypePathEdit.currentPath = slicer.util.settingsValue( "ImageStacks/lastArchetypePath", "") # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.validateInput()
def createSmall(self): """Make the internals of the widget to display in the Data Probe frame (lower left of slicer main window by default)""" # top row - things about the viewer itself self.viewerFrame = qt.QFrame(self.frame) self.viewerFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.viewerFrame) self.viewerColor = qt.QLabel(self.viewerFrame) self.viewerFrame.layout().addWidget(self.viewerColor) self.viewerName = qt.QLabel(self.viewerFrame) self.viewerFrame.layout().addWidget(self.viewerName) self.viewerRAS = qt.QLabel() self.viewerFrame.layout().addWidget(self.viewerRAS) self.viewerOrient = qt.QLabel() self.viewerFrame.layout().addWidget(self.viewerOrient) self.viewerSpacing = qt.QLabel() self.viewerFrame.layout().addWidget(self.viewerSpacing) self.viewerFrame.layout().addStretch(1) # the grid - things about the layers if True: # this method makes labels self.layerGrid = qt.QFrame(self.frame) self.layerGrid.setLayout(qt.QGridLayout()) self.frame.layout().addWidget(self.layerGrid) layers = ('L', 'F', 'B') self.layerNames = {} self.layerIJKs = {} self.layerValues = {} row = 0 for layer in layers: col = 0 self.layerGrid.layout().addWidget(qt.QLabel(layer), row, col) col += 1 self.layerNames[layer] = qt.QLabel() self.layerGrid.layout().addWidget(self.layerNames[layer], row, col) col += 1 self.layerIJKs[layer] = qt.QLabel() self.layerGrid.layout().addWidget(self.layerIJKs[layer], row, col) col += 1 self.layerValues[layer] = qt.QLabel() self.layerGrid.layout().addWidget(self.layerValues[layer], row, col) self.layerGrid.layout().setColumnStretch(col, 100) col += 1 row += 1 else: # this method use a model/view self.layerView = qt.QTableView(self.frame) self.layerView.verticalHeader().hide() self.frame.layout().addWidget(self.layerView) self.layerModel = qt.QStandardItemModel() self.layerView.setModel(self.layerModel) layers = ('L', 'F', 'B') self.layerNames = {} self.layerIJKs = {} self.layerValues = {} self.items = [] row = 0 for layer in layers: col = 0 item = qt.QStandardItem() item.setText(layer) self.layerModel.setItem(row, col, item) self.items.append(item) col += 1 self.layerNames[layer] = qt.QStandardItem() self.layerModel.setItem(row, col, self.layerNames[layer]) col += 1 self.layerIJKs[layer] = qt.QStandardItem() self.layerModel.setItem(row, col, self.layerIJKs[layer]) col += 1 self.layerValues[layer] = qt.QStandardItem() self.layerModel.setItem(row, col, self.layerValues[layer]) col += 1 row += 1 self.layerView.setColumnWidth(0, 15) self.layerView.setColumnWidth(1, 80) self.layerView.setColumnWidth(2, 65) self.layerView.setColumnWidth(3, 55) self.layerModel.setHeaderData(0, 1, "") self.layerModel.setHeaderData(1, 1, "Volume") self.layerModel.setHeaderData(2, 1, "IJK") self.layerModel.setHeaderData(3, 1, "Value") # goto module button self.goToModule = qt.QPushButton('->', self.frame) self.goToModule.setToolTip( 'Go to the DataProbe module for more information and options') self.frame.layout().addWidget(self.goToModule) self.goToModule.connect("clicked()", self.onGoToModule) # hide this for now - there's not much to see in the module itself self.goToModule.hide()