Commit 6143d2bf authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[core][process][noiseremoval] Add step and chunks properties

parent 847c0195
......@@ -41,6 +41,7 @@ from silx.gui import qt
from darfix.core import utils
from darfix.gui.blindSourceSeparationWidget import Method
from darfix.gui.grainPlotWidget import GrainPlotWidget
from darfix.gui.rsmWidget import PixelSize
_input_desc = namedtuple("_input_desc", ["name", "type", "handler", "doc"])
......@@ -73,14 +74,17 @@ class _NoiseRemoval:
dataset, indices, li_indices, bg_dataset = dataset
method = self._properties['method'] if 'method' in self._properties else ''
background_type = self._properties['background_type'] if 'background_type' in self._properties else ''
step = int(self._properties['step']) if 'step' in self._properties and self._properties['step'] != '' else None
chunks = self._properties['chunks'] if 'chunks' in self._properties and self._properties['chunks'] else None
bg = None
if background_type == "Dark data":
bg = bg_dataset
elif background_type == "Low intensity data":
bg = li_indices
size = self._properties['kernel_size'] if 'kernel_size' in self._properties else ''
print(step, chunks)
if method != '':
dataset = dataset.apply_background_subtraction(indices=indices, method=method, background=bg)
dataset = dataset.apply_background_subtraction(indices=indices, method=method, background=bg, step=step, chunk_shape=chunks)
if size != '':
dataset = dataset.apply_hot_pixel_removal(indices=indices, kernel=int(size))
return dataset, indices, li_indices, bg_dataset
......@@ -262,3 +266,30 @@ class _GrainPlot:
widget.show()
app.exec_()
return dataset
class _Transformation:
inputs = [_input_desc(name='dataset', type=tuple, handler='process',
doc='dataset to process'), ]
outputs = [
_output_desc(name='dataset', type=tuple, doc='dataset to process'), ]
def __init__(self):
self._properties = {}
def process(self, dataset):
dataset, indices, li_indices, bg_dataset = dataset
magnification = self._properties['magnification'] if 'magnification' in self._properties else None
pixelSize = self._properties['pixelSize'] if 'pixelSize' in self._properties else None
rotate = self._properties['rotate'] if 'rotate' in self._properties else None
if dataset and dataset.dims.ndim:
if dataset.dims.ndim == 1:
dataset.compute_transformation(PixelSize[pixelSize].value,
rotate)
else:
dataset.compute_transformation(magnification)
return dataset, indices, li_indices, bg_dataset
def set_properties(self, properties):
self._properties = properties
Markdown is supported
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