Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XRD
darfix
Commits
7e2e8d57
Commit
7e2e8d57
authored
May 27, 2021
by
Julia Garriga Ferrer
Browse files
[gui] Add RSM widget
parent
55ebc4c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
darfix/gui/rsmWidget.py
0 → 100644
View file @
7e2e8d57
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
__authors__
=
[
"J. Garriga"
]
__license__
=
"MIT"
__date__
=
"27/05/2021"
from
matplotlib.colors
import
hsv_to_rgb
import
numpy
from
silx.gui
import
qt
from
silx.gui.colors
import
Colormap
from
silx.gui.plot
import
Plot2D
from
silx.utils.enum
import
Enum
as
_Enum
import
darfix
from
.operationThread
import
OperationThread
class
RSMWidget
(
qt
.
QMainWindow
):
"""
Widget to apply PCA to a set of images and plot the eigenvalues found.
"""
sigComputed
=
qt
.
Signal
()
def
__init__
(
self
,
parent
=
None
):
qt
.
QWidget
.
__init__
(
self
,
parent
)
self
.
_plotWidget
=
Plot2D
()
self
.
setCentralWidget
(
self
.
_plotWidget
)
def
setDataset
(
self
,
dataset
,
indices
=
None
,
bg_indices
=
None
,
bg_dataset
=
None
):
"""
Dataset setter.
:param Dataset dataset: dataset
"""
self
.
dataset
=
dataset
self
.
indices
=
indices
self
.
bg_indices
=
bg_indices
self
.
bg_dataset
=
bg_dataset
self
.
_thread
=
OperationThread
(
self
,
self
.
dataset
.
apply_moments
)
self
.
_thread
.
setArgs
(
self
.
indices
)
self
.
_thread
.
finished
.
connect
(
self
.
_updateData
)
self
.
_thread
.
start
()
def
_updateData
(
self
):
self
.
_thread
.
finished
.
disconnect
(
self
.
_updateData
)
if
self
.
_thread
.
data
is
not
None
:
self
.
_moments
=
self
.
_thread
.
data
self
.
_plotWidget
.
addImage
(
self
.
_moments
[
0
][
0
])
else
:
print
(
"
\n
Computation aborted"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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