Mercurial > repos > rv43 > tomo
comparison tomo_reconstruct.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 | 3caba2116858 |
| children | fba792d5f83b |
comparison
equal
deleted
inserted
replaced
| 67:87a4acead65c | 68:ba5866d0251d |
|---|---|
| 16 parser.add_argument('-i', '--input_stacks', | 16 parser.add_argument('-i', '--input_stacks', |
| 17 help='Preprocessed image file stacks') | 17 help='Preprocessed image file stacks') |
| 18 parser.add_argument('-c', '--config', | 18 parser.add_argument('-c', '--config', |
| 19 help='Input config') | 19 help='Input config') |
| 20 parser.add_argument('--center_offsets', | 20 parser.add_argument('--center_offsets', |
| 21 required=True, nargs=2, type=float, help='Reconstruction center axis offsets') | 21 nargs=2, type=float, help='Reconstruction center axis offsets') |
| 22 parser.add_argument('--output_config', | 22 parser.add_argument('--output_config', |
| 23 help='Output config') | 23 help='Output config') |
| 24 parser.add_argument('--output_data', | 24 parser.add_argument('--output_data', |
| 25 help='Reconstructed tomography data') | 25 help='Reconstructed tomography data') |
| 26 parser.add_argument('-l', '--log', | 26 parser.add_argument('-l', '--log', |
| 39 if not isinstance(level, int): | 39 if not isinstance(level, int): |
| 40 raise ValueError(f'Invalid log_level: {log_level}') | 40 raise ValueError(f'Invalid log_level: {log_level}') |
| 41 logging.basicConfig(format=logging_format, level=level, force=True, | 41 logging.basicConfig(format=logging_format, level=level, force=True, |
| 42 handlers=[logging.StreamHandler()]) | 42 handlers=[logging.StreamHandler()]) |
| 43 | 43 |
| 44 logging.debug(f'config = {args.config}') | |
| 44 logging.debug(f'input_stacks = {args.input_stacks}') | 45 logging.debug(f'input_stacks = {args.input_stacks}') |
| 45 logging.debug(f'config = {args.config}') | |
| 46 logging.debug(f'center_offsets = {args.center_offsets} {type(args.center_offsets)}') | 46 logging.debug(f'center_offsets = {args.center_offsets} {type(args.center_offsets)}') |
| 47 logging.debug(f'output_config = {args.output_config}') | 47 logging.debug(f'output_config = {args.output_config}') |
| 48 logging.debug(f'output_data = {args.output_data}') | 48 logging.debug(f'output_data = {args.output_data}') |
| 49 logging.debug(f'log = {args.log}') | 49 logging.debug(f'log = {args.log}') |
| 50 logging.debug(f'is log stdout? {args.log is sys.stdout}') | 50 logging.debug(f'is log stdout? {args.log is sys.stdout}') |
| 54 log_stream=args.log, galaxy_flag=True) | 54 log_stream=args.log, galaxy_flag=True) |
| 55 if not tomo.is_valid: | 55 if not tomo.is_valid: |
| 56 raise ValueError('Invalid config file provided.') | 56 raise ValueError('Invalid config file provided.') |
| 57 logging.debug(f'config:\n{tomo.config}') | 57 logging.debug(f'config:\n{tomo.config}') |
| 58 | 58 |
| 59 # Set reconstruction center axis offsets | |
| 60 if args.center_offsets is None: | |
| 61 find_center = tomo.config.get('find_center') | |
| 62 if find_center is None: | |
| 63 raise ValueError('Invalid config file provided (missing find_center).') | |
| 64 center_offsets = [float(find_center.get('lower_center_offset')), | |
| 65 float(find_center.get('upper_center_offset'))] | |
| 66 else: | |
| 67 center_offsets = args.center_offsets | |
| 68 | |
| 59 # Load preprocessed image files | 69 # Load preprocessed image files |
| 60 tomo.loadTomoStacks(args.input_stacks) | 70 tomo.loadTomoStacks(args.input_stacks) |
| 61 | 71 |
| 62 # Reconstruct tomography stacks | 72 # Reconstruct tomography stacks |
| 63 galaxy_param = {'center_offsets' : args.center_offsets, 'output_name' : args.output_data} | 73 galaxy_param = {'center_offsets' : center_offsets, 'output_name' : args.output_data} |
| 64 logging.info(f'galaxy_param = {galaxy_param}') | 74 logging.debug(f'galaxy_param = {galaxy_param}') |
| 65 tomo.reconstructTomoStacks(galaxy_param) | 75 tomo.reconstructTomoStacks(galaxy_param) |
| 66 | 76 |
| 67 # Displaying memory usage | 77 # Displaying memory usage |
| 68 logging.info(f'Memory usage: {tracemalloc.get_traced_memory()}') | 78 logging.info(f'Memory usage: {tracemalloc.get_traced_memory()}') |
| 69 | 79 |
