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

[gui][pca] Remove maxComponents and compute widgets

parent a06eef62
......@@ -26,7 +26,7 @@
__authors__ = ["J. Garriga"]
__license__ = "MIT"
__date__ = "08/04/2020"
__date__ = "22/12/2020"
import numpy
......@@ -47,32 +47,15 @@ class PCAWidget(qt.QMainWindow):
self._plot = Plot1D()
self._plot.setDataMargins(0.05, 0.05, 0.05, 0.05)
maxNComponentsLabel = qt.QLabel("Max number of components:")
self.maxNumComp = qt.QLineEdit("")
self.maxNumComp.setToolTip("Maximum number of components to compute")
self.maxNumComp.setValidator(qt.QDoubleValidator())
self.computeB = qt.QPushButton("Compute")
widget = qt.QWidget(parent=self)
layout = qt.QGridLayout()
layout.addWidget(maxNComponentsLabel, 0, 0, 1, 1)
layout.addWidget(self.maxNumComp, 0, 1, 1, 1)
layout.addWidget(self.computeB, 0, 2, 1, 1)
layout.addWidget(self._plot, 1, 0, 1, 3)
widget.setLayout(layout)
widget.setSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)
self.setCentralWidget(widget)
self._plot.hide()
self.setCentralWidget(self._plot)
def _computePCA(self):
self.computeB.setEnabled(False)
try:
self._thread = OperationThread(self, 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, indices=None, bg_indices=None, bg_dataset=None):
......@@ -85,14 +68,13 @@ class PCAWidget(qt.QMainWindow):
self.indices = indices
self.bg_indices = bg_indices
self.bg_dataset = bg_dataset
self.computeB.pressed.connect(self._computePCA)
self._computePCA()
def _updateData(self):
"""
Plots the eigenvalues.
"""
self._thread.finished.disconnect(self._updateData)
self.computeB.setEnabled(True)
vals = self._thread.data
self._plot.show()
self._plot.addCurve(numpy.arange(len(vals)), vals, symbol='.', linestyle=' ')
......
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