Commit 8e7707c0 authored by JosefBrandt's avatar JosefBrandt

Small Bugfixes / Optimizations

parent 3ad72d39
...@@ -6,3 +6,7 @@ gepard\.cfg ...@@ -6,3 +6,7 @@ gepard\.cfg
analysis/database_config\.txt analysis/database_config\.txt
*.so *.so
*.c
external/build/
...@@ -111,8 +111,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -111,8 +111,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.specNumberSelector = QtWidgets.QSpinBox() self.specNumberSelector = QtWidgets.QSpinBox()
self.specNumberSelector.setMinimumWidth(100) self.specNumberSelector.setMinimumWidth(100)
self.specNumberSelector.setMinimum(1) self.specNumberSelector.setMinimum(1)
numParticles = self.particleContainer.getNumberOfParticles() numSpectra = self.particleContainer.getNumberOfMeasurements()
self.specNumberSelector.setMaximum(numParticles) self.specNumberSelector.setMaximum(numSpectra)
self.jumpToSpecBtn = QtWidgets.QPushButton('Jump To Spectrum of Number:') self.jumpToSpecBtn = QtWidgets.QPushButton('Jump To Spectrum of Number:')
self.jumpToSpecBtn.released.connect(self.jumpToIndicatedSpectrum) self.jumpToSpecBtn.released.connect(self.jumpToIndicatedSpectrum)
...@@ -387,8 +387,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -387,8 +387,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.typeSelectorCombo.addItems(uniquePolymers) self.typeSelectorCombo.addItems(uniquePolymers)
self.typeSelectorCombo.currentIndexChanged.connect(self.setTypeSelector) self.typeSelectorCombo.currentIndexChanged.connect(self.setTypeSelector)
numParticles = self.particleContainer.getNumberOfParticles() numSpectra = self.particleContainer.getNumberOfMeasurements()
self.specNumberSelector.setMaximum(numParticles) self.specNumberSelector.setMaximum(numSpectra)
def initializeSpecPlot(self): def initializeSpecPlot(self):
self.specPlot.loadSpectraAndInitializeSpecPlot() self.specPlot.loadSpectraAndInitializeSpecPlot()
...@@ -531,7 +531,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -531,7 +531,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.particleSelector.setValue(partIndices.index(particleIndex)+1) self.particleSelector.setValue(partIndices.index(particleIndex)+1)
specIndices = self.particleContainer.getSpectraIndicesOfParticle(self.currentParticleIndex) specIndices = self.particleContainer.getSpectraIndicesOfParticle(self.currentParticleIndex)
self.spectrumSelector.setValue(1) self.spectrumSelector.setValue(1)
self.spectrumSelector.setMaximum(len(specIndices)) self.spectrumSelector.setMaximum(len(specIndices))
......
...@@ -176,6 +176,9 @@ class ParticleContainer(object): ...@@ -176,6 +176,9 @@ class ParticleContainer(object):
def getNumberOfParticles(self): def getNumberOfParticles(self):
return len(self.particles) return len(self.particles)
def getNumberOfMeasurements(self):
return len(self.measurements)
def getParticleContours(self): def getParticleContours(self):
contours = [part.contour for part in self.particles] contours = [part.contour for part in self.particles]
return contours return contours
......
...@@ -166,7 +166,7 @@ class ParticlePainter(QtWidgets.QGraphicsItem): ...@@ -166,7 +166,7 @@ class ParticlePainter(QtWidgets.QGraphicsItem):
painter.drawEllipse(p[0]-p[2], p[1]-p[2], 2*p[2], 2*p[2]) painter.drawEllipse(p[0]-p[2], p[1]-p[2], 2*p[2], 2*p[2])
if self.pixmap is not None: if self.pixmap is not None:
painter.setOpacity(0.6) painter.setOpacity(0.4)
painter.drawPixmap(self.topLeft[1], self.topLeft[0], self.pixmap) painter.drawPixmap(self.topLeft[1], self.topLeft[0], self.pixmap)
......
...@@ -252,6 +252,9 @@ class DataSet(object): ...@@ -252,6 +252,9 @@ class DataSet(object):
self.particleContainer.clearMeasurements() self.particleContainer.clearMeasurements()
if self.particles2spectra is None:
self.particles2spectra = [[int(np.where(self.ramanscansortindex == i)[0])] for i in range(len(self.ramanscansortindex))]
if len(self.particlestats) > 0: #i.e., particle detection was completed and particle data is there if len(self.particlestats) > 0: #i.e., particle detection was completed and particle data is there
self.particleDetectionDone = True self.particleDetectionDone = True
for particleIndex, listOfScanIndices in enumerate(self.particles2spectra): for particleIndex, listOfScanIndices in enumerate(self.particles2spectra):
...@@ -259,11 +262,12 @@ class DataSet(object): ...@@ -259,11 +262,12 @@ class DataSet(object):
curParticle.measurements = [] curParticle.measurements = []
for scanIndex in listOfScanIndices: for scanIndex in listOfScanIndices:
indexOfNewMeas = self.particleContainer.addEmptyMeasurement() indexOfNewMeas = self.particleContainer.addEmptyMeasurement()
x, y = self.ramanpoints[indexOfNewMeas][0], self.ramanpoints[indexOfNewMeas][1] indexOfMeasInRamanPoints = self.ramanscansortindex[scanIndex]
x, y = self.ramanpoints[indexOfMeasInRamanPoints][0], self.ramanpoints[indexOfMeasInRamanPoints][1]
self.particleContainer.setMeasurementPixelCoords(indexOfNewMeas, x, y) self.particleContainer.setMeasurementPixelCoords(indexOfNewMeas, x, y)
self.particleContainer.setMeasurementScanIndex(indexOfNewMeas, scanIndex) self.particleContainer.setMeasurementScanIndex(indexOfNewMeas, scanIndex)
curParticle.addMeasurement(self.particleContainer.measurements[indexOfNewMeas]) curParticle.addMeasurement(self.particleContainer.measurements[indexOfNewMeas])
for particle in self.particleContainer.particles: for particle in self.particleContainer.particles:
for meas in particle.measurements: for meas in particle.measurements:
specIndex = meas.getScanIndex() specIndex = meas.getScanIndex()
......
...@@ -672,7 +672,6 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -672,7 +672,6 @@ class ParticleDetectionView(QtWidgets.QWidget):
particleContainer.setMeasurementPixelCoords(indexOfNewMeas, point.x, point.y) particleContainer.setMeasurementPixelCoords(indexOfNewMeas, point.x, point.y)
curParticle.addMeasurement(particleContainer.measurements[indexOfNewMeas]) curParticle.addMeasurement(particleContainer.measurements[indexOfNewMeas])
self.dataset.ramanpoints = measurementPoints
self.dataset.particleDetectionDone = True self.dataset.particleDetectionDone = True
self.dataset.mode = "prepareraman" self.dataset.mode = "prepareraman"
self.dataset.save() self.dataset.save()
......
...@@ -329,8 +329,8 @@ if __name__ == '__main__': ...@@ -329,8 +329,8 @@ if __name__ == '__main__':
logname = os.path.join(logpath, 'logfile.txt') logname = os.path.join(logpath, 'logfile.txt')
fp = open(logname, "a") fp = open(logname, "a")
# sys.stderr = fp sys.stderr = fp
# sys.stdout = fp sys.stdout = fp
print("starting GEPARD at: " + strftime("%d %b %Y %H:%M:%S", localtime()), flush=True) print("starting GEPARD at: " + strftime("%d %b %Y %H:%M:%S", localtime()), flush=True)
gepard = GEPARDMainWindow(logpath) gepard = GEPARDMainWindow(logpath)
......
...@@ -234,7 +234,6 @@ class RamanScanUI(QtWidgets.QWidget): ...@@ -234,7 +234,6 @@ class RamanScanUI(QtWidgets.QWidget):
for measIndex, ramanScanIndex in enumerate(cmin): for measIndex, ramanScanIndex in enumerate(cmin):
self.dataset.particleContainer.setMeasurementScanIndex(measIndex, ramanScanIndex) self.dataset.particleContainer.setMeasurementScanIndex(measIndex, ramanScanIndex)
self.dataset.ramanscansortindex = cmin
self.view.saveDataSet() self.view.saveDataSet()
self.view.prepareAnalysis() self.view.prepareAnalysis()
self.view.scaleImage(2.0) self.view.scaleImage(2.0)
......
...@@ -555,18 +555,11 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -555,18 +555,11 @@ class SampleView(QtWidgets.QGraphicsView):
def prepareAnalysis(self): def prepareAnalysis(self):
self.clearItems() self.clearItems()
if self.dataset.particleDetectionDone: if self.dataset.particleDetectionDone:
data = [] for meas in self.dataset.particleContainer.measurements:
for i in self.dataset.ramanscansortindex: number = meas.ramanScanIndex+1
data.append(list(self.dataset.ramanpoints[i])) item = RamanScanIndicator(self, number, 20, (meas.pixelcoord_x, meas.pixelcoord_y))
for i in range(len(data)):
item = RamanScanIndicator(self, i+1, 20, (data[i][0],data[i][1]))
self.scene().addItem(item) self.scene().addItem(item)
self.ramanscanitems.append(item) self.ramanscanitems.append(item)
# for index, meas in enumerate(self.dataset.particleContainer.measurements):
# number = meas.ramanScanIndex+1
# item = RamanScanIndicator(self, number, 20, (meas.pixelcoord_x, meas.pixelcoord_y))
# self.scene().addItem(item)
# self.ramanscanitems.append(item)
def resetParticleContours(self): def resetParticleContours(self):
t0 = time.time() t0 = time.time()
......
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