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
Nabu
Commits
5b605233
Commit
5b605233
authored
Jun 25, 2020
by
Nicola Vigano
Browse files
DetectorTranslationAlongBeam: return complete list of shifts (with initial zeros)
Signed-off-by:
Nicola VIGANÒ
<
nicola.vigano@esrf.fr
>
parent
0535ee49
Pipeline
#28337
passed with stages
in 3 minutes and 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nabu/preproc/alignment.py
View file @
5b605233
...
...
@@ -717,27 +717,25 @@ class DetectorTranslationAlongBeam(AlignmentBase):
cc_vs
=
np
.
fft
.
fftfreq
(
img_shape
[
-
2
],
1
/
img_shape
[
-
2
])
cc_hs
=
np
.
fft
.
fftfreq
(
img_shape
[
-
1
],
1
/
img_shape
[
-
1
])
shifts_vh
=
np
.
empty
((
num_imgs
-
1
,
2
))
shifts_vh
=
np
.
empty
((
num_imgs
,
2
))
for
ii
,
cc
in
enumerate
(
ccs
):
(
f_vals
,
fv
,
fh
)
=
self
.
extract_peak_region_2d
(
cc
,
peak_radius
=
peak_fit_radius
,
cc_vs
=
cc_vs
,
cc_hs
=
cc_hs
)
shifts_vh
[
ii
,
:]
=
self
.
refine_max_position_2d
(
f_vals
,
fv
,
fh
)
shifts_vh
[
ii
+
1
,
:]
=
self
.
refine_max_position_2d
(
f_vals
,
fv
,
fh
)
if
use_adjacent_imgs
:
shifts_vh
=
np
.
cumsum
(
shifts_vh
,
axis
=
0
)
img_shifts_vh
=
np
.
concatenate
(([[
0
,
0
]],
shifts_vh
),
axis
=
0
)
# Polynomial.fit is supposed to be more numerically stable than polyfit
# (according to numpy)
coeffs_v
=
Polynomial
.
fit
(
img_pos
,
img_
shifts_vh
[:,
0
],
deg
=
1
).
convert
().
coef
coeffs_h
=
Polynomial
.
fit
(
img_pos
,
img_
shifts_vh
[:,
1
],
deg
=
1
).
convert
().
coef
coeffs_v
=
Polynomial
.
fit
(
img_pos
,
shifts_vh
[:,
0
],
deg
=
1
).
convert
().
coef
coeffs_h
=
Polynomial
.
fit
(
img_pos
,
shifts_vh
[:,
1
],
deg
=
1
).
convert
().
coef
if
self
.
verbose
:
f
,
axs
=
plt
.
subplots
(
1
,
2
)
axs
[
0
].
scatter
(
img_pos
,
img_
shifts_vh
[:,
0
])
axs
[
0
].
scatter
(
img_pos
,
shifts_vh
[:,
0
])
axs
[
0
].
plot
(
img_pos
,
polyval
(
img_pos
,
coeffs_v
))
axs
[
0
].
set_title
(
"Vertical shifts"
)
axs
[
1
].
scatter
(
img_pos
,
img_
shifts_vh
[:,
1
])
axs
[
1
].
scatter
(
img_pos
,
shifts_vh
[:,
1
])
axs
[
1
].
plot
(
img_pos
,
polyval
(
img_pos
,
coeffs_h
))
axs
[
1
].
set_title
(
"Horizontal shifts"
)
plt
.
show
(
block
=
False
)
...
...
nabu/preproc/tests/test_alignment.py
View file @
5b605233
...
...
@@ -38,6 +38,7 @@ def bootstrap_dtr(request):
cls
.
expected_shifts_vh
=
np
.
array
((
129.93
,
353.18
))
cls
.
reference_shifts_list
=
[
[
0
,
0
],
[
-
9.39
,
11.29
],
[
-
5.02
,
3.81
],
[
-
3.67
,
9.73
],
...
...
Nicola Vigano
@vigano
mentioned in issue
#125 (closed)
·
Jun 25, 2020
mentioned in issue
#125 (closed)
mentioned in issue #125
Toggle commit list
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