Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
GEPARD
GEPARD
Commits
2c03c3ce
Commit
2c03c3ce
authored
Jul 18, 2019
by
Josef Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preparation for reorganizing contours and scanIndices
Have it managed by the particle!
parent
ca5e6bad
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
48 additions
and
79 deletions
+48
-79
analysis/analysisplots.py
analysis/analysisplots.py
+2
-29
analysis/analysisview.py
analysis/analysisview.py
+2
-3
analysis/particleAndMeasurement.py
analysis/particleAndMeasurement.py
+7
-19
analysis/particleContainer.py
analysis/particleContainer.py
+5
-4
dataset.py
dataset.py
+1
-1
detectionview.py
detectionview.py
+1
-1
gepard.py
gepard.py
+17
-7
ramancom/WITecCOM.py
ramancom/WITecCOM.py
+1
-0
ramancom/ramanbase.py
ramancom/ramanbase.py
+1
-0
ramancom/simulatedraman.py
ramancom/simulatedraman.py
+1
-0
ramanscanui.py
ramanscanui.py
+2
-10
sampleview.py
sampleview.py
+2
-2
viewitems.py
viewitems.py
+6
-3
No files found.
analysis/analysisplots.py
View file @
2c03c3ce
...
...
@@ -23,10 +23,6 @@ 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
):
...
...
@@ -132,31 +128,8 @@ class SpectraPlot(QtWidgets.QGroupBox):
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
.
spectra
=
self
.
dataset
.
particleContainer
.
spectra
assert
self
.
spectra
is
not
None
self
.
canvas
.
draw
()
def
updateParticleSpectrum
(
self
,
specIndex
,
particleSize
,
hqi
):
...
...
analysis/analysisview.py
View file @
2c03c3ce
...
...
@@ -32,7 +32,6 @@ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as Navigatio
from
.analysiswidgets
import
ExpExcelDialog
from
.analysisplots
import
TypeHistogramView
,
SpectraPlot
from
.loadresults
import
LoadTrueMatchResults
from
.particleeditor
import
ParticleEditor
from
.database
import
DataBaseWindow
from
.colorlegend
import
getColorFromNameWithSeed
...
...
@@ -56,7 +55,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
viewparent
=
viewparent
self
.
dataset
=
dataset
self
.
particleContainer
=
dataset
.
particleContainer
self
.
editor
=
ParticleEditor
(
self
.
particleContainer
,
self
)
# self.additivePlot = None
self
.
importWindow
=
None
...
...
@@ -221,6 +219,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
createMenus
()
self
.
applyHQIThresholdToResults
()
self
.
createHistogramData
()
self
.
particleContainer
.
loadSpectra
()
self
.
initializeSpecPlot
()
self
.
setTypeSelector
()
self
.
updateHistogramsAndContours
()
...
...
@@ -556,7 +555,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
currentParticleIndex
=
particleIndex
partIndices
=
self
.
particleContainer
.
getIndicesOfParticleType
(
assignment
)
self
.
particleSelector
.
setMaximum
(
len
(
partIndices
))
self
.
particleNumberLabel
.
setText
(
f
'of
{
len
(
partIndices
)
}
particles; '
)
self
.
particleSelector
.
setValue
(
partIndices
.
index
(
particleIndex
)
+
1
)
...
...
analysis/particleAndMeasurement.py
View file @
2c03c3ce
...
...
@@ -19,7 +19,7 @@ along with this program, see COPYING.
If not, see <https://www.gnu.org/licenses/>.
"""
import
numpy
as
np
from
viewitems
import
SegmentationContour
,
RamanScanIndicator
class
Particle
(
object
):
def
__init__
(
self
):
...
...
@@ -35,23 +35,9 @@ class Particle(object):
self
.
viewItem
=
None
def
addMeasurement
(
self
,
refToMeasurement
):
refToMeasurement
.
assignedParticle
=
self
self
.
measurements
.
append
(
refToMeasurement
)
# def addExistingMeasurement(self, meas):
# self.measurements.append(meas)
#
# def addEmptyMeasurement(self):
# self.measurements.append(Measurement())
# indexOfNewMeasurment = len(self.measurements)-1
# return indexOfNewMeasurment
# def setMeasurementScanIndex(self, indexOfMeasurment, scanIndex):
# self.measurements[indexOfMeasurment].ramanScanIndex = scanIndex
#
# def setMeasurementPixelCoords(self, indexOfMeasurment, x, y):
# self.measurements[indexOfMeasurment].pixelcoord_x= x
# self.measurements[indexOfMeasurment].pixelcoord_y = y
#
def
setAllSpectraToNewAssignment
(
self
,
newAssignment
):
for
meas
in
self
.
measurements
:
meas
.
setAssignment
(
newAssignment
)
...
...
@@ -127,8 +113,8 @@ class Particle(object):
for
measurement
in
self
.
measurements
:
measurement
.
applyHQIThreshold
(
minHQI
)
#
def recreateViewItem(self):
#
pass
def
recreateViewItem
(
self
):
self
.
viewItem
=
SegmentationContour
()
class
Measurement
(
object
):
...
...
@@ -141,6 +127,8 @@ class Measurement(object):
self
.
assignment_orig
=
'Not Evaluated'
self
.
assignment_afterHQI
=
None
self
.
hqi
=
None
self
.
assignedParticle
=
None
def
setAssignment
(
self
,
assignment
):
self
.
assignment_orig
=
assignment
...
...
analysis/particle
Info
.py
→
analysis/particle
Container
.py
View file @
2c03c3ce
...
...
@@ -178,9 +178,10 @@ class ParticleContainer(object):
def
getMeasurementPixelCoords
(
self
):
coords
=
[]
for
particle
in
self
.
particles
:
for
measurement
in
particle
.
getMeasurements
():
coords
.
append
([
measurement
.
pixelcoord_x
,
measurement
.
pixelcoord_y
])
# for particle in self.particles:
# for measurement in particle.getMeasurements():
for
meas
in
self
.
measurements
:
coords
.
append
([
meas
.
pixelcoord_x
,
meas
.
pixelcoord_y
])
return
coords
def
getNumberOfParticlesOfAssignment
(
self
,
assignment
):
...
...
@@ -269,7 +270,7 @@ class ParticleContainer(object):
if
newAssignment
is
not
None
:
meas
.
setAssignment
(
newAssignment
)
meas
.
setHQI
(
100
)
newParticle
.
add
Existing
Measurement
(
meas
)
newParticle
.
addMeasurement
(
meas
)
#set Particle Stats
long
,
short
,
longellipse
,
shortellipse
,
area
=
newStats
...
...
dataset.py
View file @
2c03c3ce
...
...
@@ -24,7 +24,7 @@ import numpy as np
import
cv2
from
helperfunctions
import
cv2imread_fix
,
cv2imwrite_fix
from
copy
import
copy
from
analysis.particle
Info
import
ParticleContainer
from
analysis.particle
Container
import
ParticleContainer
currentversion
=
3
...
...
detectionview.py
View file @
2c03c3ce
...
...
@@ -677,7 +677,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
self
.
dataset
.
ramanpoints
=
measurementPoints
#consider moving that to particleContainer
#
self.dataset.ramanpoints = measurementPoints #consider moving that to particleContainer
# self.dataset.particlecontours = contours
# self.dataset.particlestats = particlestats
# self.dataset.ramanscansortindex = []
...
...
gepard.py
View file @
2c03c3ce
...
...
@@ -100,13 +100,23 @@ class GEPARDMainWindow(QtWidgets.QMainWindow):
fileName
=
QtWidgets
.
QFileDialog
.
getSaveFileName
(
self
,
"Create New Project"
,
defaultPath
,
"*.pkl"
)[
0
]
if
fileName
:
# if fileName.find(' ') < 0:
self
.
fname
=
str
(
fileName
)
#TODO: No spaces for Renishaw Interface!!
self
.
view
.
new
(
self
.
fname
)
self
.
scalingChanged
(
1.
)
# else:
# QtWidgets.QMessageBox.critical(self, "Error", "File path must not contain spaces.")
isValid
,
msg
=
self
.
testFilename
(
fileName
)
if
isValid
:
self
.
fname
=
str
(
fileName
)
#TODO: No spaces for Renishaw Interface!!
self
.
view
.
new
(
self
.
fname
)
self
.
scalingChanged
(
1.
)
else
:
QtWidgets
.
QMessageBox
.
critical
(
self
,
"Error"
,
msg
)
def
testFilename
(
self
,
fileName
):
if
self
.
view
.
ramanctrl
.
name
==
'RenishawCOM'
:
#the renishawCom does not allow Spaces within filePath
if
fileName
.
find
(
' '
)
==
0
:
return
False
,
"File path must not contain spaces."
else
:
return
True
,
""
else
:
return
True
,
""
@
QtCore
.
pyqtSlot
()
def
about
(
self
):
QtWidgets
.
QMessageBox
.
about
(
self
,
'GEPARD'
,
...
...
ramancom/WITecCOM.py
View file @
2c03c3ce
...
...
@@ -47,6 +47,7 @@ class WITecCOM(RamanBase):
def
__init__
(
self
,
hostname
=
None
):
super
().
__init__
()
self
.
name
=
'WITecCOM'
if
hostname
is
None
:
hostname
=
gethostname
()
self
.
IBUCSAccess
=
win32com
.
client
.
DispatchEx
(
self
.
CLSID
,
machine
=
hostname
,
...
...
ramancom/ramanbase.py
View file @
2c03c3ce
...
...
@@ -21,6 +21,7 @@ If not, see <https://www.gnu.org/licenses/>.
class
RamanBase
(
object
):
def
__init__
(
self
):
self
.
name
=
None
self
.
connected
=
False
self
.
timeseries
=
False
...
...
ramancom/simulatedraman.py
View file @
2c03c3ce
...
...
@@ -32,6 +32,7 @@ class SimulatedRaman(RamanBase):
ramanParameters
=
{}
def
__init__
(
self
):
super
().
__init__
()
self
.
name
=
'SimulatedRaman'
self
.
currentpos
=
None
,
0.
,
0.
self
.
currentZ
=
0.
# some plausible data to simulate consecutively changing positions
...
...
ramanscanui.py
View file @
2c03c3ce
...
...
@@ -232,16 +232,8 @@ class RamanScanUI(QtWidgets.QWidget):
if
reply
==
QtWidgets
.
QMessageBox
.
Yes
:
self
.
dataset
.
mode
=
"ramanscan"
measurements2particles
=
[[
int
(
np
.
where
(
cmin
==
i
)[
0
])]
for
i
in
range
(
len
(
cmin
))]
#i.e., list of scanIndicesPerParticle
for
particleIndex
,
listOfScanIndices
in
enumerate
(
measurements2particles
):
# curParticle = self.particleContainer.getParticleOfIndex(particleIndex)
for
scanIndex
in
listOfScanIndices
:
self
.
particleContainer
.
setMeasurementScanIndex
(
indexOfNewMeas
,
scanIndex
)
for
measIndex
,
ramanScanIndex
in
enumerate
(
cmin
):
self
.
particleContainer
.
setMeasurementScaneIndex
(
measIndex
,
ramanScanIndex
)
# self.dataset.ramanscansortindex = cmin
self
.
dataset
.
saveParticleData
()
...
...
sampleview.py
View file @
2c03c3ce
...
...
@@ -34,9 +34,8 @@ from zeissimporter import ZeissImporter
from
viewitems
import
FitPosIndicator
,
Node
,
Edge
,
ScanIndicator
,
RamanScanIndicator
,
SegmentationContour
from
analysis.colorlegend
import
getColorFromNameWithSeed
from
helperfunctions
import
polygoncovering
,
cv2imread_fix
from
ramancom.configRaman
import
RamanConfigWin
from
analysis.particle
e
ditor
import
ParticleEditor
from
analysis.particle
E
ditor
import
ParticleEditor
class
SampleView
(
QtWidgets
.
QGraphicsView
):
...
...
@@ -412,6 +411,7 @@ class SampleView(QtWidgets.QGraphicsView):
p
=
QtCore
.
QPointF
(
p
.
x
(),
p
.
y
())
for
index
,
cnt
in
enumerate
(
self
.
contourItems
):
if
cnt
.
polygon
.
containsPoint
(
p
,
QtCore
.
Qt
.
OddEvenFill
):
#clicked on particle
if
not
event
.
modifiers
()
==
QtCore
.
Qt
.
ShiftModifier
:
acceptSelection
(
cnt
)
...
...
viewitems.py
View file @
2c03c3ce
...
...
@@ -20,7 +20,7 @@ If not, see <https://www.gnu.org/licenses/>.
"""
#import numpy as np
from
PyQt5
import
QtCore
,
QtWidgets
,
QtGui
from
analysis.particle
e
ditor
import
ParticleContextMenu
from
analysis.particle
E
ditor
import
ParticleContextMenu
class
SegmentationContour
(
QtWidgets
.
QGraphicsItem
):
def
__init__
(
self
,
viewparent
,
contourData
,
pos
=
(
0
,
0
)):
...
...
@@ -128,15 +128,15 @@ class FitPosIndicator(QtWidgets.QGraphicsItem):
class
RamanScanIndicator
(
QtWidgets
.
QGraphicsItem
):
def
__init__
(
self
,
view
,
number
,
radius
,
pos
=
(
0
,
0
)):
super
().
__init__
()
# self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable)
self
.
setAcceptedMouseButtons
(
QtCore
.
Qt
.
NoButton
)
self
.
setZValue
(
100
)
#higher
number
s will be in foreground. Shall always be in foreground!
self
.
setZValue
(
100
)
#higher
zValue
s will be in foreground. Shall always be in foreground!
self
.
view
=
view
self
.
number
=
number
self
.
radius
=
radius
self
.
highlight
=
False
self
.
hidden
=
False
self
.
setPos
(
pos
[
0
],
pos
[
1
])
self
.
hasNoParticleAssigned
=
False
def
setHighLight
(
self
,
highlight
):
if
highlight
!=
self
.
highlight
:
...
...
@@ -157,6 +157,9 @@ class RamanScanIndicator(QtWidgets.QGraphicsItem):
if
self
.
highlight
:
painter
.
setPen
(
QtCore
.
Qt
.
red
)
painter
.
setBrush
(
QtGui
.
QColor
(
100
,
250
,
100
,
150
))
elif
self
.
hasNoParticleAssigned
:
painter
.
setPen
(
QtCore
.
Qt
.
black
)
painter
.
setBrush
(
QtCore
.
Qt
.
red
)
else
:
painter
.
setPen
(
QtCore
.
Qt
.
green
)
painter
.
setBrush
(
QtGui
.
QColor
(
50
,
50
,
250
,
150
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment