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
9fdb42e2
Commit
9fdb42e2
authored
Jul 09, 2019
by
JosefBrandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load TrueMatchResult Works
parent
1c6ae7e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
165 deletions
+115
-165
analysis/analysisview.py
analysis/analysisview.py
+15
-25
analysis/loadresults.py
analysis/loadresults.py
+91
-133
analysis/particleInfo.py
analysis/particleInfo.py
+9
-7
No files found.
analysis/analysisview.py
View file @
9fdb42e2
...
@@ -31,7 +31,7 @@ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as Navigatio
...
@@ -31,7 +31,7 @@ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as Navigatio
from
.analysiswidgets
import
ExpExcelDialog
from
.analysiswidgets
import
ExpExcelDialog
from
.analysisplots
import
TypeHistogramView
,
SpectraPlot
from
.analysisplots
import
TypeHistogramView
,
SpectraPlot
from
.loadresults
import
Load
WITec
Results
from
.loadresults
import
Load
TrueMatch
Results
from
.particleeditor
import
ParticleEditor
from
.particleeditor
import
ParticleEditor
from
.database
import
DataBaseWindow
from
.database
import
DataBaseWindow
from
.colorlegend
import
ColorHandler
from
.colorlegend
import
ColorHandler
...
@@ -152,7 +152,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
...
@@ -152,7 +152,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
viewLayout
.
addWidget
(
splitter2
)
viewLayout
.
addWidget
(
splitter2
)
viewLayout
.
setStretch
(
1
,
1
)
viewLayout
.
setStretch
(
1
,
1
)
self
.
optionsGroup
=
QtWidgets
.
QGroupBox
(
'
Further Options
'
)
self
.
optionsGroup
=
QtWidgets
.
QGroupBox
(
'
Set HQI Threshold
'
)
optionsLayout
=
QtWidgets
.
QFormLayout
()
optionsLayout
=
QtWidgets
.
QFormLayout
()
self
.
hqiSpinBox
=
QtWidgets
.
QDoubleSpinBox
()
self
.
hqiSpinBox
=
QtWidgets
.
QDoubleSpinBox
()
...
@@ -162,7 +162,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
...
@@ -162,7 +162,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
hqiSpinBox
.
setMaximum
(
100
)
self
.
hqiSpinBox
.
setMaximum
(
100
)
self
.
hqiSpinBox
.
setMaximumWidth
(
100
)
self
.
hqiSpinBox
.
setMaximumWidth
(
100
)
self
.
hqiSpinBox
.
valueChanged
.
connect
(
self
.
applyHQIThresholdToResults
)
self
.
hqiSpinBox
.
valueChanged
.
connect
(
self
.
applyHQIThresholdToResults
)
optionsLayout
.
addRow
(
QtWidgets
.
QLabel
(
'min HQI:'
),
self
.
hqiSpinBox
)
optionsLayout
.
addRow
(
QtWidgets
.
QLabel
(
'min
imum
HQI:'
),
self
.
hqiSpinBox
)
# self.compHqiSpinBox = QtWidgets.QDoubleSpinBox()
# self.compHqiSpinBox = QtWidgets.QDoubleSpinBox()
# self.compHqiSpinBox.setValue(30.0)
# self.compHqiSpinBox.setValue(30.0)
...
@@ -171,14 +171,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
...
@@ -171,14 +171,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
# self.compHqiSpinBox.setDisabled(True)
# self.compHqiSpinBox.setDisabled(True)
# optionsLayout.addRow(QtWidgets.QLabel('min component HQI'), self.compHqiSpinBox)
# optionsLayout.addRow(QtWidgets.QLabel('min component HQI'), self.compHqiSpinBox)
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
.
optionsGroup
.
setLayout
(
optionsLayout
)
self
.
optionsGroup
.
setLayout
(
optionsLayout
)
self
.
optionsGroup
.
setMinimumWidth
(
175
)
self
.
optionsGroup
.
setMinimumWidth
(
175
)
# self.optionsGroup.setDisabled(True)
# self.optionsGroup.setDisabled(True)
...
@@ -309,7 +301,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
...
@@ -309,7 +301,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
refSelector
.
setDisabled
(
False
)
self
.
refSelector
.
setDisabled
(
False
)
def
importTrueMatchResults
(
self
):
def
importTrueMatchResults
(
self
):
self
.
importWindow
=
Load
WITec
Results
(
self
.
particleContainer
,
self
)
self
.
importWindow
=
Load
TrueMatch
Results
(
self
.
particleContainer
,
self
)
self
.
importWindow
.
exec
()
self
.
importWindow
.
exec
()
# @QtCore.pyqtSlot(int)
# @QtCore.pyqtSlot(int)
...
@@ -414,14 +406,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
...
@@ -414,14 +406,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
# print('displaying new type with resetting index')
# print('displaying new type with resetting index')
# self.displayNewPolymerType()
# self.displayNewPolymerType()
def
updateHistograms
(
self
):
def
exportToExcel
(
self
):
self
.
updateTypeHistogram
()
expWin
=
ExpExcelDialog
(
self
.
particleContainer
,
self
)
self
.
updateSizeHistogram
()
expWin
.
exec
()
def
exportToSQL
(
self
):
sqlexp
=
SQLExport
(
self
.
particleContainer
,
self
)
sqlexp
.
exec
()
def
initializeSpecPlot
(
self
):
def
initializeSpecPlot
(
self
):
self
.
specPlot
.
loadSpectraAndInitializeSpecPlot
()
self
.
specPlot
.
loadSpectraAndInitializeSpecPlot
()
...
@@ -525,10 +512,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
...
@@ -525,10 +512,6 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
particleIndicesOfType
=
self
.
particleContainer
.
getIndicesOfParticleType
(
self
.
typeSelectorCombo
.
currentText
())
particleIndicesOfType
=
self
.
particleContainer
.
getIndicesOfParticleType
(
self
.
typeSelectorCombo
.
currentText
())
return
particleIndicesOfType
[
self
.
particleSelector
.
value
()
-
1
]
return
particleIndicesOfType
[
self
.
particleSelector
.
value
()
-
1
]
def
updateHistograms
(
self
):
self
.
updateTypeHistogram
()
self
.
updateSizeHistogram
()
def
updateTypeHistogram
(
self
):
def
updateTypeHistogram
(
self
):
#draw the general histogram
#draw the general histogram
colorList
=
[]
colorList
=
[]
...
@@ -655,7 +638,14 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
...
@@ -655,7 +638,14 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
for
scanIndicator
in
self
.
parent
.
ramanscanitems
:
for
scanIndicator
in
self
.
parent
.
ramanscanitems
:
scanIndicator
.
hidden
=
hidden
scanIndicator
.
hidden
=
hidden
scanIndicator
.
update
()
scanIndicator
.
update
()
def
exportToExcel
(
self
):
expWin
=
ExpExcelDialog
(
self
.
particleContainer
,
self
)
expWin
.
exec
()
def
exportToSQL
(
self
):
sqlexp
=
SQLExport
(
self
.
particleContainer
,
self
)
sqlexp
.
exec
()
def
closeEvent
(
self
,
event
):
def
closeEvent
(
self
,
event
):
for
window
in
[
self
.
importWindow
,
self
.
dbWin
]:
for
window
in
[
self
.
importWindow
,
self
.
dbWin
]:
...
...
analysis/loadresults.py
View file @
9fdb42e2
#!/usr/bin/env python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""
"""
Created on Thu May 31 10:07:45 2018
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>
@author: brandt
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/>.
"""
"""
import
numpy
as
np
import
numpy
as
np
from
PyQt5
import
QtWidgets
from
PyQt5
import
QtWidgets
import
sys
from
os
import
chdir
,
getcwd
class
LoadWITecResults
(
QtWidgets
.
QDialog
):
class
LoadWITecResults
(
QtWidgets
.
QDialog
):
def
__init__
(
self
,
particleContainer
,
parent
):
def
__init__
(
self
,
particleContainer
,
parent
):
...
@@ -28,43 +40,34 @@ class LoadWITecResults(QtWidgets.QDialog):
...
@@ -28,43 +40,34 @@ class LoadWITecResults(QtWidgets.QDialog):
self
.
hqis
=
None
self
.
hqis
=
None
self
.
addhqis
=
None
self
.
addhqis
=
None
self
.
b
tn
1
=
QtWidgets
.
QPushButton
(
'LoadTrueMatchResults'
)
self
.
loadB
tn
=
QtWidgets
.
QPushButton
(
'LoadTrueMatchResults'
)
self
.
b
tn
1
.
resize
(
self
.
b
tn
1
.
sizeHint
())
self
.
loadB
tn
.
resize
(
self
.
loadB
tn
.
sizeHint
())
self
.
b
tn
1
.
clicked
.
connect
(
self
.
loadFileManually
)
self
.
loadB
tn
.
clicked
.
connect
(
self
.
loadFileManually
)
optionsLayout
=
QtWidgets
.
QFormLayout
()
# optionsLayout = QtWidgets.QFormLayout()
self
.
optionsGroup
=
QtWidgets
.
QGroupBox
(
'Compute Options'
)
# self.optionsGroup = QtWidgets.QGroupBox('Compute Options')
self
.
optionsGroup
.
setDisabled
(
True
)
# self.optionsGroup.setDisabled(True)
self
.
btn3
=
QtWidgets
.
QPushButton
(
'Compute'
)
#
self
.
btn3
.
clicked
.
connect
(
self
.
runCalculations
)
# self.label1 = QtWidgets.QLabel('HQI-Threshold:')
# self.spinbox1 = QtWidgets.QDoubleSpinBox(self)
self
.
label1
=
QtWidgets
.
QLabel
(
'HQI-Threshold:'
)
# self.spinbox1.valueChanged.connect(self.runCalculations)
self
.
spinbox1
=
QtWidgets
.
QDoubleSpinBox
(
self
)
# optionsLayout.addRow(self.label1, self.spinbox1)
self
.
spinbox1
.
valueChanged
.
connect
(
self
.
updateParentSpinboxes
)
optionsLayout
.
addRow
(
self
.
label1
,
self
.
spinbox1
)
self
.
label2
=
QtWidgets
.
QLabel
(
'ComponentThreshold:'
)
# self.label2 = QtWidgets.QLabel('ComponentThreshold:')
self
.
spinbox2
=
QtWidgets
.
QDoubleSpinBox
(
self
)
# self.spinbox2 = QtWidgets.QDoubleSpinBox(self)
self
.
spinbox2
.
valueChanged
.
connect
(
self
.
updateParentSpinboxes
)
# self.spinbox2.valueChanged.connect(self.updateParentSpinboxes)
optionsLayout
.
addRow
(
self
.
label2
,
self
.
spinbox2
)
# optionsLayout.addRow(self.label2, self.spinbox2)
self
.
label3
=
QtWidgets
.
QLabel
(
'Max Items in Display:'
)
self
.
numDispSpinbox
=
QtWidgets
.
QSpinBox
(
self
)
self
.
numDispSpinbox
.
setValue
(
20
)
self
.
numDispSpinbox
.
setMinimum
(
1
)
self
.
numDispSpinbox
.
setMaximum
(
40
)
self
.
numDispSpinbox
.
valueChanged
.
connect
(
self
.
updateParentSpinboxes
)
optionsLayout
.
addRow
(
self
.
label3
,
self
.
numDispSpinbox
)
optionsLayout
.
addRow
(
self
.
btn3
)
for
box
in
[
self
.
spinbox1
,
self
.
spinbox2
]:
# for box in [self.spinbox1, self.spinbox2]:
box
.
setValue
(
50
)
# for box in [self.spinbox1]:
box
.
setDecimals
(
1
)
# box.setValue(50)
box
.
setSingleStep
(
5
)
# box.setDecimals(1)
box
.
setMinimum
(
0
)
# box.setSingleStep(5)
box
.
setMaximum
(
100
)
# box.setMinimum(0)
self
.
spinbox2
.
setValue
(
30
)
#more reasonable...
# box.setMaximum(100)
## self.spinbox2.setValue(30) #more reasonable...
self
.
optionsGroup
.
setLayout
(
optionsLayout
)
#
# self.optionsGroup.setLayout(optionsLayout)
self
.
reviewGroup
=
QtWidgets
.
QGroupBox
(
'Review Changes'
)
self
.
reviewGroup
=
QtWidgets
.
QGroupBox
(
'Review Changes'
)
self
.
reviewGroup
.
setDisabled
(
True
)
self
.
reviewGroup
.
setDisabled
(
True
)
...
@@ -76,8 +79,8 @@ class LoadWITecResults(QtWidgets.QDialog):
...
@@ -76,8 +79,8 @@ class LoadWITecResults(QtWidgets.QDialog):
reviewLayout
.
addStretch
()
reviewLayout
.
addStretch
()
self
.
reviewGroup
.
setLayout
(
reviewLayout
)
self
.
reviewGroup
.
setLayout
(
reviewLayout
)
self
.
layout
.
addWidget
(
self
.
b
tn
1
,
0
,
0
)
self
.
layout
.
addWidget
(
self
.
loadB
tn
,
0
,
0
)
self
.
layout
.
addWidget
(
self
.
optionsGroup
,
1
,
0
)
#
self.layout.addWidget(self.optionsGroup, 1, 0)
self
.
layout
.
addWidget
(
self
.
reviewGroup
,
2
,
0
)
self
.
layout
.
addWidget
(
self
.
reviewGroup
,
2
,
0
)
self
.
manualPolymers
=
{}
self
.
manualPolymers
=
{}
...
@@ -90,11 +93,6 @@ class LoadWITecResults(QtWidgets.QDialog):
...
@@ -90,11 +93,6 @@ class LoadWITecResults(QtWidgets.QDialog):
self
.
numFlagForSetUnknown
=
2
self
.
numFlagForSetUnknown
=
2
self
.
numFlagForPrompt
=
3
self
.
numFlagForPrompt
=
3
def
updateParentSpinboxes
(
self
):
self
.
parent
.
hqiSpinBox
.
setValue
(
self
.
spinbox1
.
value
())
self
.
parent
.
compHqiSpinBox
.
setValue
(
self
.
spinbox2
.
value
())
self
.
parent
.
dispResultSpinBox
.
setValue
(
self
.
numDispSpinbox
.
value
())
def
show3FlagsReview
(
self
):
def
show3FlagsReview
(
self
):
self
.
editEntryWindow
=
ModifyManualEdits
(
self
,
self
.
manualPolymers
,
self
.
manualAdditives
)
self
.
editEntryWindow
=
ModifyManualEdits
(
self
,
self
.
manualPolymers
,
self
.
manualAdditives
)
self
.
editEntryWindow
.
show
()
self
.
editEntryWindow
.
show
()
...
@@ -114,18 +112,14 @@ class LoadWITecResults(QtWidgets.QDialog):
...
@@ -114,18 +112,14 @@ class LoadWITecResults(QtWidgets.QDialog):
for
lineindex
,
line
in
enumerate
(
file
):
for
lineindex
,
line
in
enumerate
(
file
):
if
lineindex
>
0
:
if
lineindex
>
0
:
self
.
trueMatchResults
.
append
(
line
)
self
.
trueMatchResults
.
append
(
line
)
self
.
runCalculations
()
self
.
btn1
.
setText
(
'Data loaded'
)
self
.
optionsGroup
.
setDisabled
(
False
)
def
formatResults
(
self
,
rawResults
):
#get rid of header line, first data interpretation
def
formatResults
(
self
,
rawResults
):
#get rid of header line, first data interpretation
results
=
[]
results
=
[]
for
index
,
line
in
enumerate
(
rawResults
):
for
index
,
line
in
enumerate
(
rawResults
):
if
index
==
0
:
if
index
==
0
:
line
=
line
.
strip
().
split
(
';'
)[:
-
1
]
#disregard the last entry of each line, as each line ends with ; <- that produces an empty entry...
line
=
line
.
strip
().
split
(
';'
)[:
-
1
]
#disregard the last entry of each line, as each line ends with ; <- that produces an empty entry...
if
line
[
0
]
!=
'Search Spectrum Name'
:
assert
line
[
0
]
==
'Search Spectrum Name'
,
'Assertion Error in loadTrueMatchResults'
print
(
'incompatible data format'
)
break
#detect, whether one- or multicomponent-search was done
#detect, whether one- or multicomponent-search was done
if
line
[
-
1
]
==
'IsMarked'
:
if
line
[
-
1
]
==
'IsMarked'
:
numhits
=
np
.
int
(
line
[
-
2
].
split
(
' '
)[
-
1
])
numhits
=
np
.
int
(
line
[
-
2
].
split
(
' '
)[
-
1
])
...
@@ -142,38 +136,29 @@ class LoadWITecResults(QtWidgets.QDialog):
...
@@ -142,38 +136,29 @@ class LoadWITecResults(QtWidgets.QDialog):
return
results
,
numspectra
,
numcomps
,
numhits
return
results
,
numspectra
,
numcomps
,
numhits
def
interpretEntry
(
self
,
index
,
entry
,
numhits
,
numcomps
):
def
interpretEntry
(
self
,
entry
,
numhits
,
numcomps
):
entry
=
entry
.
split
(
';'
)
entry
=
entry
.
split
(
';'
)
polymertype
,
additive
,
hqi
,
addhqi
=
None
,
None
,
None
,
None
#assign default None
specIndex
,
polymertype
,
additive
,
hqi
,
addhqi
=
None
,
None
,
None
,
None
,
0
#assign defaults
#specNameFormat is: SampleName_000_Spec.Data 1 (SpecIndex)
specName
=
entry
[
0
]
indexOpenBracket
=
specName
.
find
(
'('
)
indexCloseBracket
=
specName
.
find
(
')'
)
specIndex
=
int
(
specName
[
indexOpenBracket
+
1
:
indexCloseBracket
])
#find yes-flags
#find yes-flags
flags
=
np
.
where
(
np
.
array
(
entry
)
==
'yes'
)[
0
]
flags
=
np
.
where
(
np
.
array
(
entry
)
==
'yes'
)[
0
]
if
len
(
flags
)
==
0
:
if
len
(
flags
)
==
0
:
#take highest HQI entry
#take highest HQI entry
if
numcomps
==
1
:
if
numcomps
==
1
:
if
float
(
entry
[
1
])
>
self
.
spinbox1
.
value
():
polymertype
=
entry
[
2
]
polymertype
=
entry
[
2
]
hqi
=
entry
[
1
]
hqi
=
entry
[
1
]
else
:
polymertype
=
'unknown'
hqi
=
0
else
:
else
:
if
float
(
entry
[
1
])
>
self
.
spinbox1
.
value
():
polymertype
=
entry
[
5
]
polymertype
=
entry
[
5
]
hqi
=
entry
[
1
]
hqi
=
entry
[
1
]
additive
=
entry
[
7
]
if
float
(
entry
[
6
])
>
self
.
spinbox2
.
value
():
addhqi
=
entry
[
6
]
additive
=
entry
[
7
]
addhqi
=
entry
[
6
]
else
:
additive
=
'none'
addhqi
=
0
else
:
polymertype
=
'unknown'
additive
=
'none'
hqi
=
0
addhqi
=
0
elif
len
(
flags
)
==
1
:
elif
len
(
flags
)
==
1
:
#exactly one flag was placed, take this entry
#exactly one flag was placed, take this entry
if
numcomps
==
1
:
if
numcomps
==
1
:
...
@@ -193,78 +178,68 @@ class LoadWITecResults(QtWidgets.QDialog):
...
@@ -193,78 +178,68 @@ class LoadWITecResults(QtWidgets.QDialog):
addhqi
=
0
addhqi
=
0
elif
len
(
flags
)
==
3
:
elif
len
(
flags
)
==
3
:
hqi
=
100
hqi
=
100
if
i
ndex
not
in
self
.
manualPolymers
:
if
specI
ndex
not
in
self
.
manualPolymers
:
polymertype
,
ok
=
QtWidgets
.
QInputDialog
.
getText
(
self
,
'Name of main component'
,
'Spectrum at index {} is:'
.
format
(
i
ndex
))
polymertype
,
ok
=
QtWidgets
.
QInputDialog
.
getText
(
self
,
'Name of main component'
,
'Spectrum at index {} is:'
.
format
(
specI
ndex
))
self
.
manualPolymers
[
i
ndex
]
=
polymertype
self
.
manualPolymers
[
specI
ndex
]
=
polymertype
else
:
else
:
polymertype
=
self
.
manualPolymers
[
i
ndex
]
polymertype
=
self
.
manualPolymers
[
specI
ndex
]
if
numcomps
>
1
:
if
numcomps
>
1
:
addhqi
=
100
addhqi
=
100
if
entry
[
0
]
not
in
self
.
manualAdditives
:
if
entry
[
0
]
not
in
self
.
manualAdditives
:
additive
,
ok
=
QtWidgets
.
QInputDialog
.
getText
(
self
,
'Name of additive'
,
'Additive at index {} is:'
.
format
(
i
ndex
))
additive
,
ok
=
QtWidgets
.
QInputDialog
.
getText
(
self
,
'Name of additive'
,
'Additive at index {} is:'
.
format
(
specI
ndex
))
self
.
manualAdditives
[
i
ndex
]
=
additive
self
.
manualAdditives
[
specI
ndex
]
=
additive
else
:
else
:
additive
=
self
.
manualAdditives
[
i
ndex
]
additive
=
self
.
manualAdditives
[
specI
ndex
]
else
:
else
:
QtWidgets
.
QMessageBox
.
about
(
self
,
'Error!'
,
'No rule for {} flags, found at spectrum index {}'
.
format
(
len
(
flags
),
i
ndex
))
QtWidgets
.
QMessageBox
.
about
(
self
,
'Error!'
,
'No rule for {} flags, found at spectrum index {}'
.
format
(
len
(
flags
),
specI
ndex
))
if
addhqi
is
None
:
return
specIndex
,
polymertype
,
additive
,
float
(
hqi
),
float
(
addhqi
)
addhqi
=
0
return
polymertype
,
additive
,
float
(
hqi
),
float
(
addhqi
)
def
runCalculations
(
self
):
def
runCalculations
(
self
):
self
.
resultList
,
numspectra
,
numcomps
,
numhits
=
self
.
formatResults
(
self
.
trueMatchResults
)
self
.
resultList
,
numspectra
,
numcomps
,
numhits
=
self
.
formatResults
(
self
.
trueMatchResults
)
self
.
dispresults
=
self
.
numDispSpinbox
.
value
()
self
.
polymertypes
=
[
None
]
*
numspectra
self
.
hqis
=
[
None
]
*
numspectra
self
.
polymertypes
=
[]
self
.
hqis
=
[]
if
numcomps
==
1
:
#####SINGLE COMPONENT SEARCH
if
numcomps
==
1
:
#####SINGLE COMPONENT SEARCH
self
.
additives
=
None
self
.
additives
=
None
self
.
addhqis
=
None
self
.
addhqis
=
None
self
.
spinbox2
.
setEnabled
(
False
)
#
self.spinbox2.setEnabled(False)
for
index
,
entry
in
enumerate
(
self
.
resultList
):
for
index
,
entry
in
enumerate
(
self
.
resultList
):
if
len
(
entry
)
==
0
:
if
len
(
entry
)
==
0
:
del
self
.
resultList
[
index
]
del
self
.
resultList
[
index
]
else
:
else
:
polymertype
,
additive
,
hqi
,
addhqi
=
self
.
interpretEntry
(
index
,
entry
,
numhits
,
numcomps
)
specIndex
,
polymertype
,
additive
,
hqi
,
addhqi
=
self
.
interpretEntry
(
entry
,
numhits
,
numcomps
)
self
.
polymertypes
.
append
(
polymertype
)
self
.
polymertypes
[
specIndex
]
=
polymertype
self
.
hqis
.
append
(
hqi
)
self
.
hqis
[
specIndex
]
=
hqi
else
:
#####MULTI-COMPONENT SEARCH
else
:
#####MULTI-COMPONENT SEARCH
self
.
additives
=
[
]
self
.
additives
=
[
None
]
*
numspectra
self
.
addhqis
=
[
]
self
.
addhqis
=
[
None
]
*
numspectra
for
index
,
entry
in
enumerate
(
self
.
resultList
):
for
index
,
entry
in
enumerate
(
self
.
resultList
):
if
len
(
entry
)
>
0
:
if
len
(
entry
)
>
0
:
polymertype
,
additive
,
hqi
=
self
.
interpretEntry
(
index
,
entry
,
numhits
,
numcomps
)
specIndex
,
polymertype
,
additive
,
hqi
=
self
.
interpretEntry
(
entry
,
numhits
,
numcomps
)
self
.
polymertypes
.
append
(
polymertype
)
self
.
polymertypes
[
specIndex
]
=
polymertype
self
.
hqis
.
append
(
hqi
)
self
.
hqis
[
specIndex
]
=
hqi
self
.
additives
.
append
(
additive
)
self
.
additives
[
specIndex
]
=
additive
self
.
addhqis
.
append
(
addhqi
)
self
.
addhqis
[
specIndex
]
=
addhqi
assert
len
(
self
.
polymertypes
)
==
len
(
self
.
resultList
),
'incorrect number of polymer types added...'
assert
len
(
self
.
polymertypes
)
==
len
(
self
.
resultList
),
'incorrect number of polymer types added...'
assert
not
None
in
self
.
polymertypes
,
'wrong assignments in loadResults'
assert
not
None
in
self
.
hqis
,
'wrong assignments in loadResults'
self
.
particleContainer
.
applyAssignmentListToParticleMeasurements
(
self
.
polymertypes
)
self
.
particleContainer
.
applyAssignmentListToParticleMeasurements
(
self
.
polymertypes
)
self
.
particleContainer
.
applyHQIListToParticleMeasurements
(
self
.
hqis
)
self
.
particleContainer
.
applyHQIListToParticleMeasurements
(
self
.
hqis
)
self
.
parent
.
formatResults
()
if
len
(
self
.
manualPolymers
)
>
0
:
if
len
(
self
.
manualPolymers
)
>
0
:
self
.
reviewGroup
.
setDisabled
(
False
)
self
.
reviewGroup
.
setDisabled
(
False
)
self
.
parent
.
applyHQIThresholdToResults
()
self
.
loadBtn
.
setText
(
'Data loaded'
)
QtWidgets
.
QMessageBox
.
about
(
self
,
'Success'
,
'Results were imported successfully.
\n
You can close this window or modify manual edits.'
)
def
closeEvent
(
self
,
event
):
def
closeEvent
(
self
,
event
):
# self.datastats.resetResults(self.polymertypes, self.additives,
# self.hqis, self.addhqis)
self
.
parent
.
updateBtn
.
clicked
.
connect
(
self
.
parent
.
formatResults
)
self
.
parent
.
formatResults
()
self
.
parent
.
show_hide_labels
()
# minHQI = self.parent.hqiSpinBox.value()
# compHQI = self.parent.compHqiSpinBox.value()
self
.
parent
.
dataset
.
save
()
#TODO: SANITY CHECK FOR DATA CONSISTENCY!!
#TODO: SANITY CHECK FOR DATA CONSISTENCY!!
# if not self.parent.datastats.saveAnalysisResults(minHQI, compHQI):
# if not self.parent.datastats.saveAnalysisResults(minHQI, compHQI):
...
@@ -331,21 +306,4 @@ class ModifyManualEdits(QtWidgets.QWidget):
...
@@ -331,21 +306,4 @@ class ModifyManualEdits(QtWidgets.QWidget):
self
.
parent
.
manualPolymers
,
self
.
parent
.
manualAdditives
=
self
.
polymerEdits
,
self
.
additiveEdits
self
.
parent
.
manualPolymers
,
self
.
parent
.
manualAdditives
=
self
.
polymerEdits
,
self
.
additiveEdits
self
.
parent
.
runCalculations
()
self
.
parent
.
runCalculations
()
self
.
close
()
self
.
close
()
if
__name__
==
"__main__"
:
wd
=
getcwd
()
chdir
(
wd
)
try
:
del
(
app
)
except
:
pass
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
mainWin
=
LoadWITecResults
(
None
)
mainWin
.
show
()
app
.
exec_
()
analysis/particleInfo.py
View file @
9fdb42e2
...
@@ -72,22 +72,24 @@ class ParticleContainer(object):
...
@@ -72,22 +72,24 @@ class ParticleContainer(object):
particle
.
applyHQITresholdToMeasurements
(
minHQI
)
particle
.
applyHQITresholdToMeasurements
(
minHQI
)
def
applyAssignmentListToParticleMeasurements
(
self
,
assignmentList
):
def
applyAssignmentListToParticleMeasurements
(
self
,
assignmentList
):
indicesOfTransferredAssignments
=
[]
'''AssignmentList is list of spectra assignments in order of spectra indices'''
indicesOfTransferredAssignments
=
[
None
]
*
len
(
assignmentList
)
for
particle
in
self
.
particles
:
for
particle
in
self
.
particles
:
for
meas
in
particle
.
getMeasurements
():
for
meas
in
particle
.
getMeasurements
():
scanIndex
=
meas
.
getScanIndex
()
scanIndex
=
meas
.
getScanIndex
()
meas
.
setAssignment
(
assignmentList
[
scanIndex
])
meas
.
setAssignment
(
assignmentList
[
scanIndex
])
indicesOfTransferredAssignments
.
append
(
scanIndex
)
indicesOfTransferredAssignments
[
scanIndex
]
=
scanIndex
assert
n
p
.
unique
(
indicesOfTransferredAssignments
)
==
np
.
unique
((
range
(
len
(
assignmentList
))))
assert
n
ot
None
in
indicesOfTransferredAssignments
def
applyHQIListToParticleMeasurements
(
self
,
hqiList
):
def
applyHQIListToParticleMeasurements
(
self
,
hqiList
):
indicesOfTransferredAssignments
=
[]
'''HQI-List is list of spectra hqis in order of spectra indices'''
indicesOfTransferredHQIs
=
[
None
]
*
len
(
hqiList
)
for
particle
in
self
.
particles
:
for
particle
in
self
.
particles
:
for
meas
in
particle
.
getMeasurements
():
for
meas
in
particle
.
getMeasurements
():
scanIndex
=
meas
.
getScanIndex
()
scanIndex
=
meas
.
getScanIndex
()
meas
.
set
Assignment
(
hqiList
[
scanIndex
])
meas
.
set
HQI
(
hqiList
[
scanIndex
])
indicesOfTransferred
Assignments
.
append
(
scanIndex
)
indicesOfTransferred
HQIs
[
scanIndex
]
=
scanIndex
assert
n
p
.
unique
(
indicesOfTransferred
Assignments
)
==
np
.
unique
((
range
(
len
(
hqiList
))))
assert
n
ot
None
in
indicesOfTransferred
HQIs
def
getParticleOfIndex
(
self
,
index
):
def
getParticleOfIndex
(
self
,
index
):
particle
=
self
.
particles
[
index
]
particle
=
self
.
particles
[
index
]
...
...
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