Add ImageRegistrationMethodBSpline3.mha and .2.mha (compressed) - #55
Merged
blowekamp merged 1 commit intoAug 31, 2026
Merged
Conversation
blowekamp
marked this pull request as ready for review
August 31, 2026 14:41
blowekamp
added a commit
to blowekamp/SimpleITK
that referenced
this pull request
Aug 31, 2026
…eline The .2.mha alternate added in the previous commit was written uncompressed (raw). Recompress it (zlib, default level) for a ~11.3% size reduction (454681 -> 403419 bytes); pixel data is unchanged (verified byte-identical after decompression). This matches the optimal size found by sweeping zlib levels 0-9 -- levels 2-6 all reach the same 403419-byte floor, level 0-1 are actually larger than raw due to stream-framing overhead, and level 9 regresses slightly (406420 bytes) due to a known non-monotonic zlib heuristic at max effort. The default compression setting (no explicit level) already lands on this optimal floor. Binary data updated via the companion draft PR: SimpleITK/SimpleITKExternalData#55.
blowekamp
added a commit
to blowekamp/SimpleITK
that referenced
this pull request
Aug 31, 2026
Recompress the long-standing primary baseline (zlib, default level) for consistency with the .2.mha alternate added in this branch: it was previously stored uncompressed (454681 bytes), now 409917 bytes (~9.8% smaller). This only changes the file's encoding, not its content -- pixel data is verified byte-identical after decompression, and the test's reported RMS against this baseline (2.95853) is unchanged. Binary data updated via the companion draft PR: SimpleITK/SimpleITKExternalData#55.
4 tasks
blowekamp
force-pushed
the
ImageRegistrationMethodBSpline3-2-mha
branch
from
August 31, 2026 15:13
15aeb33 to
80e7bfa
Compare
blowekamp
added a commit
to SimpleITK/SimpleITK
that referenced
this pull request
Aug 31, 2026
…ent fix
ITK commits da915f9157 ("Fix JointHistogramMutualInformation marginal
pairing and MI gradient") and 3ddebbf1d9 ("Scale JHMI derivative by
the moving-intensity normalization"), both from
InsightSoftwareConsortium/ITK#6569, fix
JointHistogramMutualInformationImageToImageMetricv4: the joint PDF's
marginals were stored swapped (fixed<->moving), so GetValue() divided
p(a,b) by the wrong marginals, and the derivative formula
log(2)*dMmPDF*J/Pm - dJPDF*(log J - log Pm) was not a valid MI
gradient at all (wrong sign, wrong weighting), not merely imprecise.
Both the metric value and its gradient change. Per ITK's own migration
note (Documentation/docs/migration_guides/
joint_histogram_mutual_information_metric_correction.md), the old
derivative converged to ~35% error vs the true shift, the corrected
one to <1%, and the doc explicitly names ImageRegistrationMethod2,
ImageRegistrationMethodBSpline3, and ImageRegistrationMethodDisplacement1
as the affected canonical JHMI examples needing a SimpleITK baseline
follow-up.
ImageRegistrationMethodBSpline3 optimizes a high-DOF B-spline
control-point grid (refined via scaleFactors=[1,2,5] across 3
multi-resolution levels, ~100 GradientDescentLineSearch iterations/
level) using JHMI as its sole metric, so the old gradient's error
compounds heavily: RMS difference against the current primary
baseline is 2.95853, and against the existing .1.mha alternate
2.93438, both ~147x over the test's 0.02 tolerance.
ImageRegistrationMethod2 uses the same buggy metric but only recovers
a 2-DOF translation with a self-correcting line search; it still
passes comfortably (RMS 0.0057) because the problem is too simple for
the gradient defect to matter.
Verified this is a genuine improvement, not just a different result:
evaluated both the pre-fix and post-fix final transforms under the
same (corrected) metric via R.MetricEvaluate(). The post-fix
transform scores -0.883595, the pre-fix transform -0.771395 (more
negative = higher mutual information = better alignment) -- the
fixed optimizer converges to a ~14.5% better optimum by the metric's
own ground truth, consistent with ITK's migration note.
Add the post-fix registration output (converted to a displacement
field on the fixed image's own grid, matching TransformCompare's
internal comparison convention) as a .2.mha alternate baseline, so
CXX.Example.ImageRegistrationMethodBSpline3 and
Python.Example.ImageRegistrationMethodBSpline3 pass against both
pre- and post-fix ITK. Verified deterministic: byte-for-byte identical
displacement field across 3 repeated C++ runs and 1 Python run (RMS
0.0 pairwise) before adopting the output as a baseline.
ImageRegistrationMethodBSpline3's C#/Java/R variants share the same
DATA{...,:} content link in Examples/ImageRegistrationMethodBSpline3/
CMakeLists.txt, so this baseline covers them too, though they were
not locally testable here.
Binary data uploaded via a companion draft PR:
SimpleITK/SimpleITKExternalData#55.
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.
Compressed (zlib, default level) alternate and primary baseline objects for SimpleITK's ImageRegistrationMethodBSpline3 example, needed for InsightSoftwareConsortium/ITK#6569 (JointHistogramMutualInformation gradient fix).
Both round-trip pixel-identical to their originals; verified locally before upload.