Ejemplo n.º 1
0
    def update_kropff_fit_table_graph(self, fit_region='high'):
        """
        update the plot of the fit parameters selected
        :param fit_region: 'high', 'low' or 'bragg_peak'
        """
        o_gui = GuiUtility(parent=self)
        fit_parameter_selected = o_gui.get_kropff_fit_parameter_selected(fit_region=fit_region)
        parameter_array = []
        parameter_error_array = []
        fitting_input_dictionary = self.fitting_input_dictionary
        for _index in fitting_input_dictionary['rois'].keys():
            _parameter = fitting_input_dictionary['rois'][_index]['fitting']['kropff'][fit_region][fit_parameter_selected]
            _error = fitting_input_dictionary['rois'][_index]['fitting']['kropff'][fit_region]["{}_error".format(fit_parameter_selected)]
            parameter_array.append(_parameter)
            parameter_error_array.append(_error)
        plot_ui = o_gui.get_kropff_fit_graph_ui(fit_region=fit_region)
        x_array = np.arange(len(parameter_array))

        cleaned_parameter_array, cleaned_parameter_error_array = \
            exclude_y_value_when_error_is_nan(parameter_array,
                                              parameter_error_array)

        plot_ui.axes.cla()
        if fit_region == 'bragg_peak':
            plot_ui.axes.set_yscale("log")
        plot_ui.axes.errorbar(x_array,
                              cleaned_parameter_array,
                              cleaned_parameter_error_array,
                              marker='s')
        plot_ui.axes.set_xlabel("Row # (see Table tab)")
        plot_ui.draw()
Ejemplo n.º 2
0
 def full_reset(self):
     march_dollase_history_state = self.parent.march_dollase_history_state_full_reset
     o_gui = GuiUtility(parent=self.parent)
     o_gui.fill_march_dollase_table(
         list_state=march_dollase_history_state,
         initial_parameters=self.parent.
         march_dollase_fitting_initial_parameters)
Ejemplo n.º 3
0
    def fitting_range_changed(self):
        o_gui = GuiUtility(parent=self)
        algorithm_tab_selected = o_gui.get_tab_selected(tab_ui=self.ui.tab_algorithm)

        if algorithm_tab_selected == 'Kropff':
            self.kropff_fitting_range_changed()
        elif algorithm_tab_selected == 'March-Dollase':
            self.march_dollase_fitting_range_changed()
Ejemplo n.º 4
0
	def export_bragg_peak_profile(self):
		working_dir = str(Path(self.parent.working_dir).parent)
		_export_folder = QFileDialog.getExistingDirectory(self.parent,
		                                                  directory=working_dir,
		                                                  caption="Select Output Folder")

		QtGui.QGuiApplication.processEvents()  # to close QFileDialog

		if _export_folder:

			o_gui = GuiUtility(parent=self.parent)
			list_row_selected = o_gui.get_rows_of_table_selected(table_ui=self.parent.ui.bragg_edge_tableWidget)

			for row_selected in list_row_selected:

				# make up output file name
				name_of_row = o_gui.get_table_str_item(table_ui=self.parent.ui.bragg_edge_tableWidget,
				                                       row=row_selected,
				                                       column=0)
				[x0, y0, width, height] = name_of_row.split("; ")
				name_of_row_formatted = "x0{}_y0{}_width{}_height{}".format(x0,y0, width, height)
				file_name = "kropff_bragg_peak_profile_{}.txt".format(name_of_row_formatted)
				full_file_name = str(Path(_export_folder) / Path(file_name))

				o_fit = KropffFittingJobHandler(parent=self.parent)
				o_fit.prepare(kropff_tooldbox='bragg_peak')

				x_axis = o_fit.xaxis_to_fit
				y_axis = o_fit.list_yaxis_to_fit[row_selected]

				a0 = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting']['kropff']['high']['a0']
				b0 = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting']['kropff']['high']['b0']
				ahkl = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting']['kropff']['low']['ahkl']
				bhkl = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting']['kropff']['low']['bhkl']

				metadata = ["# Bragg peak fitting of row {}".format(row_selected+1)]
				metadata.append("# x0: {}".format(x0))
				metadata.append("# y0: {}".format(y0))
				metadata.append("# width: {}".format(width))
				metadata.append("# height: {}".format(height))
				metadata.append("# a0: {}".format(a0))
				metadata.append("# b0: {}".format(b0))
				metadata.append("# ahkl: {}".format(ahkl))
				metadata.append("# bhkl: {}".format(bhkl))
				metadata.append("#")
				metadata.append("# lambda (Angstroms), average transmission")

				make_ascii_file_from_2dim_array(metadata=metadata,
				                                col1=x_axis,
				                                col2=y_axis,
				                                output_file_name=full_file_name)

			message = "Exported {} file(s) in {}".format(len(list_row_selected), _export_folder)
			self.parent.ui.statusbar.showMessage(message, 15000)   # 15s
			self.parent.ui.statusbar.setStyleSheet("color: green")
