Skip to content
Commits on Source (2)
__pycache__/
gepard\.cfg
analysis/database_config\.txt
*.so
......@@ -115,11 +115,6 @@ class SpectraPlot(QtWidgets.QGroupBox):
layout = QtWidgets.QHBoxLayout()
self.canvas = FigureCanvas(Figure())
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.canvas.figure.subplots_adjust(left=0.1, top=0.93, bottom=0.15, right=0.9)
specNavigation = NavigationToolbar(self.canvas, self)
......@@ -138,10 +133,13 @@ class SpectraPlot(QtWidgets.QGroupBox):
#draw Sample Spectrum
self.spec_axis.axis("on")
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:
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]))
wavenumber_diff = list(self.spectra[:, 0]-100)
y_start = wavenumber_diff.index(min(wavenumber_diff))
......
......@@ -548,13 +548,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
def jumpToIndicatedSpectrum(self):
self.currentSpectrumIndex = self.specNumberSelector.value()-1
self.currentParticleIndex = self.particleContainer.getParticleIndexContainingSpecIndex(self.currentSpectrumIndex)
self.centerOnSpecIndex(self.currentSpectrumIndex)
self.viewparent.centerOnRamanIndex(self.currentSpectrumIndex)
self.viewparent.highLightContour(self.currentParticleIndex)
self.updateSpecPlot()
def centerOnSpecIndex(self, index):
self.viewparent.centerOnRamanIndex(index)
def darkenBackground(self):
self.viewparent.darkenPixmap = self.darkenAct.isChecked()
......
......@@ -39,9 +39,9 @@ class ParticleContainer(object):
self.typeHistogram = None
def addEmptyMeasurement(self):
self.measurements.append(Measurement())
indexOfNewMeas = len(self.measurements)-1
return indexOfNewMeas
newMeas = Measurement()
self.measurements.append(newMeas)
return self.measurements.index(newMeas)
def clearParticles(self):
self.particles = []
......@@ -57,7 +57,7 @@ class ParticleContainer(object):
self.measurements[indexOfMeasurment].pixelcoord_y = y
def getMeasurementScanindex(self, indexOfMeasurement):
return self.measurements[indexOfMeasurement].ramanScanIndex
return self.measurements[indexOfMeasurement].getScanIndex()
def getSpectraFromDisk(self):
spectra = None
......@@ -71,18 +71,19 @@ class ParticleContainer(object):
if fname:
#TODO: implement a more elegant way of testing through the individual imports...
try:
self.spectra, spectraNames = importSpectra.importWITecSpectra(fname)
spectra, spectraNames = importSpectra.importWITecSpectra(fname)
except ImportError:
try:
self.spectra, spectraNames = importSpectra.importRenishawSpectra(fname)
spectra, spectraNames = importSpectra.importRenishawSpectra(fname)
except ImportError:
try:
self.spectra, spectraNames = importSpectra.importPerkinElmerSpectra(fname)
spectra, spectraNames = importSpectra.importPerkinElmerSpectra(fname)
except ImportError:
pass
if spectra is not None:
np.save(self.datasetParent.getSpectraFileName(), spectra)
return spectra
def initializeParticles(self, numParticles):
......
......@@ -242,6 +242,7 @@ class DataSet(object):
self.version = 2
if self.version == 2:
print("Converting legacy version 2 to 3")
self.particleContainer = ParticleContainer(self)
self.particleContainer.initializeParticles(len(self.particlestats))
......@@ -249,10 +250,13 @@ class DataSet(object):
self.particleContainer.setParticleStats(self.particlestats)
self.particleContainer.applyPixelScaleToParticleStats(self.getPixelScale())
self.particleContainer.clearMeasurements()
if len(self.particlestats) > 0: #i.e., particle detection was completed and particle data is there
self.particleDetectionDone = True
for particleIndex, listOfScanIndices in enumerate(self.particles2spectra):
curParticle = self.particleContainer.getParticleOfIndex(particleIndex)
curParticle.measurements = []
for scanIndex in listOfScanIndices:
indexOfNewMeas = self.particleContainer.addEmptyMeasurement()
x, y = self.ramanpoints[indexOfNewMeas][0], self.ramanpoints[indexOfNewMeas][1]
......@@ -262,7 +266,7 @@ class DataSet(object):
for particle in self.particleContainer.particles:
for meas in particle.measurements:
specIndex = meas.ramanScanIndex
specIndex = meas.getScanIndex()
meas.setAssignment(self.results['polymers'][specIndex])
meas.setHQI(self.results['hqis'][specIndex])
......
......@@ -672,7 +672,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
particleContainer.setMeasurementPixelCoords(indexOfNewMeas, point.x, point.y)
curParticle.addMeasurement(particleContainer.measurements[indexOfNewMeas])
self.dataset.ramanpoints = measurementPoints
self.dataset.particleDetectionDone = True
self.dataset.mode = "prepareraman"
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__':
logpath = QtCore.QStandardPaths.writableLocation(
QtCore.QStandardPaths.AppLocalDataLocation)
fp = None
# if logpath != "":
# if not os.path.exists(logpath):
# os.mkdir(logpath)
# logname = os.path.join(logpath, 'logfile.txt')
#
# fp = open(logname, "a")
if logpath != "":
if not os.path.exists(logpath):
os.mkdir(logpath)
logname = os.path.join(logpath, 'logfile.txt')
fp = open(logname, "a")
# sys.stderr = fp
# sys.stdout = fp
print("starting GEPARD at: " + strftime("%d %b %Y %H:%M:%S", localtime()), flush=True)
......
......@@ -234,6 +234,7 @@ class RamanScanUI(QtWidgets.QWidget):
for measIndex, ramanScanIndex in enumerate(cmin):
self.dataset.particleContainer.setMeasurementScanIndex(measIndex, ramanScanIndex)
self.dataset.ramanscansortindex = cmin
self.view.saveDataSet()
self.view.prepareAnalysis()
self.view.scaleImage(2.0)
......
......@@ -555,14 +555,20 @@ class SampleView(QtWidgets.QGraphicsView):
def prepareAnalysis(self):
self.clearItems()
if self.dataset.particleDetectionDone:
for measIndex, measPoint in enumerate(self.dataset.particleContainer.getMeasurementPixelCoords()):
scanIndex = self.dataset.particleContainer.getMeasurementScanindex(measIndex)
item = RamanScanIndicator(self, scanIndex+1, 20, (measPoint[0], measPoint[1]))
data = []
for i in self.dataset.ramanscansortindex:
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.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):
# self.resetBoundary()
t0 = time.time()
for cnt in self.contourItems:
self.scene().removeItem(cnt)
......