...
 
Commits (2)
__pycache__/
gepard\.cfg
analysis/database_config\.txt
*.so
...@@ -115,11 +115,6 @@ class SpectraPlot(QtWidgets.QGroupBox): ...@@ -115,11 +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.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.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)
...@@ -138,10 +133,13 @@ class SpectraPlot(QtWidgets.QGroupBox): ...@@ -138,10 +133,13 @@ class SpectraPlot(QtWidgets.QGroupBox):
#draw Sample Spectrum #draw Sample Spectrum
self.spec_axis.axis("on") self.spec_axis.axis("on")
self.spec_axis.clear() self.spec_axis.clear()
self.spec_axis.set_title('{}, ScanPoint Number {}, Size = {} µm, HQI = {}'.format(assignment, specIndex+1, particleSize, hqi)) 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:
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.set_title('{}, ScanPoint Number {}, Size = {} µm, HQI = {}'.format(assignment, 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))
......
...@@ -548,13 +548,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -548,13 +548,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
def jumpToIndicatedSpectrum(self): 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()
......
...@@ -39,9 +39,9 @@ class ParticleContainer(object): ...@@ -39,9 +39,9 @@ class ParticleContainer(object):
self.typeHistogram = None self.typeHistogram = None
def addEmptyMeasurement(self): def addEmptyMeasurement(self):
self.measurements.append(Measurement()) newMeas = Measurement()
indexOfNewMeas = len(self.measurements)-1 self.measurements.append(newMeas)
return indexOfNewMeas return self.measurements.index(newMeas)
def clearParticles(self): def clearParticles(self):
self.particles = [] self.particles = []
...@@ -57,7 +57,7 @@ class ParticleContainer(object): ...@@ -57,7 +57,7 @@ class ParticleContainer(object):
self.measurements[indexOfMeasurment].pixelcoord_y = y self.measurements[indexOfMeasurment].pixelcoord_y = y
def getMeasurementScanindex(self, indexOfMeasurement): def getMeasurementScanindex(self, indexOfMeasurement):
return self.measurements[indexOfMeasurement].ramanScanIndex return self.measurements[indexOfMeasurement].getScanIndex()
def getSpectraFromDisk(self): def getSpectraFromDisk(self):
spectra = None spectra = None
...@@ -71,18 +71,19 @@ class ParticleContainer(object): ...@@ -71,18 +71,19 @@ class ParticleContainer(object):
if fname: if fname:
#TODO: implement a more elegant way of testing through the individual imports... #TODO: implement a more elegant way of testing through the individual imports...
try: try:
self.spectra, spectraNames = importSpectra.importWITecSpectra(fname) spectra, spectraNames = importSpectra.importWITecSpectra(fname)
except ImportError: except ImportError:
try: try:
self.spectra, spectraNames = importSpectra.importRenishawSpectra(fname) spectra, spectraNames = importSpectra.importRenishawSpectra(fname)
except ImportError: except ImportError:
try: try:
self.spectra, spectraNames = importSpectra.importPerkinElmerSpectra(fname) spectra, spectraNames = importSpectra.importPerkinElmerSpectra(fname)
except ImportError: except ImportError:
pass pass
if spectra is not None: if spectra is not None:
np.save(self.datasetParent.getSpectraFileName(), spectra) np.save(self.datasetParent.getSpectraFileName(), spectra)
return spectra return spectra
def initializeParticles(self, numParticles): def initializeParticles(self, numParticles):
......
...@@ -242,6 +242,7 @@ class DataSet(object): ...@@ -242,6 +242,7 @@ class DataSet(object):
self.version = 2 self.version = 2
if self.version == 2: if self.version == 2:
print("Converting legacy version 2 to 3")
self.particleContainer = ParticleContainer(self) self.particleContainer = ParticleContainer(self)
self.particleContainer.initializeParticles(len(self.particlestats)) self.particleContainer.initializeParticles(len(self.particlestats))
...@@ -249,20 +250,23 @@ class DataSet(object): ...@@ -249,20 +250,23 @@ class DataSet(object):
self.particleContainer.setParticleStats(self.particlestats) self.particleContainer.setParticleStats(self.particlestats)
self.particleContainer.applyPixelScaleToParticleStats(self.getPixelScale()) self.particleContainer.applyPixelScaleToParticleStats(self.getPixelScale())
self.particleContainer.clearMeasurements()
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):
curParticle = self.particleContainer.getParticleOfIndex(particleIndex) curParticle = self.particleContainer.getParticleOfIndex(particleIndex)
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] x, y = self.ramanpoints[indexOfNewMeas][0], self.ramanpoints[indexOfNewMeas][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.ramanScanIndex specIndex = meas.getScanIndex()
meas.setAssignment(self.results['polymers'][specIndex]) meas.setAssignment(self.results['polymers'][specIndex])
meas.setHQI(self.results['hqis'][specIndex]) meas.setHQI(self.results['hqis'][specIndex])
......
...@@ -672,7 +672,7 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -672,7 +672,7 @@ 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()
......
# rename this file to gepard.cfg and adapt these parameters
[Defaults]
# file path without "" !
file_path = .
[Interface]
# possible values: SIMULATED_RAMAN_CONTROL, WITEC_CONTROL, RENISHAW_CONTROL
raman_interface = SIMULATED_RAMAN_CONTROL
[General Microscope Setup]
magnification = 20
[Renishaw]
#information specific for renishaw control
#image mikrometer sizes for bright and dark field camera, format: width*height
#please insert, as it would represent an image at 1x magnification
#if unavailable, export an image from the Renishaw Camera viewer. Export as jpeg (without axes) and, within Gepard, go to Tools->ConfigureRamanControl.
img_size_BF = 9016.0*5748.0
img_size_DF = 4524.0*2874.0
#Path to measuring templates (*.wxm)
measTemplatePath = C:\RamanData
\ No newline at end of file
...@@ -323,12 +323,12 @@ if __name__ == '__main__': ...@@ -323,12 +323,12 @@ if __name__ == '__main__':
logpath = QtCore.QStandardPaths.writableLocation( logpath = QtCore.QStandardPaths.writableLocation(
QtCore.QStandardPaths.AppLocalDataLocation) QtCore.QStandardPaths.AppLocalDataLocation)
fp = None fp = None
# if logpath != "": if logpath != "":
# if not os.path.exists(logpath): if not os.path.exists(logpath):
# os.mkdir(logpath) os.mkdir(logpath)
# 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)
......
...@@ -234,6 +234,7 @@ class RamanScanUI(QtWidgets.QWidget): ...@@ -234,6 +234,7 @@ 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,14 +555,20 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -555,14 +555,20 @@ class SampleView(QtWidgets.QGraphicsView):
def prepareAnalysis(self): def prepareAnalysis(self):
self.clearItems() self.clearItems()
if self.dataset.particleDetectionDone: if self.dataset.particleDetectionDone:
for measIndex, measPoint in enumerate(self.dataset.particleContainer.getMeasurementPixelCoords()): data = []
scanIndex = self.dataset.particleContainer.getMeasurementScanindex(measIndex) for i in self.dataset.ramanscansortindex:
item = RamanScanIndicator(self, scanIndex+1, 20, (measPoint[0], measPoint[1])) data.append(list(self.dataset.ramanpoints[i]))
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):
# self.resetBoundary()
t0 = time.time() t0 = time.time()
for cnt in self.contourItems: for cnt in self.contourItems:
self.scene().removeItem(cnt) self.scene().removeItem(cnt)
......