-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make phase_cross_correlation return ndarray when disambiguate=True #7112
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this, @decorouz! I can't find the TypeError
in the "Image Registration" gallery example though...
@@ -172,11 +172,12 @@ def _disambiguate_shift(reference_image, moving_image, shift): | |||
max_slice, positive_shift, negative_shift | |||
): | |||
real_shift_acc.append(pos_shift if sl.stop is None else neg_shift) | |||
if not subpixel: | |||
real_shift = tuple(map(int, real_shift_acc)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And since real_shift
was supposed to be a 'tuple of float,' it's not clear why this mapping to integer was even performed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. I think the test is not actually testing that the bug is fixed though. Otherwise, nothing major.
@@ -172,11 +172,12 @@ def _disambiguate_shift(reference_image, moving_image, shift): | |||
max_slice, positive_shift, negative_shift | |||
): | |||
real_shift_acc.append(pos_shift if sl.stop is None else neg_shift) | |||
if not subpixel: | |||
real_shift = tuple(map(int, real_shift_acc)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this @decorouz :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think that's what I meant. Though, right now we don't need to append
shift = np.asarray(shift)because this function already returns an array with
return np.array(real_shift_acc)
@lagru well, it's EITHER/OR, of course (not both). By 'right now,' I guess that you mean 'with this PR,' since only this PR is adding return np.array(real_shift_acc)
(but this PR isn't merged yet... For me, 'right now' typically means 'on current main').
So,
- EITHER this PR keeps
return np.array(real_shift_acc)
but then line 145 needs to be updated
-real_shift : sequence of floats
+real_shift : ndarray
- OR this PR updates the code within
phase_cross_correlation
as discussed.
Co-authored-by: Lars Grüter <lagru+github@mailbox.org>
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Hello @decorouz! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
All CI failures look related to #7140. As the test suite itself is passing fine, I am going ahead and merge this. |
Thanks everyone! |
Description
ski.registration.phase_cross_correlation
returns inconsistent results.It returns a tuple when
disambiguate
is set toTrue
but numpy array when set to False. Since there's no reason for a shift to sometimes be a tuple and sometimes a numpy array, this PR attempts to fix this bug #7083 by making the function return numpy array consistently.Additionally, this gallery example returns a
TypeError: can only concatenate tuple (not "int") to tuple
whendisambiguate
is set toTrue
on this line . This PR also fixed the error.Checklist
./doc/examples
for new featuresRelease note
Summarize the introduced changes in the code block below in one or a few sentences. The
summary will be included in the next release notes automatically: