Exemplo n.º 1
0
    def register_gui(form: 'QFormLayout', on_change: Callable,
                     view) -> Dict[str, Any]:

        # Create a spin box for kernel size without add_property_to_form in order to allow a custom validate method
        size_field = KernelSpinBox(on_change)
        size_field_label = QLabel("Kernel Size")
        size_field_label.setToolTip(KERNEL_SIZE_TOOLTIP)
        form.addRow(size_field_label, size_field)

        _, mode_field = add_property_to_form(
            'Edge Mode',
            Type.CHOICE,
            valid_values=modes(),
            form=form,
            on_change=on_change,
            tooltip="Mode to handle the edges of the image")

        _, gpu_field = add_property_to_form(
            'Use GPU',
            Type.BOOL,
            default_value=False,
            tooltip='Run the median filter on the GPU',
            form=form,
            on_change=on_change)

        return {
            'size_field': size_field,
            'mode_field': mode_field,
            'use_gpu_field': gpu_field
        }
Exemplo n.º 2
0
    def register_gui(form: 'QFormLayout', on_change: Callable,
                     view) -> Dict[str, Any]:
        _, size_field = add_property_to_form(
            'Kernel Size',
            Type.INT,
            3, (0, 1000),
            form=form,
            on_change=on_change,
            tooltip="Size of the median filter kernel")

        _, mode_field = add_property_to_form(
            'Mode',
            Type.CHOICE,
            valid_values=modes(),
            form=form,
            on_change=on_change,
            tooltip="Mode to handle the edges of the image")

        _, gpu_field = add_property_to_form(
            'Use GPU',
            Type.BOOL,
            default_value=False,
            tooltip='Run the median filter on the GPU',
            form=form,
            on_change=on_change)

        return {
            'size_field': size_field,
            'mode_field': mode_field,
            'use_gpu_field': gpu_field
        }
Exemplo n.º 3
0
    def register_gui(form, on_change, view):
        _, size_field = add_property_to_form(
            'Kernel Size',
            Type.INT,
            3, (0, 1000),
            form=form,
            on_change=on_change,
            tooltip="Size of the median filter kernel")

        _, order_field = add_property_to_form(
            'Order',
            Type.INT,
            0, (0, 3),
            form=form,
            on_change=on_change,
            tooltip="Order of the Gaussian filter")

        _, mode_field = add_property_to_form(
            'Mode',
            Type.CHOICE,
            valid_values=modes(),
            form=form,
            on_change=on_change,
            tooltip="Mode to handle the edges of the image")

        return {
            'size_field': size_field,
            'order_field': order_field,
            'mode_field': mode_field
        }
Exemplo n.º 4
0
    def register_gui(form, on_change, view):
        # Rebin by uniform factor options
        _, factor = add_property_to_form('Factor',
                                         'float',
                                         0.5, (0.01, 4.0),
                                         on_change=on_change,
                                         tooltip="Factor by which the data will be rebinned, "
                                         "e.g. 0.5 is 50% reduced size",
                                         single_step_size=0.05)

        # Rebin to target shape options
        shape_range = (1, 9999)

        _, shape_x = add_property_to_form('X', Type.INT, 100, shape_range, on_change=on_change)
        _, shape_y = add_property_to_form('Y', Type.INT, 100, shape_range, on_change=on_change)

        from PyQt5.QtWidgets import QHBoxLayout, QRadioButton, QLabel, QComboBox
        shape_fields = QHBoxLayout()
        shape_fields.addWidget(shape_x)
        shape_fields.addWidget(shape_y)

        # Rebin dimension selection options
        rebin_by_factor_radio = QRadioButton("Rebin by Factor")

        def size_by_factor_toggled(enabled):
            factor.setEnabled(enabled)
            on_change()

        rebin_by_factor_radio.toggled.connect(size_by_factor_toggled)

        rebin_to_dimensions_radio = QRadioButton("Rebin to Dimensions")

        def size_by_dimensions_toggled(enabled):
            shape_x.setEnabled(enabled)
            shape_y.setEnabled(enabled)
            on_change()

        rebin_to_dimensions_radio.toggled.connect(size_by_dimensions_toggled)

        # Rebin mode options
        label_mode = QLabel("Mode")
        mode_field = QComboBox()
        mode_field.addItems(modes())

        form.addRow(rebin_to_dimensions_radio, shape_fields)
        form.addRow(rebin_by_factor_radio, factor)
        form.addRow(label_mode, mode_field)

        # Ensure good default UI state
        rebin_to_dimensions_radio.setChecked(True)
        rebin_by_factor_radio.setChecked(True)

        return {
            "rebin_to_dimensions_radio": rebin_to_dimensions_radio,
            "shape_x": shape_x,
            "shape_y": shape_y,
            "rebin_by_factor_radio": rebin_by_factor_radio,
            "factor": factor,
            "mode_field": mode_field,
        }
Exemplo n.º 5
0
    def register_gui(form, on_change, view: FiltersWindowView) -> Dict[str, Any]:
        from mantidimaging.gui.utility import add_property_to_form

        def try_to_select_relevant_stack(name: str, widget: StackSelectorWidgetView) -> None:
            for i in range(widget.count()):
                if name.lower() in widget.itemText(i).lower():
                    widget.setCurrentIndex(i)
                    break

        _, flat_widget = add_property_to_form("Flat", Type.STACK, form=form, filters_view=view, on_change=on_change)
        _, dark_widget = add_property_to_form("Dark", Type.STACK, form=form, filters_view=view, on_change=on_change)

        assert isinstance(flat_widget, StackSelectorWidgetView)
        flat_widget.setMaximumWidth(250)
        flat_widget.subscribe_to_main_window(view.main_window)
        try_to_select_relevant_stack("Flat", flat_widget)

        assert isinstance(dark_widget, StackSelectorWidgetView)
        dark_widget.setMaximumWidth(250)
        dark_widget.subscribe_to_main_window(view.main_window)
        try_to_select_relevant_stack("Dark", dark_widget)

        return {
            'flat_widget': flat_widget,
            'dark_widget': dark_widget,
        }
Exemplo n.º 6
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form
        label, _ = add_property_to_form("This filter requires sinograms\nto produce a sensible result.",
                                        Type.LABEL,
                                        form=form,
                                        on_change=on_change)

        # defaults taken from TomoPy integration
        # https://tomopy.readthedocs.io/en/latest/api/tomopy.prep.stripe.html#tomopy.prep.stripe.remove_all_stripe
        _, snr = add_property_to_form('Stripe ratio',
                                      Type.FLOAT,
                                      default_value=3,
                                      form=form,
                                      on_change=on_change,
                                      tooltip="Ratio used to segment between useful information and noise"
                                      ". Greater is less sensitive.")

        _, la_size = add_property_to_form('Large stripe kernel',
                                          Type.INT,
                                          default_value=61,
                                          valid_values=(1, 100),
                                          form=form,
                                          on_change=on_change,
                                          tooltip="Window size of the median filter to remove large stripes.")

        return {'snr': snr, 'la_size': la_size}
Exemplo n.º 7
0
    def register_gui(form, on_change, view):
        _, diff_field = add_property_to_form('Difference',
                                             'float',
                                             1000,
                                             valid_values=(1e-7, 10000),
                                             form=form,
                                             on_change=on_change,
                                             tooltip="Difference between pixels that will be used to spot outliers.\n"
                                             "It is calculated by subtracting the original image "
                                             "from the median filtered image")
        diff_field.setDecimals(7)

        _, size_field = add_property_to_form('Median kernel',
                                             Type.INT,
                                             3, (1, 1000),
                                             form=form,
                                             on_change=on_change,
                                             tooltip="The size of the median filter kernel used to find outliers.")

        _, mode_field = add_property_to_form('Mode',
                                             Type.CHOICE,
                                             valid_values=modes(),
                                             form=form,
                                             on_change=on_change,
                                             tooltip="Whether to remove bright or dark outliers")

        return {'diff_field': diff_field, 'size_field': size_field, 'mode_field': mode_field}
