Skip to content

Inverse transform should be the same type as the original - #6685

Closed
dzenanz wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
dzenanz:transformErrors
Closed

dzenanz wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
dzenanz:transformErrors

Conversation

@dzenanz

@dzenanz dzenanz commented Jul 22, 2026

Copy link
Copy Markdown
Member

This reveals that a number of transforms provide parent type as inverse. I assume this is incorrect in at least most cases, and possibly even in all cases. Here are the problematic cases:

ERROR: GetInverseTransform() did not preserve concrete type for AzimuthElevationToCartesianTransform
  Expected type: AzimuthElevationToCartesianTransform
  Actual type: AffineTransform
GetInverseTransform() returned null for BSplineTransform 
ERROR: GetInverseTransform() did not preserve concrete type for Euler3DTransform
  Expected type: Euler3DTransform
  Actual type: MatrixOffsetTransformBase
ERROR: GetInverseTransform() did not preserve concrete type for FixedCenterOfRotationAffineTransform
  Expected type: FixedCenterOfRotationAffineTransform
  Actual type: ScalableAffineTransform
ERROR: GetInverseTransform() did not preserve concrete type for QuaternionRigidTransform
  Expected type: QuaternionRigidTransform
  Actual type: MatrixOffsetTransformBase
ERROR: GetInverseTransform() did not preserve concrete type for ScaleLogarithmicTransform
  Expected type: ScaleLogarithmicTransform
  Actual type: ScaleTransform
ERROR: GetInverseTransform() did not preserve concrete type for Similarity3DTransform
  Expected type: Similarity3DTransform
  Actual type: MatrixOffsetTransformBase
ERROR: GetInverseTransform() did not preserve concrete type for VersorRigid3DTransform
  Expected type: VersorRigid3DTransform
  Actual type: MatrixOffsetTransformBase
ERROR: GetInverseTransform() did not preserve concrete type for VersorTransform
  Expected type: VersorTransform
  Actual type: MatrixOffsetTransformBase

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)

Testing AffineTransform
Testing AzimuthElevationToCartesianTransform
ERROR: GetInverseTransform() did not preserve concrete type for AzimuthElevationToCartesianTransform
  Expected type: AzimuthElevationToCartesianTransform
  Actual type: AffineTransform
Testing BSplineTransform
GetInverseTransform() returned null for BSplineTransform
Testing CenteredAffineTransform
Testing CenteredEuler3DTransform
Testing CenteredAffineTransform
Testing CenteredRigid2DTransform
Testing CenteredSimilarity2DTransform
Testing CompositeTransform
Testing ElasticBodyReciprocalSplineKernelTransform
Testing ElasticBodySplineKernelTransform
Testing Euler2DTransform
Testing Euler3DTransform
ERROR: GetInverseTransform() did not preserve concrete type for Euler3DTransform
  Expected type: Euler3DTransform
  Actual type: MatrixOffsetTransformBase
Testing FixedCenterOfRotationAffineTransform
ERROR: GetInverseTransform() did not preserve concrete type for FixedCenterOfRotationAffineTransform
  Expected type: FixedCenterOfRotationAffineTransform
  Actual type: ScalableAffineTransform
Testing IdentityTransform
Testing QuaternionRigidTransform
ERROR: GetInverseTransform() did not preserve concrete type for QuaternionRigidTransform
  Expected type: QuaternionRigidTransform
  Actual type: MatrixOffsetTransformBase
Testing Rigid2DTransform
Testing ScalableAffineTransform
Testing ScaleLogarithmicTransform
ERROR: GetInverseTransform() did not preserve concrete type for ScaleLogarithmicTransform
  Expected type: ScaleLogarithmicTransform
  Actual type: ScaleTransform
Testing ScaleTransform
Testing Similarity2DTransform
Testing Similarity3DTransform
ERROR: GetInverseTransform() did not preserve concrete type for Similarity3DTransform
  Expected type: Similarity3DTransform
  Actual type: MatrixOffsetTransformBase
Testing ThinPlateR2LogRSplineKernelTransform
Testing ThinPlateSplineKernelTransform
Testing TranslationTransform
Testing VersorRigid3DTransform
ERROR: GetInverseTransform() did not preserve concrete type for VersorRigid3DTransform
  Expected type: VersorRigid3DTransform
  Actual type: MatrixOffsetTransformBase
Testing VersorTransform
ERROR: GetInverseTransform() did not preserve concrete type for VersorTransform
  Expected type: VersorTransform
  Actual type: MatrixOffsetTransformBase
Testing VolumeSplineKernelTransform
@github-actions github-actions Bot added type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module labels Jul 22, 2026
@hjmjohnson

Copy link
Copy Markdown
Member

@dzenanz Agreed. I do think this is the most common behavior that should be the default.

@dzenanz

dzenanz commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

With KernelTransform inversion pushed through, I will take a bit of a break. Feel free to take over this PR and the associated issue.

@hjmjohnson

Copy link
Copy Markdown
Member

Thanks for the repro, @dzenanz — it pinned the problem precisely, and the failing type assertion here is exactly what drove the fix.

Superseded by #6689, which:

  • adds GetInverseTransform() overrides so the 7 affected 3D transforms (Euler3D, QuaternionRigid, Similarity3D, VersorRigid3D, Versor, FixedCenterOfRotationAffine, ScaleLogarithmic) return their concrete type — matching the 2D family;
  • generalizes your assertion (with documented exemptions for BSplineTransform and AzimuthElevationToCartesianTransform, which cannot return a same-typed inverse) and adds non-identity round-trip coverage for all 7;
  • documents the change in the ITK 6 migration guide.

Both commits credit you as co-author. Closing in favor of #6689 with your go-ahead to take it over.

@hjmjohnson hjmjohnson closed this Jul 23, 2026
@dzenanz
dzenanz deleted the transformErrors branch July 23, 2026 20:16
hjmjohnson added a commit that referenced this pull request Jul 24, 2026
…nverse

ENH: GetInverseTransform() returns concrete type for 3D transforms (resolves #6686, supersedes #6685)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants