Commit ca1b48a0 authored by JosefBrandt's avatar JosefBrandt
Browse files

Merge remote-tracking branch 'origin/RefactoringAnalysisModules' into RefactoringAnalysisModules

parents 3818cd8d 5c46290c
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -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
    return shape

def getParticleHeight(contour, dataset):
+2 −8
Original line number Diff line number Diff line
@@ -50,10 +50,7 @@ class BaseShape(object):
            
        self.solidity = area/hull_area
        
        try:
        long, short = self.getEllipseOrBoxLongAndShortSize()
        except InvalidParticleError:
            raise InvalidParticleError
        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
        
        mostFittingCriteria = 0
        bestFittingShape = 'unknown'
+8 −14
Original line number Diff line number Diff line
@@ -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():
        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])
                indicesOfTransferredAssignments[scanIndex] = scanIndex
        assert not None in indicesOfTransferredAssignments
    
    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():
        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])
                indicesOfTransferredHQIs[scanIndex] = scanIndex
        assert not None in indicesOfTransferredHQIs
    
    def reassignParticleToAssignment(self, particleIndex, newAssignment):
        particle = self.getParticleOfIndex(particleIndex)
+20 −23
Original line number Diff line number Diff line
@@ -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,7 +421,12 @@ 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()

@@ -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):