Beispiel #1
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self)
        vbox.addWidget(title)

        self.options = OptionBox("Options")
        self.options.add("Data", DataOption(self.ivm, multi=True), key="data")
        self.options.add("Within ROI", DataOption(self.ivm, data=False, rois=True, none_option=True), key="roi")
        self.options.add("All volumes", BoolOption(default=False), key="allvols")
        self.options.add("Y-axis scale", ChoiceOption(["Count", "Probability"]), key="yscale")
        self.options.add("Number of bins", NumericOption(minval=5, maxval=500, default=100, intonly=True), key="bins")
        self.options.add("Min value", NumericOption(minval=0, maxval=100, default=0), key="min")
        self.options.add("Max value", NumericOption(minval=0, maxval=500, default=100), key="max")
        self.options.option("yscale").sig_changed.connect(self._yscale_changed)
        self.options.option("min").sig_changed.connect(self._min_changed)
        self.options.option("min").sig_changed.connect(self._max_changed)
        vbox.addWidget(self.options)

        self.plot = Plot(qpo=None, parent=self, title="Data histogram", display_mode=False)
        self.plot.set_xlabel("Data value")
        self.plot.set_ylabel("Count")
        vbox.addWidget(self.plot)

        vbox.addStretch(1)
Beispiel #2
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self)
        vbox.addWidget(title)

        self._options = OptionBox("Options")
        self._options.add("Signal data", DataOption(self.ivm), key="data")
        self._clear_btn = QtGui.QPushButton("Clear points")
        self._options.add("Method", ChoiceOption(["Pick points", "Use existing ROI"], ["points", "roi"]), self._clear_btn, key="method")
        self._options.add("ROI", DataOption(self.ivm, data=False, rois=True), key="roi")
        self._view_btn = QtGui.QPushButton("View")
        self._view_btn.setEnabled(False)
        self._save_btn = QtGui.QPushButton("Save")
        self._save_btn.setEnabled(False)
        self._options.add("AIF name", TextOption("aif"), self._view_btn, self._save_btn, key="output-name")
        self._options.option("method").sig_changed.connect(self._method_changed)
        self._options.option("data").sig_changed.connect(self._recalc_aif)
        self._options.option("roi").sig_changed.connect(self._recalc_aif)
        self._clear_btn.clicked.connect(self._clear_btn_clicked)
        self._save_btn.clicked.connect(self._save_btn_clicked)
        self._view_btn.clicked.connect(self._view_btn_clicked)
        vbox.addWidget(self._options)

        self._plot = Plot(qpo=None, parent=self, title="AIF", display_mode=False)
        self._plot.set_xlabel("Volume")
        self._plot.set_ylabel("Signal")
        vbox.addWidget(self._plot)

        vbox.addStretch(1)
Beispiel #3
0
    def interface(self, generic_options=None):
        if generic_options is None:
            generic_options = {}

        if self.options_widget is None:
            self.options_widget = QtGui.QWidget()
            vbox = QtGui.QVBoxLayout()
            self.options_widget.setLayout(vbox)

            cite = Citation(CITE_TITLE, CITE_AUTHOR, CITE_JOURNAL)
            vbox.addWidget(cite)

            self.optbox = OptionBox()
            self.optbox.add("Mask for registration data",
                            DataOption(self.ivm, rois=True, data=False),
                            key="inmask",
                            checked=True)
            self.optbox.add("Mask for reference data",
                            DataOption(self.ivm, rois=True, data=False),
                            key="refmask",
                            checked=True)
            self.optbox.add("Spline order",
                            ChoiceOption([2, 3]),
                            key="splineorder",
                            checked=True)
            self.optbox.add("Use pre-defined configuration",
                            ChoiceOption(
                                ["T1_2_MNI152_2mm", "FA_2_FMRIB58_1mm"]),
                            key="config",
                            checked=True)
            vbox.addWidget(self.optbox)

        return self.options_widget
Beispiel #4
0
    def _init_ui(self):
        self.optbox.add("Minimum number of repeats per time point",
                        NumericOption(intonly=True,
                                      default=3,
                                      minval=1,
                                      maxval=20),
                        key="min_nvols")
        self.optbox.add("Custom grey matter ROI",
                        DataOption(self.ivm,
                                   rois=True,
                                   data=False,
                                   explicit=True),
                        checked=True,
                        key="gm_roi")
        self.optbox.add("Custom noise ROI",
                        DataOption(self.ivm,
                                   rois=True,
                                   data=False,
                                   explicit=True),
                        checked=True,
                        key="noise_roi")

        self.vbox.addWidget(QtGui.QLabel("Quality measures"))
        self.qms_table = QtGui.QTableView()
        self.qms_table.setModel(self.qms_model)
        self.vbox.addWidget(self.qms_table)
