Commit 6880ebdd authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Handle enable_halftomo=auto in processconfig

parent c84cb53a
......@@ -115,27 +115,28 @@ class ProcessConfig:
def _get_cor(self):
cor = self.nabu_config["reconstruction"]["rotation_axis_position"]
rec_config = self.nabu_config["reconstruction"]
cor = rec_config["rotation_axis_position"]
if isinstance(cor, str): # auto-CoR
cor_slice = self.nabu_config["reconstruction"]["cor_slice"]
cor_slice = rec_config["cor_slice"]
if cor_slice is not None or cor == "sino-coarse-to-fine":
subsampling = extract_parameters(
self.nabu_config["reconstruction"]["cor_options"]
rec_config["cor_options"]
).get("subsampling", 10)
self.corfinder = SinoCOREstimator(
self.dataset_infos,
cor_slice or 0,
subsampling=subsampling,
do_flatfield=self.nabu_config["preproc"]["flatfield_enabled"],
cor_options=self.nabu_config["reconstruction"]["cor_options"],
cor_options=rec_config["cor_options"],
logger=self.logger
)
else:
self.corfinder = COREstimator(
self.dataset_infos,
halftomo=self.nabu_config["reconstruction"]["enable_halftomo"],
halftomo=self.do_halftomo,
do_flatfield=self.nabu_config["preproc"]["flatfield_enabled"],
cor_options=self.nabu_config["reconstruction"]["cor_options"],
cor_options=rec_config["cor_options"],
logger=self.logger
)
cor = self.corfinder.find_cor(method=cor)
......@@ -162,6 +163,20 @@ class ProcessConfig:
self.dataset_infos.detector_tilt = tilt
@property
def do_halftomo(self):
"""
Return True if the current dataset is to be reconstructed using 'half-acquisition' setting.
"""
enable_halftomo = self.nabu_config["reconstruction"]["enable_halftomo"]
is_halftomo_dataset = self.dataset_infos.is_halftomo
if enable_halftomo == "auto":
if is_halftomo_dataset is None:
raise ValueError("enable_halftomo was set to 'auto', but information on field of view was not found. Please set either 0 or 1 for enable_halftomo")
return is_halftomo_dataset
return enable_halftomo
def validation_stage2(self):
validator = NabuValidator(self.nabu_config, self.dataset_infos)
if self.checks:
......@@ -339,8 +354,7 @@ class ProcessConfig:
tasks.append("build_sino")
options["build_sino"] = copy_dict_items(
nabu_config["reconstruction"],
["rotation_axis_position", "enable_halftomo", "start_x", "end_x",
"start_y", "end_y", "start_z", "end_z"]
["rotation_axis_position", "start_x", "end_x", "start_y", "end_y", "start_z", "end_z"]
)
options["build_sino"]["axis_correction"] = dataset_infos.axis_correction
tasks.append("reconstruction")
......@@ -348,8 +362,7 @@ class ProcessConfig:
options["reconstruction"] = copy_dict_items(
nabu_config["reconstruction"],
["method", "rotation_axis_position", "fbp_filter_type",
"padding_type", "enable_halftomo",
"start_x", "end_x", "start_y", "end_y", "start_z", "end_z"]
"padding_type", "start_x", "end_x", "start_y", "end_y", "start_z", "end_z"]
)
rec_options = options["reconstruction"]
rec_options["rotation_axis_position"] = dataset_infos.axis_position
......@@ -358,7 +371,7 @@ class ProcessConfig:
rec_options["angles"] = dataset_infos.reconstruction_angles
rec_options["radio_dims_y_x"] = dataset_infos.radio_dims[::-1]
rec_options["pixel_size_cm"] = dataset_infos.pixel_size * 1e-4 # pix size is in microns
if rec_options["enable_halftomo"]:
if self.do_halftomo:
rec_options["angles"] = rec_options["angles"][:rec_options["angles"].size//2]
cor_i = int(round(rec_options["rotation_axis_position"]))
# New keys
......
Supports Markdown
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