Ejemplo n.º 5
0
	def x_axis(self):
		o_gui = GuiUtility(parent=self.parent)
		tab_selected = o_gui.get_tab_selected(self.parent.ui.tabWidget).lower()

		list_ui = self.x_axis_choice_ui[tab_selected]
		if list_ui['index'].isChecked():
			return self.specified_x_axis(xaxis='index')
		elif list_ui['tof'].isChecked():
			return self.specified_x_axis(xaxis='tof')
		else:
			return self.specified_x_axis(xaxis='lambda')
Ejemplo n.º 6
0
    def update_fitting_plot(self):
        o_gui = GuiUtility(parent=self)
        algorithm_tab_selected = o_gui.get_tab_selected(tab_ui=self.ui.tab_algorithm)

        if algorithm_tab_selected == 'Kropff':
            o_kropff = Kropff(parent=self)
            o_kropff.update_fitting_plot()

        elif algorithm_tab_selected == 'March-Dollase':
            o_march = MarchDollase(parent=self)
            o_march.update_fitting_plot()
Ejemplo n.º 7
0
	def x_axis_checked(self):
		o_gui = GuiUtility(parent=self)
		tab_selected = o_gui.get_tab_selected(tab_ui=self.parent.ui.tabWidget).lower()

		list_ui = self.x_axis_choice_ui[tab_selected]

		if list_ui['index'].isChecked():
			return 'index'
		elif list_ui['tof'].isChecked():
			return 'tof'
		else:
			return 'lambda'
Ejemplo n.º 8
0
    def update_table_after_changing_row(self, changing_row=-1):
        o_gui = GuiUtility(parent=self.parent)
        o_gui.fill_march_dollase_table(
            list_state=self.parent.march_dollase_fitting_history_table,
            initial_parameters=self.parent.
            march_dollase_fitting_initial_parameters)

        # keep current selection on new row
        o_table = TableHandler(
            table_ui=self.parent.march_dollase_user_input_table)
        o_table.select_row(row=changing_row - 1)
        self.table_clicked(row=changing_row)
Ejemplo n.º 9
0
    def run_kropff_low_lambda(self, update_table_ui=False):
        gmodel = Model(kropff_low_lambda,
                       missing='drop',
                       independent_vars=['lda'])

        lda = self.xaxis_to_fit
        o_gui = GuiUtility(parent=self.parent)

        ahkl_init = np.float(str(self.parent.kropff_low_lda_ahkl_init.text()))
        bhkl_init = np.float(str(self.parent.kropff_low_lda_bhkl_init.text()))

        for _row, yaxis in enumerate(self.list_yaxis_to_fit):

            _entry = self.parent.fitting_input_dictionary['rois'][_row][
                'fitting']['kropff']['high']
            a0 = np.float(_entry['a0'])
            b0 = np.float(_entry['b0'])

            yaxis = -np.log(yaxis)
            _result = gmodel.fit(yaxis,
                                 lda=lda,
                                 a0=Parameter('a0', value=a0, vary=False),
                                 b0=Parameter('b0', value=b0, vary=False),
                                 ahkl=ahkl_init,
                                 bhkl=bhkl_init)

            ahkl = _result.params['ahkl'].value
            ahkl_error = _result.params['ahkl'].stderr
            bhkl = _result.params['bhkl'].value
            bhkl_error = _result.params['bhkl'].stderr

            yaxis_fitted = kropff_low_lambda(lda, a0, b0, ahkl, bhkl)

            result_dict = {
                'ahkl': ahkl,
                'bhkl': bhkl,
                'ahkl_error': ahkl_error,
                'bhkl_error': bhkl_error,
                'xaxis_to_fit': lda,
                'yaxis_fitted': yaxis_fitted
            }

            self.parent.fitting_input_dictionary['rois'][_row]['fitting'][
                'kropff']['low'] = deepcopy(result_dict)

            if update_table_ui:
                o_gui.update_kropff_low_lambda_table_ui(row=_row,
                                                        ahkl=ahkl,
                                                        bhkl=bhkl,
                                                        ahkl_error=ahkl_error,
                                                        bhkl_error=bhkl_error)
Ejemplo n.º 10
0
	def select_all_rows_with_negative_thkl(self):
		# activate table
		self.parent.ui.bragg_edge_tableWidget.setFocus()

		# switch to multi selection mode
		self.parent.ui.kropff_bragg_peak_multi_selection.setChecked(True)
		self.parent.ui.bragg_edge_tableWidget.setSelectionMode(2)

		list_of_rows_to_select = []
		fitting_input_dictionary_rois = self.parent.fitting_input_dictionary['rois']
		for _row in fitting_input_dictionary_rois.keys():
			_thkl = np.float(fitting_input_dictionary_rois[_row]['fitting']['kropff']['bragg_peak']['ldahkl'])
			if _thkl < 0:
				list_of_rows_to_select.append(_row)

		o_gui = GuiUtility(parent=self.parent)
		o_gui.select_rows_of_table(table_ui=self.parent.ui.bragg_edge_tableWidget,
		                           list_of_rows=list_of_rows_to_select)
Ejemplo n.º 11
0
    def run_kropff_high_lambda(self, update_table_ui=False):
        gmodel = Model(kropff_high_lambda,
                       missing='drop',
                       independent_vars=['lda'])

        lda = self.xaxis_to_fit
        o_gui = GuiUtility(parent=self.parent)

        a0_init = np.float(str(self.parent.kropff_high_lda_a0_init.text()))
        b0_init = np.float(str(self.parent.kropff_high_lda_b0_init.text()))
        for _index, yaxis in enumerate(self.list_yaxis_to_fit):

            yaxis = -np.log(yaxis)
            _result = gmodel.fit(yaxis, lda=lda, a0=a0_init, b0=b0_init)
            a0 = _result.params['a0'].value
            a0_error = _result.params['a0'].stderr
            b0 = _result.params['b0'].value
            b0_error = _result.params['b0'].stderr

            yaxis_fitted = kropff_high_lambda(self.xaxis_to_fit, a0, b0)

            result_dict = {
                'a0': a0,
                'b0': b0,
                'a0_error': a0_error,
                'b0_error': b0_error,
                'xaxis_to_fit': lda,
                'yaxis_fitted': yaxis_fitted
            }

            self.parent.fitting_input_dictionary['rois'][_index]['fitting'][
                'kropff']['high'] = deepcopy(result_dict)

            if update_table_ui:
                o_gui.update_kropff_high_lambda_table_ui(row=_index,
                                                         a0=a0,
                                                         b0=b0,
                                                         a0_error=a0_error,
                                                         b0_error=b0_error)
Ejemplo n.º 12
0
    def add_fitting_infos_to_metadata(self, metadata):
        o_tab = GuiUtility(parent=self.parent)
        fitting_algorithm_used = o_tab.get_tab_selected(
            tab_ui=self.parent.ui.tab_algorithm)
        # fitting_rois = self.fitting_rois
        # fitting_flag = True if self.parent.fitting_peak_ui else False
        metadata.append(
            "#fitting algorithm selected: {}".format(fitting_algorithm_used))
        metadata.append("#kropff fitting procedure started: {}".format(
            self.parent.fitting_procedure_started['kropff']))
        metadata.append("#Bragg peak selection range: [{}, {}]".format(
            self.parent.kropff_fitting_range['bragg_peak'][0],
            self.parent.kropff_fitting_range['bragg_peak'][1]))
        # kropff
        for _key in self.parent.kropff_fitting_range.keys():
            metadata.append("#kropff {} selection range: [{}, {}]".format(
                _key, self.parent.kropff_fitting_range[_key][0],
                self.parent.kropff_fitting_range[_key][1]))

        # March-dollase
        [left_peak,
         right_peak] = self.parent.march_dollase_fitting_range_selected
        metadata.append(
            "#march-dollase bragg peak selection range: [{}, {}]".format(
                left_peak, right_peak))
        metadata.append("#march-dollase fitting procedure started: {}".format(
            self.parent.fitting_procedure_started['march-dollase']))
        for _row_index, _row_entry in enumerate(
                self.parent.march_dollase_fitting_history_table):
            str_row_entry = [str(_value) for _value in _row_entry]
            joined_str_row_entry = ", ".join(str_row_entry)
            metadata.append("#march-dollase history table row {}: {}".format(
                _row_index, joined_str_row_entry))

        sigma = self.parent.march_dollase_fitting_initial_parameters['sigma']
        alpha = self.parent.march_dollase_fitting_initial_parameters['alpha']

        metadata.append("#march-dollase history init sigma: {}".format(sigma))
        metadata.append("#march-dollase history init alpha: {}".format(alpha))
Ejemplo n.º 13
0
    def move_table_row(self, to_row_offset=-1):
        """
		:param to_row_offset: +1 means moving row to the next row, -1 means moving up by one row
		"""
        row_selected = self.get_row_selected()
        march_dollase_fitting_history_table = self.parent.march_dollase_fitting_history_table
        row_to_move = march_dollase_fitting_history_table.pop(row_selected)

        new_row = row_selected + to_row_offset

        march_dollase_fitting_history_table.insert(new_row, row_to_move)
        self.parent.march_dollase_fitting_history_table = march_dollase_fitting_history_table

        o_gui = GuiUtility(parent=self.parent)
        o_gui.fill_march_dollase_table(
            list_state=self.parent.march_dollase_fitting_history_table,
            list_initial_parameters=self.parent.
            march_dollase_fitting_initial_parameters)

        # keep current selection on new row
        o_table = TableHandler(
            table_ui=self.parent.march_dollase_user_input_table)
        o_table.select_row(row=new_row)
        self.table_clicked(row=new_row)
Ejemplo n.º 14
0
 def advanced_mode_clicked(self):
     hide_advanced = not self.parent.ui.march_dollase_advanced_mode_checkBox.isChecked(
     )
     o_gui = GuiUtility(parent=self.parent)
     o_gui.set_columns_hidden(
         table_ui=self.parent.ui.march_dollase_user_input_table,
         list_of_columns=[5, 6],
         state=hide_advanced)
     o_gui.set_columns_hidden(
         table_ui=self.parent.ui.march_dollase_result_table,
         list_of_columns=[6, 7, 13, 14],
         state=hide_advanced)
Ejemplo n.º 15
0
	def fit_bragg_peak_selected_rows(self):
		o_gui = GuiUtility(parent=self.parent)
		list_rows_selected = o_gui.get_rows_of_table_selected(table_ui=self.parent.ui.bragg_edge_tableWidget)
		self.parent.kropff_fit_bragg_peak_region_of_selected_rows(list_row_to_fit=list_rows_selected)
