def on_calibrate_dx(self): fname = str(self.ui.dx_file_name_line.text()) last_ind = util.get_dx_dims(str(fname), 'theta') if (last_ind == None): last_ind = util.get_dx_dims(str(fname), 'data') proj, flat, dark, theta = dx.read_aps_32id(fname, proj=(0, 1)) ##self.ui.theta_step.setText(str((180.0 / np.pi * theta[1] - theta[0]).astype(np.float))) if self.params.flat_field: first = proj[0,:,:].astype(np.float)/flat[0,:,:].astype(np.float) else: first = proj[0,:,:].astype(np.float) proj, flat, dark, theta = dx.read_aps_32id(fname, proj=(last_ind[0]-1, last_ind[0])) if self.params.flat_field: last = proj[0,:,:].astype(np.float)/flat[0,:,:].astype(np.float) else: last = proj[0,:,:].astype(np.float) with spinning_cursor(): self.center_calibration = ufot.process.CenterCalibration(first, last) position = self.center_calibration.position self.overlap_viewer.set_images(first, last) self.overlap_viewer.set_position(position)
def set_gui_startup(self, path): data_size = util.get_dx_dims(str(path), 'data') data_dark_size = util.get_dx_dims(str(path), 'data_dark') data_white_size = util.get_dx_dims(str(path), 'data_white') theta_size = util.get_dx_dims(str(path), 'theta') self.ui.data_size.setText(str(data_size)) self.ui.data_dark_size.setText(str(data_dark_size)) self.ui.data_white_size.setText(str(data_white_size)) self.ui.theta_size.setText(str(theta_size)) self.ui.dx_file_name_line.setText(path) self.ui.input_path_line.setText(path) self.input_file_path = os.path.dirname(str(path)) fname = str(self.ui.dx_file_name_line.text()) proj, flat, dark, theta = dx.read_aps_32id(fname, proj=(0, 1)) self.ui.theta_step.setText(str(np.rad2deg((theta[1] - theta[0])))) self.params.theta_start = theta[0] self.params.theta_end = theta[-1] self.params.projection_number = data_size[0] self.ui.theta_start.setValue(np.rad2deg(theta[0])) self.ui.theta_end.setValue(np.rad2deg(theta[-1])) self.dsize = data_size[1] self.dsize_bin = (data_size[1]/np.power(2, float(self.params.binning))).astype(np.int) self.ui.slice_start.setRange(0, self.dsize_bin) self.ui.slice_start.setValue(self.dsize_bin/2) self.ui.slice_center.setRange(0, self.dsize) self.ui.slice_center.setValue(self.dsize/2) self.params.input_file_path = set_input_file_path(path, self.ui.dx_file_name_line, self.params.input_file_path) self.params.input_path = set_input_path(path, self.ui.input_path_line, self.params.input_path) self.params.output_path = set_output_path(path, self.ui.output_path_line, self.params.output_path) self.ui.preprocessing_container.setVisible(True) self.ui.reconstruction_container.setVisible(True) self.ui.output_container.setVisible(True) self.ui.flat_field.setVisible(True) self.ui.calibrate_dx.setVisible(True) self.ui.calibrate_container.setVisible(True) self.ui.dx_data_label.setVisible(True) self.ui.dx_data_white_label.setVisible(True) self.ui.dx_data_dark_label.setVisible(True) self.ui.dx_theta_label.setVisible(True) self.ui.pre_processing_box.setVisible(True) self.on_flat_field_clicked() self.on_pre_processing_box_clicked() self.on_show_projection_clicked()
def on_reconstruct(self): with spinning_cursor(): self.ui.centralWidget.setEnabled(False) self.repaint() self.app.processEvents() input_images = check_filename(str(self.params.input_file_path)) if not input_images: self.gui_warn("No data found in {}".format(str(self.ui.input_path_line.text()))) self.ui.centralWidget.setEnabled(True) return is_mlem = self.params.reconstruction_algorithm == 'mlem' is_sirt = self.params.reconstruction_algorithm == 'sirt' is_sirtfbp = self.params.reconstruction_algorithm == 'sirtfbp' if (is_mlem or is_sirt or is_sirtfbp) : self.params.iteration_count = self.ui.iteration_count.value() data_size = util.get_dx_dims(str(self.ui.input_path_line.text()), 'data') try: reco.tomo(self.params) except Exception as e: self.gui_warn(str(e)) self.ui.centralWidget.setEnabled(True)
def change_binning(self): self.params.binning = str(self.ui.binning_box.currentIndex()) fname = str(self.ui.dx_file_name_line.text()) try: data_size = util.get_dx_dims(str(fname), 'data') dsize = (data_size[1]/np.power(2, float(self.params.binning))).astype(np.int) except: dsize = 1024 self.ui.slice_start.setRange(0, dsize) self.ui.slice_start.setValue(dsize/2) self.ui.slice_end.setRange(dsize/2+1, dsize) self.ui.slice_end.setValue(dsize/2+1)
def load_files(self, filenames, ffc_correction): """Load *filenames* for display.""" self.filenames = filenames self.ffc_correction = ffc_correction proj, flat, dark, theta = dx.read_aps_32id(filenames, proj=(0, 1)) #self.slider.setRange(0, len(theta) - 1) self.slider.setRange(0, util.get_dx_dims(str(filenames), 'data')[0] - 1) self.slider.setSliderPosition(0) self.update_image()