diff --git a/mantidimaging/core/operations/monitor_normalisation/monitor_normalisation.py b/mantidimaging/core/operations/monitor_normalisation/monitor_normalisation.py index 6f30790fbb6..ec0c4ec1ae1 100644 --- a/mantidimaging/core/operations/monitor_normalisation/monitor_normalisation.py +++ b/mantidimaging/core/operations/monitor_normalisation/monitor_normalisation.py @@ -9,7 +9,6 @@ from mantidimaging.core.operations.base_filter import BaseFilter from mantidimaging.core.parallel import shared as ps -from mantidimaging.core.parallel import utility as pu if TYPE_CHECKING: from mantidimaging.core.data import ImageStack @@ -44,16 +43,20 @@ def filter_func(images: ImageStack, progress=None) -> ImageStack: raise RuntimeError("No logfile available for this stack.") counts = images.counts() - if counts is None: raise RuntimeError("No loaded log values for this stack.") - counts_val = pu.copy_into_shared_memory(counts.value / counts.value[0]) - do_division = ps.create_partial(_divide_by_counts, fwd_function=ps.inplace2) - arrays = [images.shared_array, counts_val] - ps.execute(do_division, arrays, images.num_projections, progress) + normalization_factor = counts.value / counts.value[0] + params = {'normalization_factor': normalization_factor} + + ps.run_compute_func(MonitorNormalisation.compute_function, images.data.shape[0], images.shared_array, params, + progress) return images + @staticmethod + def compute_function(i: int, array: np.ndarray, params: dict[str, np.ndarray]): + array[i] /= params['normalization_factor'][i] + @staticmethod def register_gui(form: QFormLayout, on_change: Callable, view: BaseMainWindowView) -> dict[str, QWidget]: return {}