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

bugfixes

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