Ejemplo n.º 16
0
    def run_bragg_peak(self, update_table_ui=False, list_row_to_fit=None):
        gmodel = Model(kropff_bragg_peak_tof,
                       nan_policy='propagate',
                       independent_vars=['lda'])

        lda = self.xaxis_to_fit
        o_gui = GuiUtility(parent=self.parent)

        ldahkl_init = np.float(
            str(self.parent.ui.kropff_bragg_peak_ldahkl_init.text()))
        tau_init = np.float(str(self.parent.kropff_bragg_peak_tau_init.text()))
        sigma_init = np.float(
            self.parent.kropff_bragg_peak_sigma_comboBox.currentText())

        for _row, yaxis in enumerate(self.list_yaxis_to_fit):

            if not list_row_to_fit is None:
                if _row not in list_row_to_fit:
                    continue

            _entry_high = self.parent.fitting_input_dictionary['rois'][_row][
                'fitting']['kropff']['high']
            a0 = np.float(_entry_high['a0'])
            b0 = np.float(_entry_high['b0'])

            _entry_low = self.parent.fitting_input_dictionary['rois'][_row][
                'fitting']['kropff']['low']
            ahkl = np.float(_entry_low['ahkl'])
            bhkl = np.float(_entry_low['bhkl'])

            yaxis = -np.log(yaxis)

            _result = gmodel.fit(yaxis,
                                 lda=lda,
                                 a0=Parameter('a0', value=a0, vary=False),
                                 b0=Parameter('b0', value=b0, vary=False),
                                 ahkl=Parameter('ahkl', value=ahkl,
                                                vary=False),
                                 bhkl=Parameter('bhkl', value=bhkl,
                                                vary=False),
                                 ldahkl=ldahkl_init,
                                 sigma=sigma_init,
                                 tau=tau_init)

            ldahkl = _result.params['ldahkl'].value
            ldahkl_error = _result.params['ldahkl'].stderr
            sigma = _result.params['sigma'].value
            sigma_error = _result.params['sigma'].stderr
            tau = _result.params['tau'].value
            tau_error = _result.params['tau'].stderr

            yaxis_fitted = kropff_bragg_peak_tof(self.xaxis_to_fit, a0, b0,
                                                 ahkl, bhkl, ldahkl, sigma,
                                                 tau)

            result_dict = {
                'ldahkl': ldahkl,
                'ldahkl_error': ldahkl_error,
                'sigma': sigma,
                'sigma_error': sigma_error,
                'tau': tau,
                'tau_error': tau_error,
                'xaxis_to_fit': lda,
                'yaxis_fitted': yaxis_fitted
            }

            self.parent.fitting_input_dictionary['rois'][_row]['fitting'][
                'kropff']['bragg_peak'] = deepcopy(result_dict)

            if update_table_ui:
                o_gui.update_kropff_bragg_edge_table_ui(
                    row=_row,
                    ldahkl=ldahkl,
                    ldahkl_error=ldahkl_error,
                    tau=tau,
                    tau_error=tau_error,
                    sigma=sigma,
                    sigma_error=sigma_error)
Ejemplo n.º 17
0
    def march_dollase(self):

        self.parent.march_dollase_history_state_full_reset = copy.deepcopy(
            self.march_dollase_history_state)

        # init widgets
        _file_path = os.path.dirname(__file__)
        up_arrow_file = os.path.abspath(
            os.path.join(_file_path, '../static/up_arrow_black.png'))
        self.parent.ui.march_dollase_user_input_up.setIcon(
            QtGui.QIcon(up_arrow_file))

        down_arrow_file = os.path.abspath(
            os.path.join(_file_path, '../static/down_arrow_black.png'))
        self.parent.ui.march_dollase_user_input_down.setIcon(
            QtGui.QIcon(down_arrow_file))

        o_gui = GuiUtility(parent=self.parent)
        o_gui.fill_march_dollase_table(
            list_state=self.march_dollase_history_state,
            initial_parameters=self.parent.
            march_dollase_fitting_initial_parameters)

        self.parent.march_dollase_fitting_history_table = self.march_dollase_history_state
        self.parent.march_dollase_fitting_history_table_default_new_row = copy.deepcopy(
            self.march_dollase_history_state[0])

        column_names = [
            u'x\u2080; y\u2080; width; height',
            u'd_spacing',
            u'sigma',
            u'alpha',
            u'A\u2081',
            u'A\u2082',
            u'A\u2085',
            u'A\u2086',
            u'd_spacing_error',
            u'sigma_error',
            u'alpha_error',
            u'A\u2081_error',
            u'A\u2082_error',
            u'A\u2085_error',
            u'A\u2086_error',
        ]
        column_sizes = [
            150, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
            100, 100
        ]
        o_march = TableHandler(
            table_ui=self.parent.ui.march_dollase_result_table)
        for _col_index, _col_name in enumerate(column_names):
            o_march.insert_column(_col_index)
        o_march.set_column_names(column_names=column_names)
        o_march.set_column_sizes(column_sizes=column_sizes)

        state_advanced_columns = not self.parent.ui.march_dollase_advanced_mode_checkBox.isChecked(
        )
        o_gui.set_columns_hidden(
            table_ui=self.parent.ui.march_dollase_user_input_table,
            list_of_columns=[5, 6],
            state=state_advanced_columns)

        # table
        self.parent.ui.march_dollase_user_input_table.verticalHeader(
        ).setVisible(True)
        self.parent.ui.march_dollase_result_table.verticalHeader().setVisible(
            True)
        self.parent.ui.march_dollase_result_table.horizontalHeader(
        ).setVisible(True)
Ejemplo n.º 18
0
    def run(self):
        working_dir = str(Path(self.parent.working_dir).parent)
        ascii_file = QFileDialog.getOpenFileName(self.parent,
                                                 caption="Select ASCII file",
                                                 directory=working_dir,
                                                 filter="ASCII (*.txt)")

        if ascii_file[0]:

            self.parent.full_reset_of_ui()
            self.parent.block_table_ui(True)
            self.parent.is_file_imported = True
            result_of_import = read_bragg_edge_fitting_ascii_format(
                full_file_name=str(ascii_file[0]))
            self.save_initial_roi_dimension_from_config_file(
                result_of_import['metadata']['columns']['3'])
            self.save_march_dollase_parameters(result_of_import['metadata'])
            self.parent.bragg_edge_range = result_of_import['metadata'][
                'bragg_edge_range']
            self.parent.bragg_peak_selection_range = result_of_import[
                'metadata']['bragg_peak_selection_range']

            self.update_selection_tab(result_of_import=result_of_import)
            self.update_interface(result_of_import=result_of_import)

            self.parent.ui.statusbar.showMessage(
                "{} has been imported!".format(ascii_file[0]), 10000)  # 10s
            self.parent.ui.statusbar.setStyleSheet("color: green")

            o_selection = BraggEdgeSelectionTab(parent=self.parent)
            o_selection.update_profile_of_bin_slider_widget()
            o_selection.update_selection_plot()

            self.parent.ui.tabWidget.setTabEnabled(
                1, self.parent.is_fit_infos_loaded())
            self.parent.ui.tabWidget.setEnabled(True)
            self.parent.ui.actionExport.setEnabled(True)

            self.parent.fitting_procedure_started[
                'kropff'] = result_of_import.get('metadata').get(
                    'kropff fitting '
                    'procedure '
                    'started', False)
            self.parent.fitting_procedure_started[
                'march-dollase'] = result_of_import.get('metadata').get(
                    'march-dollase fitting procedure started', False)

            o_kropff = Kropff(parent=self.parent)
            o_kropff.reset_all_table()

            o_march = MarchDollase(parent=self.parent)
            o_march.reset_table()

            if result_of_import.get('metadata').get(
                    'kropff fitting procedure started', False):
                # fill tables with minimum contains
                o_kropff.fill_table_with_fitting_information()

            if result_of_import.get('metadata').get(
                    'march-dollase fitting procedure started', False):
                # fill tables with minimum contains
                o_march.fill_tables_with_fitting_information()
            o_march.fill_history_table_with_fitting_information()

            self.parent.select_first_row_of_all_fitting_table()

            # self.parent.initialize_default_peak_regions()

            self.parent.block_table_ui(False)
            self.parent.update_vertical_line_in_profile_plot()
            self.parent.update_fitting_plot()
            self.parent.kropff_fitting_range_changed()

            o_gui = GuiUtility(parent=self.parent)
            o_gui.check_status_of_kropff_fitting_buttons()
Ejemplo n.º 19
0
 def fill_history_table_with_fitting_information(self):
     o_gui = GuiUtility(parent=self.parent)
     o_gui.fill_march_dollase_table(
         list_state=self.parent.march_dollase_fitting_history_table,
         initial_parameters=self.parent.
         march_dollase_fitting_initial_parameters)
