Commit 46ea3613 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[backgroundSubstractionWidget] Added chooseDimension widget

parent 238c0302
......@@ -28,7 +28,7 @@ __authors__ = ["J. Garriga"]
__license__ = "MIT"
__date__ = "08/08/2019"
# import os
import numpy
from silx.gui import qt
from silx.gui.colors import Colormap
......@@ -36,6 +36,7 @@ from silx.gui.plot.StackView import StackViewMainWindow
from darfix.core.imageOperations import background_substraction, hot_pixel_removal
from .utils import ChooseDimensionWidget
from .operationThread import OperationThread
......@@ -54,13 +55,17 @@ class BackgroundSubstractionWidget(qt.QWidget):
self.setLayout(qt.QVBoxLayout())
self._sv = StackViewMainWindow()
# TODO: modify lower bound after asking the beamline
self._sv.setColormap(Colormap(name='viridis', normalization='linear'))
self._chooseDimensionWidget = ChooseDimensionWidget(self)
self._chooseDimensionWidget.hide()
self._computeB = qt.QPushButton("Compute background substraction")
self.layout().addWidget(self._sv)
self.layout().addWidget(self._chooseDimensionWidget)
self.layout().addWidget(self._computeB)
self._computeB.clicked.connect(self.computeBS)
self._chooseDimensionWidget.filterChanged.connect(self._filterStack)
self._chooseDimensionWidget.stateDisabled.connect(self._wholeStack)
def hideButton(self):
self._computeB.hide()
......@@ -70,8 +75,8 @@ class BackgroundSubstractionWidget(qt.QWidget):
def computeBS(self):
"""
Function that starts starts the thread to compute the background
substraction
Function that starts the thread to compute the background
substraction.
"""
self._thread.setArgs(self.dataset.data, self.dataset.dark_frames)
self._thread.finished.connect(self._updateData)
......@@ -99,10 +104,19 @@ class BackgroundSubstractionWidget(qt.QWidget):
"""
self.dataset = dataset
self.setStack(dataset.data)
if self.dataset.reshaped_data is not None:
self._chooseDimensionWidget.show()
self._chooseDimensionWidget.setDimensions(self.dataset.dims)
def clearStack(self):
self._sv.setStack(None)
def _filterStack(self, dim=0, val=0):
self.setStack(numpy.take(self.dataset.reshaped_data, val, axis=dim))
def _wholeStack(self):
self.setStack(self.dataset.data)
def setStack(self, *arg, **kwargs):
"""
Sets the data passed as aguments in the stack.
......
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