Commit a8794a3c authored by JosefBrandt's avatar JosefBrandt Committed by Josef Brandt

Tidying up

parent d6af372b
__pycache__/
gepard\.cfg
analysis/database_config\.txt
*.so
...@@ -41,7 +41,6 @@ class ParticleIndicator(QtWidgets.QPushButton): ...@@ -41,7 +41,6 @@ class ParticleIndicator(QtWidgets.QPushButton):
qp = QtGui.QPainter() qp = QtGui.QPainter()
qp.begin(self) qp.begin(self)
#qp.fillRect(self.rect(), QtCore.Qt.white)
qp.setBrush(QtCore.Qt.white) qp.setBrush(QtCore.Qt.white)
qp.drawRoundedRect(0, 0, width, height, 5. ,5.) qp.drawRoundedRect(0, 0, width, height, 5. ,5.)
qp.setPen(self.color) qp.setPen(self.color)
...@@ -116,7 +115,6 @@ class SpectraPlot(QtWidgets.QGroupBox): ...@@ -116,7 +115,6 @@ class SpectraPlot(QtWidgets.QGroupBox):
layout = QtWidgets.QHBoxLayout() layout = QtWidgets.QHBoxLayout()
self.canvas = FigureCanvas(Figure()) self.canvas = FigureCanvas(Figure())
self.spec_axis = self.canvas.figure.subplots() self.spec_axis = self.canvas.figure.subplots()
self.spec_axis.axis("off")
self.reference_ax = self.spec_axis.twinx() self.reference_ax = self.spec_axis.twinx()
self.canvas.figure.subplots_adjust(left=0.1, top=0.93, bottom=0.15, right=0.9) self.canvas.figure.subplots_adjust(left=0.1, top=0.93, bottom=0.15, right=0.9)
specNavigation = NavigationToolbar(self.canvas, self) specNavigation = NavigationToolbar(self.canvas, self)
...@@ -127,21 +125,21 @@ class SpectraPlot(QtWidgets.QGroupBox): ...@@ -127,21 +125,21 @@ class SpectraPlot(QtWidgets.QGroupBox):
layout.addWidget(self.canvas) layout.addWidget(self.canvas)
self.setLayout(layout) self.setLayout(layout)
def loadSpectraAndInitializeSpecPlot(self): #formerly updateData(self).... def loadSpectraAndInitializeSpecPlot(self):
self.spectra = self.dataset.particleContainer.spectra self.spectra = self.dataset.particleContainer.getSpectraFromDisk()
assert self.spectra is not None
self.canvas.draw() self.canvas.draw()
def updateParticleSpectrum(self, specIndex, particleSize, hqi): def updateParticleSpectrum(self, specIndex, assignment, particleSize, hqi):
#draw Sample Spectrum
self.spec_axis.axis("on")
self.spec_axis.clear()
self.spec_axis.tick_params(axis='both', which='both', labelsize=15)
self.spec_axis.set_xlabel('Wavenumber (cm-1)', fontsize = 15)
self.spec_axis.set_ylabel('Counts', fontsize = 15)
if self.spectra is not None: if self.spectra is not None:
#draw Sample Spectrum
self.spec_axis.axis("on")
self.spec_axis.clear()
self.spec_axis.plot(self.spectra[:, 0], self.spectra[:, specIndex+1]) self.spec_axis.plot(self.spectra[:, 0], self.spectra[:, specIndex+1])
self.spec_axis.tick_params(axis='both', which='both', labelsize=15) self.spec_axis.set_title('{}, ScanPoint Number {}, Size = {} µm, HQI = {}'.format(assignment, specIndex+1, particleSize, hqi))
self.spec_axis.set_xlabel('Wavenumber (cm-1)', fontsize = 15)
self.spec_axis.set_ylabel('Counts', fontsize = 15)
self.spec_axis.set_title('ScanPoint Number {}, Size = {} µm, HQI = {}'.format(specIndex+1, particleSize, hqi))
self.spec_axis.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0])) self.spec_axis.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0]))
wavenumber_diff = list(self.spectra[:, 0]-100) wavenumber_diff = list(self.spectra[:, 0]-100)
y_start = wavenumber_diff.index(min(wavenumber_diff)) y_start = wavenumber_diff.index(min(wavenumber_diff))
...@@ -159,10 +157,6 @@ class SpectraPlot(QtWidgets.QGroupBox): ...@@ -159,10 +157,6 @@ class SpectraPlot(QtWidgets.QGroupBox):
self.reference_axis.set_ylabel('Ref. Intensity', fontsize = 15, color = 'r') self.reference_axis.set_ylabel('Ref. Intensity', fontsize = 15, color = 'r')
self.reference_axis.tick_params('y', colors = 'r') self.reference_axis.tick_params('y', colors = 'r')
self.reference_axis.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0])) self.reference_axis.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0]))
# wavenumber_diff = list(ref[:, 0]-100)
# y_start = wavenumber_diff.index(min(wavenumber_diff))
# y_min = min(ref[y_start:, specIndex+1])
# y_max = max(ref[y_start:, specIndex+1])
self.canvas.draw() self.canvas.draw()
......
...@@ -29,7 +29,7 @@ from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas ...@@ -29,7 +29,7 @@ from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from .analysiswidgets import ExpExcelDialog from .excelexport import ExpExcelDialog
from .analysisplots import TypeHistogramView, SpectraPlot from .analysisplots import TypeHistogramView, SpectraPlot
from .loadresults import LoadTrueMatchResults from .loadresults import LoadTrueMatchResults
from .database import DataBaseWindow from .database import DataBaseWindow
...@@ -45,7 +45,7 @@ except: ...@@ -45,7 +45,7 @@ except:
class ParticleAnalysis(QtWidgets.QMainWindow): class ParticleAnalysis(QtWidgets.QMainWindow):
def __init__(self, dataset, viewparent=None): def __init__(self, dataset, viewparent=None):
super(ParticleAnalysis, self).__init__(viewparent) super(ParticleAnalysis, self).__init__(viewparent)
self.setGeometry(100, 100, 1680, 1050) self.resize(1680, 1050)
self.setWindowTitle('Results of polymer analysis') self.setWindowTitle('Results of polymer analysis')
self.layout = QtWidgets.QHBoxLayout() self.layout = QtWidgets.QHBoxLayout()
self.widget = QtWidgets.QWidget() self.widget = QtWidgets.QWidget()
...@@ -56,7 +56,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -56,7 +56,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.dataset = dataset self.dataset = dataset
self.particleContainer = dataset.particleContainer self.particleContainer = dataset.particleContainer
# self.additivePlot = None
self.importWindow = None self.importWindow = None
self.polymerCheckBoxes = [] self.polymerCheckBoxes = []
...@@ -64,10 +63,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -64,10 +63,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.currentParticleIndex = 0 self.currentParticleIndex = 0
self.currentSpectrumIndex = 0 self.currentSpectrumIndex = 0
# self.lastSpectrumInFocus = None
self.typeHistogramPlot = TypeHistogramView(self) self.typeHistogramPlot = TypeHistogramView(self)
# self.typeHistogramPlot.indexClicked.connect(self.getAdditivePlot)
self.sizeHistogramCanvas = FigureCanvas(Figure()) self.sizeHistogramCanvas = FigureCanvas(Figure())
sizeHistGroup = QtWidgets.QGroupBox() sizeHistGroup = QtWidgets.QGroupBox()
...@@ -171,16 +168,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -171,16 +168,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.hqiSpinBox.valueChanged.connect(self.applyHQIThresholdToResults) self.hqiSpinBox.valueChanged.connect(self.applyHQIThresholdToResults)
optionsLayout.addRow(QtWidgets.QLabel('minimum HQI:'), self.hqiSpinBox) optionsLayout.addRow(QtWidgets.QLabel('minimum HQI:'), self.hqiSpinBox)
# self.compHqiSpinBox = QtWidgets.QDoubleSpinBox()
# self.compHqiSpinBox.setValue(30.0)
# self.compHqiSpinBox.setDecimals(1)
# self.compHqiSpinBox.setMinimum(0)
# self.compHqiSpinBox.setDisabled(True)
# optionsLayout.addRow(QtWidgets.QLabel('min component HQI'), self.compHqiSpinBox)
self.optionsGroup.setLayout(optionsLayout) self.optionsGroup.setLayout(optionsLayout)
self.optionsGroup.setMinimumWidth(175) self.optionsGroup.setMinimumWidth(175)
# self.optionsGroup.setDisabled(True)
self.resultScrollarea = QtWidgets.QScrollArea(self) self.resultScrollarea = QtWidgets.QScrollArea(self)
self.resultScrollarea.setFixedWidth(250) self.resultScrollarea.setFixedWidth(250)
...@@ -210,16 +199,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -210,16 +199,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.layout.addLayout(viewLayout) self.layout.addLayout(viewLayout)
minHQI = self.dataset.resultParams['minHQI'] minHQI = self.dataset.resultParams['minHQI']
# compHQI = self.dataset.resultParams['compHQI']
if minHQI is not None: if minHQI is not None:
self.hqiSpinBox.setValue(minHQI) self.hqiSpinBox.setValue(minHQI)
# self.compHqiSpinBox.setValue(compHQI)
self.createActions() self.createActions()
self.createMenus() self.createMenus()
self.applyHQIThresholdToResults() self.applyHQIThresholdToResults()
self.createHistogramData() self.createHistogramData()
self.particleContainer.loadSpectra()
self.initializeSpecPlot() self.initializeSpecPlot()
self.setTypeSelector() self.setTypeSelector()
self.updateHistogramsAndContours() self.updateHistogramsAndContours()
...@@ -228,8 +214,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -228,8 +214,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.loadTrueMatchAct = QtWidgets.QAction("Load &TrueMatch Results", self) self.loadTrueMatchAct = QtWidgets.QAction("Load &TrueMatch Results", self)
self.loadTrueMatchAct.triggered.connect(self.importTrueMatchResults) self.loadTrueMatchAct.triggered.connect(self.importTrueMatchResults)
self.loadTextFileAct = QtWidgets.QAction("Load &ordered Text File", self) self.loadSpectraAct = QtWidgets.QAction("Load &Spectra", self)
self.loadTextFileAct.setDisabled(True) self.loadSpectraAct.triggered.connect(self.initializeSpecPlot)
self.noOverlayAct = QtWidgets.QAction("&No Overlay", self) self.noOverlayAct = QtWidgets.QAction("&No Overlay", self)
self.selOverlayAct = QtWidgets.QAction("&Selected Overlay", self) self.selOverlayAct = QtWidgets.QAction("&Selected Overlay", self)
...@@ -250,7 +236,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -250,7 +236,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.seedAct = QtWidgets.QAction("&Set Color Seed", self) self.seedAct = QtWidgets.QAction("&Set Color Seed", self)
self.seedAct.triggered.connect(self.updateColorSeed) self.seedAct.triggered.connect(self.updateColorSeed)
self.removeTinyParticlesAct = QtWidgets.QAction("&Remove not unknown Particles < 1 µm") self.removeTinyParticlesAct = QtWidgets.QAction("&Remove not unknown Particles < 1 µm")
self.removeTinyParticlesAct.triggered.connect(self.removeTinyParticles) self.removeTinyParticlesAct.triggered.connect(self.removeTinyParticles)
...@@ -266,8 +252,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -266,8 +252,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.expSQLAct.triggered.connect(self.exportToSQL) self.expSQLAct.triggered.connect(self.exportToSQL)
def createMenus(self): def createMenus(self):
self.importMenu = QtWidgets.QMenu("&Import Results") self.importMenu = QtWidgets.QMenu("&Import Spectra and Results")
self.importMenu.addActions([self.loadTrueMatchAct, self.loadTextFileAct]) self.importMenu.addActions([self.loadSpectraAct, self.loadTrueMatchAct])
self.dispMenu = QtWidgets.QMenu("&Display", self) self.dispMenu = QtWidgets.QMenu("&Display", self)
self.overlayActGroup = QtWidgets.QActionGroup(self.dispMenu) self.overlayActGroup = QtWidgets.QActionGroup(self.dispMenu)
...@@ -294,7 +280,11 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -294,7 +280,11 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.menuBar().addMenu(self.dispMenu) self.menuBar().addMenu(self.dispMenu)
self.menuBar().addMenu(self.toolMenu) self.menuBar().addMenu(self.toolMenu)
self.menuBar().addMenu(self.exportMenu) self.menuBar().addMenu(self.exportMenu)
def keyPressEvent(self, event):
if event.key() in [QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter]:
self.jumpToIndicatedSpectrum()
def launchDBManager(self): def launchDBManager(self):
if self.dbWin.isHidden(): if self.dbWin.isHidden():
self.dbWin.show() self.dbWin.show()
...@@ -313,16 +303,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -313,16 +303,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
def importTrueMatchResults(self): def importTrueMatchResults(self):
self.importWindow = LoadTrueMatchResults(self.particleContainer, self) self.importWindow = LoadTrueMatchResults(self.particleContainer, self)
self.importWindow.exec() self.importWindow.exec()
# @QtCore.pyqtSlot(int)
# def getAdditivePlot(self, clickedindex):
# polymer = self.datastats.typehistogram[clickedindex][0] #get the polymer name, that was clicked on
#
# if self.datastats.sorted_additives is not None and \
# len(self.datastats.sorted_additives[clickedindex]) > 0:
# self.additivePlot = AdditiveViewer(polymer, self.datastats.sorted_additives[clickedindex])
# self.additivePlot.show()
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def applyHQIThresholdToResults(self): def applyHQIThresholdToResults(self):
hqi = self.hqiSpinBox.value() hqi = self.hqiSpinBox.value()
...@@ -409,14 +390,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -409,14 +390,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
numParticles = self.particleContainer.getNumberOfParticles() numParticles = self.particleContainer.getNumberOfParticles()
self.specNumberSelector.setMaximum(numParticles) self.specNumberSelector.setMaximum(numParticles)
# if self.lastSpectrumInFocus is not None:
# self.currentSpectrumIndex = self.lastSpectrumInFocus
# self.displayNewPolymerType(resetCurrentIndex=False)
# print('displaying new type without resetting index')
# else:
# print('displaying new type with resetting index')
# self.displayNewPolymerType()
def initializeSpecPlot(self): def initializeSpecPlot(self):
self.specPlot.loadSpectraAndInitializeSpecPlot() self.specPlot.loadSpectraAndInitializeSpecPlot()
self.updateSpecPlot() self.updateSpecPlot()
...@@ -475,8 +448,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -475,8 +448,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
def updateSpecPlot(self): def updateSpecPlot(self):
particleSize = np.round(self.particleContainer.getSizeOfParticleByIndex(self.currentParticleIndex)) particleSize = np.round(self.particleContainer.getSizeOfParticleByIndex(self.currentParticleIndex))
hqi = self.particleContainer.getHQIOfSpectrumIndex(self.currentSpectrumIndex) hqi = self.particleContainer.getHQIOfSpectrumIndex(self.currentSpectrumIndex)
self.specPlot.updateParticleSpectrum(self.currentSpectrumIndex, particleSize, hqi) assignment = self.particleContainer.getParticleAssignmentByIndex(self.currentParticleIndex)
# self.lastSpectrumInFocus = self.currentSpectrumIndex self.specPlot.updateParticleSpectrum(self.currentSpectrumIndex, assignment, particleSize, hqi)
if self.refSelector.isEnabled() and self.refSelector.currentText() != '': if self.refSelector.isEnabled() and self.refSelector.currentText() != '':
refID = self.dbWin.activeDatabase.spectraNames.index(self.refSelector.currentText()) refID = self.dbWin.activeDatabase.spectraNames.index(self.refSelector.currentText())
...@@ -540,14 +513,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -540,14 +513,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.updateSpecPlot() self.updateSpecPlot()
self.jumpToIndicatedSpectrum() self.jumpToIndicatedSpectrum()
def setWidgetsToNewParticleIndex(self, particleIndex): #TODO: Probably refactor. Its basically a combination of the above methods... Just a bit different to avoid directly jumping to the particle in sampleview def setWidgetsToNewParticleIndex(self, particleIndex):
try: try:
self.particleSelector.valueChanged.disconnect() self.particleSelector.valueChanged.disconnect()
self.spectrumSelector.valueChanged.disconnect() self.spectrumSelector.valueChanged.disconnect()
self.typeSelectorCombo.currentIndexChanged.disconnect() self.typeSelectorCombo.currentIndexChanged.disconnect()
except TypeError: except TypeError:
pass #signals were not connected... pass #signals were not connected, nothing to disconnect...
assignment = self.particleContainer.getParticleAssignmentByIndex(particleIndex) assignment = self.particleContainer.getParticleAssignmentByIndex(particleIndex)
self.typeSelectorCombo.setCurrentText(assignment) self.typeSelectorCombo.setCurrentText(assignment)
...@@ -573,16 +545,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -573,16 +545,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.spectrumSelector.valueChanged.connect(self.setSpecSelector) self.spectrumSelector.valueChanged.connect(self.setSpecSelector)
self.particleSelector.valueChanged.connect(self.setParticleSelector) self.particleSelector.valueChanged.connect(self.setParticleSelector)
def jumpToIndicatedSpectrum(self): #TODO: This should be transferred to sampleview... def jumpToIndicatedSpectrum(self):
self.currentSpectrumIndex = self.specNumberSelector.value()-1 self.currentSpectrumIndex = self.specNumberSelector.value()-1
self.currentParticleIndex = self.particleContainer.getParticleIndexContainingSpecIndex(self.currentSpectrumIndex) self.currentParticleIndex = self.particleContainer.getParticleIndexContainingSpecIndex(self.currentSpectrumIndex)
self.centerOnSpecIndex(self.currentSpectrumIndex) self.viewparent.centerOnRamanIndex(self.currentSpectrumIndex)
self.viewparent.highLightContour(self.currentParticleIndex) self.viewparent.highLightContour(self.currentParticleIndex)
self.updateSpecPlot() self.updateSpecPlot()
def centerOnSpecIndex(self, index):
self.viewparent.centerOnRamanIndex(index)
def darkenBackground(self): def darkenBackground(self):
self.viewparent.darkenPixmap = self.darkenAct.isChecked() self.viewparent.darkenPixmap = self.darkenAct.isChecked()
...@@ -639,7 +608,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -639,7 +608,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
scanIndicator.update() scanIndicator.update()
def exportToExcel(self): def exportToExcel(self):
expWin = ExpExcelDialog(self.dataset, self.particleContainer) expWin = ExpExcelDialog(self.dataset)
expWin.exec() expWin.exec()
def exportToSQL(self): def exportToSQL(self):
......
...@@ -19,27 +19,21 @@ along with this program, see COPYING. ...@@ -19,27 +19,21 @@ along with this program, see COPYING.
If not, see <https://www.gnu.org/licenses/>. If not, see <https://www.gnu.org/licenses/>.
""" """
from PyQt5 import QtWidgets, QtGui, QtCore from PyQt5 import QtWidgets
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import os import os
import sys import sys
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class ExpExcelDialog(QtWidgets.QDialog): class ExpExcelDialog(QtWidgets.QDialog):
def __init__(self, dataset, particleContainer): def __init__(self, dataset):
super(ExpExcelDialog, self).__init__() super(ExpExcelDialog, self).__init__()
self.setWindowTitle('Export Options') self.setWindowTitle('Export Options')
self.setGeometry(200, 200, 300, 300) self.setGeometry(200, 200, 300, 300)
self.dataset = dataset self.dataset = dataset
self.particleContainer = particleContainer self.particleContainer = dataset.particleContainer
self.polymers = self.particleContainer.getListOfParticleAssignments
# self.additives = self.datastats.currentAdditives
self.hqis = self.particleContainer.getListOfHighestHQIs
self.layout = QtWidgets.QHBoxLayout() self.layout = QtWidgets.QHBoxLayout()
self.setLayout(self.layout) self.setLayout(self.layout)
...@@ -48,7 +42,7 @@ class ExpExcelDialog(QtWidgets.QDialog): ...@@ -48,7 +42,7 @@ class ExpExcelDialog(QtWidgets.QDialog):
excelvbox.addWidget(QtWidgets.QLabel('Select Parameters for Export')) excelvbox.addWidget(QtWidgets.QLabel('Select Parameters for Export'))
excelgroup = QtWidgets.QGroupBox("Export to Excel", self) excelgroup = QtWidgets.QGroupBox("Export to Excel", self)
self.exportOptions = ['Polymer Type (mandatory)', 'Additives', 'Long Size (µm)', 'Short Size (µm)', 'Area (µm²)', 'HQI', 'Size Classes'] self.exportOptions = ['Polymer Type (mandatory)', 'Long Size (µm)', 'Short Size (µm)', 'Area (µm²)', 'HQI', 'Size Classes']
self.checkBoxes = [] self.checkBoxes = []
self.sizeClasses = [5, 10, 20, 50, 100, 1e6] self.sizeClasses = [5, 10, 20, 50, 100, 1e6]
self.directory = self.dataset.path self.directory = self.dataset.path
...@@ -60,11 +54,6 @@ class ExpExcelDialog(QtWidgets.QDialog): ...@@ -60,11 +54,6 @@ class ExpExcelDialog(QtWidgets.QDialog):
if option == 'Polymer Type (mandatory)': if option == 'Polymer Type (mandatory)':
self.checkBoxes[-1].setEnabled(False) #is mandatory!!! self.checkBoxes[-1].setEnabled(False) #is mandatory!!!
# if option == 'Additives':
# if self.additives is None:
# self.checkBoxes[-1].setEnabled(False)
# self.checkBoxes[-1].setChecked(False)
excelvbox.addWidget(self.checkBoxes[-1]) excelvbox.addWidget(self.checkBoxes[-1])
...@@ -85,19 +74,24 @@ class ExpExcelDialog(QtWidgets.QDialog): ...@@ -85,19 +74,24 @@ class ExpExcelDialog(QtWidgets.QDialog):
self.show() self.show()
def toExcel(self): def toExcel(self):
requiredcolumns = [] requiredcolumns = []
self.sizes = self.particleContainer.getSizesOfAllParticles() uniquePolymers = self.particleContainer.getUniquePolymers()
polymers = self.particleContainer.getListOfParticleAssignments()
sizes = self.particleContainer.getSizesOfAllParticles()
for box in self.checkBoxes: for box in self.checkBoxes:
if box.isChecked() == True: if box.isChecked() == True:
if box.text() != 'Size Classes': if box.text() != 'Size Classes':
requiredcolumns.append(box.text()) requiredcolumns.append(box.text())
if box.text() == 'Long Size (µm)': if box.text() == 'Long Size (µm)':
longSize = self.sizes longSizes = sizes
elif box.text() == 'Short Size (µm)': elif box.text() == 'Short Size (µm)':
self.shortSizes = self.particleContainer.getShortSizesOfAllParticles() shortSizes = self.particleContainer.getShortSizesOfAllParticles()
elif box.text() == 'HQI':
hqis = self.particleContainer.getListOfHighestHQIs()
elif box.text() == 'Area (µm²)': elif box.text() == 'Area (µm²)':
area = np.array([np.round(float(entry[4]), 1) for entry in self.particles]) areas = self.particleContainer.getAreasOfAllParticles()
else: else:
requiredcolumns.append('0 - 5 µm') requiredcolumns.append('0 - 5 µm')
...@@ -107,28 +101,26 @@ class ExpExcelDialog(QtWidgets.QDialog): ...@@ -107,28 +101,26 @@ class ExpExcelDialog(QtWidgets.QDialog):
requiredcolumns.append('50 - 100 µm') requiredcolumns.append('50 - 100 µm')
requiredcolumns.append('> 100 µm') requiredcolumns.append('> 100 µm')
finalData = np.zeros((self.polymers.shape[0],len(requiredcolumns)-1)) finalData = np.zeros((polymers.shape[0],len(requiredcolumns)-1))
polymertypes = [""]*self.polymers.shape[0] polymertypes = [""]*polymers.shape[0]
rowindex = 0 rowindex = 0
for polymer in np.unique(self.polymers): for polymer in uniquePolymers:
indices = self.polymers == polymer indices = self.particleContainer.getgetIndicesOfParticleType(polymer)
numentries = int(np.sum(indices)) numentries = int(np.sum(indices))
print("Num:", numentries) print("Num:", numentries)
sys.stdout.flush() sys.stdout.flush()
for colindex, column in enumerate(requiredcolumns): for colindex, column in enumerate(requiredcolumns):
if column == 'Polymer Type (mandatory)': if column == 'Polymer Type (mandatory)':
polymertypes[rowindex:rowindex+numentries] = self.polymers[indices] polymertypes[rowindex:rowindex+numentries] = polymers[indices]
# if column == 'Additives':
# finalData[rowindex:rowindex+numentries, colindex-1] = self.additives[indices]
if column == 'Long Size (µm)': if column == 'Long Size (µm)':
finalData[rowindex:rowindex+numentries, colindex-1] = longSize[indices] finalData[rowindex:rowindex+numentries, colindex-1] = longSizes[indices]
if column == 'Short Size (µm)': if column == 'Short Size (µm)':
finalData[rowindex:rowindex+numentries, colindex-1] = self.shortSizes[indices] finalData[rowindex:rowindex+numentries, colindex-1] = shortSizes[indices]
if column == 'Area (µm²)': if column == 'Area (µm²)':
finalData[rowindex:rowindex+numentries, colindex-1] = area[indices] finalData[rowindex:rowindex+numentries, colindex-1] = areas[indices]
if column == 'HQI': if column == 'HQI':
finalData[rowindex:rowindex+numentries, colindex-1] = self.hqis[indices] finalData[rowindex:rowindex+numentries, colindex-1] = hqis[indices]
if '> 100 µm' in requiredcolumns: if '> 100 µm' in requiredcolumns:
##append size classes ##append size classes
...@@ -183,25 +175,4 @@ class ExpExcelDialog(QtWidgets.QDialog): ...@@ -183,25 +175,4 @@ class ExpExcelDialog(QtWidgets.QDialog):
report.insert(len(report.columns), 'Sum total', particleclasses.sum(axis=1)) report.insert(len(report.columns), 'Sum total', particleclasses.sum(axis=1))
report.to_excel(writer, sheet_name = 'Particle Statistics', index=False) report.to_excel(writer, sheet_name = 'Particle Statistics', index=False)
writer.save() writer.save()
self.accept() self.accept()
\ No newline at end of file
class AdditiveViewer(QtWidgets.QWidget):
def __init__(self, polymername, sortedAdditives):
super(AdditiveViewer, self).__init__()
self.setGeometry(200,200, 800, 600)
self.setWindowTitle('Additives of {}'.format(polymername))
self.layout = QtWidgets.QGridLayout()
self.setLayout(self.layout)
self.canvas = FigureCanvas(Figure(figsize=(5, 3)))
self.ax = self.canvas.figure.subplots()
self.layout.addWidget(self.canvas, 0, 0)
self.ax.hist(sortedAdditives)
self.ax.set_ylabel('Number', fontsize = 15)
self.ax.tick_params(axis='both', which='both', labelsize=15)
\ No newline at end of file
...@@ -74,7 +74,7 @@ class Particle(object): ...@@ -74,7 +74,7 @@ class Particle(object):
assignments.append(meas.getAssignment()) assignments.append(meas.getAssignment())
indexOfHighestHQI = hqis.index(max(hqis)) indexOfHighestHQI = hqis.index(max(hqis))
return assignments[indexOfHighestHQI] return assignments[indexOfHighestHQI]
def getParticleSize(self): def getParticleSize(self):
if not np.isnan(self.longSize_ellipse): if not np.isnan(self.longSize_ellipse):
size = self.longSize_ellipse size = self.longSize_ellipse
...@@ -98,6 +98,9 @@ class Particle(object): ...@@ -98,6 +98,9 @@ class Particle(object):
def getNumberOfMeasurements(self):