Ejemplo n.º 20
0
	def update_fitting_plot(self):
		self.parent.ui.fitting.clear()
		o_get = Get(parent=self.parent)
		part_of_fitting_dict = o_get.part_of_fitting_selected()
		name_of_page = part_of_fitting_dict['name_of_page']
		table_ui = part_of_fitting_dict['table_ui']

		o_table = TableHandler(table_ui=table_ui)
		list_row_selected = o_table.get_rows_of_table_selected()
		x_axis_selected = o_get.x_axis_checked()

		if list_row_selected is None:
			# first fitting tab where we only display the full data with bragg peak selection
			if self.parent.fitting_peak_ui:
				self.parent.ui.fitting.removeItem(self.parent.fitting_peak_ui)
			xaxis_dict = self.parent.fitting_input_dictionary['xaxis']
			xaxis_index, xaxis_label = xaxis_dict[x_axis_selected]
			[left_xaxis_index, right_xaxis_index] = self.parent.bragg_edge_range
			xaxis = xaxis_index[left_xaxis_index: right_xaxis_index]
			selected_roi = self.parent.fitting_input_dictionary['rois'][0]
			yaxis = selected_roi['profile']
			yaxis = yaxis[left_xaxis_index: right_xaxis_index]
			yaxis = -np.log(yaxis)
			self.parent.ui.fitting.plot(xaxis, yaxis,
			                            pen=(self.parent.selection_roi_rgb[0],
			                                 self.parent.selection_roi_rgb[1],
			                                 self.parent.selection_roi_rgb[2]),
			                            symbol='o')
			self.parent.ui.fitting.setLabel("bottom", xaxis_label)
			peak_range_index = self.parent.kropff_fitting_range['bragg_peak']
			if peak_range_index[0] is None:
				peak_range = self.parent.bragg_edge_range
			else:
				peak_range = [xaxis[peak_range_index[0]], xaxis[peak_range_index[1]]]

			if self.parent.fitting_peak_ui:
				self.parent.ui.fitting.removeItem(self.parent.fitting_peak_ui)
			self.parent.fitting_peak_ui = pg.LinearRegionItem(values=peak_range,
					                                          orientation=None,
					                                          brush=None,
					                                          movable=True,
					                                          bounds=None)
			self.parent.fitting_peak_ui.sigRegionChanged.connect(self.parent.fitting_range_changed)
			self.parent.fitting_peak_ui.setZValue(-10)
			self.parent.ui.fitting.addItem(self.parent.fitting_peak_ui)

		else:

			for row_selected in list_row_selected:

				selected_roi = self.parent.fitting_input_dictionary['rois'][row_selected]

				xaxis_dict = self.parent.fitting_input_dictionary['xaxis']
				[left_xaxis_index, right_xaxis_index] = self.parent.bragg_edge_range

				yaxis = selected_roi['profile']
				xaxis_index, xaxis_label = xaxis_dict[x_axis_selected]

				xaxis = xaxis_index[left_xaxis_index: right_xaxis_index]
				yaxis = yaxis[left_xaxis_index: right_xaxis_index]

				self.parent.ui.fitting.setLabel("bottom", xaxis_label)
				self.parent.ui.fitting.setLabel("left", 'Cross Section (arbitrary units)')
				yaxis = -np.log(yaxis)
				self.parent.ui.fitting.plot(xaxis, yaxis,
				                            pen=(self.parent.selection_roi_rgb[0],
				                                 self.parent.selection_roi_rgb[1],
				                                 self.parent.selection_roi_rgb[2]),
				                            symbol='o')

				peak_range_index = self.parent.kropff_fitting_range[name_of_page]
				if peak_range_index[0] is None:
					peak_range = self.parent.bragg_edge_range
				else:
					peak_range = [xaxis[peak_range_index[0]], xaxis[peak_range_index[1]]]

				if self.parent.fitting_peak_ui:
					self.parent.ui.fitting.removeItem(self.parent.fitting_peak_ui)
				self.parent.fitting_peak_ui = pg.LinearRegionItem(values=peak_range,
					                                              orientation=None,
					                                              brush=None,
					                                              movable=False,
					                                              bounds=None)
				self.parent.fitting_peak_ui.sigRegionChanged.connect(self.parent.fitting_range_changed)
				self.parent.fitting_peak_ui.setZValue(-10)
				self.parent.ui.fitting.addItem(self.parent.fitting_peak_ui)

				o_gui = GuiUtility(parent=self.parent)
				algo_name = o_gui.get_tab_selected(self.parent.ui.tab_algorithm).lower()

				if key_path_exists_in_dictionary(dictionary=self.parent.fitting_input_dictionary,
				                                 tree_key=['rois', row_selected, 'fitting', algo_name,
				                                           name_of_page, 'xaxis_to_fit']):

					# show fit only if tof scale selected
					if x_axis_selected == 'lambda':
						_entry = self.parent.fitting_input_dictionary['rois'][row_selected]['fitting'][algo_name][name_of_page]
						xaxis = _entry['xaxis_to_fit']
						yaxis = _entry['yaxis_fitted']
						yaxis = -np.log(yaxis)
						self.parent.ui.fitting.plot(xaxis, yaxis,
						                            pen=(self.parent.fit_rgb[0],
						                                 self.parent.fit_rgb[1],
						                                 self.parent.fit_rgb[2]))

				if peak_range_index[0] is None:
					self.parent.fitting_range_changed()

		self.parent.ui.fitting.setLabel("left", "Cross Section (arbitrary Units)")