Commit 419a2d3b authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[gui][pca] Work widget to new refactoring

parent 6582791f
......@@ -26,15 +26,13 @@
__authors__ = ["J. Garriga"]
__license__ = "MIT"
__date__ = "30/01/2020"
__date__ = "08/04/2020"
import numpy
from silx.gui import qt
from silx.gui.plot import Plot1D
from darfix.core.blindSourceSeparation import BSS
from .operationThread import OperationThread
......@@ -69,27 +67,24 @@ class PCAWidget(qt.QMainWindow):
def _computePCA(self):
self.computeB.setEnabled(False)
try:
txt = self.maxNumComp.text()
if txt != "":
maxNumComp = float(self.maxNumComp.text())
else:
maxNumComp = None
self._thread = OperationThread(self.BSS.PCA)
self._thread.setArgs(None, maxNumComp)
self._thread = OperationThread(self.dataset.pca)
self._thread.setArgs(return_vals=True)
self._thread.finished.connect(self._updateData)
self._thread.start()
except Exception as e:
self.computeB.setEnabled(True)
raise e
def setDataset(self, dataset):
def setDataset(self, dataset, indices=None, bg_indices=None, bg_dataset=None):
"""
Dataset setter. Starts BSS class and initializes thread.
Dataset setter.
:param Dataset dataset: dataset
"""
self.dataset = dataset
self.BSS = BSS(self.dataset.hi_data)
self.indices = indices
self.bg_indices = bg_indices
self.bg_dataset = bg_dataset
self.computeB.pressed.connect(self._computePCA)
def _updateData(self):
......@@ -98,8 +93,7 @@ class PCAWidget(qt.QMainWindow):
"""
self._thread.finished.disconnect(self._updateData)
self.computeB.setEnabled(True)
mean, vecs, vals = self._thread.data
vals = [item for sublist in vals for item in sublist]
vals = self._thread.data
self._plot.show()
self._plot.addCurve(numpy.arange(len(vals)), vals, symbol='.', linestyle=' ')
self.sigComputed.emit()
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