Mercurial > repos > rv43 > tomo
comparison tomo_setup.py @ 68:ba5866d0251d draft
"planemo upload for repository https://github.com/rolfverberg/galaxytools commit 3fde3e85030608a8a4d8e59308353b0144314dfe"
author | rv43 |
---|---|
date | Fri, 19 Aug 2022 20:16:56 +0000 |
parents | 98a83f03d91b |
children |
comparison
equal
deleted
inserted
replaced
67:87a4acead65c | 68:ba5866d0251d |
---|---|
55 raise ValueError(f'Invalid log_level: {log_level}') | 55 raise ValueError(f'Invalid log_level: {log_level}') |
56 logging.basicConfig(format=logging_format, level=level, force=True, | 56 logging.basicConfig(format=logging_format, level=level, force=True, |
57 handlers=[logging.StreamHandler()]) | 57 handlers=[logging.StreamHandler()]) |
58 | 58 |
59 # Check command line arguments | 59 # Check command line arguments |
60 logging.info(f'config = {args.config}') | 60 logging.debug(f'config = {args.config}') |
61 if args.detector is None: | 61 if args.detector is None: |
62 logging.info(f'detector = {args.detector}') | 62 logging.debug(f'detector = {args.detector}') |
63 else: | 63 else: |
64 logging.info(f'detector = {args.detector.split()}') | 64 logging.debug(f'detector = {args.detector.split()}') |
65 logging.info(f'num_theta = {args.num_theta}') | 65 logging.debug(f'num_theta = {args.num_theta}') |
66 if args.theta_range is None: | 66 if args.theta_range is None: |
67 logging.info(f'theta_range = {args.theta_range}') | 67 logging.debug(f'theta_range = {args.theta_range}') |
68 else: | 68 else: |
69 logging.info(f'theta_range = {args.theta_range.split()}') | 69 logging.debug(f'theta_range = {args.theta_range.split()}') |
70 logging.info(f'output_config = {args.output_config}') | 70 logging.debug(f'output_config = {args.output_config}') |
71 logging.info(f'output_data = {args.output_data}') | 71 logging.debug(f'output_data = {args.output_data}') |
72 logging.info(f'log = {args.log}') | 72 logging.debug(f'log = {args.log}') |
73 logging.debug(f'is log stdout? {args.log is sys.stdout}') | 73 logging.debug(f'is log stdout? {args.log is sys.stdout}') |
74 if args.detector is not None and len(args.detector.split()) != 3: | 74 if args.detector is not None and len(args.detector.split()) != 3: |
75 raise ValueError(f'Invalid detector: {args.detector}') | 75 raise ValueError(f'Invalid detector: {args.detector}') |
76 if args.num_theta is None or int(args.num_theta) < 1: | 76 if args.num_theta is None or int(args.num_theta) < 1: |
77 raise ValueError(f'Invalid num_theta: {args.num_theta}') | 77 raise ValueError(f'Invalid num_theta: {args.num_theta}') |
95 ref_heights = [float(x.strip()) for x in inputconfig[6].split()] | 95 ref_heights = [float(x.strip()) for x in inputconfig[6].split()] |
96 assert(args.detector is not None) | 96 assert(args.detector is not None) |
97 assert(args.theta_range is not None) | 97 assert(args.theta_range is not None) |
98 else: | 98 else: |
99 ref_heights = None | 99 ref_heights = None |
100 logging.info(f'config_type = {config_type} {type(config_type)}') | 100 logging.debug(f'config_type = {config_type} {type(config_type)}') |
101 logging.info(f'input_type = {input_type} {type(input_type)}') | 101 logging.debug(f'input_type = {input_type} {type(input_type)}') |
102 logging.info(f'num_stack = {num_stack} {type(num_stack)}') | 102 logging.debug(f'num_stack = {num_stack} {type(num_stack)}') |
103 logging.info(f'stack_types = {stack_types} {type(stack_types)}') | 103 logging.debug(f'stack_types = {stack_types} {type(stack_types)}') |
104 logging.info(f'num_imgs = {num_imgs} {type(num_imgs)}') | 104 logging.debug(f'num_imgs = {num_imgs} {type(num_imgs)}') |
105 logging.info(f'img_offsets = {img_offsets} {type(img_offsets)}') | 105 logging.debug(f'img_offsets = {img_offsets} {type(img_offsets)}') |
106 logging.info(f'ref_heights = {ref_heights} {type(ref_heights)}') | 106 logging.debug(f'ref_heights = {ref_heights} {type(ref_heights)}') |
107 if config_type != 'config_file' and config_type != 'config_manual': | 107 if config_type != 'config_file' and config_type != 'config_manual': |
108 raise ValueError('Invalid input config provided.') | 108 raise ValueError('Invalid input config provided.') |
109 if input_type != 'collections' and input_type != 'files': | 109 if input_type != 'collections' and input_type != 'files': |
110 raise ValueError('Invalid input config provided.') | 110 raise ValueError('Invalid input config provided.') |
111 if len(stack_types) != num_stack: | 111 if len(stack_types) != num_stack: |
196 if len(tdf_files) != 1 or len(tdf_files[0]) < 1: | 196 if len(tdf_files) != 1 or len(tdf_files[0]) < 1: |
197 logging.warning('Unable to obtain dark field files') | 197 logging.warning('Unable to obtain dark field files') |
198 if config_type == 'config_file': | 198 if config_type == 'config_file': |
199 assert(dark_field is not None) | 199 assert(dark_field is not None) |
200 assert(dark_field['data_path'] is None) | 200 assert(dark_field['data_path'] is None) |
201 assert(dark_field['img_start'] == -1) | 201 if dark_field.get('img_start') is None or dark_field['img_start'] != -1: |
202 assert(not dark_field['num']) | 202 dark_field['img_start'] = -1 |
203 if dark_field.get('num') is None or dark_field['num'] != 0: | |
204 dark_field['num'] = 0 | |
203 else: | 205 else: |
204 tomo.config['dark_field'] = {'data_path' : None, 'img_start' : -1, 'num' : 0} | 206 tomo.config['dark_field'] = {'data_path' : None, 'img_start' : -1, 'num' : 0} |
205 tdf_files = [None] | 207 tdf_files = [None] |
206 num_collections = 0 | 208 num_collections = 0 |
207 else: | 209 else: |
208 if config_type == 'config_file': | 210 if config_type == 'config_file': |
209 assert(dark_field is not None) | 211 assert(dark_field is not None) |
210 assert(dark_field['data_path'] is not None) | 212 assert(dark_field['data_path'] is not None) |
211 assert(dark_field.get('img_start') is not None) | 213 if dark_field.get('img_start') is None: |
214 dark_field['img_start'] = 0 | |
212 else: | 215 else: |
213 tomo.config['dark_field'] = {'data_path' : tdf_files[0], 'img_start' : 0} | 216 tomo.config['dark_field'] = {'data_path' : tdf_files[0], 'img_start' : 0} |
214 dark_field = tomo.config['dark_field'] | 217 dark_field = tomo.config['dark_field'] |
215 tdf_index = [i for i,c in enumerate(collections) if c['name'] == 'tdf'] | 218 tdf_index = [i for i,c in enumerate(collections) if c['name'] == 'tdf'] |
216 tdf_index_check = [i for i,s in enumerate(stack_types) if s == 'tdf'] | 219 tdf_index_check = [i for i,s in enumerate(stack_types) if s == 'tdf'] |
227 if len(tbf_files) != 1 or len(tbf_files[0]) < 1: | 230 if len(tbf_files) != 1 or len(tbf_files[0]) < 1: |
228 exit('Unable to obtain bright field files') | 231 exit('Unable to obtain bright field files') |
229 if config_type == 'config_file': | 232 if config_type == 'config_file': |
230 assert(bright_field is not None) | 233 assert(bright_field is not None) |
231 assert(bright_field['data_path'] is not None) | 234 assert(bright_field['data_path'] is not None) |
232 assert(bright_field.get('img_start') is not None) | 235 if bright_field.get('img_start') is None: |
236 bright_field['img_start'] = 0 | |
233 else: | 237 else: |
234 tomo.config['bright_field'] = {'data_path' : tbf_files[0], 'img_start' : 0} | 238 tomo.config['bright_field'] = {'data_path' : tbf_files[0], 'img_start' : 0} |
235 bright_field = tomo.config['bright_field'] | 239 bright_field = tomo.config['bright_field'] |
236 tbf_index = [i for i,c in enumerate(collections) if c['name'] == 'tbf'] | 240 tbf_index = [i for i,c in enumerate(collections) if c['name'] == 'tbf'] |
237 tbf_index_check = [i for i,s in enumerate(stack_types) if s == 'tbf'] | 241 tbf_index_check = [i for i,s in enumerate(stack_types) if s == 'tbf'] |
249 if stack_info['num'] != len(collections) - num_collections: | 253 if stack_info['num'] != len(collections) - num_collections: |
250 raise ValueError('Inconsistent number of tomography data image sets') | 254 raise ValueError('Inconsistent number of tomography data image sets') |
251 assert(stack_info.get('stacks') is not None) | 255 assert(stack_info.get('stacks') is not None) |
252 for stack in stack_info['stacks']: | 256 for stack in stack_info['stacks']: |
253 assert(stack['data_path'] is not None) | 257 assert(stack['data_path'] is not None) |
254 assert(stack.get('img_start') is not None) | 258 if stack.get('img_start') is None: |
259 stack['img_start'] = 0 | |
255 assert(stack.get('index') is not None) | 260 assert(stack.get('index') is not None) |
256 assert(stack.get('ref_height') is not None) | 261 assert(stack.get('ref_height') is not None) |
257 else: | 262 else: |
258 tomo.config['stack_info'] = {'num' : len(collections) - num_collections, 'stacks' : []} | 263 tomo.config['stack_info'] = {'num' : len(collections) - num_collections, 'stacks' : []} |
259 stack_info = tomo.config['stack_info'] | 264 stack_info = tomo.config['stack_info'] |