Commit 545f462e authored by Lars Bittrich's avatar Lars Bittrich

bugfixes

parent 15c7be2e
...@@ -220,9 +220,11 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -220,9 +220,11 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.layout.addLayout(self.menuLayout) self.layout.addLayout(self.menuLayout)
self.layout.addLayout(viewLayout) self.layout.addLayout(viewLayout)
if self.datastats.config['minHQI'] is not None: minHQI = self.datastats.dataset.resultParams['minHQI']
self.hqiSpinBox.setValue(self.datastats.config['minHQI']) compHQI = self.datastats.dataset.resultParams['compHQI']
self.compHqiSpinBox.setValue(self.datastats.config['compHQI']) if minHQI is not None:
self.hqiSpinBox.setValue(minHQI)
self.compHqiSpinBox.setValue(compHQI)
self.createActions() self.createActions()
self.createMenus() self.createMenus()
......
...@@ -21,7 +21,7 @@ If not, see <https://www.gnu.org/licenses/>. ...@@ -21,7 +21,7 @@ If not, see <https://www.gnu.org/licenses/>.
import os import os
import numpy as np import numpy as np
import operator import operator
from dataset import loadData from dataset import loadData, recursiveDictCompare
def readDataStats(fname): def readDataStats(fname):
...@@ -38,7 +38,6 @@ def readDataStats(fname): ...@@ -38,7 +38,6 @@ def readDataStats(fname):
class DataStats(object): class DataStats(object):
def __init__(self, dataset): def __init__(self, dataset):
self.dataset = dataset self.dataset = dataset
self.config = dataset.resultParams
self.spectraResults = None #entire List of all spectra assignments self.spectraResults = None #entire List of all spectra assignments
self.additiveResults = None #entire List of all additives self.additiveResults = None #entire List of all additives
...@@ -209,11 +208,12 @@ class DataStats(object): ...@@ -209,11 +208,12 @@ class DataStats(object):
self.dataset.resultParams = {'minHQI': minHQI, self.dataset.resultParams = {'minHQI': minHQI,
'compHQI': compHQI} 'compHQI': compHQI}
self.dataset.save() self.dataset.save()
print('saved dataset; Valid:', self.testRead()) testresult = self.testRead()
print('saved dataset; Valid:', testresult)
return testresult
def testRead(self): def testRead(self):
statsread = readDataStats(self.dataset.fname) statsread = readDataStats(self.dataset.fname)
return statsread.__dict__ == self.__dict__ return recursiveDictCompare(self.__dict__, statsread.__dict__)
\ No newline at end of file
...@@ -261,7 +261,12 @@ class LoadWITecResults(QtWidgets.QDialog): ...@@ -261,7 +261,12 @@ class LoadWITecResults(QtWidgets.QDialog):
self.parent.updateBtn.clicked.connect(self.parent.formatResults) self.parent.updateBtn.clicked.connect(self.parent.formatResults)
self.parent.formatResults() self.parent.formatResults()
self.parent.show_hide_labels() self.parent.show_hide_labels()
self.parent.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value()
compHQI = self.parent.compHqiSpinBox.value()
if not self.parent.datastats.saveAnalysisResults(minHQI, compHQI):
QtWidgets.QMessageBox.warning(self.parent, 'Error!',
'Data inconsistency after saving!',
QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
self.parent.setEnabled(True) self.parent.setEnabled(True)
event.accept() event.accept()
......
...@@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License ...@@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
along with this program, see COPYING. along with this program, see COPYING.
If not, see <https://www.gnu.org/licenses/>. If not, see <https://www.gnu.org/licenses/>.
""" """
import numpy as np import numpy as np
import cv2 import cv2
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
...@@ -134,7 +135,12 @@ class ParticleEditor(object): ...@@ -134,7 +135,12 @@ class ParticleEditor(object):
del self.datastats.dataset.particles2spectra[index] del self.datastats.dataset.particles2spectra[index]
#save data #save data
self.datastats.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value()
compHQI = self.parent.compHqiSpinBox.value()
if not self.datastats.saveAnalysisResults(minHQI, compHQI):
QtWidgets.QMessageBox.warning(self.parent, 'Error!',
'Data inconsistency after saving!', QtWidgets.QMessageBox.Ok,
QtWidgets.QMessageBox.Ok)
#update contours in sampleview #update contours in sampleview
self.parent.parent.contouritem.resetContours(self.datastats.dataset.particlecontours) self.parent.parent.contouritem.resetContours(self.datastats.dataset.particlecontours)
...@@ -156,7 +162,12 @@ class ParticleEditor(object): ...@@ -156,7 +162,12 @@ class ParticleEditor(object):
self.datastats.hqis[specIndex] = 100 self.datastats.hqis[specIndex] = 100
#save data #save data
self.datastats.saveAnalysisResults() minHQI = self.parent.hqiSpinBox.value()
compHQI = self.parent.compHqiSpinBox.value()
if not self.datastats.saveAnalysisResults(minHQI, compHQI):
QtWidgets.QMessageBox.warning(self.parent, 'Error!',
'Data inconsistency after saving!',
QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
self.parent.loadParticleData() self.parent.loadParticleData()
......
...@@ -54,7 +54,6 @@ def saveData(dataset, fname): ...@@ -54,7 +54,6 @@ def saveData(dataset, fname):
dataset.zvalimg = zvalimg dataset.zvalimg = zvalimg
def arrayCompare(a1, a2): def arrayCompare(a1, a2):
print("array compare")
ind = np.isnan(a1) ind = np.isnan(a1)
if not np.any(ind): if not np.any(ind):
return np.all(a1==a2) return np.all(a1==a2)
...@@ -63,7 +62,6 @@ def arrayCompare(a1, a2): ...@@ -63,7 +62,6 @@ def arrayCompare(a1, a2):
return np.all(a1[~ind]==a2[~ind]) return np.all(a1[~ind]==a2[~ind])
def listCompare(l1, l2): def listCompare(l1, l2):
print("list compare")
if len(l1)!=len(l2): if len(l1)!=len(l2):
return False return False
for l1i, l2i in zip(l1, l2): for l1i, l2i in zip(l1, l2):
...@@ -86,16 +84,20 @@ def recursiveDictCompare(d1, d2): ...@@ -86,16 +84,20 @@ def recursiveDictCompare(d1, d2):
print(key, type(a), type(b)) print(key, type(a), type(b))
if isinstance(a, np.ndarray): if isinstance(a, np.ndarray):
if not isinstance(b, np.ndarray) or not arrayCompare(a, b): if not isinstance(b, np.ndarray) or not arrayCompare(a, b):
print("data is different!", a, b)
return False return False
elif isinstance(a, dict): elif isinstance(a, dict):
if not isinstance(b, dict): if not isinstance(b, dict):
print("data is different!", a, b)
return False return False
if not recursiveDictCompare(a, b): if not recursiveDictCompare(a, b):
return False return False
elif isinstance(a, (list, tuple)): elif isinstance(a, (list, tuple)):
if not isinstance(b, (list, tuple)) or not listCompare(a, b): if not isinstance(b, (list, tuple)) or not listCompare(a, b):
print("data is different!", a, b)
return False return False
elif a != b: elif a != b:
print("data is different!", a, b)
return False return False
return True return True
......
...@@ -122,14 +122,14 @@ class SegmentationContours(QtWidgets.QGraphicsItem): ...@@ -122,14 +122,14 @@ class SegmentationContours(QtWidgets.QGraphicsItem):
for index in self.selectedContours: for index in self.selectedContours:
# partIndex = int(np.where(self.parent.dataset.ramanscansortindex == index)[0]) # partIndex = int(np.where(self.parent.dataset.ramanscansortindex == index)[0])
partIndex = index partIndex = index
assignments.append(self.analysiswidget.datastats.particleResults[partIndex]) assignments.append(self.parent.analysiswidget.datastats.particleResults[partIndex])
assignments.append("other") assignments.append("other")
for assignment in np.unique(np.array(assignments)): for assignment in np.unique(np.array(assignments)):
combineActs.append(combineMenu.addAction(assignment)) combineActs.append(combineMenu.addAction(assignment))
reassignActs = [] reassignActs = []
reassignMenu = QtWidgets.QMenu("Reassign particle(s) into") reassignMenu = QtWidgets.QMenu("Reassign particle(s) into")
for polymer in self.analysiswidget.datastats.getUniquePolymers(): for polymer in self.parent.analysiswidget.datastats.getUniquePolymers():
reassignActs.append(reassignMenu.addAction(polymer)) reassignActs.append(reassignMenu.addAction(polymer))
reassignActs.append(reassignMenu.addAction("other")) reassignActs.append(reassignMenu.addAction("other"))
...@@ -156,7 +156,7 @@ class SegmentationContours(QtWidgets.QGraphicsItem): ...@@ -156,7 +156,7 @@ class SegmentationContours(QtWidgets.QGraphicsItem):
# QtWidgets.QMessageBox.about(self.parent, "Not yet implemented", "we are getting there...") # QtWidgets.QMessageBox.about(self.parent, "Not yet implemented", "we are getting there...")
# return # return
self.analysiswidget.editor.combineParticles(self.selectedContours, newAssignment) self.parent.analysiswidget.editor.combineParticles(self.selectedContours, newAssignment)
elif action in reassignActs: elif action in reassignActs:
newAssignment = action.text() newAssignment = action.text()
...@@ -164,7 +164,7 @@ class SegmentationContours(QtWidgets.QGraphicsItem): ...@@ -164,7 +164,7 @@ class SegmentationContours(QtWidgets.QGraphicsItem):
# QtWidgets.QMessageBox.about(self.parent, "Not yet implemented", "we are getting there...") # QtWidgets.QMessageBox.about(self.parent, "Not yet implemented", "we are getting there...")
# return # return
self.analysiswidget.editor.reassignParticles(self.selectedContours, newAssignment) self.parent.analysiswidget.editor.reassignParticles(self.selectedContours, newAssignment)
class FitPosIndicator(QtWidgets.QGraphicsItem): class FitPosIndicator(QtWidgets.QGraphicsItem):
......
Markdown is supported
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