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
d5dd3a11
Commit
d5dd3a11
authored
Aug 10, 2021
by
Julia Garriga Ferrer
Browse files
Merge branch 'ask_for_rsm' into 'master'
Ask kind of transformation See merge request
!133
parents
1b0d6401
f74c53c5
Pipeline
#52641
passed with stage
in 2 minutes and 10 seconds
Changes
5
Pipelines
2
Show whitespace changes
Inline
Side-by-side
darfix/app/ows_to_script.py
View file @
d5dd3a11
...
...
@@ -120,6 +120,7 @@ if __name__ == '__main__':
filenames=filenames,
copy_files=True, in_memory=not options.in_disk)
else:
_dir = _dir if _dir != None else os.path.dirname(options.first_filename)
dataset = Dataset(_dir=_dir,
first_filename=options.first_filename,
copy_files=True, in_memory=not options.in_disk)
...
...
darfix/core/dataset.py
View file @
d5dd3a11
...
...
@@ -1298,11 +1298,11 @@ class Dataset():
data
=
Data
(
new_urls
.
reshape
(
self
.
data
.
urls
.
shape
),
self
.
data
.
metadata
,
in_memory
=
True
)
# to modify
return
Dataset
(
_dir
=
_dir
,
data
=
data
,
dims
=
self
.
__dims
,
transformation
=
self
.
transformation
,
in_memory
=
True
)
def
compute_transformation
(
self
,
d
,
rotate
=
False
):
def
compute_transformation
(
self
,
d
,
kind
=
"magnification"
,
rotate
=
False
):
H
,
W
=
self
.
get_data
(
0
).
shape
if
self
.
dims
.
ndim
==
1
:
if
self
.
dims
.
ndim
==
1
and
kind
==
"rsm"
:
ffz
=
self
.
get_metadata_values
(
POSITIONER_METADATA
,
"ffz"
)[
0
]
mainx
=
-
self
.
get_metadata_values
(
POSITIONER_METADATA
,
"mainx"
)[
0
]
self
.
transformation
=
compute_rsm
(
H
,
W
,
d
,
ffz
,
mainx
)
...
...
darfix/core/process.py
View file @
d5dd3a11
...
...
@@ -282,11 +282,13 @@ class _Transformation:
dataset
,
indices
,
li_indices
,
bg_dataset
=
dataset
magnification
=
self
.
_properties
[
'magnification'
]
if
'magnification'
in
self
.
_properties
else
None
pixelSize
=
self
.
_properties
[
'pixelSize'
]
if
'pixelSize'
in
self
.
_properties
else
None
kind
=
self
.
_properties
[
'kind'
]
if
'kind'
in
self
.
_properties
else
True
rotate
=
self
.
_properties
[
'rotate'
]
if
'rotate'
in
self
.
_properties
else
None
if
dataset
and
dataset
.
dims
.
ndim
:
if
dataset
.
dims
.
ndim
==
1
:
if
dataset
.
dims
.
ndim
==
1
and
kind
:
dataset
.
compute_transformation
(
PixelSize
[
pixelSize
].
value
,
rotate
)
kind
=
"rsm"
,
rotate
=
rotate
)
else
:
dataset
.
compute_transformation
(
magnification
)
return
dataset
,
indices
,
li_indices
,
bg_dataset
...
...
darfix/gui/rsmWidget.py
View file @
d5dd3a11
...
...
@@ -109,5 +109,6 @@ class RSMWidget(qt.QMainWindow):
self
.
_pixelSize
=
self
.
_pixelSizeCB
.
currentText
()
self
.
_rotate
=
self
.
_rotateCB
.
isChecked
()
self
.
dataset
.
compute_transformation
(
PixelSize
[
self
.
_pixelSize
].
value
,
self
.
_rotate
)
kind
=
"rsm"
,
rotate
=
self
.
_rotate
)
self
.
sigComputed
.
emit
()
orangecontrib/darfix/widgets/transformation.py
View file @
d5dd3a11
...
...
@@ -26,7 +26,7 @@
__authors__
=
[
"J. Garriga"
]
__license__
=
"MIT"
__date__
=
"1
6
/0
7
/2021"
__date__
=
"1
0
/0
8
/2021"
from
Orange.widgets.settings
import
Setting
...
...
@@ -55,12 +55,19 @@ class TransformationWidgetOW(OWWidget):
magnification
=
Setting
(
float
(),
schema_only
=
True
)
pixelSize
=
Setting
(
str
(),
schema_only
=
True
)
kind
=
Setting
(
bool
(),
schema_only
=
True
)
rotate
=
Setting
(
bool
(),
schema_only
=
True
)
def
__init__
(
self
):
super
().
__init__
()
qt
.
QLocale
.
setDefault
(
qt
.
QLocale
(
"en_US"
))
self
.
_widget
=
None
# Add combobox to choose between RSM and magnification (in one dimension case)
self
.
_methodCB
=
qt
.
QComboBox
(
self
)
self
.
_methodCB
.
addItems
([
"RSM"
,
"Magnification"
])
self
.
_methodCB
.
hide
()
self
.
controlArea
.
layout
().
addWidget
(
self
.
_methodCB
)
self
.
_methodCB
.
currentTextChanged
.
connect
(
self
.
_changeWidget
)
@
Inputs
.
dataset
def
setDataset
(
self
,
dataset
):
...
...
@@ -68,6 +75,7 @@ class TransformationWidgetOW(OWWidget):
self
.
controlArea
.
layout
().
removeWidget
(
self
.
_widget
)
self
.
_widget
.
hide
()
if
dataset
:
self
.
_dataset
=
dataset
if
not
dataset
[
0
].
dims
.
ndim
:
msg
=
qt
.
QMessageBox
()
msg
.
setIcon
(
qt
.
QMessageBox
.
Warning
)
...
...
@@ -76,11 +84,10 @@ class TransformationWidgetOW(OWWidget):
msg
.
exec_
()
else
:
if
dataset
[
0
].
dims
.
ndim
==
1
:
self
.
_widget
=
RSMWidget
(
parent
=
self
)
if
self
.
pixelSize
:
self
.
_widget
.
pixelSize
=
self
.
pixelSize
self
.
_widget
.
rotate
=
self
.
rotate
self
.
_methodCB
.
show
()
self
.
_changeWidget
(
"RSM"
)
else
:
self
.
_methodCB
.
hide
()
self
.
_widget
=
MagnificationWidget
(
parent
=
self
)
if
self
.
magnification
:
self
.
_widget
.
magnification
=
self
.
magnification
...
...
@@ -93,14 +100,36 @@ class TransformationWidgetOW(OWWidget):
self
.
open
()
def
_changeWidget
(
self
,
method
):
"""
Change the widget displayed on the window
"""
if
self
.
_widget
:
self
.
controlArea
.
layout
().
removeWidget
(
self
.
_widget
)
self
.
_widget
.
hide
()
if
method
==
"RSM"
:
self
.
_widget
=
RSMWidget
(
parent
=
self
)
if
self
.
pixelSize
:
self
.
_widget
.
pixelSize
=
self
.
pixelSize
self
.
_widget
.
rotate
=
self
.
rotate
else
:
self
.
_widget
=
MagnificationWidget
(
parent
=
self
)
if
self
.
magnification
:
self
.
_widget
.
magnification
=
self
.
magnification
self
.
_widget
.
sigComputed
.
connect
(
self
.
_sendSignal
)
self
.
controlArea
.
layout
().
addWidget
(
self
.
_widget
)
self
.
_widget
.
setDataset
(
*
self
.
_dataset
)
def
_sendSignal
(
self
):
"""
Emits the signal with the new dataset.
"""
if
hasattr
(
self
.
_widget
,
'magnification'
):
self
.
magnification
=
self
.
_widget
.
magnification
self
.
kind
=
False
elif
hasattr
(
self
.
_widget
,
'pixelSize'
):
self
.
pixelSize
=
self
.
_widget
.
pixelSize
self
.
rotate
=
self
.
_widget
.
rotate
self
.
kind
=
True
self
.
close
()
self
.
Outputs
.
dataset
.
send
(
self
.
_widget
.
getDataset
())
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