Commit d40c7731 authored by payno's avatar payno Committed by Henri Payno
Browse files

Rename IntensityNormalizationProcess to IntensityNormalizationTask and adapt...

Rename IntensityNormalizationProcess to IntensityNormalizationTask and adapt to latest ewoks standard
parent 01da14f1
......@@ -47,7 +47,7 @@ from tomwer.synctools.stacks.reconstruction.normalization import (
from processview.core.manager import ProcessManager
from processview.core.manager import DatasetState
from tomwer.core.process.reconstruction.normalization import (
IntensityNormalizationProcess,
IntensityNormalizationTask,
)
from tomwer.core import settings
from tomwer.core import utils
......@@ -209,9 +209,9 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
# save processing result for the one with interaction. Otherwise
# this will be saved in the processing thread
IntensityNormalizationProcess._register_process(
IntensityNormalizationTask._register_process(
process_file=scan.process_file,
process=IntensityNormalizationProcess,
process=IntensityNormalizationTask,
entry=scan.entry,
configuration=self.getConfiguration(),
results={
......
......@@ -36,7 +36,7 @@ from orangecontrib.tomwer.widgets.reconstruction.NormIOW import (
from processview.core.manager import ProcessManager, DatasetState
from tomwer.io.utils.h5pyutils import EntryReader
from tomwer.core.process.reconstruction.normalization import (
IntensityNormalizationProcess,
IntensityNormalizationTask,
)
from silx.io.utils import h5py_read_dataset
import tempfile
......@@ -215,5 +215,5 @@ class TestProcessing(TestCaseQt):
self.assertTrue("tomwer_process_0" in entry)
self.assertEqual(
h5py_read_dataset(entry["tomwer_process_0"]["program"]),
IntensityNormalizationProcess.program_name(),
IntensityNormalizationTask.program_name(),
)
......@@ -16,7 +16,7 @@ from tomwer.gui.reconstruction.normalization.intensity import (
NormIntensityWindow as _NormIntensityWindow,
)
from tomwer.core.process.reconstruction.normalization import (
IntensityNormalizationProcess,
IntensityNormalizationTask,
)
logging.basicConfig(level=logging.INFO)
......@@ -46,7 +46,7 @@ class IntensityNormalizationThread(qt.QThread):
self._result = None
def run(self) -> None:
process = IntensityNormalizationProcess(process_id=None)
process = IntensityNormalizationTask(process_id=None)
process.set_properties(self._configuration)
self._result = process.process(
self.scan
......@@ -66,9 +66,9 @@ class NormIntensityWindow(_NormIntensityWindow):
def _validated(self):
scan = self.getScan()
if scan is not None:
IntensityNormalizationProcess._register_process(
IntensityNormalizationTask._register_process(
process_file=scan.process_file,
process=IntensityNormalizationProcess,
process=IntensityNormalizationTask,
entry=scan.entry,
configuration=self.getConfiguration(),
results={
......
......@@ -98,7 +98,7 @@ class AxisCalculationInput(_Enum):
for member in cls:
if value in (member.value, member.name()):
return member
raise ValueError("Cannot convert: %s" % value)
raise ValueError(f"Cannot convert: {value}")
class AxisResource(object):
......
from .normalization import ( # noqa F403
IntensityNormalizationProcess,
IntensityNormalizationTask,
results_to_tomoscan_norm,
)
from .params import IntensityNormalizationParams # noqa F403
......@@ -59,15 +59,30 @@ from tomoscan.normalization import Method as TomoScanMethod
_logger = logging.getLogger(__name__)
class IntensityNormalizationProcess(
class IntensityNormalizationTask(
Task, SuperviseProcess, input_names=("data",), output_names=("data",)
):
"""
Task to define the normalization to apply to a sinogram
"""
def __init__(self, process_id=None, varinfo=None, inputs=None, label=None):
Task.__init__(self, varinfo=varinfo, inputs=inputs, label=label)
def __init__(
self,
process_id=None,
varinfo=None,
inputs=None,
node_id=None,
node_attrs=None,
execinfo=None,
):
Task.__init__(
self,
varinfo=varinfo,
inputs=inputs,
node_id=node_id,
node_attrs=node_attrs,
execinfo=execinfo,
)
SuperviseProcess.__init__(self, process_id=process_id)
self._dry_run = False
......@@ -315,7 +330,7 @@ class IntensityNormalizationProcess(
)
else:
raise ValueError("{} is not handled".format(calc_area))
return IntensityNormalizationProcess.compute_stats(roi_area)
return IntensityNormalizationTask.compute_stats(roi_area)
@staticmethod
def compute_stats(data):
......@@ -385,7 +400,7 @@ class IntensityNormalizationProcess(
if calc_area is _CalculationArea.VOLUME:
url = DataUrl(url)
data = get_data(url)
return IntensityNormalizationProcess.compute_stats(data=data)
return IntensityNormalizationTask.compute_stats(data=data)
else:
raise ValueError("{} is not managed".format(calc_area))
......
......@@ -70,7 +70,7 @@ class TestNormalization(unittest.TestCase):
100 * 100 * 2
).reshape(2, 100, 100)
process = normalization.IntensityNormalizationProcess()
process = normalization.IntensityNormalizationTask()
process_params = normalization.IntensityNormalizationParams()
process_params.method = Method.MANUAL_ROI
expected_results = {
......
......@@ -28,7 +28,7 @@ __date__ = "19/07/2021"
from tomwer.core.process.reconstruction.normalization import (
IntensityNormalizationProcess,
IntensityNormalizationTask,
)
from processview.core.manager import ProcessManager
from tomwer.core.scan.scanbase import TomwerScanBase
......@@ -118,12 +118,16 @@ class _ProcessingThread(ProcessingThread, SuperviseProcess):
def run(self):
self.sigComputationStarted.emit()
norm_process = IntensityNormalizationProcess(process_id=self.process_id)
norm_process.set_configuration(configuration=self._i_norm_params)
norm_process.process(self._scan)
norm_process = IntensityNormalizationTask(
process_id=self.process_id,
varinfo=None,
inputs={
"data": self._scan,
"configuration": self._i_norm_params,
},
)
try:
norm_process.process(self._scan)
norm_process.run()
except Exception as e:
_logger.error(str(e))
mess = "Intensity normalization computation for {} failed.".format(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment