BUG: Fix InverseDisplacementFieldImageFilter subsampling geometry#6588
Open
hjmjohnson wants to merge 3 commits into
Open
BUG: Fix InverseDisplacementFieldImageFilter subsampling geometry#6588hjmjohnson wants to merge 3 commits into
hjmjohnson wants to merge 3 commits into
Conversation
Contributor
|
| Filename | Overview |
|---|---|
| Modules/Filtering/DisplacementField/include/itkInverseDisplacementFieldImageFilter.h | Adds output direction support and validation override declarations. |
| Modules/Filtering/DisplacementField/include/itkInverseDisplacementFieldImageFilter.hxx | Centers the landmark lattice from the input region start and applies explicit output direction when requested. |
| Modules/Filtering/DisplacementField/test/itkInverseDisplacementFieldImageFilterGTest.cxx | Adds tests for output direction behavior, centered subsampling, invalid subsampling, and non-zero-start regions. |
Reviews (2): Last reviewed commit: "ENH: Reject inputs too small for the lan..." | Re-trigger Greptile
PrepareKernelBaseSpline() scaled the sampling spacing by the subsampling factor k but kept the input origin, placing landmarks on fine indices 0, k, ..., with no low-side margin and up to k-1 unsampled voxels on the high side of every axis. The thin-plate spline had to extrapolate near the high edge, degrading the inverse asymmetrically. Start the lattice at fine index (k-1)/2 instead: margins are balanced while landmarks remain exactly on voxel centers, so sampled values stay uninterpolated. For the quadratic-field regression test (N=32, k=4) the worst-case round-trip error drops from 0.069 to 0.047 voxels. Follow-up to the subsampler direction fix from InsightSoftwareConsortium#6577; issue InsightSoftwareConsortium#6582.
The filter exposed SetSize, SetOutputSpacing and SetOutputOrigin, but the output direction could not be controlled: it always inherited the input direction cosines, so the inverse of a rotated field could not be requested on an axis-aligned grid. Add an OutputDirection member honored in GenerateOutputInformation(). Unless explicitly set, the output inherits the input direction, preserving existing behavior. Issue InsightSoftwareConsortium#6582.
An input smaller than SubsamplingFactor along any axis produces a zero-size landmark lattice and the kernel spline receives no landmarks; a zero factor divides by zero. Verify both before the pipeline runs. Issue InsightSoftwareConsortium#6582.
cca3a67 to
326899b
Compare
Member
Author
|
@greptileai review — addressed the P1 (non-zero-start region shift) in the latest push; the centered lattice now starts relative to the region index on a zero-based grid, with a new regression test. |
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.
Fixes the two geometry gaps tracked in #6582 (follow-up to #6577): the thin-plate-spline landmark lattice is now centered under subsampling, and the filter gains a
SetOutputDirectionAPI (output still inherits the input direction unless explicitly set).Lattice centering (BUG commit)
PrepareKernelBaseSpline()scaled the sampling spacing by the subsampling factor k but kept the input origin, so landmarks sat on fine indices 0, k, … — zero low-side margin and up to k−1 unsampled voxels on the high side per axis, forcing the spline to extrapolate near the high edge. The lattice now starts at fine index (k−1)/2: margins balanced, landmarks still exactly on voxel centers (values uninterpolated). Measured on the quadratic-field regression test (N=32, k=4): worst-case round-trip error 0.069 → 0.047 voxels; the test threshold (0.06) fails the old code and passes the new with margin.Output direction API (ENH commit)
The filter exposed SetSize/SetOutputSpacing/SetOutputOrigin but the output always inherited the input direction cosines, so the inverse of a rotated field could not be requested on an axis-aligned grid. Adds
m_OutputDirectionhonored inGenerateOutputInformation(); unlessSetOutputDirection()is called, the output inherits the input direction — existing behavior preserved (no default change). Three new GTests: default inheritance, explicit direction with analytic-inverse verification, and the calibrated lattice-centering bound.Original algorithm by Luis Ibanez (2004); direction-handling groundwork by @physwkim in #6577.