|
@@ -56,6 +56,10 @@ def have_flats(path):
|
|
|
glob.glob(os.path.join(small, '*.tif')))
|
|
|
|
|
|
|
|
|
+def have_params(path):
|
|
|
+ return os.path.exists(os.path.join(path, 'params.json'))
|
|
|
+
|
|
|
+
|
|
|
class Configuration(object):
|
|
|
|
|
|
def __init__(self, source, destination):
|
|
@@ -219,6 +223,7 @@ class StateMachine(object):
|
|
|
FLATCORRECT = 4
|
|
|
OPTIMIZE = 5
|
|
|
QUICK_OPTIMIZE = 6
|
|
|
+ RECONSTRUCT = 7
|
|
|
|
|
|
def __init__(self):
|
|
|
self.current = StateMachine.START
|
|
@@ -231,6 +236,7 @@ class StateMachine(object):
|
|
|
StateMachine.SYNC: collections.OrderedDict(),
|
|
|
StateMachine.OPTIMIZE: collections.OrderedDict(),
|
|
|
StateMachine.QUICK_OPTIMIZE: collections.OrderedDict(),
|
|
|
+ StateMachine.RECONSTRUCT: collections.OrderedDict(),
|
|
|
}
|
|
|
|
|
|
def add_action(self, from_state, action):
|
|
@@ -343,6 +349,38 @@ class Application(object):
|
|
|
|
|
|
return self.run_command(cmd)
|
|
|
|
|
|
+ def on_reconstruct(self):
|
|
|
+ self.log.highlight("Reconstructing ...")
|
|
|
+
|
|
|
+ with open(os.path.join(self.prefix, 'params.json')) as f:
|
|
|
+ info = self.read_info()
|
|
|
+ opt = json.load(f)
|
|
|
+
|
|
|
+ lamino_angle = opt['lamino-angle']['value']
|
|
|
+ axis = opt['x-center']['value']
|
|
|
+
|
|
|
+ x_region = 960
|
|
|
+ y_region = 960
|
|
|
+
|
|
|
+ cmd = ('tofu lamino --verbose'
|
|
|
+ ' --projections {prefix}/fc'
|
|
|
+ ' --x-region="-{x_region},{x_region},1"'
|
|
|
+ ' --y-region="-{y_region},{y_region},1"'
|
|
|
+ ' --lamino-angle {lamino_angle}'
|
|
|
+ ' --axis {x_axis},{y_axis}'
|
|
|
+ ' --overall-angle -360'
|
|
|
+ ' --pixel-size {pixel_size}e-6'
|
|
|
+ ' --roll-angle 0'
|
|
|
+ ' --slices-per-device 600'
|
|
|
+ ' --output {prefix}/Slices'
|
|
|
+ .format(pixel_size=info['PixelSize'],
|
|
|
+ x_region=x_region, y_region=y_region,
|
|
|
+ lamino_angle=lamino_angle,
|
|
|
+ x_axis=axis, y_axis=float(info['Dim_2']) / 2,
|
|
|
+ prefix=self.prefix))
|
|
|
+
|
|
|
+ return self.run_command(cmd)
|
|
|
+
|
|
|
def on_quit(self):
|
|
|
self.running = False
|
|
|
return True
|
|
@@ -435,6 +473,7 @@ class Application(object):
|
|
|
clean = Action('c', 'Clean', self.on_clean, machine.CLEAN)
|
|
|
quick_optimize = Action('q', 'Quick', self.on_quick_optimize, machine.QUICK_OPTIMIZE)
|
|
|
optimize = Action('o', 'Optimize', self.on_optimize, machine.OPTIMIZE)
|
|
|
+ reconstruct = Action('r', 'Reconstruct', self.on_reconstruct, machine.RECONSTRUCT)
|
|
|
|
|
|
machine.add_action(machine.START, sync)
|
|
|
machine.add_action(machine.START, quick_optimize)
|
|
@@ -443,16 +482,20 @@ class Application(object):
|
|
|
|
|
|
machine.add_action(machine.SYNC, quit)
|
|
|
|
|
|
- machine.add_action(machine.QUICK_OPTIMIZE, sync)
|
|
|
+ machine.add_action(machine.QUICK_OPTIMIZE, reconstruct)
|
|
|
machine.add_action(machine.QUICK_OPTIMIZE, optimize)
|
|
|
machine.add_action(machine.QUICK_OPTIMIZE, quit)
|
|
|
|
|
|
- machine.add_action(machine.OPTIMIZE, sync)
|
|
|
+ machine.add_action(machine.OPTIMIZE, reconstruct)
|
|
|
+ machine.add_action(machine.OPTIMIZE, quick_optimize)
|
|
|
machine.add_action(machine.OPTIMIZE, quit)
|
|
|
|
|
|
machine.add_action(machine.CLEAN, sync)
|
|
|
machine.add_action(machine.CLEAN, quit)
|
|
|
|
|
|
+ if have_params(self.config.destination):
|
|
|
+ machine.add_action(machine.START, reconstruct)
|
|
|
+
|
|
|
if not have_flats(self.config.destination):
|
|
|
flatcorrect = Action('f', 'Flat correct', self.on_flat_correct, machine.FLATCORRECT)
|
|
|
machine.add_action(machine.START, flatcorrect)
|