def init_ui(self): vbox = QtGui.QVBoxLayout() self.setLayout(vbox) try: proc = get_plugins("processes", "FabberProcess")[0] except: proc = None if proc is None: vbox.addWidget( QtGui.QLabel( "Fabber core library not found.\n\n You must install Fabber to use this widget" )) return title = TitleWidget(self, help="fabber-dsc", subtitle="Bayesian modelling for DSC-MRI %s" % __version__) vbox.addWidget(title) cite = Citation(FAB_CITE_TITLE, FAB_CITE_AUTHOR, FAB_CITE_JOURNAL) vbox.addWidget(cite) tabs = QtGui.QTabWidget() vbox.addWidget(tabs) self.dsc_widget = DscOptionsWidget(self.ivm) tabs.addTab(self.dsc_widget, "DSC Options") self.aif_widget = AifWidget(self.ivm) tabs.addTab(self.aif_widget, "AIF") vbox.addWidget(tabs) vbox.addWidget(RunWidget(self, save_option=True)) vbox.addStretch(1)
def __init__(self, ivm, parent, acq_options): OptionsWidget.__init__(self, ivm, parent) self.acq_options = acq_options vbox = QtWidgets.QVBoxLayout() self.setLayout(vbox) self._optbox = OptionBox() self._optbox.add("<b>Model options</b>") self._optbox.add("Delay minimum (s)", NumericOption(minval=-100, maxval=100, default=0), key="delay-min") self._optbox.add("Delay maximum (s)", NumericOption(minval=-100, maxval=100, default=0), key="delay-max") self._optbox.add("Delay step (s)", NumericOption(minval=-5, maxval=5, default=1), key="delay-step") self._optbox.add("<b>Output options</b>") self._optbox.add("Output data name suffix", TextOption(), checked=True, key="output-suffix") vbox.addWidget(self._optbox) vbox.addWidget(RunWidget(self, save_option=True)) vbox.addStretch(1)
def __init__(self, ivm, parent, acq_options): OptionsWidget.__init__(self, ivm, parent) self.acq_options = acq_options vbox = QtWidgets.QVBoxLayout() self.setLayout(vbox) cite = Citation(FAB_CITE_TITLE, FAB_CITE_AUTHOR, FAB_CITE_JOURNAL) vbox.addWidget(cite) self._optbox = OptionBox() self._optbox.add("<b>Model options</b>") self._optbox.add("Infer constant signal offset", BoolOption(default=True), key="infer-sig0") self._optbox.add("Infer delay", BoolOption(default=True), key="infer-delay") #self._optbox.add("<b>Model fitting options</b>") #self._optbox.add("Spatial regularization", BoolOption(default=True), key="spatial") self._optbox.add("<b>Output options</b>") self._optbox.add("Output data name suffix", TextOption(), checked=True, key="output-suffix") vbox.addWidget(self._optbox) vbox.addWidget(RunWidget(self, save_option=True)) vbox.addStretch(1)
def init_ui(self): vbox = QtGui.QVBoxLayout() self.setLayout(vbox) title = TitleWidget( self, title="PCA reduction", subtitle="Principal Component Analysis for 4D data") vbox.addWidget(title) self._options = OptionBox("Options") self._options.add("Data", DataOption(self.ivm, include_3d=False), key="data") self._options.add("ROI", DataOption(self.ivm, data=False, rois=True), key="roi") self._options.add("Number of components", NumericOption(minval=1, intonly=True, default=4), key="n-components") self._options.add("Output name", OutputNameOption( src_data=self._options.option("data"), suffix="_pca"), key="output-name") self._options.option("data").sig_changed.connect(self._data_changed) vbox.addWidget(self._options) self._run = RunWidget(self) self._run.sig_postrun.connect(self._postrun) vbox.addWidget(self._run) self.plot = Plot(qpo=None, parent=self, title="PCA modes") self.variance_model = QtGui.QStandardItemModel() variance_table = QtGui.QTableView() variance_table.verticalHeader().hide() variance_table.setModel(self.variance_model) tabs = QtGui.QTabWidget() tabs.addTab(self.plot, "PCA modes") tabs.addTab(variance_table, "Explained variance") tabs.setCurrentWidget(self.plot) vbox.addWidget(tabs) vbox.addStretch(1) self._data_changed()
def init_ui(self): vbox = QtGui.QVBoxLayout() self.setLayout(vbox) title = TitleWidget( self, help="asl", subtitle="Data processing for Arterial Spin Labelling MRI") vbox.addWidget(title) cite = Citation(FAB_CITE_TITLE, FAB_CITE_AUTHOR, FAB_CITE_JOURNAL) vbox.addWidget(cite) self.tabs = QtGui.QTabWidget() vbox.addWidget(self.tabs) self.asldata = AslImageWidget(self.ivm, parent=self) self.asldata.sig_changed.connect(self._data_changed) self.tabs.addTab(self.asldata, "ASL data") self.preproc = PreprocOptions(self.ivm) self.preproc.sig_enable_tab.connect(self._enable_tab) self.tabs.addTab(self.preproc, "Corrections") # Only add these if appropriate self._optional_tabs = { "veasl": VeaslOptions(self.ivm, self.asldata), "enable": EnableOptions(self.ivm), "deblur": DeblurOptions(), } self.structural = StructuralData(self.ivm) self.tabs.addTab(self.structural, "Structural data") self.calibration = CalibrationOptions(self.ivm) self.tabs.addTab(self.calibration, "Calibration") self.analysis = AnalysisOptions(self.ivm) self.analysis.optbox.option("wp").sig_changed.connect(self._wp_changed) self.tabs.addTab(self.analysis, "Analysis") self.output = OutputOptions() self.tabs.addTab(self.output, "Output") runbox = RunWidget(self, title="Run processing", save_option=True) runbox.sig_postrun.connect(self._postrun) vbox.addWidget(runbox) vbox.addStretch(1) fsldir_qwidgets = get_plugins("qwidgets", "FslDirWidget") if len(fsldir_qwidgets) > 0: fsldir = fsldir_qwidgets[0]() vbox.addWidget(fsldir)
def init_ui(self): layout = QtGui.QVBoxLayout() self.setLayout(layout) title = TitleWidget(self, title="Registration and Motion Correction", help="reg") layout.addWidget(title) if not self.reg_methods: layout.addWidget(QtGui.QLabel("No registration methods found")) layout.addStretch(1) return self.options = OptionBox("General Options") self.options.add("Mode", ChoiceOption(["Registration", "Motion Correction"], ["reg", "moco"]), key="mode") self.options.add("Method", ChoiceOption([method.display_name for method in self.reg_methods], self.reg_methods), key="method") self.options.add("Registration data", DataOption(self.ivm), key="reg") self.options.add("Reference data", DataOption(self.ivm), key="ref") self.options.add("Reference volume", ChoiceOption(["Middle volume", "Mean volume", "Specified volume"], ["median", "mean", "idx"]), key="ref-vol") self.options.add("Reference volume index", NumericOption(intonly=True), key="ref-idx") self.options.add("Output space", ChoiceOption(["Reference", "Registration", "Transformed"], ["ref", "reg", "trans"]), key="output-space") self.options.add("Output name", OutputNameOption(src_data=self.options.option("reg"), suffix="_reg"), key="output-name", checked=True) self.options.add("Also apply transform to", DataOption(self.ivm, multi=True), key="add-reg") self.options.add("Save transformation", TextOption(), key="save-transform", checked=True, default=False) self.options.option("mode").sig_changed.connect(self._update_option_visibility) self.options.option("method").sig_changed.connect(self._method_changed) self.options.option("ref").sig_changed.connect(self._update_option_visibility) self.options.option("ref-vol").sig_changed.connect(self._update_option_visibility) self.options.option("reg").sig_changed.connect(self._update_option_visibility) layout.addWidget(self.options) # Create the options boxes for reg methods - only one visible at a time! self.opt_boxes = {} for method in self.reg_methods: hbox = QtGui.QHBoxLayout() opt_box = QtGui.QGroupBox() opt_box.setTitle(method.display_name) vbox = QtGui.QVBoxLayout() opt_box.setLayout(vbox) vbox.addWidget(method.interface()) hbox.addWidget(opt_box) opt_box.setVisible(False) layout.addLayout(hbox) self.opt_boxes[method.name] = opt_box layout.addWidget(RunWidget(self)) layout.addStretch(1) self._method_changed()
def init_ui(self): main_vbox = QtGui.QVBoxLayout() self.setLayout(main_vbox) title = TitleWidget( self, help="generic/datasim", subtitle= "Simulates data for various imaging sequences, from known parameter inputs %s" % __version__) main_vbox.addWidget(title) self.tabs = QtGui.QTabWidget() main_vbox.addWidget(self.tabs) self.struc_model = ModelOptions(self.ivm, parent=self, model_type="Structural", abbrev="struc", model_classes=get_struc_models()) self.struc_model.sig_changed.connect(self._update_params) self.data_model = ModelOptions(self.ivm, parent=self, model_type="Data", abbrev="data", model_classes=get_data_models()) self.data_model.sig_changed.connect(self._update_params) self.params = ParamsOptions(self.ivm, parent=self) self.noise = NoiseOptions(self.ivm, parent=self) self.motion = MotionOptions(self.ivm, parent=self) self.output = OutputOptions(self.ivm, parent=self) self.tabs.addTab(self.struc_model, "Structure model") self.tabs.addTab(self.data_model, "Data model") self.tabs.addTab(self.params, "Parameter values") self.tabs.addTab(self.noise, "Noise") self.tabs.addTab(self.motion, "Motion") self.tabs.addTab(self.output, "Output") main_vbox.addStretch(1) main_vbox.addWidget(RunWidget(self)) self._update_params()
class PcaWidget(QpWidget): """ PCA widget """ def __init__(self, **kwargs): super(PcaWidget, self).__init__(name="PCA", icon="pca", desc="PCA reduction", group="Processing", **kwargs) def init_ui(self): vbox = QtGui.QVBoxLayout() self.setLayout(vbox) title = TitleWidget( self, title="PCA reduction", subtitle="Principal Component Analysis for 4D data") vbox.addWidget(title) self._options = OptionBox("Options") self._options.add("Data", DataOption(self.ivm, include_3d=False), key="data") self._options.add("ROI", DataOption(self.ivm, data=False, rois=True), key="roi") self._options.add("Number of components", NumericOption(minval=1, intonly=True, default=4), key="n-components") self._options.add("Output name", OutputNameOption( src_data=self._options.option("data"), suffix="_pca"), key="output-name") self._options.option("data").sig_changed.connect(self._data_changed) vbox.addWidget(self._options) self._run = RunWidget(self) self._run.sig_postrun.connect(self._postrun) vbox.addWidget(self._run) self.plot = Plot(qpo=None, parent=self, title="PCA modes") self.variance_model = QtGui.QStandardItemModel() variance_table = QtGui.QTableView() variance_table.verticalHeader().hide() variance_table.setModel(self.variance_model) tabs = QtGui.QTabWidget() tabs.addTab(self.plot, "PCA modes") tabs.addTab(variance_table, "Explained variance") tabs.setCurrentWidget(self.plot) vbox.addWidget(tabs) vbox.addStretch(1) self._data_changed() def processes(self): return {"PCA": self._options.values()} def _data_changed(self): self._run.setEnabled( self._options.option("data").value in self.ivm.data) def _postrun(self): self._update_plot() self._update_table() def _update_plot(self): self.plot.clear() extra = self.ivm.extras.get( self._options.option("output-name").value + "_modes", None) if extra is not None: arr = np.array(extra.arr) for idx in range(arr.shape[1] - 1): self.plot.add_line(arr[:, idx], name="Mode %i" % idx) self.plot.add_line(arr[:, -1], name="Mean", line_col=(255, 0, 0), line_width=3.0) def _update_table(self): self.variance_model.clear() extra = self.ivm.extras.get( self._options.option("output-name").value + "_variance", None) if extra is not None: self.debug(str(extra)) for idx, header in enumerate(extra.col_headers): self.variance_model.setHorizontalHeaderItem( idx, QtGui.QStandardItem(header)) for idx, variance in enumerate(extra.arr): self.variance_model.setItem( idx, 0, QtGui.QStandardItem(str(variance[0]))) self.variance_model.setItem( idx, 1, QtGui.QStandardItem(sf(variance[1]))) self.variance_model.setItem( idx, 2, QtGui.QStandardItem(sf(variance[2])))
def init_ui(self): vbox = QtGui.QVBoxLayout() self.setLayout(vbox) title = TitleWidget(self, help="pk", batch_btn=True, opts_btn=False) vbox.addWidget(title) self.input = OptionBox("Input data") self.input.add("DCE data", DataOption(self.ivm, include_3d=False, include_4d=True), key="data") self.input.add("ROI", DataOption(self.ivm, data=False, rois=True), key="roi") self.input.add("T1 map", DataOption(self.ivm, include_3d=True, include_4d=False), key="t1") vbox.addWidget(self.input) self.options = OptionBox("Options") self.options.add("Contrast agent R1 relaxivity (l/mmol s)", NumericOption(minval=0, maxval=10, default=3.7), key="r1") self.options.add("Contrast agent R2 relaxivity (l/mmol s)", NumericOption(minval=0, maxval=10, default=4.8), key="r2") self.options.add("Flip angle (\N{DEGREE SIGN})", NumericOption(minval=0, maxval=90, default=12), key="fa") self.options.add("TR (ms)", NumericOption(minval=0, maxval=10, default=4.108), key="tr") self.options.add("TE (ms)", NumericOption(minval=0, maxval=10, default=1.832), key="te") self.options.add("Time between volumes (s)", NumericOption(minval=0, maxval=30, default=12), key="dt") self.options.add("Estimated injection time (s)", NumericOption(minval=0, maxval=60, default=30), key="tinj") self.options.add("Ktrans/kep percentile threshold", NumericOption(minval=0, maxval=100, default=100), key="ve-thresh") self.options.add("Dose (mM/kg) - preclinical only", NumericOption(minval=0, maxval=5, default=0.6), key="dose", visible=False) models = [ "Clinical: Toft / OrtonAIF (3rd) with offset", "Clinical: Toft / OrtonAIF (3rd) no offset", "Preclinical: Toft / BiexpAIF (Heilmann)", "Preclinical: Ext Toft / BiexpAIF (Heilmann)", ] self.options.add("Pharmacokinetic model choice", ChoiceOption(models, [1, 2, 3, 4]), key="model") self.options.option("model").sig_changed.connect(self._aif_changed) vbox.addWidget(self.options) # Run button and progress vbox.addWidget(RunWidget(self, title="Run modelling")) vbox.addStretch(1) self._aif_changed()
def init_ui(self): vbox = QtGui.QVBoxLayout() self.setLayout(vbox) try: self.FabberProcess = get_plugins("processes", "FabberProcess")[0] except IndexError: self.FabberProcess = None if self.FabberProcess is None: vbox.addWidget( QtGui.QLabel( "Fabber core library not found.\n\n You must install Fabber to use this widget" )) return title = TitleWidget( self, help="fabber-dsc", subtitle="DSC modelling using the Fabber process %s" % __version__) vbox.addWidget(title) cite = Citation(FAB_CITE_TITLE, FAB_CITE_AUTHOR, FAB_CITE_JOURNAL) vbox.addWidget(cite) self.input = OptionBox("Input data") self.input.add("DCE data", DataOption(self.ivm, include_3d=False, include_4d=True), key="data") self.input.add("ROI", DataOption(self.ivm, data=False, rois=True), key="roi", checked=True) self.input.add("T1 map", DataOption(self.ivm, include_3d=True, include_4d=False), key="t1", checked=True) self.input.option("t1").sig_changed.connect(self._t1_map_changed) vbox.addWidget(self.input) self.acquisition = OptionBox("Acquisition") self.acquisition.add("Contrast agent R1 relaxivity (l/mmol s)", NumericOption(minval=0, maxval=10, default=3.7), key="r1") self.acquisition.add("Flip angle (\N{DEGREE SIGN})", NumericOption(minval=0, maxval=90, default=12), key="fa") self.acquisition.add("TR (ms)", NumericOption(minval=0, maxval=10, default=4.108), key="tr") self.acquisition.add("Time between volumes (s)", NumericOption(minval=0, maxval=30, default=12), key="delt") vbox.addWidget(self.acquisition) self.model = OptionBox("Model options") self.model.add( "Model", ChoiceOption([ "Standard Tofts model", "Extended Tofts model (ETM)", "2 Compartment exchange model", "Compartmental Tissue Update (CTU) model", "Adiabatic Approximation to Tissue Homogeneity (AATH) Model" ], ["dce_tofts", "dce_ETM", "dce_2CXM", "dce_CTU", "dce_AATH"]), key="model") self.model.add( "AIF", ChoiceOption([ "Population (Orton 2008)", "Population (Parker)", "Measured DCE signal", "Measured concentration curve" ], ["orton", "parker", "signal", "conc"]), key="aif") self.model.add("Bolus injection time (s)", NumericOption(minval=0, maxval=60, default=30), key="tinj") self.model.add("AIF data values", NumberListOption([ 0, ]), key="aif-data") self.model.add("T1 (s)", NumericOption(minval=0.0, maxval=5.0, default=1.0), key="t10") self.model.add("Allow T1 to vary", BoolOption(default=False), key="infer-t10") self.model.add("Bolus arrival time (s)", NumericOption(minval=0, maxval=2.0, default=0), key="delay") self.model.add("Allow bolus arrival time to vary", BoolOption(default=False), key="infer-delay") self.model.add("Infer kep rather than ve", BoolOption(default=False), key="infer-kep") self.model.add("Infer flow", BoolOption(default=True), key="infer-fp") self.model.add("Infer permeability-surface area", BoolOption(default=False), key="infer-ps") self.model.add("Spatial regularization", BoolOption(default=False), key="spatial") self.model.option("model").sig_changed.connect(self._model_changed) self.model.option("aif").sig_changed.connect(self._aif_changed) vbox.addWidget(self.model) # Run button and progress vbox.addWidget(RunWidget(self, title="Run modelling")) vbox.addStretch(1) self._aif_changed() self._model_changed()