def ver_config(fname): """ This function verifies experiment main config file Parameters ---------- fname : str configuration file name Returns ------- True if configuration is correct, False otherwise """ if not os.path.isfile(fname): print ('no configuration file ' + fname + ' found') return False try: config_map = ut.read_config(fname) if config_map is None: print ("can't read configuration file") return False except Exception as e: print(str(e)) print ('Cannot parse ' + fname + ' configuration file. Check paranthesis and quotations.') return False try: working_dir = config_map.working_dir if type(working_dir) != str: print('working_dir parameter should be string') return False except AttributeError: pass except: print ('working_dir parameter parsing error') return False try: experiment_id = config_map.experiment_id if type(experiment_id) != str: print('experiment_id parameter should be string') return False except AttributeError: pass except: print ('experiment_id parameter parsing error') return False try: scan = config_map.scan if type(scan) != str: # print('scan parameter should be string') return False except AttributeError: pass except: print ('scan parameter parsing error') return False try: specfile = config_map.specfile if type(specfile) != str: print('specfile parameter should be string') return False except AttributeError: pass except: print ('specfile parameter parsing error') return False return True
def ver_config_data(fname): """ This function verifies experiment config_data file Parameters ---------- fname : str configuration file name Returns ------- True if configuration is correct, False otherwise """ if not os.path.isfile(fname): print ('no configuration file ' + fname + ' found') return False config_map = ut.read_config(fname) try: config_map = ut.read_config(fname) if config_map is None: print ("can't read configuration file") return False except: print ('Cannot parse ' + fname + ' configuration file. Check paranthesis and quotations.') return False try: data_dir = config_map.data_dir if type(data_dir) != str: print('data_dir parameter should be string') return False except AttributeError: pass except: print ('data_dir parameter parsing error') return False try: if not ver_list_int('pad_crop', config_map.adjust_dimensions): return False except AttributeError: pass try: if not ver_list_int('center_shift', config_map.center_shift): return False except AttributeError: pass try: if not ver_list_int('binning', config_map.binning): return False except AttributeError: pass try: amp_threshold = config_map.amp_threshold if type(amp_threshold) != float and type(amp_threshold) != int: print('amp_threshold should be float') return False except AttributeError: pass except: print('amp_threshold parameter parsing error') return False alien_alg = 'none' try: alien_alg = config_map.alien_alg except AttributeError: pass if alien_alg == 'none': pass elif alien_alg == 'block_aliens': try: aliens = config_map.aliens if issubclass(type(aliens), list): for a in aliens: if not issubclass(type(a), list): print ('aliens should be a list of alien blocks (lists) ') return False if not ver_list_int('aliens', a): return False if (len(a) < 6): print('misconfigured alien, each alien is defined by list of six int') except AttributeError: pass except Exception as e: print('aliens parameter parsing error ', str(e)) return False elif alien_alg == 'alien_file': try: alien_file = config_map.alien_file if type(alien_file) != str: print('alien_file should be a string (mask file name)') return False except AttributeError: pass elif alien_alg == 'AutoAlien1': try: AA1_size_threshold = config_map.AA1_asym_threshold if type(AA1_size_threshold) != float and type(AA1_asym_threshold) != int: print('AA1_size_threshold should be float') return False except AttributeError: pass except: print('AA1_size_threshold parameter parsing error') return False try: AA1_asym_threshold = config_map.AA1_asym_threshold if type(AA1_asym_threshold) != float and type(AA1_asym_threshold) != int: print('AA1_asym_threshold should be float') return False except AttributeError: pass except: print('AA1_asym_threshold parameter parsing error') return False try: AA1_min_pts = config_map.AA1_min_pts if type(AA1_min_pts) != int: print('AA1_min_pts should be int') return False except AttributeError: pass except: print('AA1_min_pts parameter parsing error') return False try: AA1_eps = config_map.AA1_eps if type(AA1_eps) != float and type(AA1_eps) != int: print('AA1_eps should be float') return False except AttributeError: pass except: print('AA1_eps parameter parsing error') return False try: AA1_amp_threshold = config_map.AA1_amp_threshold if type(AA1_amp_threshold) != float and type(AA1_amp_threshold) != int: print('AA1_amp_threshold should be float') return False except AttributeError: pass except: print('AA1_amp_threshold parameter parsing error') return False try: AA1_save_arrs = config_map.AA1_save_arrs if type(AA1_save_arrs) != bool: print('AA1_save_arrs parameter should be true or false') return False except AttributeError: pass except: print('AA1_save_arrs parameter parsing error') return False try: AA1_expandcleanedsigma = config_map.AA1_expandcleanedsigma if type(AA1_expandcleanedsigma) != float and type(AA1_expandcleanedsigma) != int: print('AA1_expandcleanedsigma should be float') return False except AttributeError: pass except: print('AA1_expandcleanedsigma parameter parsing error') return False return True
def ver_config_prep(fname): """ This function verifies experiment config_prep file Parameters ---------- fname : str configuration file name Returns ------- True if configuration is correct, False otherwise """ if not os.path.isfile(fname): print ('no configuration file ' + fname + ' found') return False try: config_map = ut.read_config(fname) if config_map is None: print ("can't read configuration file") return False except: print ('Cannot parse ' + fname + ' configuration file. Check parenthesis and quotations.') return False try: if not ver_list_int('roi', config_map.roi): print ('roi parameter should be a list of int') return False except AttributeError: pass try: data_dir = config_map.data_dir if type(data_dir) != str: print('data_dir parameter should be string') return False except AttributeError: pass except: print ('data_dir parameter parsing error') return False try: darkfield_filename = config_map.darkfield_filename if type(darkfield_filename) != str: print('darkfield_filename parameter should be string') return False except AttributeError: pass except: print ('darkfield_filename parameter parsing error') return False try: whitefield_filename = config_map.whitefield_filename if type(whitefield_filename) != str: print('whitefield_filename parameter should be string') return False except AttributeError: pass except: print ('whitefield_filename parameter parsing error') return False try: if not ver_list_int('exclude_scans', config_map.exclude_scans): return False except AttributeError: pass try: min_files = config_map.min_files if type(min_files) != int: print('min_files should be int') return False except AttributeError: pass except: print('min_files parameter parsing error') return False try: separate_scans = config_map.separate_scans if type(separate_scans) != bool: print('separate_scans parameter should be true or false') return False except AttributeError: pass except: print('separate_scans parameter parsing error') return False return True
def ver_config_rec(fname): """ This function verifies experiment config_rec file Parameters ---------- fname : str configuration file name Returns ------- True if configuration is correct, False otherwise """ if not os.path.isfile(fname): print ('no configuration file ' + fname + ' found') return False try: config_map = ut.read_config(fname) if config_map is None: print ("can't read configuration file") return False except: print ('Cannot parse ' + fname + ' configuration file. Check parenthesis and quotations.') return False try: data_dir = config_map.data_dir if type(data_dir) != str: print('data_dir parameter should be string') return False except AttributeError: pass except: print ('data_dir parameter parsing error') return False try: save_dir = config_map.save_dir if type(save_dir) != str: print('save_dir parameter should be string') return False except AttributeError: pass except: print ('save_dir parameter parsing error') return False try: cont = config_map.cont if type(cont) != bool: print ('cont parameter should be true or false') return False try: continue_dir = config_map.continue_dir if type(continue_dir) != str: print('continue_dir parameter should be string') return False except AttributeError: pass except: print('continue_dir parameter parsing error') return False except AttributeError: pass except: print ('cont parameter parsing error') return False try: reconstructions = config_map.reconstructions if type(reconstructions) != int: print('reconstructions parameter should be int') return False except AttributeError: pass except: print ('reconstructions parameter parsing error') return False try: device = config_map.device if not ver_list_int('device', device): return False except AttributeError: pass except: print ('device parameter parsing error') return False try: algorithm_sequence = config_map.algorithm_sequence if not issubclass(type(algorithm_sequence), list): print ('algorithm_sequence should be a list') return False for s in algorithm_sequence: for i in range(len(s)): # the first element in each sub-list is the repeat factor and should be int if i== 0 and type(s[i]) != int: print ('algorithm_sequence configuration error, the repeat factor should be int') return False if i > 0: if not issubclass(type(s[i]), list): print ('algorithm_sequence configuration error, the sequence element should be a list') return False algorithm = s[i][0] if type(algorithm) != str: print ('algorithm_sequence configuration error, algorithm should be str') return False algorithm_options = ["ER", "HIO", "NEW_ALG"] if algorithm not in algorithm_options: print ('algorithm_sequence configuration error, algorithm should be "ER" or "HIO"') return False algorithm_repeat = s[i][1] if type(algorithm_repeat) != int: print ('algorithm_sequence configuration error, algorithm repeat should be int') return False except AttributeError: print ('missing mandatory algorithm_sequence parameter') return False except: print ('algorithm_sequence parameter parsing error') return False try: beta = config_map.beta if type(beta) != float: print('beta parameter should be float') return False except AttributeError: pass except: print ('beta parameter parsing error') return False try: generations = config_map.generations if type(generations) != int: print('generations parameter should be int') return False try: ga_metrics = config_map.ga_metrics if not issubclass(type(ga_metrics), list): print (ga_metrics + ' is not a list') return False metrics_options = ['chi', 'sharpness', 'summed_phase', 'area'] for metric in ga_metrics: if metric not in metrics_options: print ('non supported metric option used:', metric) print ('ga_metrics list can include only following strings: "chi", "sharpness", "summed_phase", "area"') return False except AttributeError: pass except: print('ga_metrics parameter parsing error') return False try: ga_breed_modes = config_map.ga_breed_modes if not issubclass(type(ga_breed_modes), list): print (ga_breed_modes + ' is not a list') return False breed_options = ['none', 'sqrt_ab', 'dsqrt', 'pixel_switch', 'b_pa', '2ab_a_b', '2a_b_pa', 'sqrt_ab_pa',\ 'sqrt_ab_pa_recip', 'sqrt_ab_recip', 'max_ab', 'max_ab_pa', 'min_ab_pa', 'avg_ab', 'avg_ab_pa'] for breed in ga_breed_modes: if breed not in breed_options: print ('non supported breed mode used:', breed) print ('ga_breed_modes list can include only following strings: “none”, “sqrt_ab”, “dsqrt”,\ “pixel_switch”, “b_pa”, “2ab_a_b”, “2a_b_pa”, “sqrt_ab_pa”, “sqrt_ab_pa_recip”, “sqrt_ab_recip”,\ “max_ab”, “max_ab_pa”, “min_ab_pa”, “avg_ab”, “avg_ab_pa”') return False except AttributeError: pass except: print('ga_breed_modes parameter parsing error') return False try: ga_cullings = config_map.ga_cullings if not ver_list_int('ga_cullings', ga_cullings): return False except AttributeError: pass except: print('ga_cullings parameter parsing error') return False try: ga_support_thresholds = config_map.ga_support_thresholds if not ver_list_float('ga_support_thresholds', ga_support_thresholds): return False except AttributeError: pass except: print('ga_support_thresholds parameter parsing error') return False try: ga_support_sigmas = config_map.ga_support_sigmas if not ver_list_float('ga_support_sigmas', ga_support_sigmas): return False except AttributeError: pass except: print('ga_support_sigmas parameter parsing error') return False try: ga_low_resolution_sigmas = config_map.ga_low_resolution_sigmas if not ver_list_float('ga_low_resolution_sigmas', ga_low_resolution_sigmas): return False except AttributeError: pass except: print('ga_low_resolution_sigmas parameter parsing error') return False except AttributeError: pass except: print ('generations parameter parsing error') return False try: twin_trigger = config_map.twin_trigger if not ver_list_int('twin_trigger', twin_trigger): return False else: try: twin_halves = config_map.twin_halves if not ver_list_int('twin_halves', twin_halves): return False except AttributeError: pass except: print('twin_halves parameter parsing error') return False except AttributeError: pass try: if not ver_list_int('shrink_wrap_trigger', config_map.shrink_wrap_trigger): return False else: try: shrink_wrap_type = config_map.shrink_wrap_type if type(shrink_wrap_type) != str: print ('shrink_wrap_type parameter should be string') return False if shrink_wrap_type != "GAUSS": print ('supporting shrink_wrap_type "GAUSS"') return False except AttributeError: pass except: print('shrink_wrap_type parameter parsing error') return False try: support_threshold = config_map.support_threshold if type(support_threshold) != float: print('support_threshold should be float') return False except AttributeError: pass except: print('support_threshold parameter parsing error') return False try: support_sigma = config_map.support_sigma if type(support_sigma) != float: print('support_sigma should be float') return False except AttributeError: pass except: print('support_sigma parameter parsing error') return False try: support_area = config_map.support_area if not issubclass(type(support_area), list): print('support_area should be list') return False for e in support_area: if type(e) != int and type(e) !=float: print('support_area should be a list of int or float') return False except AttributeError: pass except: print('support_area parameter parsing error') return False except AttributeError: pass try: if not ver_list_int('phase_support_trigger', config_map.phase_support_trigger): return False else: try: phase_min = config_map.phase_min if type(phase_min) != float: print('phase_min should be float') return False except AttributeError: pass except: print('phase_min parameter parsing error') return False try: phase_max = config_map.phase_max if type(phase_max) != float: print('phase_max should be float') return False except AttributeError: pass except: print('phase_max parameter parsing error') return False except AttributeError: pass try: if not ver_list_int('pcdi_trigger', config_map.pcdi_trigger): return False else: try: partial_coherence_type = config_map.partial_coherence_type if type(partial_coherence_type) != str: print ('partial_coherence_type parameter should be string') return False if partial_coherence_type != "LUCY": print ('partial_coherence_type parameter can be configured "LUCY"') return False except AttributeError: pass except: print('partial_coherence_type parameter parsing error') return False try: partial_coherence_iteration_num = config_map.partial_coherence_iteration_num if type(partial_coherence_iteration_num) != int: print('partial_coherence_iteration_num should be int') return False except AttributeError: pass except: print('partial_coherence_iteration_num parameter parsing error') return False try: partial_coherence_normalize = config_map.partial_coherence_normalize if type(partial_coherence_normalize) != bool: print ('partial_coherence_normalize parameter should be true or false') return False except AttributeError: pass except: print('partial_coherence_normalize parameter parsing error') return False try: partial_coherence_roi = config_map.partial_coherence_roi if not ver_list_int('partial_coherence_roi', partial_coherence_roi): return False except AttributeError: print("'partial_coherence_roi' parameter must be configured when pcdi in active") return False except: print("'partial_coherence_roi' parameter parsing error") return False except AttributeError: pass try: if not ver_list_int('resolution_trigger', config_map.resolution_trigger): return False else: try: iter_res_sigma_range = config_map.iter_res_sigma_range if not ver_list_float('iter_res_sigma_range', iter_res_sigma_range): return False except AttributeError: pass except: print("'iter_res_sigma_range' parameter parsing error") return False try: iter_res_det_range = config_map.iter_res_det_range if not ver_list_float('iter_res_det_range', iter_res_det_range): return False except AttributeError: pass except: print("'iter_res_det_range' parameter parsing error") return False except AttributeError: pass try: if not ver_list_int('average_trigger', config_map.average_trigger): return False except AttributeError: pass try: if not ver_list_int('progress_trigger', config_map.progress_trigger): return False except AttributeError: pass return True
def get_conf_dict(experiment_dir): """ Reads configuration files and creates dictionary with parameters that are needed for visualization. Parameters ---------- experiment_dir : str directory where the experiment files are located Returns ------- conf_dict : dict a dictionary containing configuration parameters """ if not os.path.isdir(experiment_dir): print("Please provide a valid experiment directory") return None conf_dir = os.path.join(experiment_dir, 'conf') conf = os.path.join(conf_dir, 'config_disp') # verify configuration file if not ver.ver_config_disp(conf): print('incorrect configuration file ' + conf + ', cannot parse') return None # parse the conf once here and save it in dictionary, it will apply to all images in the directory tree conf_dict = {} try: conf_map = ut.read_config(conf) items = conf_map.items() for item in items: key = item[0] val = item[1] conf_dict[key] = val except: return None # get specfile and last_scan from the config file and add it to conf_dict main_conf = os.path.join(conf_dir, 'config') if os.path.isfile(main_conf): try: config_map = ut.read_config(main_conf) except: print("info: can't read " + conf + " configuration file") return None try: conf_dict['beamline'] = config_map.beamline except Exception as e: print(e) print('beamline must be defined in the configuration file', main_conf) return None try: conf_dict['specfile'] = config_map.specfile scan = config_map.scan last_scan = scan.split('-')[-1] conf_dict['last_scan'] = int(last_scan) except: print("specfile or scan range not in main config") # get binning from the config_data file and add it to conf_dict data_conf = os.path.join(conf_dir, 'config_data') if os.path.isfile(data_conf): try: conf_map = ut.read_config(data_conf) conf_dict['binning'] = conf_map.binning except AttributeError: pass except Exception as e: print(e) print("info: can't load " + data_conf + " configuration file") return conf_dict
def manage_reconstruction(proc, experiment_dir, rec_id=None): """ This function starts the interruption discovery process and continues the recontruction processing. It reads configuration file defined as <experiment_dir>/conf/config_rec. If multiple generations are configured, or separate scans are discovered, it will start concurrent reconstructions. It creates image.npy file for each successful reconstruction. Parameters ---------- proc : str processing library, choices are: cpu, cuda, opencl experiment_dir : str directory where the experiment files are loacted rec_id : str optional, if given, alternate configuration file will be used for reconstruction, (i.e. <rec_id>_config_rec) Returns ------- nothing """ print('starting reconstruction') # the rec_id is a postfix added to config_rec configuration file. If defined, use this configuration. conf_dir = os.path.join(experiment_dir, 'conf') if rec_id is None: conf_file = os.path.join(conf_dir, 'config_rec') else: conf_file = os.path.join(conf_dir, rec_id + '_config_rec') # check if file exists if not os.path.isfile(conf_file): print('no configuration file ' + conf_file + ' found') return # verify the configuration file if not ver.ver_config_rec(conf_file): # if not verified, the ver will print message return try: config_map = ut.read_config(conf_file) if config_map is None: print("can't read configuration file " + conf_file) return except Exception as e: print('Cannot parse configuration file ' + conf_file + ' , check for matching parenthesis and quotations') print(str(e)) return # find which librarry to run it on, default is numpy ('np') lib = 'np' if proc == 'auto': try: import cupy lib = 'cp' except: # currently we could not install arrayfire on linux, so numpy is the second choice pass elif proc == 'cp': try: import cupy lib = 'cp' except: print('cupy is not installed, select different library (proc)') return elif proc == 'np': pass # lib set to 'np' elif proc == 'af' or 'cpu' or proc == 'cuda' or proc == 'opencl': try: import arrayfire lib = proc except: print( 'arrayfire is not installed, select different library (proc)') return else: print('invalid "proc" value', proc, 'is not supported') return # exp_dirs_data list hold pairs of data and directory, where the directory is the root of data/data.tif file, and # data is the data.tif file in this directory. exp_dirs_data = [] # experiment may be multi-scan in which case reconstruction will run for each scan for dir in os.listdir(experiment_dir): if dir.startswith('scan'): datafile = os.path.join(experiment_dir, dir, 'data', 'data.tif') if os.path.isfile(datafile): exp_dirs_data.append( (datafile, os.path.join(experiment_dir, dir))) # if there are no scan directories, assume it is combined scans experiment if len(exp_dirs_data) == 0: # in typical scenario data_dir is not configured, and it is defaulted to <experiment_dir>/data # the data_dir is ignored in multi-scan scenario try: data_dir = config_map.data_dir except AttributeError: data_dir = os.path.join(experiment_dir, 'data') datafile = os.path.join(data_dir, 'data.tif') if os.path.isfile(datafile): exp_dirs_data.append((datafile, experiment_dir)) no_runs = len(exp_dirs_data) if no_runs == 0: print('did not find data.tif nor data.npy file(s). ') return try: generations = config_map.generations except: generations = 0 try: reconstructions = config_map.reconstructions except: reconstructions = 1 device_use = [] if lib == 'cpu' or lib == 'np': cpu_use = [-1] * reconstructions if no_runs > 1: for _ in range(no_runs): device_use.append(cpu_use) else: device_use = cpu_use else: try: devices = config_map.device except: devices = [-1] if no_runs * reconstructions > 1: data_shape = ut.read_tif(exp_dirs_data[0][0]).shape device_use = get_gpu_use(devices, no_runs, reconstructions, data_shape) else: device_use = devices if no_runs == 1: if len(device_use) == 0: device_use = [-1] dir_data = exp_dirs_data[0] datafile = dir_data[0] dir = dir_data[1] if generations > 1: gen_rec.reconstruction(lib, conf_file, datafile, dir, device_use) elif reconstructions > 1: mult_rec.reconstruction(lib, conf_file, datafile, dir, device_use) else: rec.reconstruction(lib, conf_file, datafile, dir, device_use) else: if len(device_use) == 0: device_use = [[-1]] else: # check if is it worth to use last chunk if lib != 'cpu' and lib != 'np' and len( device_use[0]) > len(device_use[-1]) * 2: device_use = device_use[0:-1] if generations > 1: r = 'g' elif reconstructions > 1: r = 'm' else: r = 's' q = Queue() for gpus in device_use: q.put((None, gpus)) # index keeps track of the multiple directories index = 0 processes = {} while index < no_runs: pid, gpus = q.get() if pid is not None: os.kill(pid, signal.SIGKILL) del processes[pid] datafile = exp_dirs_data[index][0] dir = exp_dirs_data[index][1] p = Process(target=rec_process, args=(lib, conf_file, datafile, dir, gpus, r, q)) p.start() processes[p.pid] = index index += 1 # close the queue while len(processes.items()) > 0: pid, gpus = q.get() os.kill(pid, signal.SIGKILL) time.sleep(.1) del processes[pid] q.close() print('finished reconstruction')
def load_tab(self, load_item): """ It verifies given configuration file, reads the parameters, and fills out the window. Parameters ---------- conf : str configuration file (config_disp) Returns ------- nothing """ if os.path.isfile(load_item): conf = load_item else: conf = os.path.join(load_item, 'conf', 'config_disp') if not os.path.isfile(conf): msg_window( 'info: the load directory does not contain config_disp file' ) return if not ver.ver_config_data(conf): msg_window('please check configuration file ' + conf + '. Cannot parse, ') return try: conf_map = ut.read_config(conf) except Exception as e: msg_window('please check configuration file ' + conf + '. Cannot parse, ' + str(e)) return self.parse_spec() try: self.results_dir = str(conf_map.results_dir).replace(" ", "") except AttributeError: if self.results_dir is None: self.results_dir = self.main_win.experiment_dir self.result_dir_button.setStyleSheet("Text-align:left") self.result_dir_button.setText(self.results_dir) # if parameters are configured, override the readings from spec file try: make_twin = conf_map.make_twin if make_twin: self.make_twin.setChecked(True) else: self.make_twin.setChecked(False) except: self.make_twin.setChecked(False) try: self.diffractometer.setText( str(conf_map.diffractometer).replace(" ", "")) except AttributeError: pass try: self.crop.setText(str(conf_map.crop).replace(" ", "")) except AttributeError: pass try: self.rampups.setText(str(conf_map.rampups).replace(" ", "")) except AttributeError: pass try: self.energy.setText(str(conf_map.energy).replace(" ", "")) self.energy.setStyleSheet('color: black') except AttributeError: pass try: self.delta.setText(str(conf_map.delta).replace(" ", "")) self.delta.setStyleSheet('color: black') except AttributeError: pass try: self.gamma.setText(str(conf_map.gamma).replace(" ", "")) self.gamma.setStyleSheet('color: black') except AttributeError: pass try: self.detdist.setText(str(conf_map.detdist).replace(" ", "")) self.detdist.setStyleSheet('color: black') except AttributeError: pass try: self.theta.setText(str(conf_map.theta).replace(" ", "")) self.theta.setStyleSheet('color: black') except AttributeError: pass try: self.chi.setText(str(conf_map.chi).replace(" ", "")) self.chi.setStyleSheet('color: black') except AttributeError: pass try: self.phi.setText(str(conf_map.phi).replace(" ", "")) self.phi.setStyleSheet('color: black') except AttributeError: pass try: self.scanmot.setText(str(conf_map.scanmot).replace(" ", "")) self.scanmot.setStyleSheet('color: black') except AttributeError: pass try: self.scanmot_del.setText( str(conf_map.scanmot_del).replace(" ", "")) self.scanmot_del.setStyleSheet('color: black') except AttributeError: pass try: self.detector.setText(str(conf_map.detector).replace(" ", "")) self.detector.setStyleSheet('color: black') except AttributeError: pass
def load_tab(self, load_item): """ It verifies given configuration file, reads the parameters, and fills out the window. Parameters ---------- conf : str configuration file (config_prep) Returns ------- nothing """ if os.path.isfile(load_item): # the configuration file was given conf = load_item else: conf = os.path.join(load_item, 'conf', 'config_prep') if not os.path.isfile(conf): msg_window( 'info: the load directory does not contain config_prep file' ) return if not ver.ver_config_prep(conf): msg_window('please check configuration file ' + conf + '. Cannot parse, ') return try: conf_map = ut.read_config(conf) except Exception as e: msg_window('please check configuration file ' + conf + '. Cannot parse, ' + str(e)) return self.parse_spec() try: separate_scans = conf_map.separate_scans if separate_scans: self.separate_scans.setChecked(True) else: self.separate_scans.setChecked(False) except: self.separate_scans.setChecked(False) # the separate_scan parameter affects other tab (results_dir in dispaly tab) # this tab has to notify observer about the initial setup self.notify() try: if os.path.isdir(conf_map.data_dir): self.data_dir_button.setStyleSheet("Text-align:left") self.data_dir_button.setText(conf_map.data_dir) else: msg_window('The data_dir directory in config_prep file ' + conf_map.data_dir + ' does not exist') except: self.data_dir_button.setText('') try: if os.path.isfile(conf_map.darkfield_filename): self.dark_file_button.setStyleSheet("Text-align:left") self.dark_file_button.setText(conf_map.darkfield_filename) else: msg_window('The darkfield file ' + conf_map.darkfield_filename + ' in config_prep file does not exist') self.dark_file_button.setText('') except: self.dark_file_button.setText('') try: if os.path.isfile(conf_map.whitefield_filename): self.white_file_button.setStyleSheet("Text-align:left") self.white_file_button.setText(conf_map.whitefield_filename) else: self.white_file_button.setText('') msg_window('The whitefield file ' + conf_map.whitefield_filename + ' in config_prep file does not exist') except: self.white_file_button.setText('') try: self.Imult.setText(str(conf_map.Imult).replace(" ", "")) except: pass try: self.detector.setText(str(conf_map.detector).replace(" ", "")) except: pass try: self.min_files.setText(str(conf_map.min_files).replace(" ", "")) except: pass try: self.exclude_scans.setText( str(conf_map.exclude_scans).replace(" ", "")) except: pass try: self.roi.setText(str(conf_map.roi).replace(" ", "")) except: pass