Commit c90f7b26 authored by JosefBrandt's avatar JosefBrandt
Browse files

Several Bugfixes

parent 2026524b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ class SpectraPlot(QtWidgets.QGroupBox):
        layout = QtWidgets.QHBoxLayout()
        self.canvas = FigureCanvas(Figure())
        self.spec_axis = self.canvas.figure.subplots()
        self.reference_ax = self.spec_axis.twinx()
        self.reference_axis = self.spec_axis.twinx()
        self.canvas.figure.subplots_adjust(left=0.1, top=0.93, bottom=0.15, right=0.9)
        specNavigation = NavigationToolbar(self.canvas, self)
        specNavigation.setOrientation(QtCore.Qt.Vertical)
+13 −1
Original line number Diff line number Diff line
@@ -60,12 +60,24 @@ def getParticleStatsWithPixelScale(cnt, fullimage, dataset):
    
    newStats.height = getParticleHeight(cnt, dataset)    
    newStats.shape = getParticleShape(cnt, newStats.height)
    if newStats.shape == 'fibre':
        newStats.longSize, newStats.shortSize = getFibreDimension(cnt)
        newStats.longSize *= pixelscale
        newStats.shortSize *= pixelscale
    
    partImg = getParticleImageFromFullimage(cnt, fullimage)
    newStats.color = getParticleColor(partImg)
    
    return newStats

def getFibreDimension(contour):
    longSize = cv2.arcLength(contour, True)/2
    img = contoursToImg([contour])[0]
    dist = cv2.distanceTransform(img, cv2.DIST_L2, 3)
    maxThickness = np.max(dist)*2
    return longSize, maxThickness
    
    

def getParticleColor(imgRGB, colorClassifier=None):
    img = cv2.cvtColor(imgRGB, cv2.COLOR_RGB2HSV_FULL)
    meanHSV = cv2.mean(img)
+8 −2
Original line number Diff line number Diff line
@@ -180,12 +180,14 @@ class ParticleEditor(QtCore.QObject):
        for partIndex in contourindices:
            self.particleContainer.reassignParticleToAssignment(partIndex, newAssignment)
        
        self.viewparent.updateParticleInfoBox(partIndex)
        self.particleAssignmentChanged.emit()
     
    @QtCore.pyqtSlot(list, str)
    def paintParticles(self, contourIndices, newAssignment):
        print(f'painting indices {contourIndices} into {newAssignment}')
        self.createSafetyBackup()
        self.viewparent.removeParticleInfoBox()
        self.storedIndices = contourIndices
        self.storedAssignmend = newAssignment
        
@@ -208,6 +210,7 @@ class ParticleEditor(QtCore.QObject):
        except NotConnectedContoursError:
            QtWidgets.QMessageBox.critical(self.viewparent, 'ERROR!', 
                                       'Particle contours are not connected.\nThat is currently not supported!')
            self.viewparent.updateParticleInfoBox(self.storedIndices[-1])
            self.storedIndices = []
            self.storedAssignmend = None
            self.destroyParticlePainter()
@@ -238,6 +241,7 @@ class ParticleEditor(QtCore.QObject):
        
        self.viewparent.resetContourIndices()
        self.particleContainer.resetParticleIndices()
        self.viewparent.updateParticleInfoBox(self.particleContainer.getNumberOfParticles()-1)
        self.particleAssignmentChanged.emit()
    
    @QtCore.pyqtSlot(list, str)
@@ -245,12 +249,14 @@ class ParticleEditor(QtCore.QObject):
        print(f'changing color of particles {contourIndices} into {newColor}')
        for partIndex in contourIndices:
            self.particleContainer.changeParticleColor(partIndex, newColor)
        self.viewparent.updateParticleInfoBox(partIndex)
            
    @QtCore.pyqtSlot(list, str)
    def changeParticleShapes(self, contourIndices, newShape):
        print(f'changing shape of particles {contourIndices} into {newShape}')
        for partIndex in contourIndices:
            self.particleContainer.changeParticleShape(partIndex, newShape)
        self.viewparent.updateParticleInfoBox(partIndex)
    
    @QtCore.pyqtSlot(list)
    def deleteParticles(self, contourIndices):
+2 −2
Original line number Diff line number Diff line
@@ -352,8 +352,8 @@ if __name__ == '__main__':
        logname = os.path.join(logpath, 'logfile.txt')

        fp = open(logname, "a")
#        sys.stderr = fp
#        sys.stdout = fp
        sys.stderr = fp
        sys.stdout = fp
    print("starting GEPARD at: " + strftime("%d %b %Y %H:%M:%S", localtime()), flush=True)
    
    gepard = GEPARDMainWindow(logpath)
+5 −0
Original line number Diff line number Diff line
@@ -191,6 +191,11 @@ def updateParticleStats(dset):
            except InvalidParticleError:
                markForDeletion(particle)
            
            if particle.shape == 'fibre':
                particle.longSize, particle.shortSize = pc.getFibreDimension(particle.contour)
                particle.longSize *= dset.getPixelScale()
                particle.shortSize *= dset.getPixelScale()
            
    print(f'deleting {len(deleteIndices)} particles')
    for index in sorted(deleteIndices, reverse=True):
        dset.particleContainer.removeParticle(index)
Loading