Skip to content

Add ImageRegistrationMethodBSpline3.mha and .2.mha (compressed) - #55

Merged
blowekamp merged 1 commit into
SimpleITK:mainfrom
blowekamp:ImageRegistrationMethodBSpline3-2-mha
Aug 31, 2026
Merged

Add ImageRegistrationMethodBSpline3.mha and .2.mha (compressed)#55
blowekamp merged 1 commit into
SimpleITK:mainfrom
blowekamp:ImageRegistrationMethodBSpline3-2-mha

Conversation

@blowekamp

@blowekamp blowekamp commented Aug 31, 2026

Copy link
Copy Markdown
Member

Compressed (zlib, default level) alternate and primary baseline objects for SimpleITK's ImageRegistrationMethodBSpline3 example, needed for InsightSoftwareConsortium/ITK#6569 (JointHistogramMutualInformation gradient fix).

  • .2.mha: new alternate baseline reflecting the corrected ITK output (previously uploaded uncompressed; now recompressed, same pixel data, ~11.3% smaller).
  • .mha: the existing primary baseline, recompressed in place (same pixel data as before, just re-encoded; was uncompressed, now ~9.8% smaller). This updates the object referenced by the already-existing content link, it does not change the primary baseline's actual displacement content.

Both round-trip pixel-identical to their originals; verified locally before upload.

@blowekamp
blowekamp marked this pull request as ready for review August 31, 2026 14:41
@blowekamp blowekamp changed the title Add ImageRegistrationMethodBSpline3.2.mha Add ImageRegistrationMethodBSpline3.mha and .2.mha (compressed) Aug 31, 2026
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.
@blowekamp
blowekamp force-pushed the ImageRegistrationMethodBSpline3-2-mha branch from 15aeb33 to 80e7bfa Compare August 31, 2026 15:13
@blowekamp
blowekamp merged commit 205fca7 into SimpleITK:main Aug 31, 2026
1 check passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant