diff --git a/README.md b/README.md index 9d6b375..372d1bf 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ options: Input parameters: * `'do_whitefield_correction': 1/0` - Specifies whether to do in-place white field correction. * `'wf_data_file': str` - Path to the hdf5 file with corrected white field image. - * `'wf_dataset': str` - Name of the dataset containing white field image in the hdf5 file. + * `'wf_dataset': str` [Optional] - Name of the dataset containing white field image in the hdf5 file, default is `"data/data"`. * `'wf_method': 'div'|'sub'` - Method of white field correction - either division or subtraction is supported. Algorithm Output: diff --git a/dap/algos/whitefield_correction.py b/dap/algos/whitefield_correction.py index b66eddd..ad8e07c 100644 --- a/dap/algos/whitefield_correction.py +++ b/dap/algos/whitefield_correction.py @@ -53,11 +53,12 @@ def calc_apply_whitefield_correction(results, data): f"{params_required=}") return + wf_dataset = results.get("wf_dataset", "data/data") # TODO: cache white field data, only reload if file changed # maybe store checksum in results as "_checksum" try: with h5py.File(wf_data_file, "r") as wfile: - whitefield_image = np.asarray(wfile["data/data"]) + whitefield_image = np.asarray(wfile[wf_dataset]) except Exception as error: print(f"ERROR: Can't read whitefield from file {wf_data_file}. Skipping\n" f"{error=}")