Beispiel #5
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self)
        vbox.addWidget(title)

        self.options = OptionBox("Options")
        self.options.add("Data", DataOption(self.ivm, multi=True), key="data")
        self.options.add("Within ROI",
                         DataOption(self.ivm,
                                    data=False,
                                    rois=True,
                                    none_option=True),
                         key="roi")
        self.options.add("All volumes",
                         BoolOption(default=False),
                         key="allvols")
        self.options.add("Number of bins",
                         NumericOption(minval=5,
                                       maxval=250,
                                       default=50,
                                       intonly=True),
                         key="bins")
        vbox.addWidget(self.options)

        self.plot = Plot(qpo=None,
                         parent=self,
                         title="Radial profile",
                         display_mode=False)
        self.plot.set_xlabel("Distance (mm)")
        self.plot.set_ylabel("Mean data value")
        vbox.addWidget(self.plot)

        vbox.addStretch(1)
    def _refresh_gui(self):
        options = dict(self.model.options)
        self.gui.clear()
        for struc in self.model.default_strucs:
            data_opt = self.gui.add("%s map" % struc.name.upper(), DataOption(self.model._ivm, explicit=True), checked=True, enabled=struc.name in options["pvmaps"], key=struc.name)
            data_opt.value = options["pvmaps"].get(struc.name, None)

        for struc in options["additional"].values():
            del_btn = self._struc_delete_btn(struc)
            display_type = {"add" : "map", "embed" : "embedding", "act" : "mask"}.get(struc["struc_type"], "map")
            data_opt = self.gui.add("%s %s" % (struc["name"], display_type), DataOption(self.model._ivm, explicit=True, rois=True), del_btn, key=struc["name"])
            data_opt.value = struc.get("pvmap", None)

        res_opts = options.get("resampling", {})
        self.gui.add("Resampling", ChoiceOption(["Downsample", "From another data set", "Specified resolution"], ["down", "data", "res"], 
                     default=res_opts.get("type", "res")), checked=True, enabled="type" in res_opts, key="type")
        self.gui.add("Output space from", DataOption(self.ivm), key="grid")
        self.gui.add("Output resample factor", NumericOption(intonly=True, minval=1, maxval=10, default=2), key="factor")
        self.gui.add("Voxel sizes (mm)", NumberListOption(load_btn=False), key="voxel-sizes")
        for opt in ("grid", "factor", "voxel-sizes"):
            if opt in res_opts:
                self.gui.option(opt).value = res_opts[opt]

        self.gui.add(None, RunButton("Add user-defined structure", callback=self._add_embedding), key="add_embedding")
        self._update_resamp_visibility()
Beispiel #7
0
    def _init_ui(self):
        self.optbox.add("Motion correction",
                        BoolOption(default=True),
                        key="mc")
        #opt = self.optbox.add("Deblurring", BoolOption(), key="deblur")
        #opt.sig_changed.connect(self._deblur_changed)
        opt = self.optbox.add("ENABLE volume selection",
                              BoolOption(),
                              key="use_enable")
        opt.sig_changed.connect(self._enable_changed)
        self.optbox.add(
            "Distortion correction",
            ChoiceOption(["Fieldmap", "Phase encoding reversed calibration"],
                         ["fmap", "cblip"]),
            key="distcorr",
            checked=True)
        self.optbox.option("distcorr").sig_changed.connect(
            self._distcorr_changed)
        self.optbox.add("Phase encode direction",
                        ChoiceOption(["x", "y", "z", "-x", "-y", "-z"]),
                        key="pedir")
        self.optbox.add("Echo spacing (ms)",
                        NumericOption(minval=0,
                                      maxval=1,
                                      step=0.01,
                                      decimals=3),
                        key="echospacing")

        self.fmap_opts = OptionBox("Fieldmap distortion correction")
        self.fmap_opts.add("Fieldmap image (rads)",
                           DataOption(self.ivm,
                                      include_4d=False,
                                      explicit=True),
                           key="fmap")
        self.fmap_opts.add("Fieldmap magnitude image (rads)",
                           DataOption(self.ivm,
                                      include_4d=False,
                                      explicit=True),
                           key="fmapmag")
        self.fmap_opts.add("Fieldmap magnitude brain image (rads)",
                           DataOption(self.ivm,
                                      include_4d=False,
                                      explicit=True),
                           key="fmapmagbrain")
        self.vbox.addWidget(self.fmap_opts)

        self.cblip_opts = OptionBox(
            "Phase-encoding reversed distortion correction")
        self.cblip_opts.add("Phase-encode reversed image",
                            DataOption(self.ivm,
                                       include_4d=False,
                                       explicit=True),
                            key="cblip")
        self.vbox.addWidget(self.cblip_opts)

        self._distcorr_changed()
Beispiel #8
0
    def __init__(self, ivl, rois=True, data=True):
        OptionBox.__init__(self, border=True)
        self.ivl = ivl
        self.ivm = ivl.ivm
        self._qpdata = None
        self._no_update = False
        self.grid.setVerticalSpacing(2)

        self._view_btn = QtGui.QPushButton()
        self._view_btn.setIcon(QtGui.QIcon(get_icon("visible.png")))
        self._view_btn.setFixedSize(16, 16)
        self._view_btn.setToolTip("Visibility")
        self._view_btn.clicked.connect(self._view_btn_clicked)
        self._data = self.add("Data" if data else "ROI",
                              DataOption(self.ivm,
                                         data=data,
                                         rois=rois,
                                         follow_current=True),
                              self._view_btn,
                              key="data")
        self._view_roi = self.add("View ROI",
                                  DataOption(self.ivm, data=False, rois=True),
                                  checked=True,
                                  key="view_roi")
        self._levels_btn = QtGui.QPushButton()
        self._levels_btn.setIcon(QtGui.QIcon(get_icon("levels.png")))
        self._levels_btn.setFixedSize(16, 16)
        self._levels_btn.setToolTip("Adjust colour map levels")
        self._levels_btn.clicked.connect(self._levels_clicked)
        self._cmap = self.add("Colour map",
                              ChoiceOption([
                                  "jet", "hot", "gist_heat", "flame",
                                  "bipolar", "spectrum", "custom"
                              ]),
                              self._levels_btn,
                              key="cmap")
        self._alpha = self.add("Alpha",
                               NumericOption(minval=0,
                                             maxval=255,
                                             default=255,
                                             edit=False,
                                             intonly=True),
                               key="alpha")
        self._value_label = QtGui.QLabel()
        self.add("Value", self._value_label)
        self.add("", stretch=2)

        self._data.sig_changed.connect(self._data_changed)
        self._view_roi.sig_changed.connect(self._view_roi_changed)
        self._cmap.sig_changed.connect(self._cmap_changed)
        self._alpha.sig_changed.connect(self._alpha_changed)
        self.ivl.sig_focus_changed.connect(self._focus_changed)
        self.qpdata = None
Beispiel #9
0
    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()
Beispiel #10
0
    def init_ui(self):
        FslWidget.init_ui(self)

        self.options.add("Input structural data",
                         DataOption(self.ivm),
                         key="data")
        self.options.add("Image type",
                         ChoiceOption(
                             ["T1 weighted", "T2 weighted", "Proton Density"],
                             return_values=["T1", "T2", "PD"]),
                         key="img_type")
        self.options.add("Strong bias field", BoolOption(), key="strongbias")
        self.options.add("Re-orientation to standard space",
                         BoolOption(invert=True),
                         key="noreorient")
        self.options.add("Automatic cropping",
                         BoolOption(invert=True),
                         key="nocrop")
        self.options.add("Bias field correction",
                         BoolOption(invert=True),
                         key="nobias")
        #self.options.add("Registration to standard space", BoolOption(invert=True), key="noreg")
        #self.options.add("Non-linear registration", BoolOption(invert=True), key="nononlinreg")
        self.options.add("Segmentation", BoolOption(invert=True), key="noseg")
        self.options.add("Sub-cortical segmentation",
                         BoolOption(invert=True),
                         key="nosubcortseg")
        self.options.add("BET Intensity threshold",
                         NumericOption(minval=0, maxval=1, default=0.5),
                         key="betfparam")
        self.options.add("Bias field smoothing extent (mm)",
                         NumericOption(minval=0, maxval=100, default=20),
                         key="bias_smoothing")
Beispiel #11
0
    def init_ui(self):
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)

        title = TitleWidget(self, 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("Transform", TransformOption(self.ivm), key="transform")
        self.options.add("Apply to data", DataOption(self.ivm), key="data")
        self.options.add("Interpolation", ChoiceOption(["Nearest neighbour", "Linear", "Spline"], [0, 1, 3], default=1), key="interp-order")
        self.options.add("Output name", OutputNameOption(src_data=self.options.option("data"), suffix="_reg"), key="output-name")
        self.options.option("transform").sig_changed.connect(self._transform_changed)
        layout.addWidget(self.options)

        self.details = TransformDetails()
        layout.addWidget(self.details)

        layout.addWidget(RunButton(self))
        layout.addStretch(1)
        self._transform_changed()
    def __init__(self, parent, ivm, existing_strucs):
        super(AddEmbeddingDialog, self).__init__(parent)
        self.ivm = ivm
        self.sel_text = None
        self.sel_data = None
        self.existing_names = [struc.name for struc in existing_strucs]

        self.setWindowTitle("Add embedding")
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        self._opts = OptionBox()
        pvmap = self._opts.add("PV map / mask", DataOption(ivm, data=True, rois=True), key="pvmap")
        pvmap.sig_changed.connect(self._pvmap_changed)
        self._opts.add("ROI region", ChoiceOption([]), key="region")
        name = self._opts.add("Name of embedded structure", TextOption(), key="name")
        name.textChanged.connect(self._name_changed)
        self._opts.add("Structure type", ChoiceOption(["Embedding", "Activation mask", "Additional PVE"], return_values=["embed", "act", "add"]), key="type")
        self._opts.add("Parent structure", ChoiceOption([s.display_name for s in existing_strucs], [s.name for s in existing_strucs]), key="parent")
        self._opts.add("Edge smoothing sigma (mm)", NumericOption(minval=0, maxval=10, default=1, decimals=2), checked=True, enabled=False, key="sigma")
        vbox.addWidget(self._opts)

        self._warning = QtWidgets.QLabel(parent=self)
        self._warning.setStyleSheet("color: red;")
        vbox.addWidget(self._warning)

        self.button_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        self.button_box.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
        vbox.addWidget(self.button_box)
        self._pvmap_changed()
Beispiel #13
0
    def init_ui(self):
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)

        title = TitleWidget(self, help="simple_maths")
        layout.addWidget(title)

        info = QtGui.QLabel(MATHS_INFO)
        info.setWordWrap(True)
        layout.addWidget(info)

        self.optbox = OptionBox()
        self.optbox.add("Data space from", DataOption(self.ivm), key="grid")
        self.optbox.add("Command", TextOption(), key="cmd")
        self.optbox.add("Output name",
                        OutputNameOption(src_data=self.optbox.option("grid")),
                        key="output-name")
        self.optbox.add("Output is an ROI", BoolOption(), key="output-is-roi")
        layout.addWidget(self.optbox)

        hbox = QtGui.QHBoxLayout()
        self.go_btn = RunButton(self)
        hbox.addWidget(self.go_btn)
        hbox.addStretch(1)
        layout.addLayout(hbox)

        layout.addStretch(1)
