Commit 1c6ae7e5 authored by JosefBrandt's avatar JosefBrandt

Basic plots working, proceeding to contours
parent d1ae9d81
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
GEPARD - Gepard-Enabled PARticle Detection
Copyright (C) 2018 Lars Bittrich and Josef Brandt, Leibniz-Institut für
Polymerforschung Dresden e. V. <bittrich-lars@ipfdd.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program, see COPYING.
If not, see <https://www.gnu.org/licenses/>.
"""
from PyQt5 import QtWidgets, QtGui, QtCore
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
import os
import numpy as np
from analysis import importSpectra
class ParticleIndicator(QtWidgets.QPushButton):
def __init__(self, number, numtotal, color, text, parent=None):
super().__init__(parent)
self.number = number
self.numtotal = numtotal
self.color = color
self.text = text
self.setFixedHeight(30)
def paintEvent(self, event):
r = self.number/self.numtotal
width = self.width()
height = self.height()
qp = QtGui.QPainter()
qp.begin(self)
#qp.fillRect(self.rect(), QtCore.Qt.white)
qp.setBrush(QtCore.Qt.white)
qp.drawRoundedRect(0, 0, width, height, 5. ,5.)
qp.setPen(self.color)
qp.setBrush(self.color)
qp.drawRoundedRect(0, 0, int(width*r), height, 5. ,5.)
qp.setPen(QtCore.Qt.black)
qp.setBrush(QtCore.Qt.NoBrush)
qp.drawRoundedRect(0, 0, width, height, 5. ,5.)
font = qp.font()
font.setPointSize(13)
font.setStyleStrategy(QtGui.QFont.NoAntialias)
font.setWeight(0)
qp.setFont(font)
qp.setCompositionMode(QtGui.QPainter.RasterOp_SourceXorDestination)
qp.setPen(QtCore.Qt.white)
qp.drawText(5, 0, width-10, height, QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter,
self.text)
qp.end()
class TypeHistogramView(QtWidgets.QScrollArea):
indexClicked = QtCore.pyqtSignal(int)
def __init__(self, parent=None):
super().__init__(parent)
self.view = QtWidgets.QWidget(self)
self.view.setCursor(QtGui.QCursor(QtCore.Qt.WhatsThisCursor))
self.view.setMinimumWidth(250)
group = QtWidgets.QGroupBox('Polymer Type Distribution', self.view)
self.indicatorbox = QtWidgets.QVBoxLayout()
self.indicatorbox.setContentsMargins(5,5,5,5)
group.setLayout(self.indicatorbox)
hbox = QtWidgets.QHBoxLayout()
hbox.addWidget(group)
self.view.setLayout(hbox)
self.setWidgetResizable(True)
self.setWidget(self.view)
self.setAlignment(QtCore.Qt.AlignHCenter)
self.widgets = []
def updateTypeHistogram(self, types):
# print("Updating polymer type view", flush=True)
for pi in self.widgets:
self.indicatorbox.removeWidget(pi)
pi.setParent(None)
pi.destroy()
self.indicatorbox.takeAt(0)
self.widgets = []
numtotal = sum([num for num, text, color in types])
def getIndexFunction(index):
return lambda : self.indexClicked.emit(index)
for index, entry in enumerate(types):
num, text, color = entry
# print("num, text, color:", num, text, color, flush=True)
pi = ParticleIndicator(num, numtotal, color, text)
self.indicatorbox.addWidget(pi)
pi.clicked.connect(getIndexFunction(index))
self.widgets.append(pi)
self.indicatorbox.addStretch()
self.view.update()
class SpectraPlot(QtWidgets.QGroupBox):
def __init__(self, dataset):
super(SpectraPlot, self).__init__()
self.dataset = dataset
self.spectra = None
layout = QtWidgets.QHBoxLayout()
self.canvas = FigureCanvas(Figure())
self.spec_axis = self.canvas.figure.subplots()
self.spec_axis.axis("off")
self.reference_ax = 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)
specNavigation.setFixedWidth(50)
layout.addWidget(specNavigation)
layout.addWidget(self.canvas)
self.setLayout(layout)
def loadSpectraAndInitializeSpecPlot(self): #formerly updateData(self)....
def tryLoadingNumpySpecFile():
specPath = self.dataset.getSpectraFileName()
if os.path.exists(specPath):
return np.load(specPath)
else:
raise ImportError
try:
self.spectra = tryLoadingNumpySpecFile()
except ImportError:
fname = QtWidgets.QFileDialog.getOpenFileName(QtWidgets.QWidget(), 'Select Spectra File', self.dataset.path, 'text file (*.txt)')[0]
try:
self.spectra, spectraNames = importSpectra.importWITecSpectra(fname)
except ImportError:
try:
self.spectra, spectraNames = importSpectra.importRenishawSpectra(fname)
except ImportError:
self.spectra, spectraNames = importSpectra.importPerkinElmerSpectra(fname)
if self.spectra is None:
raise ImportError
else:
np.save(self.dataset.getSpectraFileName(), self.spectra)
self.canvas.draw()
def updateParticleSpectrum(self, specIndex, particleSize, hqi):
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.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)
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]))
wavenumber_diff = list(self.spectra[:, 0]-100)
y_start = wavenumber_diff.index(min(wavenumber_diff))
y_min = min(self.spectra[y_start:, specIndex+1])
y_max = max(self.spectra[y_start:, specIndex+1])
self.spec_axis.set_ybound(0.9*y_min, 1.1*y_max)
self.canvas.draw()
def updateReferenceSpectrum(self, ref_wavenumber, ref_intensity):
#draw Reference
self.reference_axis.clear()
self.reference_axis.tick_params(axis='both', which='both', labelsize=15)
self.reference_axis.plot(ref_wavenumber, ref_intensity, color = 'r')
self.reference_axis.set_ylabel('Ref. Intensity', fontsize = 15, color = '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]))
# 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()
\ No newline at end of file
......@@ -22,20 +22,20 @@ If not, see <https://www.gnu.org/licenses/>.
from PyQt5 import QtCore, QtGui, QtWidgets
import numpy as np
import sys, os
import random
import colorsys
import sys
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from .analysiswidgets import ExpExcelDialog, AdditiveViewer, ParticleTypeView
from .analysiswidgets import ExpExcelDialog
from .analysisplots import TypeHistogramView, SpectraPlot
from .loadresults import LoadWITecResults
from .particleeditor import ParticleEditor
from .database import DataBaseWindow
#from .datastats import DataStats
from analysis import importSpectra
from .colorlegend import ColorHandler
try:
from .sqlexport import SQLExport
sqlEnabled = True
......@@ -56,8 +56,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.parent = parent
self.dataset = dataset
self.particleContainer = dataset.particleContainer
# self.datastats = DataStats(dataset)
self.editor = ParticleEditor(self.particleContainer, self)
self.colorHandler = ColorHandler()
# self.additivePlot = None
self.importWindow = None
......@@ -67,9 +67,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.currentParticleIndex = 0
self.currentSpectrumIndex = 0
self.lastSpectrumInFocus = None
# self.lastSpectrumInFocus = None
self.typeHistogramPlot = ParticleTypeView(self)
self.typeHistogramPlot = TypeHistogramView(self)
# self.typeHistogramPlot.indexClicked.connect(self.getAdditivePlot)
self.sizeHistogramCanvas = FigureCanvas(Figure())
......@@ -85,76 +85,69 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
sizeHistLayout.addWidget(self.sizeHistogramCanvas)
sizeHistGroup.setLayout(sizeHistLayout)
specGroup = QtWidgets.QGroupBox()
specLayout = QtWidgets.QHBoxLayout()
self.specCanvas = FigureCanvas(Figure())
self.spec_ax = self.specCanvas.figure.subplots()
self.spec_ax.axis("off")
self.ref_ax = self.spec_ax.twinx()
self.specCanvas.figure.subplots_adjust(left=0.1, top=0.93, bottom=0.15, right=0.9)
specNavigation = NavigationToolbar(self.specCanvas, self)
specNavigation.setOrientation(QtCore.Qt.Vertical)
specNavigation.setFixedWidth(50)
specLayout.addWidget(specNavigation)
specLayout.addWidget(self.specCanvas)
specGroup.setLayout(specLayout)
viewLayout = QtWidgets.QVBoxLayout()
self.menuLayout = QtWidgets.QVBoxLayout()
self.specPlot = SpectraPlot(self.dataset)
splitter1 = QtWidgets.QSplitter(QtCore.Qt.Vertical)
splitter1.addWidget(specGroup)
splitter1.addWidget(self.specPlot)
splitter1.addWidget(sizeHistGroup)
splitter2 = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
splitter2.addWidget(splitter1)
splitter2.addWidget(self.typeHistogramPlot)
splitter2.setSizes([300, 150])
referenceGroup = QtWidgets.QGroupBox('Reference Spectra')
referenceLayout = QtWidgets.QHBoxLayout()
self.refSelector = QtWidgets.QComboBox()
self.refSelector.setMinimumWidth(200)
self.refSelector.setDisabled(True)
self.dbWin = DataBaseWindow(self)
self.dbWin.selectDataBase(refreshParent=True) #this includes updating the refSelector
self.refSelector.currentIndexChanged.connect(self.updateSpecPlot)
referenceLayout.addWidget(QtWidgets.QLabel('Select Reference'))
referenceLayout.addWidget(self.refSelector)
referenceLayout.addStretch()
referenceGroup.setLayout(referenceLayout)
self.navigationGroup = QtWidgets.QGroupBox('Navigate through polymers')
self.navigationGroup.setDisabled(True)
navigationLayout = QtWidgets.QHBoxLayout()
self.polymerComboBox = QtWidgets.QComboBox()
self.polymerComboBox.currentIndexChanged.connect(self.displayNewPolymerType)
self.polymerComboBox.setMinimumWidth(150)
self.typeSelectorCombo = QtWidgets.QComboBox()
self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType)
self.typeSelectorCombo.setMinimumWidth(150)
self.particleSelector = QtWidgets.QSpinBox()
self.particleSelector.valueChanged.connect(self.selectParticle)
self.particleSelector.valueChanged.connect(self.updateParticleSelection)
self.particleNumberLabel = QtWidgets.QLabel('of xx particles; ')
self.spectrumSelector = QtWidgets.QSpinBox()
self.spectrumSelector.valueChanged.connect(self.selectSpectrum)
self.spectrumNumberLabel = QtWidgets.QLabel('of xx spectra')
for spinbox in [self.particleSelector, self.spectrumSelector]:
spinbox.setMinimum(1)
spinbox.setSingleStep(1)
spinbox.setValue(1)
navigationLayout.addWidget(QtWidgets.QLabel('Select Polymer Type:'))
navigationLayout.addWidget(self.polymerComboBox)
navigationLayout.addWidget(self.typeSelectorCombo)
navigationLayout.addStretch()
navigationLayout.addWidget(QtWidgets.QLabel('Select Particle'))
navigationLayout.addWidget(self.particleSelector)
navigationLayout.addWidget(self.particleNumberLabel)
navigationLayout.addStretch()
navigationLayout.addWidget(QtWidgets.QLabel('Select Spectrum'))
navigationLayout.addWidget(self.spectrumSelector)
navigationLayout.addStretch()
navigationLayout.addWidget(self.spectrumNumberLabel)
# navigationLayout.addStretch()
self.navigationGroup.setLayout(navigationLayout)
referenceGroup = QtWidgets.QGroupBox('Reference Spectra')
referenceLayout = QtWidgets.QHBoxLayout()
self.refSelector = QtWidgets.QComboBox()
self.refSelector.setDisabled(True)
self.dbWin = DataBaseWindow(self)
self.dbWin.selectDataBase(refreshParent=True) #this includes updating the refSelector
self.refSelector.currentIndexChanged.connect(self.updateSpecPlot)
referenceLayout.addWidget(QtWidgets.QLabel('Select Reference'))
referenceLayout.addWidget(self.refSelector)
referenceGroup.setLayout(referenceLayout)
topLayout = QtWidgets.QHBoxLayout()
topLayout.addWidget(self.navigationGroup)
topLayout.addWidget(referenceGroup)
topLayout.addStretch()
viewLayout = QtWidgets.QVBoxLayout()
viewLayout.addLayout(topLayout)
viewLayout.addWidget(splitter2)
viewLayout.setStretch(1, 1)
......@@ -163,11 +156,12 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
optionsLayout = QtWidgets.QFormLayout()
self.hqiSpinBox = QtWidgets.QDoubleSpinBox()
self.hqiSpinBox.setValue(75.0)
self.hqiSpinBox.setValue(self.dataset.resultParams['minHQI'])
self.hqiSpinBox.setDecimals(1)
self.hqiSpinBox.setMinimum(0)
self.hqiSpinBox.setMaximum(100)
self.hqiSpinBox.setMaximumWidth(45)
self.hqiSpinBox.setMaximumWidth(100)
self.hqiSpinBox.valueChanged.connect(self.applyHQIThresholdToResults)
optionsLayout.addRow(QtWidgets.QLabel('min HQI:'), self.hqiSpinBox)
# self.compHqiSpinBox = QtWidgets.QDoubleSpinBox()
......@@ -180,13 +174,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.dispResultSpinBox = QtWidgets.QSpinBox()
self.dispResultSpinBox.setValue(20)
self.dispResultSpinBox.setMinimum(1)
self.dispResultSpinBox.setMaximumWidth(100)
self.dispResultSpinBox.valueChanged.connect(self.updateHistograms)
optionsLayout.addRow(QtWidgets.QLabel('Max. items in display:'), self.dispResultSpinBox)
self.updateBtn = QtWidgets.QPushButton('Update Results')
self.updateBtn.clicked.connect(self.applyHQIThresholdToResults)
# self.updateBtn.setDisabled(True)
optionsLayout.addRow(self.updateBtn)
self.optionsGroup.setLayout(optionsLayout)
self.optionsGroup.setMinimumWidth(175)
......@@ -211,7 +202,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.resultCheckBoxes.setLayout(self.resultCheckBoxesLayout)
self.layout_SArea.addWidget(self.resultCheckBoxes)
self.menuLayout = QtWidgets.QVBoxLayout()
self.menuLayout.addWidget(self.optionsGroup)
self.menuLayout.addWidget(self.resultScrollarea)
......@@ -226,9 +218,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.createActions()
self.createMenus()
self.loadSpectraAndInitializeSpecPlot()
self.applyHQIThresholdToResults()
self.createHistogramData()
self.updateHistograms()
self.initializeSpecPlot()
self.displayNewPolymerType()
self.updateParticleSelection()
# self.createPolymerOverlay()
def createActions(self):
self.loadTrueMatchAct = QtWidgets.QAction("Load &TrueMatch Results", self)
......@@ -312,50 +308,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.refSelector.addItems(self.dbWin.activeDatabase.spectraNames)
self.refSelector.setDisabled(False)
def loadSpectraAndInitializeSpecPlot(self): #formerly updateData(self)....
def tryLoadingNumpySpecFile():
specPath = self.dataset.getSpectraFileName()
if os.path.exists(specPath):
return np.load(specPath)
else:
raise ImportError
try:
self.spectra = tryLoadingNumpySpecFile()
except ImportError:
fname = QtWidgets.QFileDialog.getOpenFileName(QtWidgets.QWidget(), 'Select Spectra File', self.dataset.path, 'text file (*.txt)')[0]
try:
self.spectra, spectraNames = importSpectra.importWITecSpectra(fname)
except ImportError:
try:
self.spectra, spectraNames = importSpectra.importRenishawSpectra(fname)
except ImportError:
self.spectra, spectraNames = importSpectra.importPerkinElmerSpectra(fname)
if self.spectra is None:
raise ImportError
else:
np.save(self.dataset.getSpectraFileName(), self.spectra)
self.specCanvas.draw()
# self.loadParticleData()
# def loadParticleData(self):
# #check, if dataset already contains results. Otherwise load them...
# if not self.datastats.loadParticleData():
# self.show()
# answer = QtWidgets.QMessageBox.question(self, 'Warning', 'No (or inconsistent) spectra results found, please run import dialog.\nPress OK to import or cancel to set to empty.', QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
# if answer == QtWidgets.QMessageBox.Ok:
# self.importTrueMatchResults()
# elif answer == QtWidgets.QMessageBox.Cancel:
# self.datastats.invalidateSpectra()
# self.updateBtn.clicked.connect(self.formatResults)
# self.formatResults()
# else:
# self.updateBtn.clicked.connect(self.formatResults)
# self.formatResults()
def importTrueMatchResults(self):
self.importWindow = LoadWITecResults(self.particleContainer, self)
self.importWindow.exec()
......@@ -371,13 +323,17 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
@QtCore.pyqtSlot()
def applyHQIThresholdToResults(self):
self.particleContainer.applyHQITresholdToParticles(self.hqiSpinBox.value())
hqi = self.hqiSpinBox.value()
self.particleContainer.applyHQITresholdToParticles(hqi)
self.dataset.resultParams['minHQI'] = hqi
self.dataset.save()
self.createHistogramData()
self.updateHistograms()
# def formatResults(self):
# if self.datastats.spectraResults is not None:
# print('formatResults')
# self.updateBtn.setDisabled(False)
# self.optionsGroup.setDisabled(False)
#
# self.datastats.formatResults(self.hqiSpinBox.value(), self.compHqiSpinBox.value())
......@@ -422,7 +378,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.resultCheckBoxesLayout.addWidget(self.showTotalSelector)
#generate new checkboxes
self.polymerCheckBoxes = []
self.polymerCheckBoxes = []#
uniquePolymers = self.particleContainer.getUniquePolymers()
for index, polymer in enumerate(uniquePolymers):
self.polymerCheckBoxes.append(QtWidgets.QCheckBox(self))
......@@ -444,20 +400,20 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.expSQLAct.setDisabled(False)
self.navigationGroup.setEnabled(True)
self.polymerComboBox.currentIndexChanged.disconnect()
self.polymerComboBox.clear()
self.polymerComboBox.addItems(uniquePolymers)
self.polymerComboBox.currentIndexChanged.connect(self.displayNewPolymerType)
self.typeSelectorCombo.currentIndexChanged.disconnect()
self.typeSelectorCombo.clear()
self.typeSelectorCombo.addItems(uniquePolymers)
self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType)
self.polymerIndex = self.polymerComboBox.currentIndex()
if self.lastSpectrumInFocus is not None:
self.currentSpectrumIndex = self.lastSpectrumInFocus
self.displayNewPolymerType(resetCurrentIndex=False)
else:
self.displayNewPolymerType()
self.polymerIndex = self.typeSelectorCombo.currentIndex()
# 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()
self.updateHistograms()
self.createPolymerOverlay()
def exportToExcel(self):
expWin = ExpExcelDialog(self.particleContainer, self)
......@@ -466,47 +422,23 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
def exportToSQL(self):
sqlexp = SQLExport(self.particleContainer, self)
sqlexp.exec()
def initializeSpecPlot(self):
self.specPlot.loadSpectraAndInitializeSpecPlot()
self.updateSpecPlot()
def updateSpecPlot(self, centerOn=True, highlightContour=True):
#draw Sample Spectrum
specIndex = self.currentSpectrumIndex
self.spec_ax.axis("on")
self.spec_ax.clear()
self.spec_ax.plot(self.spectra[:, 0], self.spectra[:, specIndex+1])
self.spec_ax.tick_params(axis='both', which='both', labelsize=15)
self.spec_ax.set_xlabel('Wavenumber (cm-1)', fontsize = 15)
self.spec_ax.set_ylabel('Counts', fontsize = 15)
self.spec_ax.set_title('ScanPoint Number {}, Size = {} µm'.format(specIndex+1,
self.particleContainer.getSizeOfParticleByIndex(self.currentParticleIndex)))
self.spec_ax.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0]))
wavenumber_diff = list(self.spectra[:, 0]-100)
y_start = wavenumber_diff.index(min(wavenumber_diff))
y_min = min(self.spectra[y_start:, specIndex+1])
y_max = max(self.spectra[y_start:, specIndex+1])
self.spec_ax.set_ybound(0.9*y_min, 1.1*y_max)
#draw Reference
self.ref_ax.clear()
particleSize = self.particleContainer.getSizeOfParticleByIndex(self.currentParticleIndex)
hqi = self.particleContainer.getHQIOfSpectrumIndex(self.currentSpectrumIndex)
self.specPlot.updateParticleSpectrum(self.currentSpectrumIndex, particleSize, hqi)
self.parent.centerOnRamanIndex(self.currentSpectrumIndex, centerOn=centerOn, highlightContour=highlightContour) #TODO: is this reasonable to do in that way???
self.parent.highLightRamanIndex(self.currentSpectrumIndex)
# self.lastSpectrumInFocus = self.currentSpectrumIndex
if self.refSelector.isEnabled() and self.refSelector.currentText() != '':
self.ref_ax.tick_params(axis='both', which='both', labelsize=15)
refID = self.dbWin.activeDatabase.spectraNames.index(self.refSelector.currentText())
ref = self.dbWin.activeDatabase.spectra[refID]
self.ref_ax.plot(ref[:, 0], ref[:, 1], color = 'r')
self.ref_ax.set_ylabel('Ref. Intensity', fontsize = 15, color = 'r')
self.ref_ax.tick_params('y', colors = 'r')
self.ref_ax.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.spec_ax.figure.canvas.draw()
self.parent.centerOnRamanIndex(specIndex, centerOn=centerOn, highlightContour=highlightContour)
self.parent.highLightRamanIndex(specIndex)
self.lastSpectrumInFocus = specIndex
self.specPlot.updateReferenceSpectrum(ref[:, 0], ref[:, 1])
def selectContour(self, index, centerOn=True):
print('select Contour in analysisview not yet refactored')
......@@ -531,7 +463,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
# #disconnect analysis widgets:
# self.particleSelector.valueChanged.disconnect()
# self.spectrumSelector.valueChanged.disconnect()
# self.polymerComboBox.currentIndexChanged.disconnect()
# self.typeSelectorCombo.currentIndexChanged.disconnect()
#
# #set widgets...
# self.particleSelector.setValue(subPartInd+1)
......@@ -542,53 +474,61 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
#
# selectedPolymer = self.datastats.currentPolymers[specIndex]
# self.polymerIndex = uniquePolymers.index(selectedPolymer)
# self.polymerComboBox.setCurrentIndex(self.polymerIndex)
# self.typeSelectorCombo.setCurrentIndex(self.polymerIndex)
#
# #reconnect all widgets:
# self.particleSelector.valueChanged.connect(self.selectParticle)
# self.particleSelector.valueChanged.connect(self.updateParticleSelection)
# self.spectrumSelector.valueChanged.connect(self.selectSpectrum)
# self.polymerComboBox.currentIndexChanged.connect(self.displayNewPolymerType)
# self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType)
#
# self.updateSpecPlot(centerOn=centerOn)