Commit 86522ed2 authored by Hackmet's avatar Hackmet

Several Bugfixes

parent 8e5899e5
...@@ -336,9 +336,9 @@ class ParticleAnalysis(QtWidgets.QWidget): ...@@ -336,9 +336,9 @@ class ParticleAnalysis(QtWidgets.QWidget):
self.specCanvas.draw() self.specCanvas.draw()
####fake data!!! ####fake data!!!
if self.spectraResults is None: # if self.spectraResults is None:
self.spectraResults = ['empty']*(self.spectra.shape[1]-1) # self.spectraResults = ['empty']*(self.spectra.shape[1]-1)
self.hqis = [100]*(self.spectra.shape[1]-1) # self.hqis = [100]*(self.spectra.shape[1]-1)
self.loadParticleData() self.loadParticleData()
...@@ -362,7 +362,16 @@ class ParticleAnalysis(QtWidgets.QWidget): ...@@ -362,7 +362,16 @@ class ParticleAnalysis(QtWidgets.QWidget):
#check, if dataset already contains results. Otherwise load them... #check, if dataset already contains results. Otherwise load them...
if self.spectraResults is None or (len(self.spectraResults) != len(sortindices)): if self.spectraResults is None or (len(self.spectraResults) != len(sortindices)):
QtWidgets.QMessageBox.about(self, 'Info', 'No (or inconsistent) spectra results found, please run import dialog.') self.show()
# QtWidgets.QMessageBox.about(self, 'Info', 'No (or inconsistent) spectra results found, please run import dialog.')
answer = QtWidgets.QMessageBox.question(self, 'Warning', 'No (or inconsistent) spectra results found, please run import dialog.\nPress OK to import or cancel to set to empty.', QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
if answer == QtWidgets.QMessageBox.Ok:
self.importResults()
elif answer == QtWidgets.QMessageBox.Cancel:
self.spectraResults = ['empty']*(self.spectra.shape[1]-1)
self.hqis = [100]*(self.spectra.shape[1]-1)
self.updateBtn.clicked.connect(self.formatResults)
self.formatResults()
else: else:
self.updateBtn.clicked.connect(self.formatResults) self.updateBtn.clicked.connect(self.formatResults)
self.formatResults() self.formatResults()
...@@ -383,6 +392,7 @@ class ParticleAnalysis(QtWidgets.QWidget): ...@@ -383,6 +392,7 @@ class ParticleAnalysis(QtWidgets.QWidget):
self.additivePlot.show() self.additivePlot.show()
def formatResults(self): def formatResults(self):
if self.spectraResults is not None:
print('formatResults') print('formatResults')
self.updateBtn.setDisabled(False) self.updateBtn.setDisabled(False)
self.optionsGroup.setDisabled(False) self.optionsGroup.setDisabled(False)
......
...@@ -77,7 +77,7 @@ class ParticleEditor(object): ...@@ -77,7 +77,7 @@ class ParticleEditor(object):
cv2.drawContours(img, [cnt], 0, 1, 1) cv2.drawContours(img, [cnt], 0, 1, 1)
img = np.uint8(cv2.morphologyEx(img, cv2.MORPH_CLOSE, np.ones((3, 3)))) img = np.uint8(cv2.morphologyEx(img, cv2.MORPH_CLOSE, np.ones((3, 3))))
temp, contours, hierarchy = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) temp, contours, hierarchy = cv2.findContours(img, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)
newContour = contours[0] newContour = contours[0]
stats = self.characterizeParticle(newContour) stats = self.characterizeParticle(newContour)
......
...@@ -75,6 +75,7 @@ class DataSet(object): ...@@ -75,6 +75,7 @@ class DataSet(object):
# parameters specifically for raman scan # parameters specifically for raman scan
self.pshift = None # shift of raman scan position relative to image center self.pshift = None # shift of raman scan position relative to image center
self.coordOffset = [0, 0] #offset of entire coordinate system
self.seedpoints = np.array([]) self.seedpoints = np.array([])
self.seeddeletepoints = np.array([]) self.seeddeletepoints = np.array([])
self.detectParams = {'points': np.array([[50,0],[100,200],[200,255]]), self.detectParams = {'points': np.array([[50,0],[100,200],[200,255]]),
...@@ -230,6 +231,9 @@ class DataSet(object): ...@@ -230,6 +231,9 @@ class DataSet(object):
if not force: if not force:
assert not self.readin assert not self.readin
p0 = copy(self.lastpos) p0 = copy(self.lastpos)
p0[0] += self.coordOffset[0]
p0[1] += self.coordOffset[1]
if mode == 'df': if mode == 'df':
p0[0] -= self.imagedim_df[0]/2 p0[0] -= self.imagedim_df[0]/2
p0[1] += self.imagedim_df[1]/2 p0[1] += self.imagedim_df[1]/2
......
...@@ -173,6 +173,14 @@ class MeasureParticleWindow(QtWidgets.QMainWindow): ...@@ -173,6 +173,14 @@ class MeasureParticleWindow(QtWidgets.QMainWindow):
self.snapshotAct.triggered.connect(self.view.takeScreenshot) self.snapshotAct.triggered.connect(self.view.takeScreenshot)
self.snapshotAct.setDisabled(True) self.snapshotAct.setDisabled(True)
self.checkCoordsAct = QtWidgets.QAction("Check Coordinate System", self)
self.checkCoordsAct.triggered.connect(self.view.checkCoords)
self.checkCoordsAct.setDisabled(True)
self.configCoordsAct = QtWidgets.QAction("Reconfigure Coordinate System", self)
self.configCoordsAct.triggered.connect(self.view.configureCoords)
self.configCoordsAct.setDisabled(True)
self.configRamanCtrlAct = QtWidgets.QAction("Configure Raman Control", self) self.configRamanCtrlAct = QtWidgets.QAction("Configure Raman Control", self)
self.configRamanCtrlAct.triggered.connect(self.view.configureRamanControl) self.configRamanCtrlAct.triggered.connect(self.view.configureRamanControl)
if self.view.simulatedRaman: if self.view.simulatedRaman:
...@@ -254,6 +262,9 @@ class MeasureParticleWindow(QtWidgets.QMainWindow): ...@@ -254,6 +262,9 @@ class MeasureParticleWindow(QtWidgets.QMainWindow):
self.toolsMenu = QtWidgets.QMenu("Tools") self.toolsMenu = QtWidgets.QMenu("Tools")
self.toolsMenu.addAction(self.snapshotAct) self.toolsMenu.addAction(self.snapshotAct)
self.toolsMenu.addAction(self.configRamanCtrlAct) self.toolsMenu.addAction(self.configRamanCtrlAct)
self.toolsMenu.addSeparator()
self.toolsMenu.addAction(self.checkCoordsAct)
self.toolsMenu.addAction(self.configCoordsAct)
self.helpMenu = QtWidgets.QMenu("&Help", self) self.helpMenu = QtWidgets.QMenu("&Help", self)
self.helpMenu.addAction(self.aboutAct) self.helpMenu.addAction(self.aboutAct)
......
...@@ -86,6 +86,7 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -86,6 +86,7 @@ class SampleView(QtWidgets.QGraphicsView):
self.setMinimumSize(600,600) self.setMinimumSize(600,600)
self.darkenPixmap = False self.darkenPixmap = False
self.microscopeMode = None self.microscopeMode = None
self.coordTestMode = False
def takeScreenshot(self): def takeScreenshot(self):
#TODO: #TODO:
...@@ -210,8 +211,14 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -210,8 +211,14 @@ class SampleView(QtWidgets.QGraphicsView):
def open(self, fname): def open(self, fname):
self.saveDataSet() self.saveDataSet()
if self.dataset is not None: #####TODO: properly close and delete all widget instances for avoiding that data from a currently opened dataset is saved into the new... if self.dataset is not None:
self.dataset.save() self.dataset.save()
#close all widgets
for widget in [self.detectionwidget, self.ramanwidget, self.oscanwidget, self.analysiswidget]:
widget.close()
widget.destroy()
self.contouritem.resetContours()
self.dataset = loadData(fname) self.dataset = loadData(fname)
self.setMicroscopeMode() self.setMicroscopeMode()
self.imparent.setWindowTitle(self.dataset.name + (" SIMULATION" if simulatedRaman else "")) self.imparent.setWindowTitle(self.dataset.name + (" SIMULATION" if simulatedRaman else ""))
...@@ -470,7 +477,11 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -470,7 +477,11 @@ class SampleView(QtWidgets.QGraphicsView):
self.analysiswidget.currentSpectrumIndex = specIndex self.analysiswidget.currentSpectrumIndex = specIndex
selectedPolymer = self.analysiswidget.currentPolymers[specIndex] selectedPolymer = self.analysiswidget.currentPolymers[specIndex]
try:
self.analysiswidget.polymerIndex = self.analysiswidget.uniquePolymers.index(selectedPolymer) self.analysiswidget.polymerIndex = self.analysiswidget.uniquePolymers.index(selectedPolymer)
except:
print(selectedPolymer)
raise
#subparticleIndex #subparticleIndex
partIndicesOfThatPolymer = self.analysiswidget.indices[self.analysiswidget.polymerIndex] partIndicesOfThatPolymer = self.analysiswidget.indices[self.analysiswidget.polymerIndex]
...@@ -545,3 +556,18 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -545,3 +556,18 @@ class SampleView(QtWidgets.QGraphicsView):
self.scene().removeItem(item) self.scene().removeItem(item)
self.ramanscanitems = [] self.ramanscanitems = []
def checkCoords(self):
if not os.path.exists(self.dataset.getImageName):
QtWidgets.QMessageBox.about(self, 'No Fullimage found', 'Optical scan was not complete.\nPlease acquire fullimage first with newly defined border points.')
else:
self.coordTestMode = True
QtWidgets.QMessageBox.about(self, 'Check Coordinate System', 'Microscope is moving to 5 positions.\nFirst, only x and y are moved, z only if x,y positions are confirmed')
points = (self.dataset.fitpoints if len(self.dataset.ramanpoints) == 0 else self.dataset.ramanpoints)
for i in range(5):
#get random scanindex:
point = points[np.random.randint(len(points))]
def configureCoords(self):
pass
\ No newline at end of file
...@@ -36,7 +36,7 @@ class SegmentationContours(QtWidgets.QGraphicsItem): ...@@ -36,7 +36,7 @@ class SegmentationContours(QtWidgets.QGraphicsItem):
def boundingRect(self): def boundingRect(self):
return self.brect return self.brect
def resetContours(self, contours): def resetContours(self, contours=[]):
cp = [] cp = []
x0 = None x0 = None
for c in contours: for c in contours:
......
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