Beispiel #14
0
    def init_ui(self):
        FslWidget.init_ui(self)

        data = self.options.add("Input data", DataOption(self.ivm), key="data")
        data.sig_changed.connect(self._data_changed)
        self.options.add("Output extracted brain image",
                         OutputNameOption(src_data=data, suffix="_brain"),
                         key="output-brain",
                         checked=True,
                         enabled=True)
        self.options.add("Output brain mask",
                         OutputNameOption(src_data=data, suffix="_brain_mask"),
                         key="output-mask",
                         checked=True)
        self.options.add("Intensity threshold",
                         NumericOption(minval=0, maxval=1, default=0.5),
                         key="thresh")
        self.options.add("Head radius (mm)",
                         NumericOption(intonly=True,
                                       minval=0,
                                       maxval=300,
                                       default=200),
                         key="radius",
                         checked=True)
        self.centre = self.options.add("Brain centre (raw co-ordinates)",
                                       PickPointOption(self.ivl),
                                       key="centre",
                                       checked=True)
Beispiel #15
0
    def _new_roi(self):
        dialog = QtGui.QDialog(self)
        dialog.setWindowTitle("New ROI")
        vbox = QtGui.QVBoxLayout()
        dialog.setLayout(vbox)

        optbox = OptionBox()
        optbox.add("ROI name", TextOption(), key="name")
        optbox.add("Data space from", DataOption(self.ivm), key="grid")
        vbox.addWidget(optbox)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
                                         | QtGui.QDialogButtonBox.Cancel)
        buttons.accepted.connect(dialog.accept)
        buttons.rejected.connect(dialog.reject)
        vbox.addWidget(buttons)

        ok = dialog.exec_()
        if ok:
            roiname = optbox.option("name").value
            grid = self.ivm.data[optbox.option("grid").value].grid
            roidata = np.zeros(grid.shape, dtype=np.int)
            self.ivm.add(NumpyData(roidata, grid=grid, roi=True, name=roiname),
                         make_current=True)

            # Throw away old history. FIXME is this right, should we keep existing data and history?
            # Also should we cache old history in case we go back to this ROI?
            self._history = []
            self._undo_btn.setEnabled(False)
            self.options.option("roi").value = roiname
Beispiel #16
0
    def init_ui(self):
        self.setStatusTip("Click points on the 4D volume to see data curve")

        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self, "Multi-Voxel Visualisation", help="curve_compare", batch_btn=False)
        vbox.addWidget(title)

        self.plot = Plot(clear_btn=True)
        self.plot.clear_btn.clicked.connect(self._clear)
        self.plot.options.sig_options_changed.connect(self._options_changed)
        vbox.addWidget(self.plot)

        self.options = OptionBox("Options")
        self.options.add("Data set", DataOption(self.ivm, include_3d=False), key="data")
        col_names = [text for text in self.colors]
        cols = [col for text, col in self.colors.items()]
        self.options.add("Plot colour", ChoiceOption(col_names, cols, default="red"), key="col")
        self.options.add("Show individual curves", BoolOption(default=True), key="indiv")
        self.options.add("Show mean curve", BoolOption(), key="mean")

        self.options.option("data").sig_changed.connect(self._data_changed)
        self.options.option("indiv").sig_changed.connect(self._indiv_changed)
        self.options.option("mean").sig_changed.connect(self._mean_changed)
        self.options.option("col").sig_changed.connect(self._col_changed)

        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(self.options)
        hbox.addStretch()
        vbox.addLayout(hbox)

        vbox.addStretch(1)    
        self._options_changed()
Beispiel #17
0
    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()
Beispiel #18
0
    def init_ui(self):
        layout = QtGui.QVBoxLayout()
        
        title = TitleWidget(self, help="roibuilder", batch_btn=False)
        layout.addWidget(title)

        self.options = OptionBox("Options")
        btn = QtGui.QPushButton("New")
        btn.clicked.connect(self._new_roi)
        self.options.add("ROI", DataOption(self.ivm, rois=True, data=False), btn, key="roi")
        self.options.add("Current label", NumericOption(minval=1, slider=False, intonly=True), key="label")
        self.options.add("Label description", TextOption(), key="label_text")
        self.options.option("roi").sig_changed.connect(self._roi_changed)
        self.options.option("label").sig_changed.connect(self._label_changed)
        self.options.option("label_text").sig_changed.connect(self._label_text_changed)
        layout.addWidget(self.options)
        
        # Add toolbox buttons in a grid
        hbox = QtGui.QHBoxLayout()
        self._toolbox = QtGui.QGroupBox()
        self._toolbox.setTitle("Toolbox")
        self.tools_grid = QtGui.QGridLayout()
        self._toolbox.setLayout(self.tools_grid)

        x, y, cols = 0, 0, 4
        for tool in TOOLS:
            self._add_tool(tool, y, x)
            x += 1
            if x == cols:
                y += 1
                x = 0

        self._undo_btn = QtGui.QPushButton()
        self._undo_btn.clicked.connect(self.undo)
        self._undo_btn.setEnabled(False)
        undo_icon = QtGui.QIcon(get_icon("undo"))
        self._undo_btn.setIcon(undo_icon)
        self._undo_btn.setToolTip("Undo last action")
        self._undo_btn.setFixedSize(32, 32)
        self.tools_grid.addWidget(self._undo_btn, y, x)

        hbox.addWidget(self._toolbox)
        self._toolbox.setEnabled(False)
        hbox.addStretch(1)
        layout.addLayout(hbox)

        # Tool options box - initially invisible
        hbox = QtGui.QHBoxLayout()
        self._tool_options = QtGui.QGroupBox()
        self._tool_options.setVisible(False)

        hbox.addWidget(self._tool_options)
        hbox.addStretch(1)
        layout.addLayout(hbox)

        layout.addStretch(1)
        self.setLayout(layout)
Beispiel #19
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        vbox.addWidget(TitleWidget(self))

        self.optbox = OptionBox("Resampling options")
        self.data = self.optbox.add("Data to resample",
                                    DataOption(self.ivm),
                                    key="data")
        self.resample_type = self.optbox.add(
            "Resampling method",
            ChoiceOption(
                ["On to grid from another data set", "Upsample", "Downsample"],
                ["data", "up", "down"]),
            key="type")
        self.grid_data = self.optbox.add("Use grid from",
                                         DataOption(self.ivm),
                                         key="grid")
        self.factor = self.optbox.add("Factor",
                                      NumericOption(default=2,
                                                    minval=2,
                                                    maxval=10,
                                                    intonly=True),
                                      key="factor")
        self.slicewise = self.optbox.add("2D only", BoolOption(), key="2d")
        self.order = self.optbox.add(
            "Interpolation",
            ChoiceOption(["Nearest neighbour", "Linear", "Quadratic", "Cubic"],
                         [0, 1, 2, 3],
                         default=1),
            key="order")
        self.output_name = self.optbox.add("Output name",
                                           OutputNameOption(src_data=self.data,
                                                            suffix="_res"),
                                           key="output-name")
        vbox.addWidget(self.optbox)
        self.resample_type.sig_changed.connect(self._resample_type_changed)

        self.run = RunButton("Resample", self._run)
        vbox.addWidget(self.run)
        vbox.addStretch(1)

        self._resample_type_changed()
Beispiel #20
0
 def _init_ui(self):
     self._batdefault = 1.3
     self.optbox.add("<b>Model fitting options</b>")
     self.optbox.add("Custom ROI",
                     DataOption(self.ivm,
                                data=False,
                                rois=True,
                                explicit=True),
                     key="roi",
                     checked=True)
     self.optbox.add("Spatial regularization",
                     BoolOption(default=True),
                     key="spatial")
     self.optbox.add("Fix label duration",
                     BoolOption(default=False, invert=True),
                     key="infertau")
     self.optbox.add("Fix arterial transit time",
                     BoolOption(default=True, invert=True),
                     key="inferbat")
     self.optbox.add("T1 value uncertainty",
                     BoolOption(default=False),
                     key="infert1")
     self.optbox.add("Macro vascular component",
                     BoolOption(default=True),
                     key="inferart")
     self.optbox.add("Partial volume correction",
                     BoolOption(default=False),
                     key="pvcorr")
     self.optbox.add("")
     self.optbox.add("<b>Default parameters</b>")
     self.optbox.add("Arterial Transit Time",
                     NumericOption(minval=0,
                                   maxval=2.5,
                                   default=self._batdefault,
                                   decimals=3),
                     key="bat",
                     checked=True)
     self.optbox.add("T1 (s)",
                     NumericOption(minval=0,
                                   maxval=3,
                                   default=1.3,
                                   decimals=3),
                     key="t1",
                     checked=True)
     self.optbox.add("T1b (s)",
                     NumericOption(minval=0,
                                   maxval=3,
                                   default=1.65,
                                   decimals=3),
                     key="t1b",
                     checked=True)
     self.optbox.add("")
     self.optbox.add(
         "<b>White paper mode</b>  (defaults from Alsop, 2015 consensus paper)"
     )
     self.optbox.add("Enable white paper mode", BoolOption(), key="wp")
Beispiel #21
0
    def init_ui(self):
        FslWidget.init_ui(self)

        self.options.add("Structural image (brain extracted)",
                         DataOption(self.ivm, include_4d=False),
                         key="data")
        self.options.add("Image type",
                         ChoiceOption(
                             ["T1 weighted", "T2 weighted", "Proton Density"],
                             return_values=[1, 2, 3]),
                         key="type")
        self.options.add("Number of tissue type classes",
                         NumericOption(intonly=True,
                                       minval=2,
                                       maxval=10,
                                       default=3),
                         key="class")
        self.options.add("Output estimated bias field",
                         BoolOption(),
                         key="biasfield")
        self.options.add("Output bias-corrected image",
                         BoolOption(),
                         key="biascorr")
        self.options.add("Remove bias field",
                         BoolOption(default=True),
                         key="nobias")
        self.options.add("Bias field smoothing extent (mm)",
                         NumericOption(minval=0, maxval=100, default=20),
                         key="lowpass")
        self.options.add(
            "Number of main-loop iterations during bias-field removal",
            NumericOption(intonly=True, minval=1, maxval=10, default=4),
            key="iter")
        self.options.add(
            "Number of main-loop iterations after bias-field removal",
            NumericOption(intonly=True, minval=1, maxval=10, default=4),
            key="fixed")
        self.options.add("Number of segmentation iterations",
                         NumericOption(intonly=True,
                                       minval=1,
                                       maxval=100,
                                       default=15),
                         key="init")
        self.options.add("Initial segmentation spatial smoothness",
                         NumericOption(minval=0, maxval=1, default=0.02),
                         key="fHard")
        self.options.add("Spatial smoothness for mixeltype",
                         NumericOption(minval=0, maxval=5, default=0.3),
                         key="mixel")
        self.options.add("Segmentation spatial smoothness",
                         NumericOption(minval=0, maxval=5, default=0.1),
                         key="Hyper")
Beispiel #22
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        vbox.addWidget(TitleWidget(self))

        optbox = OptionBox("Resampling options")
        self.data = optbox.add("Data to resample", DataOption(self.ivm))
        self.grid_data = optbox.add("Resample onto grid from",
                                    DataOption(self.ivm))
        self.order = optbox.add(
            "Interpolation",
            ChoiceOption(["Nearest neighbour", "Linear", "Quadratic", "Cubic"],
                         [0, 1, 2, 3]))
        self.output_name = optbox.add(
            "Output name", OutputNameOption(src_data=self.data, suffix="_res"))
        vbox.addWidget(optbox)

        self.run = RunButton("Resample", self._run)
        vbox.addWidget(self.run)

        vbox.addStretch(1)
Beispiel #23
0
 def _init_ui(self):
     self.optbox.add(
         "Structural data from",
         ChoiceOption(
             ["No structural data", "Structural image", "FSL_ANAT output"],
             [None, "img", "fsl_anat"]),
         key="struc_src")
     self.optbox.option("struc_src").sig_changed.connect(
         self._data_from_changed)
     self.optbox.add("Structural image",
                     DataOption(self.ivm, include_4d=False, explicit=True),
                     key="struc")
     self.optbox.add("FSL_ANAT directory",
                     FileOption(dirs=True),
                     key="fslanat")
     self.optbox.set_visible("fslanat", False)
     self.optbox.add("")
     self.optbox.add("<b>Override automatic segmentation</b>",
                     key="override_label")
     self.optbox.add("Brain image",
                     DataOption(self.ivm, include_4d=False, explicit=True),
                     key="struc_bet",
                     checked=True)
     self.optbox.add("White matter",
                     DataOption(self.ivm, include_4d=False, explicit=True),
                     key="wmseg",
                     checked=True)
     self.optbox.add("Grey matter",
                     DataOption(self.ivm, include_4d=False, explicit=True),
                     key="gmseg",
                     checked=True)
     self.optbox.add("CSF",
                     DataOption(self.ivm, include_4d=False, explicit=True),
                     key="csfseg",
                     checked=True)
     self._data_from_changed()
Beispiel #24
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self, title="Simulate Motion", help="sim_motion")
        vbox.addWidget(title)

        self.option_box = OptionBox("Options")
        data = self.option_box.add("Data set",
                                   DataOption(self.ivm,
                                              include_4d=True,
                                              include_3d=False),
                                   key="data")
        self.option_box.add("Random translation standard deviation (mm)",
                            NumericOption(minval=0,
                                          maxval=5,
                                          default=1,
                                          decimals=2),
                            key="std")
        self.option_box.add(
            "Random rotation standard deviation (\N{DEGREE SIGN})",
            NumericOption(minval=0, maxval=10, default=1, decimals=2),
            key="std_rot")
        self.option_box.add("Padding (mm)",
                            NumericOption(minval=0,
                                          maxval=10,
                                          default=5,
                                          decimals=1),
                            key="padding",
                            checked=True)
        self.option_box.add(
            "Interpolation",
            ChoiceOption(["Nearest neighbour", "Linear", "Quadratic", "Cubic"],
                         return_values=range(4),
                         default=3),
            key="order")
        self.option_box.add("Output name",
                            OutputNameOption(src_data=data, suffix="_moving"),
                            key="output-name")
        vbox.addWidget(self.option_box)

        run_btn = QtGui.QPushButton('Run', self)
        run_btn.clicked.connect(self.run)
        vbox.addWidget(run_btn)

        vbox.addStretch(1)
Beispiel #25
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self)
        vbox.addWidget(title)

        hbox = QtGui.QHBoxLayout()
        self.options = OptionBox("Re-orient data")
        data = self.options.add("Data item", DataOption(self.ivm), key="data")
        data.sig_changed.connect(self._data_changed)
        self.trans, self.rot = {}, {}
        self.options.add("Translation")
        for axis, label in {2: "axial", 0: "sagittal", 1: "coronal"}.items():
            trans = self.options.add("  %s (mm)" % label.title(),
                                     NumericOption(minval=-100,
                                                   maxval=100,
                                                   default=0),
                                     key="trans-%s" % label)
            trans.sig_changed.connect(self._translate(axis, label))
            self.trans[axis] = trans
        self.options.add("Rotation")
        for axis, label in {2: "axial", 0: "sagittal", 1: "coronal"}.items():
            rot = self.options.add("  %s (degrees)" % label.title(),
                                   NumericOption(minval=-180,
                                                 maxval=180,
                                                 default=0),
                                   key="rot-%s" % label)
            rot.sig_changed.connect(self._rotate(axis, label))
            self.rot[axis] = rot
        hbox.addWidget(self.options)
        vbox.addLayout(hbox)

        self.gridview = GridView(self.ivm, self.ivl)
        vbox.addWidget(self.gridview)

        hbox = QtGui.QHBoxLayout()
        reset_btn = QtGui.QPushButton("Reset to original")
        reset_btn.clicked.connect(self._reset)
        hbox.addWidget(reset_btn)
        hbox.addStretch(1)
        vbox.addLayout(hbox)

        vbox.addStretch(1)
Beispiel #26
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self, title="Simulate Motion", help="sim_motion")
        vbox.addWidget(title)

        self.option_box = OptionBox("Options")
        data = self.option_box.add("Data set",
                                   DataOption(self.ivm,
                                              include_4d=True,
                                              include_3d=False),
                                   key="data")
        self.option_box.add("Motion standard deviation (mm)",
                            NumericOption(minval=0,
                                          maxval=5,
                                          default=1,
                                          decimals=2),
                            key="std")
        self.option_box.add("Padding (mm)",
                            NumericOption(minval=0,
                                          maxval=10,
                                          default=5,
                                          decimals=1),
                            key="padding",
                            checked=True)
        self.option_box.add("Output name",
                            OutputNameOption(src_data=data, suffix="_moving"),
                            key="output-name")
        vbox.addWidget(self.option_box)

        run_btn = QtGui.QPushButton('Run', self)
        run_btn.clicked.connect(self.run)
        vbox.addWidget(run_btn)

        vbox.addStretch(1)
Beispiel #27
0
    def init_ui(self):
        FabberWidget.init_ui(self)

        self.run_box = RunBox(self.get_process, self.get_options, title="Run Fabber", save_option=True)
        self.vbox.addWidget(self.run_box)
        self.vbox.addStretch(1)

        model_opts_btn = QtGui.QPushButton('Model Options')
        method_opts_btn = QtGui.QPushButton('Method Options')
        edit_priors_btn = QtGui.QPushButton('Edit Priors')
        options_btn = QtGui.QPushButton('Edit')

        self.options.add("Main input data", DataOption(self.ivm), key="data")
        self.options.add("Model group", ChoiceOption(), key="model-group")
        self.options.add("Model", ChoiceOption(), model_opts_btn, key="model")
        self.options.add("Parameter priors", edit_priors_btn)
        self.options.add("Inference method", ChoiceOption(), method_opts_btn, key="method")
        self.options.add("General options", options_btn)

        self.options.option("model-group").sig_changed.connect(self._model_group_changed)
        method_opts_btn.clicked.connect(self._show_method_options)
        model_opts_btn.clicked.connect(self._show_model_options)
        edit_priors_btn.clicked.connect(self._show_prior_options)
        options_btn.clicked.connect(self._show_general_options)
        
        model_groups = ["ALL"]
        for group in FabberProcess.api().get_model_groups():
            model_groups.append(group.upper())
        self.options.option("model-group").setChoices(model_groups)
        self.options.option("model-group").value = "ALL"
        self._model_group_changed()

        self.options.option("model").value = "poly"
        self.options.option("method").setChoices(FabberProcess.api().get_methods())
        self.options.option("method").value = "vb"
        self._options_changed()