Exemplo n.º 8
0
    def register_gui(form, on_change, view):
        _, diff_field = add_property_to_form('Difference',
                                             'float',
                                             1,
                                             valid_values=(-1000000, 1000000),
                                             form=form,
                                             on_change=on_change)
        diff_field.setDecimals(7)

        _, size_field = add_property_to_form('Size',
                                             Type.INT,
                                             3, (0, 1000),
                                             form=form,
                                             on_change=on_change)

        _, apply_to_field = add_property_to_form('Apply to',
                                                 Type.CHOICE,
                                                 valid_values=("Projections",
                                                               "Sinograms"),
                                                 form=form,
                                                 on_change=on_change)

        return {
            'diff_field': diff_field,
            'size_field': size_field,
            'apply_to_field': apply_to_field
        }
Exemplo n.º 9
0
    def register_gui(form: 'QFormLayout', on_change: Callable,
                     view: 'BaseMainWindowView') -> Dict[str, 'QWidget']:
        from mantidimaging.gui.utility import add_property_to_form

        value_range = (-10000000, 10000000)

        _, mode_field = add_property_to_form(
            'Replace with',
            Type.CHOICE,
            valid_values=NaNRemovalFilter.MODES,
            form=form,
            on_change=on_change,
            tooltip="Values used to replace NaNs")

        _, replace_value_field = add_property_to_form(
            "Replacement Value",
            'float',
            valid_values=value_range,
            form=form,
            on_change=on_change,
            tooltip="The value to replace the NaNs with")
        replace_value_field.setDecimals(7)

        mode_field.currentTextChanged.connect(
            lambda text: enable_correct_fields_only(mode_field,
                                                    replace_value_field))

        return {
            "mode_field": mode_field,
            "replace_value_field": replace_value_field
        }
Exemplo n.º 10
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        label, _ = add_property_to_form(
            "This filter requires sinograms\nto produce a sensible result.",
            Type.LABEL,
            form=form,
            on_change=on_change)
        _, order = add_property_to_form(
            'Polynomial fit order',
            Type.INT,
            default_value=1,
            form=form,
            on_change=on_change,
            tooltip="Polynomial fit order. Check sarepy for more information")
        _, sigmax = add_property_to_form(
            'Sigma X',
            Type.INT,
            default_value=3,
            form=form,
            on_change=on_change,
            tooltip="Sigma of the Gaussian window in the x-direction")
        _, sigmay = add_property_to_form(
            'Sigma Y',
            Type.INT,
            default_value=3,
            form=form,
            on_change=on_change,
            tooltip="Sigma of the Gaussian window in the y-direction")

        return {'order': order, 'sigmax': sigmax, 'sigmay': sigmay}
Exemplo n.º 11
0
    def register_gui(form, on_change, view):
        _, size_field = add_property_to_form('Kernel Size', Type.INT, 3, (0, 1000), form=form, on_change=on_change)

        _, order_field = add_property_to_form('Order', Type.INT, 0, (0, 3), form=form, on_change=on_change)

        _, mode_field = add_property_to_form('Mode', Type.CHOICE, valid_values=modes(), form=form, on_change=on_change)

        return {'size_field': size_field, 'order_field': order_field, 'mode_field': mode_field}
Exemplo n.º 12
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        value_range = (-10000000, 10000000)

        _, clip_min_field = add_property_to_form('Clip Min',
                                                 'float',
                                                 valid_values=value_range,
                                                 form=form,
                                                 on_change=on_change)
        clip_min_field.setDecimals(7)

        _, clip_max_field = add_property_to_form('Clip Max',
                                                 'float',
                                                 valid_values=value_range,
                                                 form=form,
                                                 on_change=on_change)
        clip_max_field.setDecimals(7)

        _, clip_min_new_value_field = add_property_to_form(
            'Min Replacement Value',
            'float',
            valid_values=value_range,
            form=form,
            on_change=on_change,
            tooltip='The value that will be used to replace pixel values '
            'that fall below Clip Min.')

        _, clip_max_new_value_field = add_property_to_form(
            'Max Replacement Value',
            'float',
            valid_values=value_range,
            form=form,
            on_change=on_change,
            tooltip='The value that will be used to replace pixel values '
            'that are above Clip Max.')

        clip_min_new_value_field.setDecimals(7)
        clip_max_new_value_field.setDecimals(7)

        # Ensures that the new_value fields are set to be clip_min
        # or clip_max, unless the user has explicitly changed them
        def update_field_on_value_changed(field, field_new_value):
            field_new_value.setValue(field.value())

        # using lambda we can pass in parameters
        clip_min_field.valueChanged.connect(
            lambda: update_field_on_value_changed(clip_min_field, clip_min_new_value_field))
        clip_max_field.valueChanged.connect(
            lambda: update_field_on_value_changed(clip_max_field, clip_max_new_value_field))

        return {
            "clip_min_field": clip_min_field,
            "clip_max_field": clip_max_field,
            "clip_min_new_value_field": clip_min_new_value_field,
            "clip_max_new_value_field": clip_max_new_value_field
        }
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        label, _ = add_property_to_form(
            "This filter requires sinograms\nto produce a sensible result.",
            Type.LABEL,
            form=form,
            on_change=on_change)
        _, sigma = add_property_to_form(
            'Sigma',
            Type.INT,
            default_value=3,
            form=form,
            on_change=on_change,
            tooltip=
            "Sigma of the Gaussian window used to separate the low-pass and"
            " high-pass components of the intensity profile of each column.")

        _, size = add_property_to_form(
            'Stripe kernel',
            Type.INT,
            default_value=21,
            form=form,
            on_change=on_change,
            tooltip="Window size of the median filter to remove large stripes."
        )

        _, window_dim = add_property_to_form(
            'Dimension of the window',
            Type.INT,
            default_value=1,
            valid_values=(1, 2),
            form=form,
            on_change=on_change,
            tooltip="Whether to perform the median on 1D or 2D view of the data"
        )

        _, filtering_dim = add_property_to_form(
            'Filtering dim',
            Type.INT,
            default_value=1,
            valid_values=(1, 2),
            form=form,
            on_change=on_change,
            tooltip="Whether to use a 1D or 2D low-pass filter. "
            "This uses different Sarepy methods")
        return {
            'sigma': sigma,
            'size': size,
            'window_dim': window_dim,
            'filtering_dim': filtering_dim
        }
Exemplo n.º 14
0
 def register_gui(form, on_change, view):
     from mantidimaging.gui.utility import add_property_to_form
     label, roi_field = add_property_to_form("ROI",
                                             Type.STR,
                                             form=form,
                                             on_change=on_change,
                                             default_value="0, 0, 200, 200")
     add_property_to_form("Select ROI",
                          Type.BUTTON,
                          form=form,
                          on_change=on_change,
                          run_on_press=lambda: view.roi_visualiser(roi_field))
     return {'roi_field': roi_field}
 def register_gui(form, on_change, view):
     label, roi_field = add_property_to_form("ROI",
                                             Type.STR,
                                             form=form,
                                             on_change=on_change,
                                             default_value="0, 0, 200, 200")
     add_property_to_form(
         "Select ROI",
         "button",
         form=form,
         on_change=on_change,
         run_on_press=lambda: view.roi_visualiser(roi_field))
     return {'roi_field': roi_field}
Exemplo n.º 16
0
    def register_gui(form: 'QFormLayout', on_change: Callable, view: 'BasePresenter') -> Dict[str, 'QWidget']:
        from mantidimaging.gui.utility import add_property_to_form

        _, value_widget = add_property_to_form("Divide by", Type.FLOAT, form=form, on_change=on_change)
        assert value_widget is not None, "Requested widget was for FLOAT, got None instead"
        value_widget.setDecimals(7)
        _, unit_widget = add_property_to_form("Unit",
                                              Type.CHOICE,
                                              valid_values=["micron", "cm"],
                                              form=form,
                                              on_change=on_change)

        return {'value_widget': value_widget}
Exemplo n.º 17
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        _, radius_field = add_property_to_form('Radius',
                                               Type.FLOAT,
                                               0.95, (0.0, 1.0),
                                               form=form,
                                               on_change=on_change)

        _, value_field = add_property_to_form('Set to value',
                                              Type.FLOAT,
                                              0, (-10000, 10000),
                                              form=form,
                                              on_change=on_change)

        return {'radius_field': radius_field, 'value_field': value_field}
Exemplo n.º 18
0
    def register_gui(form, on_change,
                     view: FiltersWindowView) -> Dict[str, Any]:
        from mantidimaging.gui.utility import add_property_to_form
        _, min_input_widget = add_property_to_form(
            'Min input',
            Type.FLOAT,
            form=form,
            on_change=on_change,
            valid_values=(-2147483647, 2147483647),
            tooltip="Minimum value of the data that will be used.\n"
            "Anything below this will be clipped to 0")
        min_input_widget.setDecimals(8)
        _, max_input_widget = add_property_to_form(
            'Max input',
            Type.FLOAT,
            form=form,
            on_change=on_change,
            default_value=5.0,
            valid_values=(-2147483647, 2147483647),
            tooltip="Maximum value of the data that will be used.\n"
            "Anything above it will be clipped to 0")
        max_input_widget.setDecimals(8)
        _, max_output_widget = add_property_to_form(
            'Max output',
            Type.FLOAT,
            form=form,
            on_change=on_change,
            default_value=65535.0,
            valid_values=(1, 2147483647),
            tooltip="Maximum value of the OUTPUT images. They will \n"
            "be rescaled to range [0, MAX OUTPUT]")
        max_output_widget.setDecimals(8)
        _, preset_widget = add_property_to_form(
            'Preset',
            Type.CHOICE,
            form=form,
            on_change=on_change,
            valid_values=["Use values from above", "int8", "int16", "int32"],
            tooltip="Provides pre-set ranges to rescale to.")

        return {
            'min_input_widget': min_input_widget,
            'max_input_widget': max_input_widget,
            'max_output_widget': max_output_widget,
            'preset_widget': preset_widget
        }
    def register_gui(form, on_change, view):
        label, roi_field = add_property_to_form("Air Region",
                                                Type.STR,
                                                form=form,
                                                on_change=on_change,
                                                default_value="0, 0, 200, 200")
        add_property_to_form(
            "Select Air Region",
            "button",
            form=form,
            on_change=on_change,
            run_on_press=lambda: view.roi_visualiser(roi_field))

        _, mode_field = add_property_to_form(
            'Normalise Mode',
            Type.CHOICE,
            valid_values=modes(),
            form=form,
            on_change=on_change,
            tooltip="Method to normalise output values")

        _, flat_field_widget = add_property_to_form(
            "Flat file",
            Type.STACK,
            form=form,
            filters_view=view,
            on_change=on_change,
            tooltip="Flat images to be used for normalising.")

        assert isinstance(flat_field_widget, StackSelectorWidgetView)
        flat_field_widget.setMaximumWidth(375)
        flat_field_widget.subscribe_to_main_window(view.main_window)
        flat_field_widget.try_to_select_relevant_stack("Flat")
        flat_field_widget.try_to_select_relevant_stack("Flat Before")

        flat_field_widget.setEnabled(False)
        mode_field.currentTextChanged.connect(
            lambda text: enable_correct_fields_only(text, flat_field_widget))

        return {
            'roi_field': roi_field,
            'norm_mode': mode_field,
            'flat_field': flat_field_widget
        }
Exemplo n.º 20
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        _, radius_field = add_property_to_form(
            'Radius',
            Type.FLOAT,
            0.95, (0.01, 0.99),
            form=form,
            on_change=on_change,
            tooltip="Radius [0, 1] of image that should be left untouched.")

        _, value_field = add_property_to_form('Set to value',
                                              Type.FLOAT,
                                              0, (-10000, 10000),
                                              form=form,
                                              on_change=on_change,
                                              tooltip="The value of the mask.")

        return {'radius_field': radius_field, 'value_field': value_field}
Exemplo n.º 21
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        range1 = (0, 1000000)
        range2 = (-1000000, 1000000)

        _, x_field = add_property_to_form('Abcissa X',
                                          Type.INT,
                                          valid_values=range1,
                                          form=form,
                                          on_change=on_change)

        _, y_field = add_property_to_form('Ordinate Y',
                                          Type.INT,
                                          valid_values=range1,
                                          form=form,
                                          on_change=on_change)

        _, thresh = add_property_to_form('Threshold',
                                         Type.FLOAT,
                                         valid_values=range2,
                                         form=form,
                                         on_change=on_change)

        _, thresh_min = add_property_to_form('Threshold Min',
                                             Type.FLOAT,
                                             valid_values=range2,
                                             form=form,
                                             on_change=on_change)

        _, thresh_max = add_property_to_form('Threshold Max',
                                             Type.FLOAT,
                                             valid_values=range2,
                                             form=form,
                                             on_change=on_change)

        _, theta = add_property_to_form('Theta',
                                        Type.INT,
                                        valid_values=(-1000, 1000),
                                        form=form,
                                        on_change=on_change)

        _, rwidth = add_property_to_form('RWidth',
                                         Type.INT,
                                         valid_values=range2,
                                         form=form,
                                         on_change=on_change)

        return {
            "x_field": x_field,
            "y_field": y_field,
            "thresh": thresh,
            "thresh_min": thresh_min,
            "thresh_max": thresh_max,
            "theta": theta,
            "rwidth": rwidth,
        }
Exemplo n.º 22
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        _, threshold_field = add_property_to_form('Threshold',
                                                  'float',
                                                  0.95, (0.0, 1.0),
                                                  form=form,
                                                  on_change=on_change)
        threshold_field.setSingleStep(0.05)

        return {'threshold_field': threshold_field}
Exemplo n.º 23
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        _, angle = add_property_to_form('Angle of rotation\ncounter clockwise (degrees)',
                                        Type.FLOAT,
                                        0, (-180, 180),
                                        form=form,
                                        on_change=on_change)
        angle.setDecimals(7)

        return {"angle": angle}
Exemplo n.º 24
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        _, angle = add_property_to_form('Angle of rotation\ncounter clockwise (degrees)',
                                        Type.FLOAT,
                                        0, (-359, 359),
                                        form=form,
                                        on_change=on_change,
                                        tooltip="How much degrees to rotate counter-clockwise")
        angle.setDecimals(7)

        return {"angle": angle}
Exemplo n.º 25
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        label, _ = add_property_to_form("This filter requires sinograms\nto produce a sensible result.",
                                        Type.LABEL,
                                        form=form,
                                        on_change=on_change)
        # Filter type option
        _, value_filter_type = add_property_to_form('Filter Type', Type.CHOICE, form=form, on_change=on_change)

        # Wavelet options
        _, value_wf_level = add_property_to_form('Level',
                                                 Type.INT,
                                                 default_value=1,
                                                 valid_values=(0, 100),
                                                 form=form,
                                                 on_change=on_change)

        _, value_wf_wname = add_property_to_form('Wavelet Filter',
                                                 Type.CHOICE,
                                                 valid_values=wavelet_names(),
                                                 form=form,
                                                 on_change=on_change)

        _, value_wf_sigma = add_property_to_form('Sigma', Type.FLOAT, 2.0, (0.0, 100.0), form=form, on_change=on_change)

        # Titarenko options
        # _, value_ti_nblock = add_property_to_form('Number of Blocks',
        #                                           Type.INT,
        #                                           0, (0, 100),
        #                                           form=form,
        #                                           on_change=on_change)
        #
        # _, value_ti_alpha = add_property_to_form('Alpha', Type.FLOAT, 1.5, form=form, on_change=on_change)

        # Smoothing filter options
        _, value_sf_size = add_property_to_form('Size', Type.INT, 5, (0, 100), form=form, on_change=on_change)
        # ('titarenko', [value_ti_nblock, value_ti_alpha])
        filters = [('fourier-wavelet', [value_wf_level, value_wf_wname, value_wf_sigma]),
                   ('smoothing-filter', [value_sf_size])]

        def on_filter_type_change(name):
            for f in filters:
                enabled = name == f[0]
                for ui_item in f[1]:
                    ui_item.setEnabled(enabled)
            on_change()

        value_filter_type.addItems([f[0] for f in filters])
        value_filter_type.currentIndexChanged[str].connect(on_filter_type_change)
        on_filter_type_change(value_filter_type.currentText())

        return {
            "value_filter_type": value_filter_type,
            "value_wf_level": value_wf_level,
            "value_wf_wname": value_wf_wname,
            "value_wf_sigma": value_wf_sigma,
            "value_sf_size": value_sf_size,
        }
Exemplo n.º 26
0
    def register_gui(form: 'QFormLayout', on_change: Callable,
                     view: 'BasePresenter') -> Dict[str, Any]:
        from mantidimaging.gui.utility import add_property_to_form

        _, value_widget = add_property_to_form(
            "Divide by",
            Type.FLOAT,
            form=form,
            on_change=on_change,
            tooltip="Value the data will be divided by")
        assert value_widget is not None, "Requested widget was for FLOAT, got None instead"
        value_widget.setDecimals(7)
        _, unit_widget = add_property_to_form(
            "Unit",
            Type.CHOICE,
            valid_values=["micron", "cm"],
            form=form,
            on_change=on_change,
            tooltip="The unit of the input number. "
            "Microns will be converted to cm before division")

        return {'value_widget': value_widget, 'unit_widget': unit_widget}
Exemplo n.º 27
0
    def register_gui(form, on_change,
                     view: FiltersWindowView) -> Dict[str, Any]:
        from mantidimaging.gui.utility import add_property_to_form
        _, min_input_widget = add_property_to_form('Min input',
                                                   Type.FLOAT,
                                                   form=form,
                                                   on_change=on_change,
                                                   valid_values=(-2147483647,
                                                                 2147483647))
        _, max_input_widget = add_property_to_form('Max input',
                                                   Type.FLOAT,
                                                   form=form,
                                                   on_change=on_change,
                                                   default_value=5.0,
                                                   valid_values=(-2147483647,
                                                                 2147483647))
        _, max_output_widget = add_property_to_form('Max output',
                                                    Type.FLOAT,
                                                    form=form,
                                                    on_change=on_change,
                                                    default_value=65535.0,
                                                    valid_values=(1,
                                                                  2147483647))
        _, preset_widget = add_property_to_form(
            'Preset',
            Type.CHOICE,
            form=form,
            on_change=on_change,
            valid_values=["Use values from above", "int8", "int16", "int32"])

        return {
            'min_input_widget': min_input_widget,
            'max_input_widget': max_input_widget,
            'max_output_widget': max_output_widget,
            'preset_widget': preset_widget
        }
Exemplo n.º 28
0
    def load_filter(self, filter_idx, plugin_parameters=None):
        delete_all_widgets_from_layout(self.view.filterPropertiesLayout)
        savu_filter = self.model.filter(filter_idx)

        parameters_widgets: List[QWidget] = []
        for parameter in savu_filter.visible_parameters():
            value = plugin_parameters.get(parameter.name, parameter.value) if plugin_parameters \
                else parameter.value

            label, widget = add_property_to_form(
                parameter.name,
                parameter.type,
                value,
                tooltip=parameter.description,
                form=self.view.filterPropertiesLayout,
            )
            parameters_widgets.append(widget)

        self.current_filter = (savu_filter, parameters_widgets)
        self.view.set_description(savu_filter.synopsis, savu_filter.info)
