Commit a1f9b4a1 authored by Josef Brandt's avatar Josef Brandt

Bugfix in setting up measurement and loading results

parent 75473df2
......@@ -121,7 +121,7 @@ class LoadTrueMatchResults(QtWidgets.QWidget):
print('spectra in batch:', len(resBatch))
for result in resBatch:
specIndex, polymertype, additive, hqi, addhqi = self.interpretEntry(resBatchIndex, numSpectraInPreviousBatches, result, numhits, numcomps)
print('assigning currentSpecIndex', specIndex)
self.polymertypes[specIndex] = polymertype
self.hqis[specIndex] = hqi
if numcomps > 1:
......@@ -154,6 +154,7 @@ class LoadTrueMatchResults(QtWidgets.QWidget):
#specNameFormat is: SampleName_000_Spec.Data 1 (SpecIndex)
specName = result[0]
curSpecIndex = self.getSpecIndexFromName(specName)
specIndex = numSpectraInPreviousBatches + curSpecIndex
#find yes-flags
......@@ -207,15 +208,37 @@ class LoadTrueMatchResults(QtWidgets.QWidget):
return specIndex, polymertype, additive, float(hqi), float(addhqi)
def getSpecIndexFromName(self, specName):
number = ''
for i in reversed(range(len(specName))):
if specName[i] == ')':
continue
if specName[i] != '(':
number = specName[i] + number
def specNameHasBrackets():
if specName.find('(') != -1 and specName.find(')') != -1:
return True
else:
break
return int(number)
return False
def isNumber(string):
try:
int(string)
return True
except:
return False
index = ''
if specNameHasBrackets():
for i in reversed(range(len(specName))):
if specName[i] == ')':
continue
if specName[i] != '(':
index = specName[i] + index
else:
break
index = int(index)
else:
for i in reversed(range(len(specName))):
if isNumber(specName[i]):
index = specName[i] + index
else:
break
index = int(index) - 1
return index
def closeEvent(self, event):
for win in [self.editEntryWindow, self.sortWindow]:
......
......@@ -22,9 +22,11 @@ import os
import pickle
import numpy as np
import sys
import cv2
from copy import copy
from .analysis.particleContainer import ParticleContainer
from .legacyConvert import legacyConversion, currentVersion
from .helperfunctions import cv2imwrite_fix, cv2imread_fix
# for legacy pickle import the old module name dataset must be found
# (no relative import)
from . import dataset
......@@ -44,6 +46,8 @@ def loadData(fname):
retds.__dict__.update(ds.__dict__)
if retds.version < currentVersion:
legacyConversion(retds)
elif retds.zvalimg=="saved":
retds.loadZvalImg()
return retds
def saveData(dataset, fname):
......@@ -174,9 +178,15 @@ class DataSet(object):
if self.zvalimg is not None:
cv2imwrite_fix(self.getZvalImageName(), self.zvalimg)
self.zvalimg = "saved"
def loadZvalImg(self):
if os.path.exists(self.getZvalImageName()):
self.zvalimg = cv2imread_fix(self.getZvalImageName(), cv2.IMREAD_GRAYSCALE)
def getZval(self, pixelpos):
assert self.zvalimg is not None
if self.zvalimg == "saved":
self.loadZvalImg()
i, j = int(round(pixelpos[1])), int(round(pixelpos[0]))
if i>=self.zvalimg.shape[0]:
print('error in getZval:', self.zvalimg.shape, i, j)
......
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