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
tomotools
nxtomomill
Commits
e67ea2fd
Commit
e67ea2fd
authored
Oct 04, 2021
by
Henri Payno
Browse files
[app][dxfile2nx] allow to provide pixel size as a single value
close
#66
parent
fb24e3c8
Pipeline
#55829
passed with stages
in 10 minutes and 47 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nxtomomill/app/dxfile2nx.py
View file @
e67ea2fd
...
...
@@ -64,6 +64,24 @@ def convert_2elmts__tuple_to_float(input_str) -> tuple:
return
float
(
v1
),
float
(
v2
)
def
_get_pixel_size
(
input_str
)
->
tuple
:
try
:
values
=
convert_2elmts__tuple_to_float
(
input_str
)
except
ValueError
:
try
:
value
=
float
(
input_str
)
except
Exception
:
raise
ValueError
(
f
"Unable to convert
{
input_str
}
to pixel size."
f
"Should be provided as a tuple (x_pixel_size, y_pixel_size) "
f
"or as a single value pixel_size"
)
else
:
return
value
,
value
else
:
return
values
def
main
(
argv
):
""" """
parser
=
argparse
.
ArgumentParser
(
...
...
@@ -103,7 +121,7 @@ def main(argv):
parser
.
add_argument
(
"--pixel-size"
,
default
=
(
None
,
None
),
help
=
"pixel size in meter as (x pixel size, y pixel size)"
,
help
=
"pixel size in meter as (x pixel size, y pixel size)
or as a single value
"
,
)
parser
.
add_argument
(
"--fov"
,
...
...
@@ -167,7 +185,7 @@ def main(argv):
input_entry
=
options
.
input_entry
,
output_entry
=
options
.
output_entry
,
scan_range
=
convert_2elmts__tuple_to_float
(
options
.
scan_range
),
pixel_size
=
convert_2elmts__tuple_to_float
(
options
.
pixel_size
),
pixel_size
=
_get_pixel_size
(
options
.
pixel_size
),
field_of_view
=
options
.
field_of_view
,
distance
=
distance
,
overwrite
=
options
.
overwrite
,
...
...
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