Commit e2628155 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

app.reconstruct: Check z-region for reconstruction

parent 382efabc
......@@ -31,6 +31,51 @@ def get_subregion(slices_indices, radio_nz):
return (z_start, z_stop)
def check_margin(subregion, n_z, logger, min_delta_z=10):
delta_z = subregion[-1] - subregion[-2]
if delta_z >= min_delta_z:
return subregion
if n_z < min_delta_z:
logger.error("Need at least %d detector rows to perform phase/unsharp properly. Results will probably be inaccurate." % min_delta_z)
return (0, n_z)
logger.warning("Processing at least 10 detector rows for phase/unsharp")
hz1 = min_delta_z // 2
hz2 = min_delta_z - hz1
zmin, zmax = subregion
zmin = max(zmin - hz1, 0)
zmax = min(zmax + hz2, n_z)
if zmax - zmin < min_delta_z:
zmin = max(zmin - hz1, 0)
zmax = min(zmax + hz2, n_z)
return (zmin, zmax)
def get_reconstruction_region(arg_slice, process_config, logger):
n_z = process_config.dataset_infos._radio_dims_notbinned[-1]
rec_opts = process_config.nabu_config["reconstruction"]
if arg_slice == "":
# This will be handled in future versions by inspecting available memory
logger.warning("The argument --slice was not provided. This might result in insufficient memory errors.")
subregion = (rec_opts["start_z"], rec_opts["end_z"])
#
else:
subregion = get_subregion(
args["slice"],
process_config.dataset_infos.radio_dims[-1]
)
delta_z = subregion[-1] - subregion[-2]
# This will be handled in future versions by inspecting available memory
if delta_z == n_z:
logger.warning("It seems that all the volume will be reconstructed. This will probably result in insufficient memory errors. To avoid this, please provide --slice argument or start_z and end_z in parameters file")
steps = process_config.processing_steps
if "phase" in steps or "unsharp_mask" in steps:
subregion = check_margin(subregion, n_z, logger)
#
return subregion
def main():
args = parse_params_values(
ReconstructConfig,
......@@ -45,29 +90,20 @@ def main():
logfile=args["log_file"]
)
# For now we need the --slice argument
if args["slice"].strip() == "":
msg = "Need to provide the --slice argument (ex. --slice 1024 or --slice 0-1024)"
logger.fatal(msg)
exit(1)
#
subregion = get_subregion(
args["slice"],
proc.dataset_infos.radio_dims[-1]
)
subregion = get_reconstruction_region(args["slice"].strip(), proc, logger)
logger.info("Going to reconstruct slices %s" % str(subregion))
subregion = (None, None) + subregion
# (hopefully) temporary patch
if args["energy"] > 0:
logger.warning("Using user-provided energy %.2f keV" % args["energy"])
proc.dataset_infos.dataset_scanner._energy = args["energy"]
proc.processing_options["phase"]["energy_kev"] = args["energy"]
if proc.dataset_infos.energy < 1e-3 and proc.nabu_config["phase"]["method"] != None:
msg = "No information on energy. Cannot retrieve phase. Please use the --energy option"
logger.fatal(msg)
raise ValueError(msg)
if "phase" in proc.processing_steps:
if args["energy"] > 0:
logger.warning("Using user-provided energy %.2f keV" % args["energy"])
proc.dataset_infos.dataset_scanner._energy = args["energy"]
proc.processing_options["phase"]["energy_kev"] = args["energy"]
if proc.dataset_infos.energy < 1e-3 and proc.nabu_config["phase"]["method"] != None:
msg = "No information on energy. Cannot retrieve phase. Please use the --energy option"
logger.fatal(msg)
raise ValueError(msg)
#
if __has_pycuda__:
......
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