def memoryCheck(self): """Run a periodic memory check in a window""" if not hasattr(self, 'sysInfo'): self.sysInfo = slicer.vtkSystemInformation() self.sysInfoWindow = qt.QTextBrowser() if self.sysInfoWindow.visible: return self.sysInfoWindow.show() self.memoryCallback()
def __init__(self, *args): BaseComponents.BlissWidget.__init__(self, *args) # Data attribtues self.energy_hwobj = None self.transmission_hwobj = None self.resolution_hwobj = None self.queue_model_hwobj = None self.session_hwobj = None # Qt-Slots self.defineSlot("populate_parameter_widget",({})) # Properties self.addProperty("session", "string", "/session") self.addProperty("queue-model", "string", "/queue-model") self.addProperty("beamline_setup", "string", "/beamline-setup") # Layout self.stack = qt.QWidgetStack(self, 'stack') self.parameters_widget = DCParametersWidget(self, "parameters_widget") self.toggle_page_button = qt.QPushButton('View Results', self, 'toggle_page_button') self.toggle_page_button.setFixedWidth(100) self.results_view = qt.QTextBrowser(self, "results_view") self.stack.addWidget(self.parameters_widget) self.stack.addWidget(self.results_view) main_layout = qt.QVBoxLayout(self) self.layout().addWidget(self.stack) bottom_layout = qt.QHBoxLayout(main_layout) bottom_layout.addStretch() bottom_layout.addWidget(self.toggle_page_button) # Logic self.stack.raiseWidget(self.parameters_widget) self.parameters_widget.collection_type = None qt.QObject.connect(self.toggle_page_button, qt.SIGNAL('clicked()'), self.toggle_page) self.toggle_page_button.setDisabled(True)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... indexPath = self.resourcePath('HTML/SlicerCMF/index.html') url = qt.QUrl.fromLocalFile(indexPath) modulesTextBrowser = qt.QTextBrowser() modulesTextBrowser.setSource(url) modulesTextBrowser.connect('anchorClicked(QUrl)', self.onAnchorClicked) sp = qt.QSizePolicy() sp.setVerticalPolicy(qt.QSizePolicy.Expanding) sp.setHorizontalPolicy(qt.QSizePolicy.Expanding) sp.setVerticalStretch(1) sp.setHorizontalStretch(1) modulesTextBrowser.setSizePolicy(sp) self.modulesTextBrowser = modulesTextBrowser self.layout.addWidget(self.modulesTextBrowser)
def __init__(self, *args): BaseComponents.BlissWidget.__init__(self, *args) self.session_hwobj = None # Framwork-2 properties self.addProperty("tunable-energy", "boolean", "True") self.addProperty("session", "string", "/session") self.addProperty("beamline_setup", "string", "/beamline-setup") # Qt-Slots self.defineSlot("populate_edna_parameter_widget", ({})) # Layout self.stack = qt.QWidgetStack(self, "stack") self.parameters_widget = CharParametersWidget(self) self.toggle_page_button = qt.QPushButton("View Results", self, "toggle_page_button") self.toggle_page_button.setFixedWidth(100) self.results_view = qt.QTextBrowser(self, "results_view") self.stack.addWidget(self.parameters_widget) self.stack.addWidget(self.results_view) main_layout = qt.QVBoxLayout(self) self.layout().addWidget(self.stack) bottom_layout = qt.QHBoxLayout(main_layout) bottom_layout.addStretch() bottom_layout.addWidget(self.toggle_page_button) # Logic self.stack.raiseWidget(self.parameters_widget) self.parameters_widget.collection_type = None qt.QObject.connect(self.toggle_page_button, qt.SIGNAL("clicked()"), self.toggle_page) self.toggle_page_button.setDisabled(True)
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.tutorials = { "ShapeAnalysisModule": "https://bit.ly/2Fyn97v", # SPHARM-PDM Generator "GroupWiseRegistrationModule": "https://bit.ly/2WsFiun", "RegressionComputation": "https://bit.ly/2uVYche", "ShapeVariationAnalyzer": "https://bit.ly/2HYbHVA", # Population Analysis "SRep": "https://bit.ly/3sTEG3H", "SRepCreator": "https://bit.ly/3sTEG3H", "SRepRefinement": "https://bit.ly/3sTEG3H", } # The anchor associated with each link corresponds to the name of the module to select. # For example, after the user click on the link associated with `href="#DataImporter"`, # the "DataImporter" module is selected. text = """ <br> <u>Workflow quick-reference:</u><br> <br> The drop-down Modules are ordered to follow the basic workflow for choosing and using data. As a quick reference, the basic steps involve:<br> <br> 1. Use the <a href="#DataImporter"><b>Data importer</b></a> module to load your segmentations from FreeSurf, FSL, Autoseg, or a bunch of vtp's<br><br> 2. Use <a href="#ShapePopulationViewer"><b>Shape Population Viewer</b></a> to do a quality check on the imported data<br><br> 3. Use <a href="#ShapeAnalysisModule"><b>SPHARM-PDM Generator</b></a> to do spherical harmonics based analysis<br><br> 4. Use the <a href="#GroupWiseRegistrationModule"><b>Study-specific Shape Analysis</b></a> module.<br><br> 5. Use the <a href="#SkeletalRepresentationVisualizer"><b>S-Rep Shape Analysis</b></a> module to do shape analysis via skeletal representations.<br><br> 6. Use the <a href="#ShapeVariationAnalyzer"><b>Shape Evaluator</b></a> module to compute a mean shape and see how the population varies.<br><br> 7. Use <a href="#RegressionComputation"><b>Shape Regressions</b></a> module to do regression based analysis.<br><br> 8. Use the <a href="#MFSDA"><b>Shape Statistics</b></a> module.<br><br> """ # TEXTEDIT self.HomeTextSection = qt.QTextBrowser() self.HomeTextSection.setHtml(text) self.HomeTextSection.setMinimumHeight(400) self.HomeTextSection.connect('anchorClicked(QUrl)', self.onAnchorClicked) self.layout.addWidget(self.HomeTextSection) # SPACER self.layout.addStretch() # SAMPLE DATA REGISTRATION for json_file in [ 'DataImporterInputData.json', 'MFSDAInputData.json', 'ShapeRegressionInputData.json', 'SPHARM-PDMTestData.json', 'SPHARM-PDMFiducials.json', 'SRepCreatorData.json', 'SVAInputData.json' ]: with open( self.resourcePath('SampleDataDescription/%s' % json_file), 'r') as json_data: source_data = json.load(json_data) if 'iconPath' in source_data: iconPath = self.resourcePath(source_data['iconPath']) else: iconPath = None SampleDataLogic.registerCustomSampleDataSource( category=source_data['category'], sampleName=source_data['sampleName'], uris=source_data['uris'], checksums=source_data.get('checksums', None), fileNames=source_data['fileNames'], nodeNames=None, thumbnailFileName=iconPath, loadFileType=None, customDownloader=self.downloadSampleDataInFolder, ) # HIDE SAMPLE DATA 'BUILTIN' CATEGORY slicer.modules.sampledata.widgetRepresentation().self( ).setCategoryVisible('BuiltIn', False) self.sampleDataModuleTab = None self.sampleDataTabTextEdit = None self.moduleNameToSampleDataCategory = { "DataImporter": "Data Importer", "MFSDA": "Covariate Significance Testing", "ShapeAnalysisModule": "SPHARM-PDM", "RegressionComputation": "Shape Regression", "ShapeVariationAnalyzer": "Population Analysis", "SRepCreator": "Skeletal Representation Creator" } self.sampleDataModuleTab = self.addSampleDataTab() self.updateSampleDataTab("Home") moduleMenu = slicer.util.mainWindow().moduleSelector().modulesMenu() moduleMenu.connect("currentModuleChanged(QString)", self.updateSampleDataTab)
def setupWindow(self): self.setWindowTitle("lapdMouse Data Archive Browser") self.resize(1000, 600) if 'lapdMouseDBBrowser' in slicer.util.moduleNames(): self.modulePath = slicer.modules.lapdmousedbbrowser.path.replace( "lapdMouseDBBrowser.py", "") else: self.modulePath = '.' self.downloadIcon = qt.QIcon( os.path.join(self.modulePath, 'Resources', 'Icons', 'download.png')) self.storedIcon = qt.QIcon( os.path.join(self.modulePath, 'Resources', 'Icons', 'stored.png')) self.logo = qt.QPixmap( os.path.join(self.modulePath, 'Resources', 'Icons', 'lapdMouseDBBrowser.png')) self.banner = qt.QFrame() self.banner.setLayout(qt.QGridLayout()) logo = qt.QLabel() logo.setPixmap(self.logo) self.banner.layout().addWidget(logo, 0, 0) self.bannerTextBrowser = qt.QTextBrowser() self.bannerTextBrowser.setOpenExternalLinks(True) self.bannerTextBrowser.setMaximumHeight(120) text = "<h1>lapdMouse Data Archive Browser</h1>" text += "The lapdMouse data archive contains anatomically derived lung models and aerosol deposition measurements of mice for modeling and computational toxicology in mice." text += " For more details about available datasets, data representation, other software, and support, please visit the <a href=\"https://doi.org/10.25820/9arg-9w56\">lapdMouse archive</a>" text += "<br />This work was supported in part by NIH project R01ES023863." self.bannerTextBrowser.html = text self.banner.layout().addWidget(self.bannerTextBrowser, 0, 1) self.table = qt.QTableWidget(self) self.table.setRowCount(0) self.table.setColumnCount(1) self.table.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.table.setHorizontalHeaderLabels(["Dataset name" ]) #,"Status","Comment"]) self.table.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self.table.setSelectionMode(qt.QAbstractItemView.SingleSelection) self.table.horizontalHeader().setStretchLastSection(True) self.table.connect("itemSelectionChanged()", self.onDatasetChanged) self.customForm = qt.QFrame() self.customForm.setLayout(qt.QFormLayout()) self.customFormName = qt.QLineEdit("", self.customForm) self.customFormName.readOnly = True self.customForm.layout().addRow("Name", self.customFormName) self.customFormDatasetInfo = qt.QLabel('<a href=\"' + self.projectURL + '\">info</a>') self.customFormDatasetInfo.setTextFormat(1) self.customFormDatasetInfo.setOpenExternalLinks(True) self.customForm.layout().addRow("Info", self.customFormDatasetInfo) self.customFormAction = qt.QFrame(self.customForm) self.customFormAction.setLayout(qt.QHBoxLayout()) self.customFormAction.layout().setSpacing(0) self.customFormAction.layout().setMargin(0) self.customFormDownloadButton = qt.QPushButton( "download standard file selection", self.customFormAction) self.customFormAction.layout().addWidget(self.customFormDownloadButton) self.customFormDownloadButton.connect("clicked()", self.onDownloadDataset) self.customFormLoadButton = qt.QPushButton( "load standard file selection in Slicer", self.customFormAction) self.customFormAction.layout().addWidget(self.customFormLoadButton) self.customFormLoadButton.connect("clicked()", self.onLoadDataset) self.customForm.layout().addRow("Quick actions", self.customFormAction) self.customFormFiles = qt.QTableWidget(self.customForm) self.customFormFiles.setRowCount(0) self.customFormFiles.setColumnCount(3) self.customFormFiles.setHorizontalHeaderLabels( ["Status", "Filename", "Size"]) self.customFormFiles.horizontalHeader().setSectionResizeMode( 1, qt.QHeaderView.Stretch) self.customFormFiles.setSelectionBehavior( qt.QAbstractItemView.SelectRows) self.customFormFiles.setMinimumHeight(400) self.customForm.layout().addRow("Files", self.customFormFiles) self.customFormAction2 = qt.QFrame(self.customForm) self.customFormAction2.setLayout(qt.QHBoxLayout()) self.customFormAction2.layout().setSpacing(0) self.customFormAction2.layout().setMargin(0) self.customFormDownloadButton2 = qt.QPushButton( "download selected files", self.customFormAction2) self.customFormAction2.layout().addWidget( self.customFormDownloadButton2) self.customFormDownloadButton2.connect("clicked()", self.onDownloadSelectedDataset) self.customFormDeleteButton2 = qt.QPushButton("delete selected files", self.customFormAction2) self.customFormAction2.layout().addWidget(self.customFormDeleteButton2) self.customFormDeleteButton2.connect("clicked()", self.onDeleteSelectedDataset) self.customFormLoadButton2 = qt.QPushButton( "load selected files in Slicer", self.customFormAction2) self.customFormAction2.layout().addWidget(self.customFormLoadButton2) self.customFormLoadButton2.connect("clicked()", self.onLoadSelectedDataset) self.customForm.layout().addRow("", self.customFormAction2) splitView = qt.QSplitter(self) splitView.addWidget(self.table) splitView.addWidget(self.customForm) splitView.setSizes([200, 800]) self.updateTable() self.onDatasetChanged() self.setMenuWidget(self.banner) self.setCentralWidget(splitView)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # File area # filesCollapsibleButton = ctk.ctkCollapsibleButton() filesCollapsibleButton.text = "Input files" filesCollapsibleButton.collapsed = False self.layout.addWidget(filesCollapsibleButton) # Layout within the files collapsible button filesFormLayout = qt.QFormLayout(filesCollapsibleButton) # select one file buttonLayout = qt.QHBoxLayout() self.archetypeText = qt.QLineEdit() buttonLayout.addWidget(self.archetypeText) self.addFromArchetype = qt.QPushButton("Browse...") buttonLayout.addWidget(self.addFromArchetype) self.archetypeStartNumber = 0 filesFormLayout.addRow("Filename pattern: ", buttonLayout) # file list group fileListGroupBox = ctk.ctkCollapsibleGroupBox() fileListGroupBox.title = "File list" fileListLayout = qt.QVBoxLayout() fileListGroupBox.setLayout(fileListLayout) filesFormLayout.addRow("", fileListGroupBox) self.addByBrowsingButton = qt.QPushButton("Select files...") fileListLayout.addWidget(self.addByBrowsingButton) self.fileTable = qt.QTextBrowser() fileListLayout.addWidget(self.fileTable) fileListGroupBox.collapsed = True # original volume size self.originalVolumeSizeLabel = qt.QLabel() filesFormLayout.addRow("Size: ", self.originalVolumeSizeLabel) # reverse slice order self.reverseCheckBox = qt.QCheckBox() self.reverseCheckBox.toolTip = "Read the images in reverse order (flips loaded volume along IS axis)" filesFormLayout.addRow("Reverse: ", self.reverseCheckBox) # original spacing self.spacingWidget = slicer.qMRMLCoordinatesWidget() self.spacingWidget.setMRMLScene(slicer.mrmlScene) self.spacingWidget.decimalsOption = ctk.ctkDoubleSpinBox.DecimalsByKey | ctk.ctkDoubleSpinBox.DecimalsByShortcuts | ctk.ctkDoubleSpinBox.DecimalsByValue self.spacingWidget.minimum = 0.0 self.spacingWidget.maximum = 1000000000.0 self.spacingWidget.quantity = "length" self.spacingWidget.unitAwareProperties = slicer.qMRMLCoordinatesWidget.Precision | slicer.qMRMLCoordinatesWidget.Prefix | slicer.qMRMLCoordinatesWidget.Scaling | slicer.qMRMLCoordinatesWidget.Suffix self.spacingWidget.coordinates = "1,1,1" self.spacingWidget.toolTip = "Set the colunm, row, slice spacing; original spacing not including downsample" filesFormLayout.addRow("Spacing: ", self.spacingWidget) # # 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", "vtkMRMLVectorVolumeNode" ] 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.noneDisplay = "(Create new volume)" self.outputSelector.setMRMLScene(slicer.mrmlScene) self.outputSelector.setToolTip( "Pick the output volume to populate or None to autogenerate.") outputFormLayout.addRow("Output Volume: ", self.outputSelector) # # output ROI selector # self.outputROISelector = slicer.qMRMLNodeComboBox() self.outputROISelector.nodeTypes = [ "vtkMRMLAnnotationROINode", "vtkMRMLMarkupsROINode" ] self.outputROISelector.showChildNodeTypes = False self.outputROISelector.showHidden = False self.outputROISelector.showChildNodeTypes = False self.outputROISelector.noneEnabled = True self.outputROISelector.removeEnabled = True self.outputROISelector.renameEnabled = True self.outputROISelector.addEnabled = False self.outputROISelector.noneDisplay = "(Full volume)" self.outputROISelector.setMRMLScene(slicer.mrmlScene) self.outputROISelector.setToolTip( "Set the region of the volume that will be loaded") outputFormLayout.addRow("Region of interest: ", self.outputROISelector) # # Quality selector # qualityLayout = qt.QVBoxLayout() self.qualityPreviewRadioButton = qt.QRadioButton("preview") self.qualityHalfRadioButton = qt.QRadioButton("half resolution") self.qualityFullRadioButton = qt.QRadioButton("full resolution") qualityLayout.addWidget(self.qualityPreviewRadioButton) qualityLayout.addWidget(self.qualityHalfRadioButton) qualityLayout.addWidget(self.qualityFullRadioButton) self.qualityPreviewRadioButton.setChecked(True) outputFormLayout.addRow("Quality: ", qualityLayout) self.sliceSkipSpinBox = qt.QSpinBox() self.sliceSkipSpinBox.toolTip = "Skips the selected number of slices between each pair of output volume slices (use, for example, on long thin samples with more slices than in-plane resolution)" outputFormLayout.addRow("Slice skip: ", self.sliceSkipSpinBox) # Force grayscale output self.grayscaleCheckBox = qt.QCheckBox() self.grayscaleCheckBox.toolTip = "Force reading the image in grayscale. Only makes a difference if the input has color (RGB or RGBA) voxels." self.grayscaleCheckBox.checked = True outputFormLayout.addRow("Grayscale: ", self.grayscaleCheckBox) # output volume size self.outputVolumeSizeLabel = qt.QLabel() outputFormLayout.addRow("Output size: ", self.outputVolumeSizeLabel) # output volume spacing self.outputSpacingWidget = slicer.qMRMLCoordinatesWidget() self.outputSpacingWidget.setMRMLScene(slicer.mrmlScene) self.outputSpacingWidget.readOnly = True self.outputSpacingWidget.frame = False self.outputSpacingWidget.decimalsOption = ctk.ctkDoubleSpinBox.DecimalsByKey | ctk.ctkDoubleSpinBox.DecimalsByShortcuts | ctk.ctkDoubleSpinBox.DecimalsByValue self.outputSpacingWidget.minimum = 0.0 self.outputSpacingWidget.maximum = 1000000000.0 self.outputSpacingWidget.quantity = "length" self.outputSpacingWidget.unitAwareProperties = slicer.qMRMLCoordinatesWidget.Precision | slicer.qMRMLCoordinatesWidget.Prefix | slicer.qMRMLCoordinatesWidget.Scaling | slicer.qMRMLCoordinatesWidget.Suffix self.outputSpacingWidget.coordinates = "1,1,1" self.outputSpacingWidget.toolTip = "Slice spacing of the volume that will be loaded" outputFormLayout.addRow("Output spacing: ", self.outputSpacingWidget) self.loadButton = qt.QPushButton("Load files") self.loadButton.toolTip = "Load files as a 3D volume" self.loadButton.enabled = False outputFormLayout.addRow(self.loadButton) # connections self.reverseCheckBox.connect('toggled(bool)', self.updateLogicFromWidget) self.sliceSkipSpinBox.connect("valueChanged(int)", self.updateLogicFromWidget) self.spacingWidget.connect("coordinatesChanged(double*)", self.updateLogicFromWidget) self.qualityPreviewRadioButton.connect( "toggled(bool)", lambda toggled, widget=self.qualityPreviewRadioButton: self. onQualityToggled(toggled, widget)) self.qualityHalfRadioButton.connect( "toggled(bool)", lambda toggled, widget=self.qualityHalfRadioButton: self. onQualityToggled(toggled, widget)) self.qualityFullRadioButton.connect( "toggled(bool)", lambda toggled, widget=self.qualityFullRadioButton: self. onQualityToggled(toggled, widget)) self.grayscaleCheckBox.connect('toggled(bool)', self.updateLogicFromWidget) self.outputROISelector.connect("currentNodeChanged(vtkMRMLNode*)", self.setOutputROINode) self.addByBrowsingButton.connect('clicked()', self.addByBrowsing) self.addFromArchetype.connect('clicked()', self.selectArchetype) self.archetypeText.connect('textChanged(const QString &)', self.populateFromArchetype) self.loadButton.connect('clicked()', self.onLoadButton) # Add vertical spacer self.layout.addStretch(1) self.loadButton.enabled = False