Repository navigation
BUG: fit_bspline_displacement_field ignored displacement_weights - #953
Merged
Merged
Conversation
The else branch of the length check replaced valid displacement_weights with ones, so every point was weighted equally. fit_transform_to_paired_points (bspline, diffeo, syn, tv) and fit_time_varying_transform_to_point_sets pass their displacement_weights through, so they ignored them too. Remove the else; the default further down already fills in ones when no weights are given.
ntustison
approved these changes
Nov 8, 2026
Member
|
Thanks @jig-mistry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fit_bspline_displacement_fieldignoresdisplacement_weights. When the weights have the right length, theelsebranch of the length check replaces them with ones:Two points 4 voxels apart with opposite displacements show it. Swapping the weights should flip the field between them, but on main it does not:
The values from this PR are the ones
fitBsplineDisplacementFieldToScatteredDataD2gives when called directly with the same weights. The same happens when the points are combined with a densedisplacement_field.fit_transform_to_paired_points(bspline, diffeo, syn and tv) andfit_time_varying_transform_to_point_setspassdisplacement_weightsthrough, so they ignored the weights as well.This removes the
else. The existing default further down already fills in ones when no weights are given, so calls without weights give the same result as before.test_bspline_field_displacement_weightschecks the example above, and thatNonegives the same field as equal weights. It fails on main and passes here.Some side notes:
fitBsplineDisplacementFieldhas the sameelse.rasterize_points=True: this case could not be reached before, and it gives a wrong field. The rasterization infitBsplineDisplacementFieldToScatteredData.cxxdivides by the summed weight, which is then 0. I can send a separate fix for that.