Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute Divide Function #2087

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading