Mercurial > repos > rv43 > tomo
comparison tomo_reconstruct.py @ 15:1bcca1f2adb4 draft
"planemo upload for repository https://github.com/rolfverberg/galaxytools commit 38c19bf5addbc46f45d598f981bb1a48f7bca691"
author | rv43 |
---|---|
date | Wed, 13 Apr 2022 16:02:44 +0000 |
parents | f9c52762c32c |
children | 7f723407beb3 |
comparison
equal
deleted
inserted
replaced
14:50c8d19d5f89 | 15:1bcca1f2adb4 |
---|---|
2 | 2 |
3 import logging | 3 import logging |
4 | 4 |
5 import sys | 5 import sys |
6 import argparse | 6 import argparse |
7 import tracemalloc | |
7 | 8 |
8 from tomo import Tomo | 9 from tomo import Tomo |
9 | 10 |
10 def __main__(): | 11 def __main__(): |
11 | 12 |
14 description='Perfrom a tomography reconstruction') | 15 description='Perfrom a tomography reconstruction') |
15 parser.add_argument('-i', '--input_stacks', | 16 parser.add_argument('-i', '--input_stacks', |
16 help='Preprocessed image file stacks') | 17 help='Preprocessed image file stacks') |
17 parser.add_argument('-c', '--config', | 18 parser.add_argument('-c', '--config', |
18 help='Input config') | 19 help='Input config') |
20 parser.add_argument('--center_offsets', | |
21 required=True, nargs=2, type=float, help='Reconstruction center axis offsets') | |
19 parser.add_argument('--output_config', | 22 parser.add_argument('--output_config', |
20 help='Output config') | 23 help='Output config') |
21 parser.add_argument('--output_data', | 24 parser.add_argument('--output_data', |
22 help='Reconstructed tomography data') | 25 help='Reconstructed tomography data') |
23 parser.add_argument('-l', '--log', | 26 parser.add_argument('-l', '--log', |
24 type=argparse.FileType('w'), | 27 type=argparse.FileType('w'), |
25 default=sys.stdout, | 28 default=sys.stdout, |
26 help='Log file') | 29 help='Log file') |
27 args = parser.parse_args() | 30 args = parser.parse_args() |
31 | |
32 # Starting memory monitoring | |
33 tracemalloc.start() | |
28 | 34 |
29 # Set basic log configuration | 35 # Set basic log configuration |
30 logging_format = '%(asctime)s : %(levelname)s - %(module)s : %(funcName)s - %(message)s' | 36 logging_format = '%(asctime)s : %(levelname)s - %(module)s : %(funcName)s - %(message)s' |
31 log_level = 'INFO' | 37 log_level = 'INFO' |
32 level = getattr(logging, log_level.upper(), None) | 38 level = getattr(logging, log_level.upper(), None) |
35 logging.basicConfig(format=logging_format, level=level, force=True, | 41 logging.basicConfig(format=logging_format, level=level, force=True, |
36 handlers=[logging.StreamHandler()]) | 42 handlers=[logging.StreamHandler()]) |
37 | 43 |
38 logging.debug(f'input_stacks = {args.input_stacks}') | 44 logging.debug(f'input_stacks = {args.input_stacks}') |
39 logging.debug(f'config = {args.config}') | 45 logging.debug(f'config = {args.config}') |
46 logging.debug(f'center_offsets = {args.center_offsets} {type(args.center_offsets)}') | |
40 logging.debug(f'output_config = {args.output_config}') | 47 logging.debug(f'output_config = {args.output_config}') |
41 logging.debug(f'output_data = {args.output_data}') | 48 logging.debug(f'output_data = {args.output_data}') |
42 logging.debug(f'log = {args.log}') | 49 logging.debug(f'log = {args.log}') |
43 logging.debug(f'is log stdout? {args.log is sys.stdout}') | 50 logging.debug(f'is log stdout? {args.log is sys.stdout}') |
44 | 51 |
51 | 58 |
52 # Load preprocessed image files | 59 # Load preprocessed image files |
53 tomo.loadTomoStacks(args.input_stacks) | 60 tomo.loadTomoStacks(args.input_stacks) |
54 | 61 |
55 # Reconstruct tomography stacks | 62 # Reconstruct tomography stacks |
56 tomo.reconstructTomoStacks(args.output_data) | 63 galaxy_param = {'center_offsets' : args.center_offsets, 'output_name' : args.output_data} |
64 tomo.reconstructTomoStacks(galaxy_param) | |
65 | |
66 # Displaying memory usage | |
67 logging.info(f'Memory usage: {tracemalloc.get_traced_memory()}') | |
68 | |
69 # stopping memory monitoring | |
70 tracemalloc.stop() | |
57 | 71 |
58 if __name__ == "__main__": | 72 if __name__ == "__main__": |
59 __main__() | 73 __main__() |
60 | 74 |