Exemplo n.º 29
0
    def register_gui(form, on_change, view):
        # Rebin by uniform factor options
        _, factor = add_property_to_form('Factor',
                                         'float',
                                         0.5, (0.0, 1.0),
                                         on_change=on_change)
        factor.setSingleStep(0.05)

        # Rebin to target shape options
        shape_range = (0, 9999)

        _, shape_x = add_property_to_form('X',
                                          Type.INT,
                                          valid_values=shape_range,
                                          on_change=on_change)
        _, shape_y = add_property_to_form('Y',
                                          Type.INT,
                                          valid_values=shape_range,
                                          on_change=on_change)

        from PyQt5 import Qt
        shape_fields = Qt.QHBoxLayout()
        shape_fields.addWidget(shape_x)
        shape_fields.addWidget(shape_y)

        # Rebin dimension selection options
        rebin_by_factor_radio = Qt.QRadioButton("Rebin by Factor")

        def size_by_factor_toggled(enabled):
            factor.setEnabled(enabled)
            on_change()

        rebin_by_factor_radio.toggled.connect(size_by_factor_toggled)

        rebin_to_dimensions_radio = Qt.QRadioButton("Rebin to Dimensions")

        def size_by_dimensions_toggled(enabled):
            shape_x.setEnabled(enabled)
            shape_y.setEnabled(enabled)
            on_change()

        rebin_to_dimensions_radio.toggled.connect(size_by_dimensions_toggled)

        # Rebin mode options
        label_mode = Qt.QLabel("Mode")
        mode_field = Qt.QComboBox()
        mode_field.addItems(modes())

        form.addRow(rebin_to_dimensions_radio, shape_fields)
        form.addRow(rebin_by_factor_radio, factor)
        form.addRow(label_mode, mode_field)

        # Ensure good default UI state
        rebin_to_dimensions_radio.setChecked(True)
        rebin_by_factor_radio.setChecked(True)

        return {
            "rebin_to_dimensions_radio": rebin_to_dimensions_radio,
            "shape_x": shape_x,
            "shape_y": shape_y,
            "rebin_by_factor_radio": rebin_by_factor_radio,
            "factor": factor,
            "mode_field": mode_field,
        }
Exemplo n.º 30
0
    def register_gui(form, on_change, view):
        from mantidimaging.gui.utility import add_property_to_form

        range1 = (0, 1000000)
        range2 = (-1000000, 1000000)

        _, x_field = add_property_to_form(
            'Center of rotation X position',
            Type.INT,
            valid_values=range1,
            form=form,
            on_change=on_change,
            tooltip="abscissa location of center of rotation")

        _, y_field = add_property_to_form(
            'Center of rotation Y position',
            Type.INT,
            valid_values=range1,
            form=form,
            on_change=on_change,
            tooltip="ordinate location of center of rotation")

        _, thresh = add_property_to_form(
            'Threshold',
            Type.FLOAT,
            valid_values=range2,
            form=form,
            on_change=on_change,
            tooltip="maximum value of an offset due to a ring artifact")

        _, thresh_min = add_property_to_form(
            'Threshold Min',
            Type.FLOAT,
            valid_values=range2,
            form=form,
            on_change=on_change,
            tooltip="min value for portion of image to filter")

        _, thresh_max = add_property_to_form(
            'Threshold Max',
            Type.FLOAT,
            valid_values=range2,
            form=form,
            on_change=on_change,
            tooltip="max value for portion of image to filter")

        _, theta = add_property_to_form(
            'Theta',
            Type.INT,
            valid_values=(-1000, 1000),
            form=form,
            on_change=on_change,
            tooltip="minimum angle in degrees to be considered ring artifact")

        _, rwidth = add_property_to_form(
            'RWidth',
            Type.INT,
            valid_values=range2,
            form=form,
            on_change=on_change,
            tooltip="Maximum width of the rings to be filtered in pixels")

        return {
            "x_field": x_field,
            "y_field": y_field,
            "thresh": thresh,
            "thresh_min": thresh_min,
            "thresh_max": thresh_max,
            "theta": theta,
            "rwidth": rwidth,
        }