Skip to content

Commit

Permalink
Compute Divide Function (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtygier-stfc committed Mar 4, 2024
2 parents 20aceba + e1154c2 commit 6fce472
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions mantidimaging/core/operations/divide/divide.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from typing import Union, Callable, Dict, Any, TYPE_CHECKING

from mantidimaging import helper as h
import numpy as np

from mantidimaging.core.parallel import shared as ps
from mantidimaging.core.operations.base_filter import BaseFilter
from mantidimaging.gui.utility.qt_helpers import Type

Expand Down Expand Up @@ -43,9 +46,16 @@ def filter_func(images: ImageStack, value: Union[int, float] = 0, unit="micron",
if unit == "micron":
value *= 1e-4

images.data /= value
params = {'value': value}
ps.run_compute_func(DivideFilter.compute_function, images.data.shape[0], images.shared_array, params, progress)

return images

@staticmethod
def compute_function(i: int, array: np.ndarray, params: dict):
value = params['value']
array[i] /= value

@staticmethod
def register_gui(form: 'QFormLayout', on_change: Callable, view: 'BasePresenter') -> Dict[str, Any]:
from mantidimaging.gui.utility import add_property_to_form
Expand Down Expand Up @@ -75,9 +85,3 @@ def execute_wrapper( # type: ignore
value = value_widget.value()
unit = unit_widget.currentText()
return partial(DivideFilter.filter_func, value=value, unit=unit)

@staticmethod
def validate_execute_kwargs(kwargs: Dict[str, Any]) -> bool:
if 'value_widget' not in kwargs:
return False
return True

0 comments on commit 6fce472

Please sign in to comment.