|
@@ -441,56 +441,68 @@ class Application(object):
|
|
|
|
|
|
def on_flat_correct(self):
|
|
|
self.log.highlight("Flat field correction ...")
|
|
|
- info = self.read_info()
|
|
|
- path = self.current.path
|
|
|
- data = dict(path=path, prefix=self.current.prefix, num=info['TOMO_N'], step=1)
|
|
|
-
|
|
|
- cmd = ('tofu flatcorrect --verbose'
|
|
|
- ' --reduction-mode median'
|
|
|
- ' --projections "{path}/{prefix}*.edf"'
|
|
|
- ' --darks {path}/darkend0000.edf'
|
|
|
- ' --flats {path}/ref*_0000.edf'
|
|
|
- ' --flats2 {path}/ref*_{num}.edf'
|
|
|
- ' --number {num}'
|
|
|
- ' --step {step}'
|
|
|
- ' --absorptivity'
|
|
|
- ' --fix-nan-and-inf'.format(**data))
|
|
|
|
|
|
- large_cmd = cmd + ' --output {path}/fc/fc-%04i.tif'.format(path=path)
|
|
|
- small_cmd = cmd + ' --resize 2 --output {path}/fc-small/fc-%04i.tif'.format(path=path)
|
|
|
-
|
|
|
- if not self.run_command(small_cmd):
|
|
|
- self.log.error("Could not create small flat field corrected projections")
|
|
|
- return result
|
|
|
+ try:
|
|
|
+ info = self.read_info()
|
|
|
+ path = self.current.path
|
|
|
+ data = dict(path=path, prefix=self.current.prefix, num=info['TOMO_N'], step=1)
|
|
|
+
|
|
|
+ cmd = ('tofu flatcorrect --verbose'
|
|
|
+ ' --reduction-mode median'
|
|
|
+ ' --projections "{path}/{prefix}*.edf"'
|
|
|
+ ' --darks {path}/darkend0000.edf'
|
|
|
+ ' --flats {path}/ref*_0000.edf'
|
|
|
+ ' --flats2 {path}/ref*_{num}.edf'
|
|
|
+ ' --number {num}'
|
|
|
+ ' --step {step}'
|
|
|
+ ' --absorptivity'
|
|
|
+ ' --fix-nan-and-inf'.format(**data))
|
|
|
+
|
|
|
+ large_cmd = cmd + ' --output {path}/fc/fc-%04i.tif'.format(path=path)
|
|
|
+ small_cmd = cmd + ' --resize 2 --output {path}/fc-small/fc-%04i.tif'.format(path=path)
|
|
|
+
|
|
|
+ if not self.run_command(small_cmd):
|
|
|
+ self.log.error("Could not create small flat field corrected projections")
|
|
|
+ return result
|
|
|
+
|
|
|
+ return self.run_command(large_cmd)
|
|
|
+ except Exception as e:
|
|
|
+ self.log.error("Error: {}".format(e))
|
|
|
|
|
|
- return self.run_command(large_cmd)
|
|
|
+ return False
|
|
|
|
|
|
def on_quick_optimize(self):
|
|
|
self.log.highlight("Quick optimization ...")
|
|
|
|
|
|
- if self.optimize(True):
|
|
|
- with open(self.params_name) as f:
|
|
|
- opt = json.load(f)
|
|
|
- opt['x-center']['value'] *= 2.0
|
|
|
+ try:
|
|
|
+ if self.optimize(True):
|
|
|
+ with open(self.params_name) as f:
|
|
|
+ opt = json.load(f)
|
|
|
+ opt['x-center']['value'] *= 2.0
|
|
|
|
|
|
- with open(self.params_name, 'w') as f:
|
|
|
- json.dump(opt, f)
|
|
|
+ with open(self.params_name, 'w') as f:
|
|
|
+ json.dump(opt, f)
|
|
|
|
|
|
- params = self.read_optimal_params()
|
|
|
- self.log.highlight(" Optimal axis: {}".format(params.angle))
|
|
|
- self.log.highlight(" Optimal center: {}".format(params.axis))
|
|
|
- return True
|
|
|
+ params = self.read_optimal_params()
|
|
|
+ self.log.highlight(" Optimal axis: {}".format(params.angle))
|
|
|
+ self.log.highlight(" Optimal center: {}".format(params.axis))
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ self.log.error("Error: {}".format(e))
|
|
|
|
|
|
return False
|
|
|
|
|
|
def on_optimize(self):
|
|
|
self.log.highlight("Optimizing ...")
|
|
|
|
|
|
- if self.optimize(False):
|
|
|
- params = self.read_optimal_params()
|
|
|
- self.log.highlight(" Optimal axis: {}".format(params.angle))
|
|
|
- self.log.highlight(" Optimal center: {}".format(params.axis))
|
|
|
- return True
|
|
|
+ try:
|
|
|
+ if self.optimize(False):
|
|
|
+ params = self.read_optimal_params()
|
|
|
+ self.log.highlight(" Optimal axis: {}".format(params.angle))
|
|
|
+ self.log.highlight(" Optimal center: {}".format(params.axis))
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ self.log.error("Could not optimize: {}".format(e))
|
|
|
|
|
|
return False
|
|
|
|