Commit 5c46290c authored by JosefBrandt's avatar JosefBrandt

Fix in loading TrueMatch results

parent 1d7c4a61
......@@ -74,10 +74,7 @@ def getParticleColor(imgRGB, colorClassifier=None):
def getParticleShape(contour, particleHeight, shapeClassifier=None):
if shapeClassifier is None:
shapeClassifier = ShapeClassifier()
try:
shape = shapeClassifier.classifyShape(contour, particleHeight)
except InvalidParticleError:
raise
shape = shapeClassifier.classifyShape(contour, particleHeight)
return shape
def getParticleHeight(contour, dataset):
......
......@@ -50,10 +50,7 @@ class BaseShape(object):
self.solidity = area/hull_area
try:
long, short = self.getEllipseOrBoxLongAndShortSize()
except InvalidParticleError:
raise InvalidParticleError
long, short = self.getEllipseOrBoxLongAndShortSize()
self.aspectRatio = long/short
avgLength = (long+short)/2
......@@ -138,10 +135,7 @@ class ShapeClassifier(object):
newShape = BaseShape()
newShape.contour = contour
newShape.height = particleHeight
try:
newShape.getParticleCharacteristics()
except InvalidParticleError:
raise InvalidParticleError
newShape.getParticleCharacteristics()
mostFittingCriteria = 0
bestFittingShape = 'unknown'
......
......@@ -134,23 +134,17 @@ class ParticleContainer(object):
def applyAssignmentListToParticleMeasurements(self, assignmentList):
'''AssignmentList is list of spectra assignments in order of spectra indices'''
indicesOfTransferredAssignments = [None]*len(assignmentList)
for particle in self.particles:
for meas in particle.getMeasurements():
scanIndex = meas.getScanIndex()
meas.setAssignment(assignmentList[scanIndex])
indicesOfTransferredAssignments[scanIndex] = scanIndex
assert not None in indicesOfTransferredAssignments
assert len(assignmentList) == len(self.measurements), f'assertion error in assignment of results: {len(assignmentList)} results for {len(self.measurements)} spectra...'
for meas in self.measurements:
scanIndex = meas.getScanIndex()
meas.setAssignment(assignmentList[scanIndex])
def applyHQIListToParticleMeasurements(self, hqiList):
'''HQI-List is list of spectra hqis in order of spectra indices'''
indicesOfTransferredHQIs = [None]*len(hqiList)
for particle in self.particles:
for meas in particle.getMeasurements():
scanIndex = meas.getScanIndex()
meas.setHQI(hqiList[scanIndex])
indicesOfTransferredHQIs[scanIndex] = scanIndex
assert not None in indicesOfTransferredHQIs
assert len(hqiList) == len(self.measurements), f'assertion error in assignment of hqis: {len(hqiList)} results for {len(self.measurements)} spectra...'
for meas in self.measurements:
scanIndex = meas.getScanIndex()
meas.setHQI(hqiList[scanIndex])
def reassignParticleToAssignment(self, particleIndex, newAssignment):
particle = self.getParticleOfIndex(particleIndex)
......
......@@ -81,7 +81,7 @@ class SampleView(QtWidgets.QGraphicsView):
self.boundaryitems = [[],[]]
self.scanitems = []
self.ramanscanitems = []
self.particleInfoBoxes = []
self.particleInfoBox = None
self.imgdata = None
self.isblocked = False
self.contourItems = []
......@@ -387,26 +387,19 @@ class SampleView(QtWidgets.QGraphicsView):
cnt.update()
if cnt.particleIndex not in self.selectedParticleIndices:
self.selectedParticleIndices.append(cnt.particleIndex)
addParticleInfoBox(cnt.particleIndex)
# addParticleInfoBox(cnt.particleIndex)
def removeContourFromSelection(cnt):
cnt.isSelected = False
cnt.update()
self.selectedParticleIndices.remove(cnt.particleIndex)
removeParticleInfoBox(cnt.particleIndex)
# removeParticleInfoBox(cnt.particleIndex)
def addParticleInfoBox(index):
newInfoBox = ParticleInfo(self.dataset.particleContainer.getParticleOfIndex(cnt.particleIndex))
self.particleInfoBoxes.append(newInfoBox)
self.scene().addItem(newInfoBox)
self.update()
def removeParticleInfoBox(index):
for infoBox in self.particleInfoBoxes:
if infoBox.particle.index == index:
self.scene().removeItem(infoBox)
self.particleInfoBoxes.remove(infoBox)
self.update()
def updateParticleInfoBox(index):
if self.particleInfoBox is not None:
self.scene().removeItem(self.particleInfoBox)
self.particleInfoBox = ParticleInfo(self.dataset.particleContainer.getParticleOfIndex(index))
self.scene().addItem(self.particleInfoBox)
p = self.mapToScene(event.pos())
p = QtCore.QPointF(p.x(), p.y())
......@@ -428,8 +421,13 @@ class SampleView(QtWidgets.QGraphicsView):
cnt.update()
if cnt.particleIndex in self.selectedParticleIndices:
self.selectedParticleIndices.remove(cnt.particleIndex)
removeParticleInfoBox(cnt.particleIndex)
if len(self.selectedParticleIndices) > 0:
updateParticleInfoBox(self.selectedParticleIndices[-1])
else:
self.scene().removeItem(self.particleInfoBox)
self.particleInfoBox = None
self.update()
def scaleImage(self, factor):
......@@ -499,7 +497,7 @@ class SampleView(QtWidgets.QGraphicsView):
self.item.setOpacity(1)
else:
self.item.setPiparticleInfoBoxesxmap(QtGui.QPixmap())
self.item.setPiparticleInfoBoxxmap(QtGui.QPixmap())
if self.mode == "OpticalScan":
for i, p in zip(self.dataset.fitindices, self.dataset.fitpoints):
p = self.dataset.mapToPixel(p, mode=microscope_mode, force=True)
......@@ -616,12 +614,11 @@ class SampleView(QtWidgets.QGraphicsView):
self.contourItems[index].isSelected = True
self.selectedParticleIndices =[index]
for infoBox in self.particleInfoBoxes:
self.scene().removeItem(infoBox)
if self.particleInfoBox is not None:
self.scene().removeItem(self.particleInfoBox)
newInfoBox = ParticleInfo(self.dataset.particleContainer.getParticleOfIndex(index))
self.particleInfoBoxes = [newInfoBox]
self.scene().addItem(newInfoBox)
self.particleInfoBox = ParticleInfo(self.dataset.particleContainer.getParticleOfIndex(index))
self.scene().addItem(self.particleInfoBox)
self.update()
def centerOnRamanIndex(self, index, centerOn=True, highlightIndex=True):
......
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