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

rename Inorm to Sino norm. More generic

parent 001a2646
.. _intensity normalization:
.. _sinogram normalization:
I normalization
```````````````
sino normalization
``````````````````
.. image:: img/intensity_normalization/main_screen.png
.. image:: img/sino_normalization/main_screen.png
Behavior
......
......@@ -39,7 +39,7 @@ from orangewidget import gui
from orangewidget.widget import Input, Output
from ...orange.managedprocess import SuperviseOW
from tomwer.gui.reconstruction.normalization.intensity import (
NormIntensityWindow as _NormIntensityWindow,
SinoNormWindow as _SinoNormWindow,
)
from tomwer.synctools.stacks.reconstruction.normalization import (
INormalizationProcessStack,
......@@ -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 (
IntensityNormalizationTask,
SinoNormalizationTask,
)
from tomwer.core import settings
from tomwer.core import utils
......@@ -58,7 +58,7 @@ import functools
_logger = logging.getLogger(__name__)
class NormIntensityWindow(_NormIntensityWindow):
class SinoNormWindow(_SinoNormWindow):
"""
implementation of NormIntensityWindow for orange. Add a lock processing
and a processing stack
......@@ -67,7 +67,7 @@ class NormIntensityWindow(_NormIntensityWindow):
sigValidate = qt.Signal()
def __init__(self, parent, process_id=None):
assert isinstance(parent, NormIOW)
assert isinstance(parent, SinoNormOW)
super().__init__(parent)
self._parentValidate = self.parent()._validate
self._processing_stack = INormalizationProcessStack(process_id=process_id)
......@@ -105,7 +105,7 @@ class NormIntensityWindow(_NormIntensityWindow):
self._parentValidate(scan)
class NormIOW(WidgetLongProcessing, SuperviseOW):
class SinoNormOW(WidgetLongProcessing, SuperviseOW):
"""
A simple widget managing the copy of an incoming folder to an other one
......@@ -113,8 +113,8 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
"""
# note of this widget should be the one registered on the documentation
name = "I normalization"
id = "orange.widgets.tomwer.reconstruction.NormIOW.NormIOW"
name = "sino normalization"
id = "orange.widgets.tomwer.reconstruction.SinoNormOW.SinoNormOW"
description = "Define normalization on intensity to be applied on projections"
icon = "icons/norm_I.svg"
priority = 28
......@@ -152,7 +152,7 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
SuperviseOW.__init__(self, parent)
WidgetLongProcessing.__init__(self)
self._window = NormIntensityWindow(self, process_id=self.process_id)
self._window = SinoNormWindow(self, process_id=self.process_id)
self._layout = gui.vBox(self.mainArea, self.name).layout()
self._layout.setContentsMargins(0, 0, 0, 0)
......@@ -222,9 +222,9 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
tomwer_processing_res_code = extra_infos.pop(
"tomwer_processing_res_code", "unprocessed"
)
IntensityNormalizationTask._register_process(
SinoNormalizationTask._register_process(
process_file=scan.process_file,
process=IntensityNormalizationTask,
process=SinoNormalizationTask,
entry=scan.entry,
configuration=self.getConfiguration(),
results={
......
......@@ -30,13 +30,13 @@ __date__ = "09/06/2021"
from silx.gui.utils.testutils import TestCaseQt
from silx.gui import qt
from tomwer.core.utils.scanutils import MockHDF5
from orangecontrib.tomwer.widgets.reconstruction.NormIOW import (
NormIOW as _NormIOW,
from orangecontrib.tomwer.widgets.reconstruction.SinoNormOW import (
SinoNormOW as _NormIOW,
)
from processview.core.manager import ProcessManager, DatasetState
from tomwer.io.utils.h5pyutils import EntryReader
from tomwer.core.process.reconstruction.normalization import (
IntensityNormalizationTask,
SinoNormalizationTask,
)
from silx.io.utils import h5py_read_dataset
import tempfile
......@@ -213,5 +213,5 @@ class TestProcessing(TestCaseQt):
self.assertTrue("tomwer_process_0" in entry)
self.assertEqual(
h5py_read_dataset(entry["tomwer_process_0"]["program"]),
IntensityNormalizationTask.program_name(),
SinoNormalizationTask.program_name(),
)
......@@ -13,10 +13,10 @@ from tomwer.core.scan.scanfactory import ScanFactory
from tomwer.core.scan.hdf5scan import HDF5TomoScan
from tomwer.core.scan.scanbase import TomwerScanBase
from tomwer.gui.reconstruction.normalization.intensity import (
NormIntensityWindow as _NormIntensityWindow,
SinoNormWindow as _SinoNormWindow,
)
from tomwer.core.process.reconstruction.normalization import (
IntensityNormalizationTask,
SinoNormalizationTask,
)
logging.basicConfig(level=logging.INFO)
......@@ -47,7 +47,7 @@ class IntensityNormalizationThread(qt.QThread):
def run(self) -> None:
process = IntensityNormalizationTask(
process = SinoNormalizationTask(
process_id=None,
inputs={
"data": self.scan,
......@@ -59,9 +59,9 @@ class IntensityNormalizationThread(qt.QThread):
self._result = self.scan.intensity_normalization.tomwer_processing_res
class NormIntensityWindow(_NormIntensityWindow):
class NormIntensityWindow(_SinoNormWindow):
def __init__(self, parent=None):
_NormIntensityWindow.__init__(self, parent)
_SinoNormWindow.__init__(self, parent)
self._processingThread = IntensityNormalizationThread()
self._hideLockButton()
......@@ -72,9 +72,9 @@ class NormIntensityWindow(_NormIntensityWindow):
def _validated(self):
scan = self.getScan()
if scan is not None:
IntensityNormalizationTask._register_process(
SinoNormalizationTask._register_process(
process_file=scan.process_file,
process=IntensityNormalizationTask,
process=SinoNormalizationTask,
entry=scan.entry,
configuration=self.getConfiguration(),
results={
......
......@@ -34,10 +34,10 @@ from collections import namedtuple
import pytest
from tomwer.core.process.reconstruction.nabu.nabuslices import NabuSlices
from tomwer.core.process.reconstruction.normalization.params import (
IntensityNormalizationParams,
SinoNormalizationParams,
)
from tomwer.core.process.reconstruction.normalization.normalization import (
IntensityNormalizationTask,
SinoNormalizationTask,
)
from tomwer.core.utils.scanutils import MockHDF5
from tomwer.core.process.reconstruction.nabu import settings as nabu_settings
......@@ -154,13 +154,13 @@ def test_normalization(norm_setting, expected_nabu_conf, tmp_path):
cfg_folder = os.path.join(str(scan_dir), "nabu_cfg_files")
cfg_file = os.path.join(cfg_folder, "entry_scan.cfg")
assert not os.path.exists(cfg_file)
norm_params = IntensityNormalizationParams(
norm_params = SinoNormalizationParams(
method=norm_setting.method,
source=norm_setting.source,
extra_infos=norm_setting.extra_infos,
)
normalization = IntensityNormalizationTask(
normalization = SinoNormalizationTask(
inputs={
"data": scan,
"configuration": norm_params.to_dict(),
......
from .normalization import ( # noqa F403
IntensityNormalizationTask,
SinoNormalizationTask,
)
from .params import IntensityNormalizationParams # noqa F403
from .params import SinoNormalizationParams # noqa F403
......@@ -36,7 +36,7 @@ __date__ = "25/06/2021"
from tomwer.core.process.task import Task
from .params import (
IntensityNormalizationParams,
SinoNormalizationParams,
_ValueCalculationFct,
_ValueSource,
)
......@@ -55,7 +55,7 @@ import logging
_logger = logging.getLogger(__name__)
class IntensityNormalizationTask(
class SinoNormalizationTask(
Task, SuperviseProcess, input_names=("data",), output_names=("data",)
):
"""
......@@ -85,7 +85,7 @@ class IntensityNormalizationTask(
self.set_configuration(inputs["configuration"])
def set_properties(self, properties):
if isinstance(properties, IntensityNormalizationParams):
if isinstance(properties, SinoNormalizationParams):
self._settings = properties.to_dict()
else:
self._settings = properties
......@@ -104,7 +104,7 @@ class IntensityNormalizationTask(
}
)
scan.intensity_normalization.set_extra_infos(extra_infos)
params = IntensityNormalizationParams.from_dict(self._settings)
params = SinoNormalizationParams.from_dict(self._settings)
# define the method used to the scan
scan.intensity_normalization.method = params.method
# after this processing the source
......@@ -152,7 +152,7 @@ class IntensityNormalizationTask(
self.outputs.data = scan
def _compute_from_manual_roi(self, scan):
params = IntensityNormalizationParams.from_dict(self.get_configuration())
params = SinoNormalizationParams.from_dict(self.get_configuration())
extra_info = params.extra_infos
start_x = extra_info.get("start_x", None)
end_x = extra_info.get("end_x", None)
......@@ -325,7 +325,7 @@ class IntensityNormalizationTask(
raise ValueError(
"Frame where expected and not a " "{}D object".format(data.ndim)
)
return IntensityNormalizationTask.compute_stats(roi_area)
return SinoNormalizationTask.compute_stats(roi_area)
@staticmethod
def compute_stats(data):
......
......@@ -98,7 +98,7 @@ class _ROIInfo:
self.y_max = y_max
class IntensityNormalizationParams:
class SinoNormalizationParams:
"""Information regarding the intensity normalization to be done"""
def __init__(self, method=Method.NONE, source=_ValueSource.NONE, extra_infos=None):
......@@ -151,7 +151,7 @@ class IntensityNormalizationParams:
@staticmethod
def from_dict(dict_):
params = IntensityNormalizationParams()
params = SinoNormalizationParams()
params.load_from_dict(dict_=dict_)
return params
......
......@@ -70,7 +70,7 @@ class TestNormalization(unittest.TestCase):
100 * 100 * 2
).reshape(2, 100, 100)
process_params = normalization.IntensityNormalizationParams()
process_params = normalization.SinoNormalizationParams()
process_params.method = Method.SUBTRACTION
process_params.source = params._ValueSource.MANUAL_ROI
expected_results = {
......@@ -88,7 +88,7 @@ class TestNormalization(unittest.TestCase):
"calc_fct": calc_fct,
"calc_area": "volume",
}
process = normalization.IntensityNormalizationTask(
process = normalization.SinoNormalizationTask(
inputs={
"data": self.scan,
"configuration": process_params,
......
......@@ -53,7 +53,7 @@ import weakref
import typing
class NormIntensityWindow(qt.QMainWindow):
class SinoNormWindow(qt.QMainWindow):
sigConfigurationChanged = qt.Signal()
"""signal emit when the configuration change"""
......@@ -199,7 +199,7 @@ class NormIntensityWindow(qt.QMainWindow):
class _Viewer(qt.QTabWidget):
def __init__(self, parent):
if not isinstance(parent, NormIntensityWindow):
if not isinstance(parent, SinoNormWindow):
raise TypeError("Expect a NormIntensityWindow as parrent")
qt.QTabWidget.__init__(self, parent)
self._projView = _ProjPlotWithROI(parent=self)
......@@ -430,7 +430,7 @@ class _NormIntensityOptions(qt.QWidget):
"""Signal emit when the configuration changes"""
def __init__(self, parent):
if not isinstance(parent, NormIntensityWindow):
if not isinstance(parent, SinoNormWindow):
raise TypeError(
"parent is expected to be an instance of " "NormIntensityWindow "
)
......@@ -584,14 +584,14 @@ class _NormIntensityOptions(qt.QWidget):
pass
def getConfiguration(self) -> dict:
return _normParams.IntensityNormalizationParams(
return _normParams.SinoNormalizationParams(
method=self.getCurrentMethod(),
source=self.getCurrentSource(),
extra_infos=self.getExtraInfos(),
).to_dict()
def setConfiguration(self, config: dict):
params = _normParams.IntensityNormalizationParams.from_dict(config)
params = _normParams.SinoNormalizationParams.from_dict(config)
self.setCurrentMethod(params.method)
extra_infos = params.extra_infos
if (
......
......@@ -32,7 +32,7 @@ __date__ = "23/06/2021"
from silx.gui.utils.testutils import TestCaseQt
from tomwer.gui.reconstruction.normalization.intensity import NormIntensityWindow
from tomwer.gui.reconstruction.normalization.intensity import SinoNormWindow
from tomwer.core.utils.scanutils import MockHDF5
from tomwer.core.process.reconstruction.normalization.params import (
Method as NormalizationMethod,
......@@ -47,7 +47,7 @@ import os
class TestNormIntensityWindow(TestCaseQt):
def setUp(self):
super(TestNormIntensityWindow, self).setUp()
self._widget = NormIntensityWindow(parent=None)
self._widget = SinoNormWindow(parent=None)
self._tmp_dir = tempfile.mkdtemp()
scan_path = os.path.join(self._tmp_dir, "my_scan_2")
self.scan = MockHDF5(
......
......@@ -28,7 +28,7 @@ __date__ = "19/07/2021"
from tomwer.core.process.reconstruction.normalization import (
IntensityNormalizationTask,
SinoNormalizationTask,
)
from processview.core.manager import ProcessManager
from tomwer.core.scan.scanbase import TomwerScanBase
......@@ -109,7 +109,7 @@ class _ProcessingThread(ProcessingThread, SuperviseProcess):
def run(self):
self.sigComputationStarted.emit()
norm_process = IntensityNormalizationTask(
norm_process = SinoNormalizationTask(
process_id=self.process_id,
varinfo=None,
inputs={
......
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