Repository navigation
BUG: Mark BSplineInterpolateImageFunction modified on a spline order change - #7277
Merged
hjmjohnson merged 1 commit intoNov 30, 2026
Conversation
…change SetSplineOrder() changed the interpolator without calling Modified(). ResampleImageFilter folds the interpolator's modified time into its own, so after changing the spline order, the next Update() did nothing and returned the output of the old order. Any cache keyed on the interpolator's modified time had the same problem. SetSplineOrder() now calls Modified() when the order changes; setting the order it already has leaves the time alone. SetInputImage() still does not call Modified(), because ResampleImageFilter calls it during every execution.
hjmjohnson
force-pushed
the
bspline-spline-order-modified
branch
from
November 30, 2026 19:24
7030c3d to
73de3d0
Compare
hjmjohnson
marked this pull request as ready for review
November 30, 2026 19:35
Contributor
[Medium impact] The PR appears safe to merge.
|
dzenanz
approved these changes
Nov 30, 2026
dzenanz
left a comment
Member
There was a problem hiding this comment.
Change itself looks good. I did not take a good look at the test.
gdevenyi
approved these changes
Nov 30, 2026
gdevenyi
left a comment
Contributor
There was a problem hiding this comment.
The change is right. Approving.
- Early return:
SetSplineOrder()returns beforeModified()when the order is unchanged, so an unchanged order costs nothing.KeepsUpToDateWhenBSplineOrderIsUnchangedpins that. SetInputImage(): leaving it alone is correct, for theResampleImageFilterand v3 registration reasons in the PR body.- Stale coefficients (no change needed here): changing the order still leaves the coefficients of the old order until
SetInputImage()runs.ResampleImageFilterand the metrics'Initialize()both call it, so the newModified()is enough for them. A caller that changes the order and evaluates directly must still callSetInputImage()again, as before. - Local run at 73de3d0, GCC 15, Release, minimal ImageGrid + ImageFunction build: both new
ResampleImageFilterGTests pass, andctestpasses 339/339. - #7223: now that it is stacked here, it has
FollowsTheFixedInterpolatorSplineOrder, which fails without thisModified().
The ComplexBSplineInterpolateImageFunction follow-up sounds right.
Review assisted by Claude Code (claude-opus-5-5); the build and tests above were run locally.
hjmjohnson
merged commit Nov 30, 2026
7830484
into
InsightSoftwareConsortium:main
19 of 20 checks passed
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.
BSplineInterpolateImageFunction::SetSplineOrder()now callsModified(). Before this change, changing the spline order after anUpdate()leftResampleImageFilterup to date, so the nextUpdate()returned the output of the old order. Found while reviewing #7223, whose fixed sample cache is keyed on the fixed interpolator's modified time; this should land first.Merge danger: two-way door. Blast radius: anything that reads a B-spline interpolator's modified time, which now changes when the order changes.
Not fixed here:
ComplexBSplineInterpolateImageFunction::SetSplineOrder()(Review module) has the same missingModified(); it can follow separately.Shape of the change
BSplineInterpolateImageFunction::SetSplineOrder(order) if (order == m_SplineOrder) return; // unchanged: MTime untouched ... update order, poles, points-to-index ... + this->Modified();SetInputImage()is deliberately left alone.ResampleImageFiltercalls it during every execution (itkResampleImageFilter.hxx:163,:195) and folds the interpolator's modified time into its own (:645). The v3ImageRegistrationMethod,MultiResolutionImageRegistrationMethod,ImageToSpatialObjectRegistrationMethod, andPointSetToImageRegistrationMethodalso fold it in, and their metrics callSetInputImage()inInitialize(). Marking it modified there would make all of these re-execute on every update.Outside tests, the only ITK callers of this interpolator's
SetSplineOrder()areComplexBSplineInterpolateImageFunction, which holds its interpolators as private members, andDirectFourierReconstructionImageToImageFilter, which creates them insideGenerateData(). Neither folds their modified time into its own.Evidence
Two GTests in
itkResampleImageFilterGTest.cxx:ReexecutesWhenBSplineOrderChanges: resample a random 8x8 image at spline order 1, callSetSplineOrder(3), update again, and compare with a fresh order 3 resample.KeepsUpToDateWhenBSplineOrderIsUnchanged: setting the order the interpolator already has leaves both its modified time and the filter's output untouched.Without the
Modified()line:With it, all 6
ResampleImageFilterGTests pass, andctest -L "ITKImageFunction|ITKImageGrid" -R "BSpline|Resample"passes 40 of 40 (macOS arm64, conda clang, Release).pre-commit run --all-filespasses.#7223 rebased onto this branch: a metric that changes its fixed interpolator's order and calls
SetInputImage(), withoutInitialize(), returned the order 1 value (2.5768 instead of 2.6680) without this fix and the order 3 value with it.Not tested: Windows/MSVC, downstream consumers.
AI assistance
Claude Code (claude-opus-5-5) did the root-cause analysis, the caller audit, and the regression tests, under review by the author.