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
XRD
darfix
Commits
c9dfb71e
Commit
c9dfb71e
authored
May 19, 2021
by
Julia Garriga Ferrer
Browse files
Merge branch 'fix_widgets_stack' into 'master'
Fix roi bugs See merge request
!122
parents
3e3f1b4f
8abe583d
Pipeline
#46974
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
darfix/core/dataset.py
View file @
c9dfb71e
...
...
@@ -26,7 +26,7 @@
__authors__
=
[
"J. Garriga"
]
__license__
=
"MIT"
__date__
=
"2
2
/0
2
/2021"
__date__
=
"2
6
/0
4
/2021"
import
copy
import
glob
...
...
@@ -668,7 +668,7 @@ class Dataset():
return
Dataset
(
_dir
=
_dir
,
data
=
new_data
,
dims
=
self
.
__dims
,
in_memory
=
self
.
_in_memory
)
def
apply_roi
(
self
,
origin
=
None
,
size
=
None
,
center
=
None
,
indices
=
None
):
def
apply_roi
(
self
,
origin
=
None
,
size
=
None
,
center
=
None
,
indices
=
None
,
roi_dir
=
None
):
"""
Applies a region of interest to the data.
...
...
@@ -681,13 +681,16 @@ class Dataset():
:param indices: Indices of the images to apply background subtraction.
If None, the roi is applied to all the data.
:type indices: Union[None, array_like]
:param roi_dir: Directory path for the new dataset
:type roi_dir: str
:returns: dataset with data with roi applied.
Note: To preserve consistence of shape between images, if `indices`
is not None, only the data modified is returned.
:rtype: Dataset
"""
roi_dir
=
self
.
dir
+
"/"
+
self
.
treated
+
"/roi/"
if
roi_dir
is
None
:
roi_dir
=
self
.
dir
+
"/"
+
self
.
treated
+
"/roi/"
self
.
running_data
=
self
.
get_data
(
indices
)
if
not
os
.
path
.
isdir
(
roi_dir
):
os
.
mkdir
(
roi_dir
)
...
...
darfix/gui/roiSelectionWidget.py
View file @
c9dfb71e
...
...
@@ -26,7 +26,7 @@
__authors__
=
[
"J. Garriga"
]
__license__
=
"MIT"
__date__
=
"
11/12
/202
0
"
__date__
=
"
26/04
/202
1
"
# import os
...
...
@@ -61,6 +61,7 @@ class ROISelectionWidget(qt.QWidget):
self
.
indices
=
None
self
.
bg_indices
=
None
self
.
bg_dataset
=
None
self
.
_original_dataset
=
True
self
.
setLayout
(
qt
.
QVBoxLayout
())
self
.
_sv
=
StackViewMainWindow
()
...
...
@@ -179,8 +180,10 @@ class ROISelectionWidget(qt.QWidget):
self
.
roi
=
RectangleROI
()
self
.
roi
.
setGeometry
(
origin
=
self
.
getRoi
().
getOrigin
(),
size
=
self
.
getRoi
().
getSize
())
self
.
thread
=
OperationThread
(
self
,
self
.
_update_dataset
.
apply_roi
)
roi_dir
=
self
.
_update_dataset
.
dir
if
not
self
.
_original_dataset
else
None
self
.
thread
.
setArgs
(
size
=
numpy
.
flip
(
self
.
roi
.
getSize
()),
center
=
numpy
.
flip
(
self
.
roi
.
getCenter
()))
center
=
numpy
.
flip
(
self
.
roi
.
getCenter
()),
roi_dir
=
roi_dir
)
self
.
thread
.
finished
.
connect
(
self
.
_updateData
)
self
.
thread
.
start
()
...
...
@@ -199,6 +202,7 @@ class ROISelectionWidget(qt.QWidget):
self
.
_okB
.
setEnabled
(
True
)
if
self
.
thread
.
data
:
self
.
_update_dataset
=
self
.
thread
.
data
self
.
_original_dataset
=
False
assert
self
.
_update_dataset
is
not
None
self
.
setStack
(
self
.
_update_dataset
)
self
.
resetROI
()
...
...
@@ -212,15 +216,15 @@ class ROISelectionWidget(qt.QWidget):
Signal emitted with the roi parameters.
"""
if
self
.
roi
:
if
self
.
bg_dataset
is
not
None
:
self
.
bg_dataset
=
self
.
bg_dataset
.
apply_roi
(
size
=
numpy
.
flip
(
self
.
roi
.
getSize
()),
center
=
numpy
.
flip
(
self
.
roi
.
getCenter
()))
self
.
sigComputed
.
emit
(
self
.
roi
.
getOrigin
().
tolist
(),
self
.
roi
.
getSize
().
tolist
())
else
:
self
.
sigComputed
.
emit
([],
[])
def
getDataset
(
self
):
return
self
.
_update_dataset
,
self
.
indices
,
self
.
bg_indices
,
self
.
bg_dataset
bg_dataset
=
(
self
.
bg_dataset
.
apply_roi
(
size
=
numpy
.
flip
(
self
.
roi
.
getSize
()),
center
=
numpy
.
flip
(
self
.
roi
.
getCenter
()))
if
self
.
bg_dataset
is
not
None
else
None
)
return
self
.
_update_dataset
,
self
.
indices
,
self
.
bg_indices
,
bg_dataset
def
getStackViewColormap
(
self
):
"""
...
...
@@ -254,6 +258,7 @@ class ROISelectionWidget(qt.QWidget):
"""
self
.
roi
=
None
self
.
_update_dataset
=
self
.
dataset
self
.
_original_dataset
=
True
self
.
setStack
(
self
.
dataset
)
def
clearStack
(
self
):
...
...
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