Commit 1136f597 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[gui][bss] Filtered data and dimensions correctly managed

parent 1c4c59a9
......@@ -62,7 +62,6 @@ class PCAWidget(qt.QWidget):
:param Dataset dataset: dataset
"""
self.dataset = dataset
print(self.dataset.hi_data.shape)
self.BSS = BSS(self.dataset.hi_data)
self._thread = OperationThread(self.BSS.PCA)
self.computePCA()
......
......@@ -31,6 +31,7 @@ __date__ = "25/11/2019"
import numpy
from silx.gui import qt
from silx.gui.colors import Colormap
from silx.gui.plot import StackView, Plot1D
from silx.gui.widgets.FrameBrowser import HorizontalSliderWithBrowser
......@@ -113,12 +114,13 @@ class BSSWidget(qt.QMainWindow):
by the moving motor.
"""
self._sv_components = StackView(parent=self)
self._sv_components.setColormap(Colormap(name='jet', normalization='linear'))
self._sv_components.setGraphTitle("Components")
self._sv_components.sigFrameChanged.connect(self.setCurve)
self._sv_components.sigFrameChanged.connect(self._setCurve)
self._plot_rocking_curves = Plot1D(parent=self)
self._plot_rocking_curves.setGraphTitle("Rocking curves")
self._plot_rocking_curves.sigActiveCurveChanged.connect(self.setComponent)
self._plot_rocking_curves.sigActiveCurveChanged.connect(self._setComponent)
right_widget = qt.QWidget(self)
# Layout for the right widget that contains the plot of the
......@@ -202,13 +204,13 @@ class BSSWidget(qt.QMainWindow):
self.computeButton.setEnabled(True)
qt.QApplication.restoreOverrideCursor()
def setComponent(self, prev_legend=None, legend=None):
def _setComponent(self, prev_legend=None, legend=None):
if legend:
self._sv_components.blockSignals(True)
self._sv_components.setFrameNumber(int(legend))
self._sv_components.blockSignals(False)
def setCurve(self, index=-1):
def _setCurve(self, index=-1):
if index >= 0:
self._plot_rocking_curves.blockSignals(True)
self._plot_rocking_curves.setActiveCurve(str(index))
......@@ -233,7 +235,20 @@ class BSSWidget(qt.QMainWindow):
self._rc_browser.setRange(0, len(self.dataset.dims.get(self.dimension).unique_values) - 1)
self._rc_browser.setValue(0)
for i in range(len(self.W.T)):
W = numpy.take(self.W.T[i].reshape(self.dataset.dims.shape), 0, self.dimension)
if self.dataset.li_data:
# If filter data is activated, the matrix W has reduced dimensionality, so reshaping is not possible
# Create empty array with shape the total number of frames
W = numpy.empty(self.dataset.threshold.shape)
# Set actual values of W where threshold of filter is True
W[self.dataset.threshold] = self.W.T[i]
# Take only the thresholds for the dimension
threshold = numpy.take(self.dataset.threshold.reshape(self.dataset.dims.shape), 0, axis=self.dimension)
# Reshape W into the dimensions and take the first element of the chosen dimension
W = numpy.take(W.reshape(self.dataset.dims.shape), 0, self.dimension)
# Take only the values of W that correspond to high intensity data
W = W[threshold]
else:
W = numpy.take(self.W.T[i].reshape(self.dataset.dims.shape), 0, self.dimension)
self._plot_rocking_curves.addCurve(numpy.arange(len(W)), W, legend=str(i))
else:
raise ValueError('Axis %s is not managed' % axis)
......@@ -246,5 +261,18 @@ class BSSWidget(qt.QMainWindow):
self.index = index
self._plot_rocking_curves.clear()
for i in range(len(self.W.T)):
W = numpy.take(self.W.T[i].reshape(self.dataset.dims.shape), self.index, self.dimension)
if self.dataset.li_data:
# If filter data is activated, the matrix W has reduced dimensionality, so reshaping is not possible
# Create empty array with shape the total number of frames
W = numpy.empty(self.dataset.threshold.shape)
# Set actual values of W where threshold of filter is True
W[self.dataset.threshold] = self.W.T[i]
# Take only the thresholds for the dimension
threshold = numpy.take(self.dataset.threshold.reshape(self.dataset.dims.shape), self.index, axis=self.dimension)
# Reshape W into the dimensions and take the chosen element and dimension
W = numpy.take(W.reshape(self.dataset.dims.shape), self.index, self.dimension)
# Take only the values of W that correspond to high intensity data
W = W[threshold]
else:
W = numpy.take(self.W.T[i].reshape(self.dataset.dims.shape), self.index, self.dimension)
self._plot_rocking_curves.addCurve(numpy.arange(len(W)), W, legend=str(i))
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