Mercurial > repos > rv43 > tomo
comparison tomo_setup.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 | b8977c98800b |
children | ef5c2f7b49ec |
comparison
equal
deleted
inserted
replaced
14:50c8d19d5f89 | 15:1bcca1f2adb4 |
---|---|
6 import sys | 6 import sys |
7 import re | 7 import re |
8 import yaml | 8 import yaml |
9 import argparse | 9 import argparse |
10 import numpy as np | 10 import numpy as np |
11 import tracemalloc | |
11 | 12 |
12 from tomo import Tomo | 13 from tomo import Tomo |
13 import msnc_tools as msnc | 14 import msnc_tools as msnc |
14 | 15 |
16 #from memory_profiler import profile | |
17 #@profile | |
15 def __main__(): | 18 def __main__(): |
16 | 19 |
17 # Parse command line arguments | 20 # Parse command line arguments |
18 parser = argparse.ArgumentParser( | 21 parser = argparse.ArgumentParser( |
19 description='Setup tomography reconstruction') | 22 description='Setup tomography reconstruction') |
40 type=argparse.FileType('w'), | 43 type=argparse.FileType('w'), |
41 default=sys.stdout, | 44 default=sys.stdout, |
42 help='Log file') | 45 help='Log file') |
43 parser.add_argument('tomo_ranges', metavar='N', type=int, nargs='+') | 46 parser.add_argument('tomo_ranges', metavar='N', type=int, nargs='+') |
44 args = parser.parse_args() | 47 args = parser.parse_args() |
48 | |
49 # Starting memory monitoring | |
50 tracemalloc.start() | |
45 | 51 |
46 # Set basic log configuration | 52 # Set basic log configuration |
47 logging_format = '%(asctime)s : %(levelname)s - %(module)s : %(funcName)s - %(message)s' | 53 logging_format = '%(asctime)s : %(levelname)s - %(module)s : %(funcName)s - %(message)s' |
48 log_level = 'INFO' | 54 log_level = 'INFO' |
49 level = getattr(logging, log_level.upper(), None) | 55 level = getattr(logging, log_level.upper(), None) |
153 exit(f'Unable to obtain tomography images for set {stack["index"]}') | 159 exit(f'Unable to obtain tomography images for set {stack["index"]}') |
154 tomo_stack_files.append(tomo_files[0]) | 160 tomo_stack_files.append(tomo_files[0]) |
155 num_collections += 1 | 161 num_collections += 1 |
156 | 162 |
157 # Preprocess the image files | 163 # Preprocess the image files |
158 tomo.genTomoStacks(tdf_files[0], tbf_files[0], tomo_stack_files, args.dark, args.bright, | 164 galaxy_param = {'tdf_files' : tdf_files[0], 'tbf_files' : tbf_files[0], |
159 args.tomo, args.detectorbounds, args.output_data) | 165 'tomo_stack_files' : tomo_stack_files, 'dark_field_pngname' : args.dark, |
166 'bright_field_pngname' : args.bright, 'tomo_field_pngname' : args.tomo, | |
167 'detectorbounds_pngname' : args.detectorbounds, 'output_name' : args.output_data} | |
168 tomo.genTomoStacks(galaxy_param) | |
160 if not tomo.is_valid: | 169 if not tomo.is_valid: |
161 IOError('Unable to load all required image files.') | 170 IOError('Unable to load all required image files.') |
171 | |
172 # Displaying memory usage | |
173 logging.info(f'Memory usage: {tracemalloc.get_traced_memory()}') | |
174 | |
175 # stopping memory monitoring | |
176 tracemalloc.stop() | |
162 | 177 |
163 if __name__ == "__main__": | 178 if __name__ == "__main__": |
164 __main__() | 179 __main__() |
165 | 180 |