def save_to_cfg(self): self.cfg['overviews']['number_ov'] = str(self.number_ov) self.cfg['overviews']['ov_active'] = str( [int(ov.active) for ov in self.__overviews]) self.cfg['overviews']['ov_centre_sx_sy'] = str( [utils.round_xy(ov.centre_sx_sy) for ov in self.__overviews]) self.cfg['overviews']['ov_rotation'] = str( [ov.rotation for ov in self.__overviews]) self.cfg['overviews']['ov_size'] = str( [ov.frame_size for ov in self.__overviews]) self.cfg['overviews']['ov_size_selector'] = str( [ov.frame_size_selector for ov in self.__overviews]) self.cfg['overviews']['ov_pixel_size'] = str( [ov.pixel_size for ov in self.__overviews]) self.cfg['overviews']['ov_dwell_time'] = str( [ov.dwell_time for ov in self.__overviews]) self.cfg['overviews']['ov_dwell_time_selector'] = str( [ov.dwell_time_selector for ov in self.__overviews]) self.cfg['overviews']['ov_wd_stig_xy'] = str( [ov.wd_stig_xy for ov in self.__overviews]) self.cfg['overviews']['ov_acq_interval'] = str( [ov.acq_interval for ov in self.__overviews]) self.cfg['overviews']['ov_acq_interval_offset'] = str( [ov.acq_interval_offset for ov in self.__overviews]) self.cfg['overviews']['ov_viewport_images'] = json.dumps( [ov.vp_file_path for ov in self.__overviews]) self.cfg['debris']['auto_detection_area'] = str( self.use_auto_debris_area) self.cfg['debris']['detection_area'] = str( [ov.debris_detection_area for ov in self.__overviews]) self.cfg['debris']['auto_area_margin'] = str( self.auto_debris_area_margin) self.cfg['debris']['show_detection_area'] = str( self.detection_area_visible) # Stub OV self.cfg['overviews']['stub_ov_centre_sx_sy'] = str( utils.round_xy(self.__stub_overview.centre_sx_sy)) self.cfg['overviews']['stub_ov_grid_size_selector'] = str( self.__stub_overview.grid_size_selector) self.cfg['overviews']['stub_ov_overlap'] = str( self.__stub_overview.overlap) self.cfg['overviews']['stub_ov_frame_size_selector'] = str( self.__stub_overview.frame_size_selector) self.cfg['overviews']['stub_ov_pixel_size'] = str( self.__stub_overview.pixel_size) self.cfg['overviews']['stub_ov_dwell_time'] = str( self.__stub_overview.dwell_time) self.cfg['overviews']['stub_ov_viewport_image'] = str( self.__stub_overview.vp_file_path)
def save_to_cfg(self): """Save current parameters to the self.cfg ConfigParser object. The stage calibration parameters are saved to self.syscfg whenever the calibration is changed at runtime. """ # Stage calibration parameters self.cfg[self._device]['stage_scale_factor_x'] = str( self.stage_calibration[0]) self.cfg[self._device]['stage_scale_factor_y'] = str( self.stage_calibration[1]) self.cfg[self._device]['stage_rotation_angle_x'] = str( self.stage_calibration[2]) self.cfg[self._device]['stage_rotation_angle_y'] = str( self.stage_calibration[3]) # Viewport parameters self.cfg['viewport']['vp_centre_dx_dy'] = str( utils.round_xy(self.vp_centre_dx_dy)) self.cfg['viewport']['vp_scale'] = str(round(self.vp_scale, 3)) self.cfg['viewport']['sv_scale_tile'] = str( round(self.sv_scale_tile, 3)) self.cfg['viewport']['sv_scale_ov'] = str(round(self.sv_scale_ov, 3)) self.cfg['viewport']['sv_offset_x_tile'] = str(self.sv_tile_vx_vy[0]) self.cfg['viewport']['sv_offset_y_tile'] = str(self.sv_tile_vx_vy[1]) self.cfg['viewport']['sv_offset_x_ov'] = str(self.sv_ov_vx_vy[0]) self.cfg['viewport']['sv_offset_y_ov'] = str(self.sv_ov_vx_vy[1])
def save_to_cfg(self): self.cfg['imported']['number_imported'] = str(self.number_imported) self.cfg['imported']['image_src'] = json.dumps( [img.image_src for img in self.__imported_images]) self.cfg['imported']['description']= json.dumps( [img.description for img in self.__imported_images]) self.cfg['imported']['centre_sx_sy']= str( [utils.round_xy(img.centre_sx_sy) for img in self.__imported_images]) self.cfg['imported']['rotation']= str( [img.rotation for img in self.__imported_images]) self.cfg['imported']['size']= str( [img.size for img in self.__imported_images]) self.cfg['imported']['pixel_size']= str( [img.pixel_size for img in self.__imported_images]) self.cfg['imported']['transparency']= str( [img.transparency for img in self.__imported_images])
def save_to_cfg(self): """Save current grid configuration to ConfigParser object self.cfg. The reasons why all grid parameters are saved as lists in the user configuration are backward compatibility and readability.""" self.cfg['grids']['number_grids'] = str(self.number_grids) self.cfg['grids']['grid_active'] = str( [int(grid.active) for grid in self.__grids]) self.cfg['grids']['origin_sx_sy'] = str( [utils.round_xy(grid.origin_sx_sy) for grid in self.__grids]) self.cfg['grids']['rotation'] = str( [grid.rotation for grid in self.__grids]) self.cfg['grids']['size'] = str( [grid.size for grid in self.__grids]) self.cfg['grids']['overlap'] = str( [grid.overlap for grid in self.__grids]) self.cfg['grids']['row_shift'] = str( [grid.row_shift for grid in self.__grids]) self.cfg['grids']['active_tiles'] = str( [grid.active_tiles for grid in self.__grids]) self.cfg['grids']['tile_size'] = str( [grid.frame_size for grid in self.__grids]) self.cfg['grids']['tile_size_selector'] = str( [grid.frame_size_selector for grid in self.__grids]) self.cfg['grids']['pixel_size'] = str( [grid.pixel_size for grid in self.__grids]) self.cfg['grids']['dwell_time'] = str( [grid.dwell_time for grid in self.__grids]) self.cfg['grids']['dwell_time_selector'] = str( [grid.dwell_time_selector for grid in self.__grids]) self.cfg['grids']['display_colour'] = str( [grid.display_colour for grid in self.__grids]) self.cfg['grids']['wd_stig_xy'] = str( [grid.wd_stig_xy for grid in self.__grids]) self.cfg['grids']['acq_interval'] = str( [grid.acq_interval for grid in self.__grids]) self.cfg['grids']['acq_interval_offset'] = str( [grid.acq_interval_offset for grid in self.__grids]) self.cfg['grids']['use_wd_gradient'] = str( [int(grid.use_wd_gradient) for grid in self.__grids]) self.cfg['grids']['wd_gradient_ref_tiles'] = str( [grid.wd_gradient_ref_tiles for grid in self.__grids]) self.cfg['grids']['wd_gradient_params'] = str( [grid.wd_gradient_params for grid in self.__grids]) # Save the working distances and stigmation parameters of those tiles # that are active and/or selected for the autofocus and/or the # working distance gradient. wd_stig_dict = {} for g in range(self.number_grids): for t in range(self.__grids[g].number_tiles): tile_key = str(g) + '.' + str(t) if (self.__grids[g][t].wd > 0 and (self.__grids[g][t].tile_active or self.__grids[g][t].autofocus_active or self.__grids[g][t].wd_grad_active)): # Only save tiles with WD != 0 which are active or # selected for autofocus or wd gradient. wd_stig_dict[tile_key] = [ round(self.__grids[g][t].wd, 9), round(self.__grids[g][t].stig_xy[0], 6), round(self.__grids[g][t].stig_xy[1], 6) ] # Save as JSON string in config: self.cfg['grids']['wd_stig_params'] = json.dumps(wd_stig_dict) # Also save list of autofocus reference tiles. self.cfg['autofocus']['ref_tiles'] = json.dumps( self.autofocus_ref_tiles) # Save tile previews currently held in memory as pngs base_dir = self.cfg['acq']['base_dir'] for g in range(self.number_grids): for t in range(self.__grids[g].number_tiles): preview_path = utils.tile_preview_save_path( base_dir, g, t) img = self.__grids[g][t].preview_img if img is not None: img.save(preview_path)