Skip to content

Volume constructors accept non-invertible affine matrices #450

Closed

Description

@yinkev

Describe the bug

Volume and VolumeGeometry can accept a rank-deficient affine matrix when a dependent column is small enough to pass the approximate scaled-orthogonality check. The object is then invalid for later spatial operations that require inversion.

To reproduce

Start from an identity affine and make one spatial column a small multiple of another, for example:

affine = np.eye(4)
affine[:3, 2] = affine[:3, 0] * 1e-6
Volume(np.zeros((2, 2, 2)), affine, coordinate_system="PATIENT")

Current behavior: construction succeeds, but downstream operations may fail at np.linalg.inv().

Expected behavior

The public volume constructors should reject non-invertible affine matrices immediately with a clear ValueError, while continuing to accept genuinely invertible scaled-orthogonal affines.

Scope

Validate invertibility at the shared constructor boundary, update the affine contract documentation, and cover both Volume and VolumeGeometry.

Process note

I am filing this issue before the replacement pull request in accordance with the developer guide's issue-first recommendation. PR #435 was opened before that preflight and will be superseded.

Activity

  1. yinkev commented on Jul 25, 2026

    @yinkev
    ContributorAuthor

    Duplicate of #440. A parallel authorized remediation had already created the canonical issue-first record and compliant replacement PR before this batch completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions