Commit 3e75e7d7 authored by Henri Payno's avatar Henri Payno
Browse files

roi process: move some preprocessing in the `run` function

parent f48370f9
Pipeline #78547 passed with stages
in 6 minutes and 48 seconds
......@@ -65,29 +65,6 @@ class ROIProcess(
input_names=["xas_obj", "roi_size", "roi_origin"],
output_names=["xas_obj"],
):
def __init__(self, **kwargs):
super().__init__(**kwargs)
if 0 in self.inputs.roi_size:
raise ValueError(
f"Unabme to apply a roi of size 0. Requested ROI size is {self.inputs.roi_size}"
)
# handle -1 value
roi_size = list(self.inputs.roi_size)
roi_origin = list(self.inputs.roi_origin)
xas_obj = self.getXasObject(self.inputs.xas_obj)
if roi_size[0] == -1:
roi_origin[0] = 0
roi_size[0] = xas_obj.spectra.shape[1]
if roi_size[1] == -1:
roi_origin[1] = 0
roi_size[1] = xas_obj.spectra.shape[0]
# define the ROI
self.roi = _ROI(
origin=roi_origin,
size=roi_size,
)
def _apply_roi(self, xas_obj, roi):
_logger.warning("applying roi")
assert isinstance(xas_obj, XASObject)
......@@ -162,6 +139,29 @@ class ROIProcess(
:return: spectra dict
:rtype: :class:`.XASObject`
"""
# preprocessing on the roi
if 0 in self.inputs.roi_size:
raise ValueError(
f"Unabme to apply a roi of size 0. Requested ROI size is {self.inputs.roi_size}"
)
# handle -1 value
roi_size = list(self.inputs.roi_size)
roi_origin = list(self.inputs.roi_origin)
xas_obj = self.getXasObject(self.inputs.xas_obj)
if roi_size[0] == -1:
roi_origin[0] = 0
roi_size[0] = xas_obj.spectra.shape[1]
if roi_size[1] == -1:
roi_origin[1] = 0
roi_size[1] = xas_obj.spectra.shape[0]
# define the ROI
self.roi = _ROI(
origin=roi_origin,
size=roi_size,
)
# processing
xas_obj = self.inputs.xas_obj
_xas_obj = self.getXasObject(xas_obj=xas_obj)
......
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