Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Zelenka
prasopes
Commits
68db28ee
Commit
68db28ee
authored
Aug 19, 2019
by
Yan
Browse files
Parameters log pt2
* Parameters shifts based on the selected range
parent
2f51375a
Changes
2
Hide whitespace changes
Inline
Side-by-side
prasopes/__main__.py
View file @
68db28ee
...
...
@@ -129,28 +129,6 @@ def update_spectrum(chromatogram, spect, ds, ms, fn, chrom, config):
spect
.
get_figure
().
canvas
.
draw
()
def
update_paramstable
(
table
,
ms
,
chrom
):
if
len
(
ms
[
'params'
])
==
0
:
table
.
setRowCount
(
0
)
return
table
.
setRowCount
(
len
(
ms
[
'params'
][
0
]))
validator
=
QtGui
.
QDoubleValidator
()
for
row
,
paramname
in
enumerate
(
ms
[
'params'
][
0
]):
[
table
.
setItem
(
row
,
col
,
QtWidgets
.
QTableWidgetItem
())
for
col
in
range
(
2
)]
table
.
item
(
row
,
0
).
setText
(
paramname
)
vals
=
[
param
[
row
]
for
param
in
ms
[
'params'
][
1
]]
if
all
([
type
(
val
)
in
[
np
.
float32
,
np
.
float64
]
for
val
in
vals
]):
aver
=
np
.
average
(
vals
)
minim
=
min
(
vals
)
maxim
=
max
(
vals
)
text
=
"{:.2f} (from {:.2f} to {:.2f})"
.
format
(
aver
,
minim
,
maxim
)
else
:
values
=
[
str
(
i
)
for
i
in
np
.
unique
(
np
.
array
(
vals
),
axis
=
0
)]
text
=
" or "
.
join
(
values
)
table
.
item
(
row
,
1
).
setText
(
text
)
def
dropped
(
event
,
parent
,
chromatogram
,
spectrum
,
ds
,
ms
,
filename
,
chrom
,
update
,
config
,
loadthread
):
dropurl
=
event
.
mimeData
().
urls
()[
0
].
toLocalFile
()
...
...
@@ -239,6 +217,7 @@ def main():
params_logger
.
addHandler
(
barHandler
)
barHandler
.
setLevel
(
"DEBUG"
)
paramstable
=
dt
.
table
([
"name"
,
"value"
],
100
)
graph
=
Figure
(
figsize
=
(
5
,
4
),
dpi
=
100
,
facecolor
=
"None"
)
grid
=
graph
.
add_gridspec
(
2
,
1
)
chromatogram
=
graph
.
add_subplot
(
grid
[
0
,
0
],
facecolor
=
(
1
,
1
,
1
,
0.8
))
...
...
@@ -259,7 +238,7 @@ def main():
button
=
3
)
time_selector
=
SpanSelector
(
chromatogram
,
lambda
x_min
,
x_max
:
gt
.
pick_times
(
x_min
,
x_max
,
spectrum
,
ds
,
chromatogram
,
ms
,
chrom
)
,
x_min
,
x_max
,
spectrum
,
ds
,
chromatogram
,
ms
,
chrom
,
paramstable
),
'horizontal'
,
useblit
=
True
,
rectprops
=
dict
(
alpha
=
0.15
,
facecolor
=
'purple'
),
button
=
3
)
...
...
@@ -380,8 +359,7 @@ def main():
toolBar
.
addAction
(
autozoomy
)
paramsdock
=
QtWidgets
.
QDockWidget
()
paramstable
=
dt
.
table
([
"name"
,
"value"
],
100
)
update
.
signal
.
connect
(
lambda
:
update_paramstable
(
paramstable
,
ms
,
chrom
))
update
.
signal
.
connect
(
lambda
:
gt
.
update_paramstable
(
paramstable
,
ms
,
chrom
))
paramsdock
.
setWidget
(
paramstable
)
fileModel
=
QtWidgets
.
QFileSystemModel
()
...
...
prasopes/graphtools.py
View file @
68db28ee
...
...
@@ -157,7 +157,7 @@ def plot_subtime(mpl_spectrum, mpl_chromatogram, ds, ms_data, chrom_data):
def
pick_times
(
x_min
,
x_max
,
mpl_spectrum
,
data_set
,
mpl_chromatogram
,
mass_spect
,
chrom_spect
):
mass_spect
,
chrom_spect
,
table
):
"""subselect part of the chromatogram and plot it"""
chrom_spect
[
't_start'
]
=
x_min
chrom_spect
[
't_end'
]
=
x_max
...
...
@@ -168,6 +168,7 @@ def pick_times(x_min, x_max, mpl_spectrum, data_set, mpl_chromatogram,
goodtimes
=
np
.
where
((
times
<
len
(
subset
[
'chrom_dat'
][
0
]))
&
~
(
times
<
0
))[
0
]
chrom_spect
[
'timesarg'
].
append
(
times
[
goodtimes
])
times
=
times
-
len
(
subset
[
'chrom_dat'
][
0
])
update_paramstable
(
table
,
mass_spect
,
chrom_spect
)
plot_subtime
(
mpl_spectrum
,
mpl_chromatogram
,
data_set
,
mass_spect
,
chrom_spect
)
...
...
@@ -340,3 +341,28 @@ def populate(mpl_chromatogram, mpl_spectrum, data_set,
ax
.
set_ylim
(
ax
.
get_ylim
()[
1
]
*-
0.01
,
ax
.
get_ylim
()[
1
]
*
1.1
)
ax
.
figure
.
canvas
.
draw
()
return
def
update_paramstable
(
table
,
ms
,
chrom
):
if
len
(
ms
[
'params'
])
==
0
:
table
.
setRowCount
(
0
)
return
table
.
setRowCount
(
len
(
ms
[
'params'
][
0
]))
for
row
,
paramname
in
enumerate
(
ms
[
'params'
][
0
]):
[
table
.
setItem
(
row
,
col
,
QtWidgets
.
QTableWidgetItem
())
for
col
in
range
(
2
)]
table
.
item
(
row
,
0
).
setText
(
paramname
)
vals
=
[
param
[
row
]
for
param
in
ms
[
'params'
][
1
]
if
(
param
[
0
]
>=
chrom
[
't_start'
]
and
param
[
0
]
<=
chrom
[
't_end'
])]
if
len
(
vals
)
==
0
:
table
.
item
(
row
,
1
).
setText
(
""
)
continue
elif
all
([
type
(
val
)
in
[
np
.
float32
,
np
.
float64
]
for
val
in
vals
]):
aver
=
np
.
average
(
vals
)
minim
=
min
(
vals
)
maxim
=
max
(
vals
)
text
=
"{:.2f} (from {:.2f} to {:.2f})"
.
format
(
aver
,
minim
,
maxim
)
else
:
values
=
[
str
(
i
)
for
i
in
np
.
unique
(
np
.
array
(
vals
),
axis
=
0
)]
text
=
" or "
.
join
(
values
)
table
.
item
(
row
,
1
).
setText
(
text
)
Write
Preview
Supports
Markdown
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