Skip to content

fix: conjugate U and Vh in SVD-based inverse filters, expose decomposition choice - #600

Open
talonchandler wants to merge 2 commits into
mainfrom
fix/598-tilt-inverse
Open

talonchandler wants to merge 2 commits into
mainfrom
fix/598-tilt-inverse

Conversation

@talonchandler

@talonchandler talonchandler commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #598.

What

  • isotropic_thin_3d.apply_inverse_transfer_function builds its Tikhonov filter from conj(U) and conj(Vh) (shared and per-tile paths), with the same one-line change in isotropic_fluorescent_thin_3d (real transfer functions there, no behavior change). The least-squares inverse needs the conjugates; they are no-ops without tilt, which is why untilted reconstructions were unaffected. Under tilt the old filter reconstructed as if the azimuth were rotated by pi.
  • isotropic_thin_3d.reconstruct gains decomposition={"auto", "svd", "per_channel"} so a tilt fit and the final reconstruction can use the same estimator. "auto" preserves the previous requires_grad switch, so existing callers are unchanged.

Verification

  • Simulation: a tilted round trip now closes at the same azimuth (band r 0.99 to 1.00, both decompositions) and fails at azimuth + pi, as it should.
  • Real ops0031 corner tile: per_channel at the stored production azimuth + pi gives r 0.81 against the trusted July reconstruction; without the + pi migration, -0.40.
  • Untilted outputs are unchanged to float noise (max diff about 1e-5 of signal std).
  • New regression test test_tilted_round_trip; full suite passes including GPU tests on an L40S node.

Migration

Azimuths fitted through the old inverse sit pi away from the forward-model convention: pipelines that refit each run are fine; replaying stored fits needs + pi. Suggest releasing as 3.1.0 with a breaking-change note. Companions: #601 (same conjugate fix for the vectorial model) and czbiohub-sf/ops_monorepo#452 (production).

…ition choice

The Tikhonov inverse filters built from a singular system omitted the
complex conjugates of U and Vh. For the forward model H = (U S Vh)^T the
least-squares inverse needs conj(U) and conj(Vh). With real or purely
imaginary transfer functions the conjugates are no-ops, which is why
untilted reconstructions were unaffected. With complex transfer functions
the unconjugated filter is wrong:

- isotropic_thin_3d under tilted illumination reconstructed as if the
  azimuth were rotated by pi, so gradient fits of the tilt landed pi away
  from the forward model's azimuth (#598).
- inplane_oriented_thick_pol3d_vector's transfer function is complex and
  not Hermitian-symmetric; its unconjugated filter was not the
  pseudoinverse (200% operator error vs torch.linalg.pinv) and returned
  the f00 phase channel with the sign flipped.
- isotropic_fluorescent_thin_3d is conjugated for consistency (real TFs,
  no behavior change).

reconstruct() also gains an explicit decomposition argument
('auto'/'svd'/'per_channel') so a gradient-based tilt fit and the final
reconstruction can use the same estimator instead of switching on
requires_grad; 'auto' preserves the previous behavior.

BREAKING: tilt azimuths fitted through the old inverse are pi away from
the forward-model convention. Reusing stored fits with this version
requires adding pi to the stored azimuth (see #598).

Fixes #598
…o its own PR

Same root cause, different user base (birefringence reconstructions) and
different validation needs, so it ships separately.
@talonchandler

Copy link
Copy Markdown
Collaborator Author

@ieivanov this follows your recommendations in #598 and supports your work for the benchmarked segmentations. I'll handle the OPS pipeline dependency.

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.

isotropic_thin_3d with tilted illumination: inverse filter omits complex conjugates, and reconstruct switches decomposition on requires_grad

1 participant