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
tomoscan
Commits
d0563409
Commit
d0563409
authored
Sep 10, 2020
by
payno
Browse files
add alignment_projections property
# Conflicts: # tomoscan/scanbase.py
parent
90a88847
Changes
5
Hide whitespace changes
Inline
Side-by-side
tomoscan/esrf/edfscan.py
View file @
d0563409
...
...
@@ -77,7 +77,6 @@ class EDFTomoScan(TomoScanBase):
# data caches
self
.
_darks
=
None
self
.
_flats
=
None
self
.
_projections
=
None
self
.
__tomo_n
=
None
self
.
__ref_n
=
None
self
.
__dark_n
=
None
...
...
@@ -243,9 +242,27 @@ class EDFTomoScan(TomoScanBase):
@
docstring
(
TomoScanBase
.
update
)
def
update
(
self
):
if
self
.
path
is
not
None
:
self
.
projections
=
EDFTomoScan
.
get_proj_urls
(
all_
projections
=
EDFTomoScan
.
get_proj_urls
(
self
.
path
,
n_frames
=
self
.
_edf_n_frames
)
def
select_proj
(
ddict
,
from_
,
to_
):
indexes
=
sorted
(
set
(
ddict
.
keys
()))
sel_indexes
=
indexes
[
from_
:
to_
]
res
=
{}
for
index
in
sel_indexes
:
res
[
index
]
=
ddict
[
index
]
return
res
if
self
.
tomo_n
is
not
None
and
len
(
all_projections
)
>
self
.
tomo_n
:
self
.
_projections
=
select_proj
(
all_projections
,
0
,
self
.
tomo_n
)
self
.
_alignment_projections
=
select_proj
(
all_projections
,
self
.
tomo_n
,
None
)
else
:
self
.
_projections
=
all_projections
self
.
_alignment_projections
=
{}
self
.
_darks
=
EDFTomoScan
.
get_darks_url
(
self
.
path
)
self
.
_flats
=
EDFTomoScan
.
get_refs_url
(
self
.
path
)
...
...
tomoscan/esrf/hdf5scan.py
View file @
d0563409
...
...
@@ -145,7 +145,6 @@ class HDF5TomoScan(TomoScanBase):
# for now the default entry is 1_tomo but should change with time
# data caches
self
.
_projections
=
None
self
.
_projections_compacted
=
None
self
.
_flats
=
None
self
.
_darks
=
None
...
...
@@ -327,7 +326,6 @@ class HDF5TomoScan(TomoScanBase):
@
property
@
docstring
(
TomoScanBase
.
projections
)
def
projections
(
self
)
->
typing
.
Union
[
dict
,
None
]:
"""projections / radio, does not include the return projections"""
if
self
.
_projections
is
None
:
if
self
.
frames
:
proj_frames
=
tuple
(
...
...
@@ -346,6 +344,23 @@ class HDF5TomoScan(TomoScanBase):
def
projections
(
self
,
projections
:
dict
):
self
.
_projections
=
projections
@
property
@
docstring
(
TomoScanBase
.
alignment_projections
)
def
alignment_projections
(
self
)
->
typing
.
Union
[
dict
,
None
]:
if
self
.
_alignment_projections
is
None
:
if
self
.
frames
:
proj_frames
=
tuple
(
filter
(
lambda
x
:
x
.
image_key
==
ImageKey
.
PROJECTION
and
x
.
is_control
==
True
,
self
.
frames
,
)
)
self
.
_alignment_projections
=
{}
for
proj_frame
in
proj_frames
:
self
.
_alignment_projections
[
proj_frame
.
index
]
=
proj_frame
.
url
return
self
.
_alignment_projections
@
property
@
docstring
(
TomoScanBase
.
darks
)
def
darks
(
self
)
->
typing
.
Union
[
dict
,
None
]:
...
...
@@ -833,3 +848,17 @@ class Frame:
@
is_control
.
setter
def
is_control
(
self
,
is_return
:
bool
):
self
.
_is_control_frame
=
is_return
def
__str__
(
self
):
return
(
"Frame {index},: image_key: {image_key},"
"is_control: {is_control},"
"rotation_angle: {rotation_angle},"
"url: {url}"
.
format
(
index
=
self
.
index
,
image_key
=
self
.
image_key
,
is_control
=
self
.
is_control
,
rotation_angle
=
self
.
rotation_angle
,
url
=
self
.
url
.
path
(),
)
)
tomoscan/esrf/test/test_edfscan.py
View file @
d0563409
...
...
@@ -302,7 +302,8 @@ class TestProjections(unittest.TestCase):
)
mock
.
end_acquisition
()
scan
=
EDFTomoScan
(
scan
=
self
.
folder
)
self
.
assertEqual
(
len
(
scan
.
projections
),
11
+
2
)
self
.
assertEqual
(
len
(
scan
.
projections
),
11
)
self
.
assertEqual
(
len
(
scan
.
alignment_projections
),
2
)
proj_angle_dict
=
scan
.
get_proj_angle_url
()
self
.
assertEqual
(
len
(
proj_angle_dict
),
11
+
2
)
self
.
assertTrue
(
90
in
proj_angle_dict
)
...
...
tomoscan/esrf/test/test_hdf5scan.py
View file @
d0563409
...
...
@@ -153,6 +153,10 @@ class TestHDF5Scan(HDF5TestBaseClass):
url_0
=
projections
[
list
(
projections
.
keys
())[
0
]]
self
.
assertEqual
(
url_0
.
file_path
(),
os
.
path
.
join
(
self
.
scan
.
master_file
))
self
.
assertEqual
(
url_0
.
data_slice
(),
22
)
# should be 4 but angles are truely missleading: 179.88, 180.0, 90, 0.
# in this case we are not using any information from image_key_control
# and we wait deduce 'return mode' from angles.
self
.
assertEqual
(
len
(
self
.
scan
.
alignment_projections
),
3
)
def
testDark
(
self
):
"""Make sure darks are valid"""
...
...
tomoscan/scanbase.py
View file @
d0563409
...
...
@@ -174,13 +174,26 @@ class TomoScanBase:
@
property
def
projections
(
self
)
->
Union
[
None
,
dict
]:
"""list of projections files"""
"""if found dict of projections urls with index during acquisition as
key"""
return
self
.
_projections
@
projections
.
setter
def
projections
(
self
,
projections
:
dict
)
->
None
:
self
.
_projections
=
projections
@
property
def
alignment_projections
(
self
)
->
Union
[
None
,
dict
]:
"""
dict of projections made for alignment with acquisition index as key
None if not found
"""
return
self
.
_alignment_projections
@
alignment_projections
.
setter
def
alignment_projections
(
self
,
alignment_projs
):
self
.
_alignment_projections
=
alignment_projs
@
property
def
dark_n
(
self
)
->
Union
[
None
,
int
]:
raise
NotImplementedError
(
"Base class"
)
...
...
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