Beispiel #28
0
    def init_ui(self):
        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        title = TitleWidget(self, title="Add Noise", help="noise")
        vbox.addWidget(title)

        self.option_box = OptionBox("Options")
        data = self.option_box.add("Data set",
                                   DataOption(self.ivm),
                                   key="data")
        self.option_box.add("Gaussian standard deviation",
                            NumericOption(minval=0, maxval=100, default=50),
                            key="std")
        self.option_box.add("Output name",
                            OutputNameOption(src_data=data, suffix="_noisy"),
                            key="output-name")
        vbox.addWidget(self.option_box)

        run_btn = QtGui.QPushButton('Run', self)
        run_btn.clicked.connect(self.run)
        vbox.addWidget(run_btn)

        vbox.addStretch(1)
Beispiel #29
0
    def __init__(self, ivm):
        QtGui.QWidget.__init__(self)
        self.ivm = ivm

        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        self.optbox = OptionBox()
        self.optbox.add(
            "AIF source",
            ChoiceOption(["Global sequence of values", "Voxelwise image"],
                         ["global", "voxelwise"]),
            key="aif_source")
        self.optbox.option("aif_source").sig_changed.connect(
            self._aif_source_changed)
        self.optbox.add("AIF", NumberListOption(), key="aif")
        self.optbox.add("AIF image", DataOption(self.ivm), key="suppdata")
        self.optbox.add("AIF type",
                        ChoiceOption(["DSC signal", "Concentration"],
                                     [False, True]),
                        key="aifconc")
        vbox.addWidget(self.optbox)
        vbox.addStretch()
        self._aif_source_changed()
Beispiel #30
0
    def __init__(self, ivm=None):
        QtGui.QWidget.__init__(self)
        self._ivm = ivm
        self._poolvals_edited = False

        vbox = QtGui.QVBoxLayout()
        self.setLayout(vbox)

        self.optbox = OptionBox()
        vbox.addWidget(self.optbox)

        self.optbox.add("<b>Output options</b>")
        self.optbox.add("CEST R*",
                        BoolOption(default=True),
                        key="save-model-extras")
        self.optbox.add("Parameter maps",
                        BoolOption(default=False),
                        key="save-mean")
        #self.optbox.add("Parameter variance", BoolOption(default=False), key="var")
        self.optbox.add("Model fit",
                        BoolOption(default=False),
                        key="save-model-fit")
        self.optbox.add("Prefix for output",
                        TextOption(),
                        checked=True,
                        key="output-prefix")

        self.optbox.add(" ")
        self.optbox.add("<b>Analysis options</b>")
        self.optbox.add("Spatial Regularization", BoolOption(), key="spatial")
        self.optbox.add("Allow uncertainty in T1/T2 values",
                        BoolOption(),
                        key="t12prior")
        self.optbox.add("Prior T1 map",
                        DataOption(self._ivm),
                        key="t1img",
                        checked=True)
        self.optbox.add("Prior T2 map",
                        DataOption(self._ivm),
                        key="t2img",
                        checked=True)
        self.optbox.add("Tissue PV map (GM+WM)",
                        DataOption(self._ivm),
                        key="pvimg",
                        checked=True)
        self.optbox.option("t12prior").sig_changed.connect(self._update_ui)
        self.optbox.add("Use steady state solution for MT bias reduction",
                        BoolOption(default=False),
                        key="new-ss")
        self.optbox.option("new-ss").sig_changed.connect(self._update_ui)
        self.optbox.add("TR (s)",
                        NumericOption(default=3.0,
                                      minval=0,
                                      maxval=5,
                                      digits=3,
                                      step=0.1),
                        key="tr")
        self.optbox.add("Excitation flip angle (\N{DEGREE SIGN})",
                        NumericOption(default=12.0,
                                      minval=0,
                                      maxval=25,
                                      digits=3,
                                      step=1.0),
                        key="fa")
        self.optbox.add(
            "MT pool Line shape",
            ChoiceOption(
                ["None", "Gaussian", "Lorentzian", "Super Lorentzian"],
                ["none", "gaussian", "lorentzian", "superlorentzian"]),
            key="lineshape")

        self.alexmt_cite = Citation(ALEXMT_CITE_TITLE, ALEXMT_CITE_AUTHOR,
                                    ALEXMT_CITE_JOURNAL)
        vbox.addWidget(self.alexmt_cite)

        vbox.addStretch(1)
        self._update_ui()