Commit f40f33f7 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[orangeconrib] Added output signal for datasets in operations

parent 8d839c88
Pipeline #13401 failed with stage
in 26 seconds
......@@ -6,6 +6,5 @@ py_testproject:
- pip install --upgrade setuptools wheel
- pip install flake8
- pip install -r requirements.txt
- pip install .
- flake8 --ignore=E501,W503,E402
- python -m unittest discover -v
\ No newline at end of file
......@@ -44,6 +44,7 @@ class BackgroundSubstractionWidget(qt.QWidget):
Widget to apply background substraction from a dataset.
The dataset should have raw data and dark data.
"""
signalComputed = qt.Signal()
def __init__(self, parent=None):
qt.QWidget.__init__(self, parent)
......@@ -80,6 +81,7 @@ class BackgroundSubstractionWidget(qt.QWidget):
self.dataset.data = self._thread.data
assert self.dataset.data is not None
self.setStack(self.dataset.data)
self.signalComputed.emit()
def setDataset(self, dataset):
"""
......@@ -93,6 +95,9 @@ class BackgroundSubstractionWidget(qt.QWidget):
def setStack(self, *arg, **kwargs):
"""
Sets the data passed as aguments in the stack
Sets the data passed as aguments in the stack.
Mantains the current frame showed in the view.
"""
nframe = self._sv.getFrameNumber()
self._sv.setStack(*arg, **kwargs)
self._sv.setFrameNumber(nframe)
......@@ -33,6 +33,7 @@ __date__ = "26/07/2019"
# import numpy
from silx.gui import qt
from silx.gui.colors import Colormap
from silx.gui.plot.StackView import StackViewMainWindow
from silx.gui.plot.items.roi import RectangleROI
from silx.gui.plot.tools.roi import RegionOfInterestManager, RegionOfInterestTableWidget
......@@ -50,6 +51,7 @@ class ROISelectionWidget(qt.QWidget):
self.setLayout(qt.QVBoxLayout())
self._sv = StackViewMainWindow()
self._sv.setColormap(Colormap(name='viridis', normalization='linear', vmin=0))
self.layout().addWidget(self._sv)
plot = self._sv.getPlot()
......@@ -96,11 +98,14 @@ class ROISelectionWidget(qt.QWidget):
def setStack(self, *arg, **kwargs):
"""
Sets the data passed as aguments in the stack.
Mantains the current frame showed in the view.
"""
first_frame_shape = self.dataset.data[0].shape
self.setRoi(center=(first_frame_shape[0] / 2, first_frame_shape[1] / 2),
size=(first_frame_shape[0] / 5, first_frame_shape[1] / 5))
nframe = self._sv.getFrameNumber()
self._sv.setStack(*arg, **kwargs)
self._sv.setFrameNumber(nframe)
def setRoi(self, roi=None, origin=None, size=None, center=None):
"""
......
......@@ -43,7 +43,7 @@ class ShiftCorrectionWidget(qt.QWidget):
"""
A widget to apply shift correction to a stack of images
"""
signalProgress = qt.Signal()
signalComputed = qt.Signal()
def __init__(self, parent=None):
qt.QWidget.__init__(self, parent)
......@@ -55,7 +55,7 @@ class ShiftCorrectionWidget(qt.QWidget):
self.layout().addWidget(self._inputW)
self._sv = StackViewMainWindow()
self._sv.setColormap(Colormap(name='viridis', normalization='linear'))
self._sv.setColormap(Colormap(name='viridis', normalization='linear', vmin=0))
self.layout().addWidget(self._sv)
self._inputW.correctionB.clicked.connect(self.correct)
......@@ -91,12 +91,16 @@ class ShiftCorrectionWidget(qt.QWidget):
self.dataset.data = self.thread.data
assert self.dataset.data is not None
self.setStack(self.dataset.data)
self.signalComputed.emit()
def setStack(self, *arg, **kwargs):
"""
Sets the data passed as aguments in the stack
Sets the data passed as aguments in the stack.
Mantains the current frame showed in the view.
"""
nframe = self._sv.getFrameNumber()
self._sv.setStack(*arg, **kwargs)
self._sv.setFrameNumber(nframe)
def getStack(self):
"""
......
from Orange.widgets.widget import OWWidget
from linkdick06.gui.backgroundSubstractionWidget import BackgroundSubstractionWidget
from Orange.canvas.registry.description import InputSignal
from Orange.canvas.registry.description import InputSignal, OutputSignal
from linkdick06.core.dataset import Dataset
......@@ -12,13 +12,18 @@ class BackgroundSubstractionWidgetOW(OWWidget):
want_main_area = False
inputs = [InputSignal('dataset', Dataset, 'process')]
outputs = [OutputSignal('dataset', Dataset)]
def __init__(self):
super().__init__()
self._backgroundSubstraction = BackgroundSubstractionWidget(parent=self)
self.controlArea.layout().addWidget(self._backgroundSubstraction)
self._widget = BackgroundSubstractionWidget(parent=self)
self._widget.signalComputed.connect(self._sendSignal)
self.controlArea.layout().addWidget(self._widget)
def process(self, dataset):
assert dataset.dark_frames, "Dark frames must be given in order to compute noise reduction"
self._backgroundSubstraction.setDataset(dataset=dataset)
self._widget.setDataset(dataset=dataset)
def _sendSignal(self):
self.send('dataset', self._widget.dataset)
......@@ -3,7 +3,7 @@ import numpy
from Orange.widgets.widget import OWWidget
from silx.gui import qt
from linkdick06.gui.roiSelectionWidget import ROISelectionWidget
from Orange.canvas.registry.description import InputSignal
from Orange.canvas.registry.description import InputSignal, OutputSignal
from linkdick06.core.dataset import Dataset
from linkdick06.core.roi import apply_3D_ROI
......@@ -16,6 +16,7 @@ class RoiSelectionWidgetOW(OWWidget):
want_main_area = False
inputs = [InputSignal('dataset', Dataset, 'process')]
outputs = [OutputSignal('dataset', Dataset)]
def __init__(self):
super().__init__()
......@@ -34,4 +35,8 @@ class RoiSelectionWidgetOW(OWWidget):
def _createRoi(self):
roi = self._roiSelection.getRoi()
self.dataset.data = apply_3D_ROI(self.dataset.data, roi.getSize() / 2, numpy.flip(roi.getCenter()))
if self.dataset.dark_frames:
self.dataset.dark_frames = apply_3D_ROI(self.dataset.dark_frames,
roi.getSize() / 2, numpy.flip(roi.getCenter()))
self._roiSelection.setStack(self.dataset.data)
self.send('dataset', self.dataset)
from Orange.widgets.widget import OWWidget
from linkdick06.gui.shiftCorrectionWidget import ShiftCorrectionWidget
from Orange.canvas.registry.description import InputSignal
from Orange.canvas.registry.description import InputSignal, OutputSignal
from linkdick06.core.dataset import Dataset
......@@ -12,12 +12,17 @@ class ShiftCorrectionWidgetOW(OWWidget):
want_main_area = False
inputs = [InputSignal('dataset', Dataset, 'process')]
outputs = [OutputSignal('dataset', Dataset)]
def __init__(self):
super().__init__()
self._shiftCorrection = ShiftCorrectionWidget(parent=self)
self._shiftCorrection.signalComputed.connect(self._sendSignal)
self.controlArea.layout().addWidget(self._shiftCorrection)
def process(self, dataset):
self._shiftCorrection.setDataset(dataset=dataset)
def _sendSignal(self):
self.send('dataset', self._shiftCorrection.dataset)
numpy==1.16.4
silx==0.10.1
\ No newline at end of file
silx==0.10.1
PyQt5
\ No newline at end of file
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