Skip to content

Commit

Permalink
chaning excute_wrapper back to oringal
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmeigh committed Jun 12, 2024
1 parent 1711ef8 commit 63a69ba
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions mantidimaging/core/operations/flat_fielding/flat_fielding.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,36 +92,29 @@ def filter_func(images: ImageStack,
dark_avg = None

if selected_flat_fielding == "Both, concatenated":
if flat_before is None:
raise ValueError("Missing stack: flat_before is required for 'Both, concatenated'")
if flat_after is None:
raise ValueError("Missing stack: flat_after is required for 'Both, concatenated'")
if flat_before is None or flat_after is None:
raise ValueError("Missing flat stacks for 'Both, concatenated'")
flat_avg = (flat_before.data.mean(axis=0) + flat_after.data.mean(axis=0)) / 2.0
if use_dark:
if dark_before is None or dark_after is None:
raise ValueError("Missing stack: dark_before and dark_after are required for 'Both, concatenated'")
raise ValueError("Missing dark stacks for 'Both, concatenated'")
dark_avg = (dark_before.data.mean(axis=0) + dark_after.data.mean(axis=0)) / 2.0

elif selected_flat_fielding == "Only After":
if flat_after is None:
raise ValueError("Missing stack: flat_after is required for 'Only After'")
flat_avg = flat_after.data.mean(axis=0)
if use_dark:
if dark_after is None:
raise ValueError("Missing stack: dark_after is required for 'Only After'")
dark_avg = dark_after.data.mean(axis=0)
if use_dark and dark_after is None:
raise ValueError("Missing stack: dark_after is required for 'Only After'")
dark_avg = dark_after.data.mean(axis=0) if use_dark else np.zeros_like(flat_avg)

elif selected_flat_fielding == "Only Before":
if flat_before is None:
raise ValueError("Missing stack: flat_before is required for 'Only Before'")
flat_avg = flat_before.data.mean(axis=0)
if use_dark:
if dark_before is None:
raise ValueError("Missing stack: dark_before is required for 'Only Before'")
dark_avg = dark_before.data.mean(axis=0)

if dark_avg is None:
dark_avg = np.zeros_like(flat_avg)
if use_dark and dark_before is None:
raise ValueError("Missing stack: dark_before is required for 'Only Before'")
dark_avg = dark_before.data.mean(axis=0) if use_dark else np.zeros_like(flat_avg)

if flat_avg is not None and dark_avg is not None:
if flat_avg.ndim != 2 or dark_avg.ndim != 2:
Expand All @@ -134,7 +127,7 @@ def filter_func(images: ImageStack,
f"flat had shape: {flat_avg.shape}, and dark had shape: {dark_avg.shape}")

params = {'flat_avg': flat_avg, 'dark_avg': dark_avg}
ps.run_compute_func(FlatFieldFilter.compute_function, len(images.data), [images.shared_array], params)
ps.run_compute_func(FlatFieldFilter._compute_flat_field, len(images.data), [images.shared_array], params)

h.check_data_stack(images)
return images
Expand Down Expand Up @@ -255,14 +248,10 @@ def register_gui(form, on_change, view) -> dict[str, Any]:
}

@staticmethod
def execute_wrapper(args: dict[str, Any]) -> partial[Any]:
images = args['images']
flat_before_widget = args['flat_before_widget']
flat_after_widget = args['flat_after_widget']
dark_before_widget = args['dark_before_widget']
dark_after_widget = args['dark_after_widget']
selected_flat_fielding_widget = args['selected_flat_fielding_widget']
use_dark_widget = args['use_dark_widget']
def execute_wrapper(flat_before_widget: DatasetSelectorWidgetView, flat_after_widget: DatasetSelectorWidgetView,
dark_before_widget: DatasetSelectorWidgetView, dark_after_widget: DatasetSelectorWidgetView,
selected_flat_fielding_widget: QComboBox, use_dark_widget: QCheckBox,
images: ImageStack) -> partial[Any]:

flat_before_images = BaseFilter.get_images_from_stack(flat_before_widget, "flat before")
flat_after_images = BaseFilter.get_images_from_stack(flat_after_widget, "flat after")
Expand Down

0 comments on commit 63a69ba

Please sign in to comment.