Commit 9fe40a1b authored by payno's avatar payno
Browse files

try to speed up reconstruction

parent 41c0b550
Pipeline #41484 failed with stage
in 4 minutes and 28 seconds
from os import path, mkdir
from time import time
import functools
import numpy as np
from ..resources.logger import LoggerOrPrint
from .utils import use_options, pipeline_step, WriterConfigurator
......@@ -70,6 +71,7 @@ class FullFieldPipeline:
self._set_params(process_config, sub_region, extra_options, phase_margin)
self.set_subregion(sub_region)
self._init_pipeline()
self._preprocess = True
def _set_params(self, process_config, sub_region, extra_options, phase_margin):
......@@ -638,7 +640,9 @@ class FullFieldPipeline:
@pipeline_step("mlog", "Taking logarithm")
def _take_log(self):
t0 = time()
self.mlog.take_logarithm(self.radios)
print("take log: {}".format(time() - t0))
@pipeline_step("radios_movements", "Applying radios movements")
def _radios_movements(self, radios=None):
......@@ -650,15 +654,22 @@ class FullFieldPipeline:
@pipeline_step("sino_normalization", "Normalizing sinograms")
def _normalize_sinos(self, radios=None):
t0 = time()
if radios is None:
radios = self.radios
sinos = radios.transpose((1, 0, 2))
self.sino_normalization.normalize(sinos)
print("normalization sino time: {}".format(time - t0))
@pipeline_step("sino_builder", "Building sinograms")
def _build_sino(self, radios=None):
t0 = time()
if radios is None:
radios = self.radios
self.__build_sinos(radios=radios)
print("build sino time: {}".format(time - t0))
def __build_sinos(self, radios):
# Either a new array (previously allocated in "_sinobuilder_output"),
# or a view of "radios"
self.sinos = self.sino_builder.radios_to_sinos(
......@@ -667,7 +678,6 @@ class FullFieldPipeline:
copy=self._sinobuilder_copy
)
@pipeline_step("sino_deringer", "Removing rings on sinograms")
def _destripe_sinos(self, sinos=None):
if sinos is None:
sinos = self.sinos
......@@ -711,24 +721,38 @@ class FullFieldPipeline:
}
)
def _process_chunk(self):
self._flatfield()
self._double_flatfield()
self._ccd_corrections()
self._retrieve_phase()
self._apply_unsharp()
self._take_log()
self._radios_movements()
self._normalize_sinos()
self._build_sino()
self._destripe_sinos()
if self._preprocess:
self._flatfield()
self._double_flatfield()
self._ccd_corrections()
self._retrieve_phase()
self._apply_unsharp()
self._take_log()
self._radios_movements()
self._normalize_sinos()
self._build_sino()
self._destripe_sinos()
self._preprocess = False
# update cor position
options = self.processing_options["reconstruction"]
if options["enable_halftomo"]:
rot_center = options["rotation_axis_position_halftomo"]
else:
rot_center = options["rotation_axis_position"]
if options.get("cor_estimated_auto", False):
self.logger.info("Estimated center of rotation: %.2f" % rot_center)
if self.sino_builder._halftomo_flip:
rot_center = self.sino_builder.rot_center
self.reconstruction.fbp.rot_center = rot_center
self.reconstruction.fbp.axis_pos = rot_center
self._reconstruct()
self._compute_histogram()
self._write_data()
self._process_finalize()
def process_chunk(self, sub_region=None):
if sub_region is not None:
self._reset_sub_region(sub_region)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment