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
b421c24d
Commit
b421c24d
authored
Jul 17, 2019
by
JosefBrandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Particle Deletion possible
Currently the spectra points are still there...
parent
92775bcc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
27 deletions
+46
-27
analysis/analysisview.py
analysis/analysisview.py
+4
-5
analysis/analysiswidgets.py
analysis/analysiswidgets.py
+3
-3
analysis/particleeditor.py
analysis/particleeditor.py
+21
-2
analysis/sqlexport.py
analysis/sqlexport.py
+18
-17
No files found.
analysis/analysisview.py
View file @
b421c24d
...
...
@@ -475,7 +475,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
sizeHist_ax
.
figure
.
canvas
.
draw
()
def
updateSpecPlot
(
self
):
particleSize
=
self
.
particleContainer
.
getSizeOfParticleByIndex
(
self
.
currentParticleIndex
)
particleSize
=
np
.
round
(
self
.
particleContainer
.
getSizeOfParticleByIndex
(
self
.
currentParticleIndex
)
)
hqi
=
self
.
particleContainer
.
getHQIOfSpectrumIndex
(
self
.
currentSpectrumIndex
)
self
.
specPlot
.
updateParticleSpectrum
(
self
.
currentSpectrumIndex
,
particleSize
,
hqi
)
# self.lastSpectrumInFocus = self.currentSpectrumIndex
...
...
@@ -614,8 +614,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
for
index
,
partIndex
in
enumerate
(
indices
):
self
.
setWidgetsToNewParticleIndex
(
partIndex
)
assignment
=
self
.
dataset
.
particleContainer
.
getParticleAssignmentByIndex
(
partIndex
)
specIndices
=
self
.
dataset
.
particleContainer
.
getSpectraIndicesOfParticle
(
partIndex
)
assignment
=
self
.
particleContainer
.
getParticleAssignmentByIndex
(
partIndex
)
specIndices
=
self
.
particleContainer
.
getSpectraIndicesOfParticle
(
partIndex
)
self
.
viewparent
.
highLightContour
(
partIndex
)
self
.
viewparent
.
centerOnRamanIndex
(
specIndices
[
0
])
reply
=
QtWidgets
.
QMessageBox
.
question
(
self
,
f
'Particle
{
index
+
1
}
of
{
numIndices
}
'
,
...
...
@@ -635,7 +635,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
particleContainer
.
resetParticleIndices
()
self
.
viewparent
.
resetContourIndices
()
self
.
updateHistogramsAndContours
()
def
show_hide_labels
(
self
):
hidden
=
self
.
hideLabelAct
.
isChecked
()
...
...
@@ -644,7 +643,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
scanIndicator
.
update
()
def
exportToExcel
(
self
):
expWin
=
ExpExcelDialog
(
self
.
particleContainer
,
self
)
expWin
=
ExpExcelDialog
(
self
.
dataset
,
self
.
particleContainer
)
expWin
.
exec
()
def
exportToSQL
(
self
):
...
...
analysis/analysiswidgets.py
View file @
b421c24d
...
...
@@ -30,13 +30,13 @@ from matplotlib.figure import Figure
class
ExpExcelDialog
(
QtWidgets
.
QDialog
):
def
__init__
(
self
,
dataset
,
par
ent
):
super
(
ExpExcelDialog
,
self
).
__init__
(
parent
)
def
__init__
(
self
,
dataset
,
par
ticleContainer
):
super
(
ExpExcelDialog
,
self
).
__init__
()
self
.
setWindowTitle
(
'Export Options'
)
self
.
setGeometry
(
200
,
200
,
300
,
300
)
self
.
dataset
=
dataset
self
.
particleContainer
=
self
.
dataset
.
particleContainer
self
.
particleContainer
=
particleContainer
# self.particles = self.datastats.getParticleStats()
self
.
polymers
=
self
.
particleContainer
.
getListOfParticleAssignments
# self.additives = self.datastats.currentAdditives
...
...
analysis/particleeditor.py
View file @
b421c24d
...
...
@@ -35,6 +35,8 @@ class ParticleContextMenu(QtWidgets.QMenu):
combineParticlesSignal
=
QtCore
.
pyqtSignal
(
list
,
str
)
reassignParticlesSignal
=
QtCore
.
pyqtSignal
(
list
,
str
)
paintParticlesSignal
=
QtCore
.
pyqtSignal
(
list
,
str
)
deleteParticlesSignal
=
QtCore
.
pyqtSignal
(
list
)
def
__init__
(
self
,
viewparent
):
super
(
ParticleContextMenu
,
self
).
__init__
()
self
.
viewparent
=
viewparent
...
...
@@ -80,6 +82,7 @@ class ParticleContextMenu(QtWidgets.QMenu):
self
.
addMenu
(
self
.
combineMenu
)
self
.
addMenu
(
self
.
reassignMenu
)
self
.
addMenu
(
self
.
paintMenu
)
self
.
deleteAct
=
self
.
addAction
(
"Delete particle(s)"
)
action
=
self
.
exec_
(
screenPos
)
...
...
@@ -92,6 +95,8 @@ class ParticleContextMenu(QtWidgets.QMenu):
self
.
reassignParticlesSignal
.
emit
(
self
.
selectedParticleIndices
,
newAssignment
)
elif
action
in
self
.
paintActs
:
self
.
paintParticlesSignal
.
emit
(
self
.
selectedParticleIndices
,
newAssignment
)
elif
action
==
self
.
deleteAct
:
self
.
deleteParticlesSignal
.
emit
(
self
.
selectedParticleIndices
)
def
validifyAssignment
(
self
,
assignment
):
if
assignment
==
"other"
:
...
...
@@ -122,6 +127,7 @@ class ParticleEditor(QtCore.QObject):
contextMenu
.
combineParticlesSignal
.
connect
(
self
.
combineParticles
)
contextMenu
.
reassignParticlesSignal
.
connect
(
self
.
reassignParticles
)
contextMenu
.
paintParticlesSignal
.
connect
(
self
.
paintParticles
)
contextMenu
.
deleteParticlesSignal
.
connect
(
self
.
deleteParticles
)
def
createSafetyBackup
(
self
):
self
.
actionCounter
+=
1
...
...
@@ -248,7 +254,20 @@ class ParticleEditor(QtCore.QObject):
return
long
,
short
,
longellipse
,
shortellipse
,
cv2
.
contourArea
(
cnt
)
@
QtCore
.
pyqtSlot
(
list
)
def
deleteParticles
(
self
,
contourIndices
):
reply
=
QtWidgets
.
QMessageBox
.
question
(
self
,
f
'About to delete
{
len
(
contourIndices
)
}
particles.'
,
"Are you sure to permanantly delete these particles?"
,
QtWidgets
.
QMessageBox
.
Yes
|
QtWidgets
.
QMessageBox
.
No
,
QtWidgets
.
QMessageBox
.
No
)
if
reply
==
QtWidgets
.
QMessageBox
.
Yes
:
for
partIndex
in
sorted
(
contourIndices
,
reverse
=
True
):
self
.
viewparent
.
removeParticleContour
(
partIndex
)
self
.
viewparent
.
dataset
.
particleContainer
.
removeParticles
([
partIndex
])
self
.
viewparent
.
dataset
.
particleContainer
.
resetParticleIndices
()
self
.
viewparent
.
resetContourIndices
()
self
.
viewparent
.
analysiswidget
.
updateHistogramsAndContours
()
\ No newline at end of file
analysis/sqlexport.py
View file @
b421c24d
...
...
@@ -21,9 +21,11 @@ class SQLExport(QtWidgets.QDialog):
self
.
particleContainer
=
particleContainer
# self.polymerList = self.datastats.particleContainer
particlestats
=
self
.
datastats
.
getParticleStats
()
self
.
longSizes
=
np
.
round
(
np
.
array
([
i
[
0
]
if
np
.
isnan
(
i
[
2
])
else
i
[
2
]
for
i
in
particlestats
]),
1
)
self
.
shortSize
=
np
.
round
(
np
.
array
([
i
[
1
]
if
np
.
isnan
(
i
[
3
])
else
i
[
3
]
for
i
in
particlestats
]),
1
)
# particlestats = self.datastats.getParticleStats()
self
.
longSizes
=
self
.
particleContainer
.
getSizesOfAllParticles
()
self
.
shortSize
=
self
.
particleContainer
.
getShortSizesOfAllParticles
()
# self.longSizes = np.round(np.array([i[0] if np.isnan(i[2]) else i[2] for i in particlestats]), 1)
# self.shortSize = np.round(np.array([i[1] if np.isnan(i[3]) else i[3] for i in particlestats]), 1)
#spectra can be quite some data size, they are not copied here but referenced later on...
...
...
@@ -48,7 +50,6 @@ class SQLExport(QtWidgets.QDialog):
self
.
cnx
=
None
self
.
createInterface
()
def
createInterface
(
self
):
layout
=
QtWidgets
.
QVBoxLayout
()
self
.
setLayout
(
layout
)
...
...
@@ -110,7 +111,8 @@ class SQLExport(QtWidgets.QDialog):
for
index
,
entry
in
enumerate
([
'Detected Result*'
,
'DB Polymer Category*'
,
'DB Categorized Result'
,
'DB Paint Remark'
,
'Comment'
]):
typeLayout
.
addWidget
(
QtWidgets
.
QLabel
(
entry
),
0
,
index
+
1
)
self
.
polymerTypes
=
np
.
unique
(
self
.
polymerList
)
# self.polymerTypes = np.unique(self.polymerList)
self
.
polymerTypes
=
self
.
particleContainer
.
getUniquePolymers
()
self
.
polymerCheckboxes
=
[]
self
.
db_polyms
=
[]
self
.
db_categs
=
[]
...
...
@@ -180,8 +182,8 @@ class SQLExport(QtWidgets.QDialog):
for
index
,
polymerType
in
enumerate
(
self
.
polymerTypes
):
if
self
.
polymerCheckboxes
[
index
].
isChecked
():
polymIndices
=
np
.
where
(
self
.
polymerList
==
polymerType
)[
0
]
#
polymIndices = np.where(self.polymerList == polymerType)[0]
polymIndices
=
self
.
particleContainer
.
getIndicesOfParticleType
(
polymerType
)
particleCols
=
self
.
getEntireTable
(
'particles'
)[
0
]
sizeCols
=
[
i
for
i
in
particleCols
if
i
.
startswith
(
'Size'
)
and
i
.
endswith
(
']'
)]
...
...
@@ -213,7 +215,7 @@ class SQLExport(QtWidgets.QDialog):
cursor
.
execute
(
sql_command
)
except
:
print
(
sql_command
)
self
.
cnx
.
commit
()
#
self.cnx.commit()
newIndices
=
self
.
getPartIndicesOfSample
(
self
.
sampleSelector
.
currentText
())
addedParticleIndex
=
list
(
set
(
newIndices
)
-
set
(
currentParticleInd
))[
0
]
...
...
@@ -244,7 +246,7 @@ class SQLExport(QtWidgets.QDialog):
cursor
.
execute
(
sql_command
)
except
:
print
(
sql_command
)
self
.
cnx
.
commit
()
#
self.cnx.commit()
#remove spectrum for log...
sql_command
=
format_str
.
format
(
method
=
method
,
lib
=
lib
,
hqi
=
hqi
,
spec
=
'SpecFile'
,
res
=
res
,
com
=
com
)
self
.
log
.
append
(
sql_command
)
...
...
@@ -255,15 +257,14 @@ class SQLExport(QtWidgets.QDialog):
particles2analasyses
[
addedParticleIndex
].
append
(
addedAnalysisIndex
)
##upload particles2analyses:
for
particleInd
in
particles2analasyses
:
for
anaInd
in
particles2analasyses
[
particleInd
]:
sql_command
=
"""INSERT INTO particles2analysis (IDParticles, IDAnalysis) VALUES ("{}", "{}");"""
.
format
(
particleInd
,
anaInd
)
cursor
.
execute
(
sql_command
)
self
.
log
.
append
(
sql_command
)
self
.
cnx
.
commit
()
#
##upload particles2analyses:
#
for particleInd in particles2analasyses:
#
for anaInd in particles2analasyses[particleInd]:
#
sql_command = """INSERT INTO particles2analysis (IDParticles, IDAnalysis) VALUES ("{}", "{}");""".format(particleInd, anaInd)
#
cursor.execute(sql_command)
#
self.log.append(sql_command)
#
self.cnx.commit()
for
index
,
polymType
in
enumerate
(
self
.
polymerTypes
):
if
self
.
polymerCheckboxes
[
index
].
isChecked
():
...
...
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