Forward model, linear operator and Tikhonov estimate for ultrasound phase-aberration correction
DefinitionArxiv2401_10389_BasicObjects of Section II and Supplemental materials C of Xing, Malescot, Martineau, Rungta and Provost (2025), all at the central angular frequency .
- Probe and medium. A one-dimensional probe has elements and the medium consists of point scatterers. The transmission operator and the reflection operator are complex matrices, and the backscattering matrix is the diagonal matrix , .
- Model signals (eqs. 2 and 5). Without aberration, element receives . With per-element aberration factors acting identically on transmit and receive, it receives .
- Matrix form (eqs. 6, 7, 10). The transfer matrix is (plain transpose). The forward model is , with the entrywise product. Its gradient matrix is .
- Linear operator (eq. 13). The augmented unknown is . The operator is .
- Regularization (eqs. 14, 15, 35). . For a forward operator , a real matrix , a parameter and a signal , the Tikhonov objective is . The normal matrix is , with the conjugate transpose, and the closed-form estimate is . is the second-difference matrix with first row , interior rows centred on the diagonal, and last row .
- Multiple transmit angles (eqs. 16-18). For angles with per-element transmit delays , . The vectorized multi-angle signal has entry equal to computed with , the aberration being the same for all angles. stacks the operators built with .
Formalization Note Rows of the stacked operator are indexed by pairs rather than by a single integer; the order of the stacking does not affect any statement. is written for every , and the printed pattern is consistent for . The statements use , the length of the augmented unknown, with .
import Mathlib
/-!
Xing, Malescot, Martineau, Rungta and Provost, *Inverse Problem Approach to Aberration Correction
for in vivo Transcranial Imaging Based on a Sparse Representation of Contrast-enhanced Ultrasound
Data*, arXiv:2401.10389v3 (2025): the single-frequency forward model of a probe with `Ne` elements
insonifying `Ns` point scatterers through a phase-screen aberrator (Sections II.A and II.B), its
gradient and first-order linearization (Section II.B), the Tikhonov-regularized least-squares
solution with the second-difference matrix (Section II.C and Supplemental materials C), and the
multi-angle operator (Section II.D). All operators are taken at the central frequency `ω₀`.
-/
open Matrix
noncomputable section
namespace Arxiv2401_10389
variable {Ne Ns : ℕ}
/-- Eq. (2), Section II.A, PDF p. 2: the model signal on receive element `m` without aberration,
`M̂_m(Γ) = ∑_s ∑_n R_{m,s} Γ_{s,s} T_{n,s}`. The reflection operator `R` and the transmission
operator `T` are `Ne × Ns` complex matrices, and the diagonal backscattering matrix is
`Γ = diag γ`. -/
def unaberratedSignal (R : Matrix (Fin Ne) (Fin Ns) ℂ) (γ : Fin Ns → ℂ)
(T : Matrix (Fin Ne) (Fin Ns) ℂ) : Fin Ne → ℂ :=
fun m => ∑ s, ∑ n, R m s * γ s * T n s
/-- Eq. (5), Section II.A, PDF p. 3: the model signal on receive element `m` with the same
aberration factors `u_n` on transmit and receive,
`M̂_m(Γ, u) = ∑_s ∑_n u_m R_{m,s} Γ_{s,s} T_{n,s} u_n`. -/
def aberratedSignal (R : Matrix (Fin Ne) (Fin Ns) ℂ) (γ : Fin Ns → ℂ)
(T : Matrix (Fin Ne) (Fin Ns) ℂ) (u : Fin Ne → ℂ) : Fin Ne → ℂ :=
fun m => ∑ s, ∑ n, u m * R m s * γ s * T n s * u n
/-- Eq. (7), Section II.B, PDF p. 3: the transfer matrix `H = R Γ Tᵀ` (plain transpose), an
`Ne × Ne` matrix that does not depend on the aberration. -/
def transferMatrix (R : Matrix (Fin Ne) (Fin Ns) ℂ) (γ : Fin Ns → ℂ)
(T : Matrix (Fin Ne) (Fin Ns) ℂ) : Matrix (Fin Ne) (Fin Ne) ℂ :=
R * diagonal γ * Tᵀ
/-- Eq. (6), Section II.B, PDF p. 3: the forward model in matrix form, `M̂(Γ, u) = u ∘ H u`,
with `∘` the Hadamard (entrywise) product. -/
def forwardModel (R : Matrix (Fin Ne) (Fin Ns) ℂ) (γ : Fin Ns → ℂ)
(T : Matrix (Fin Ne) (Fin Ns) ℂ) (u : Fin Ne → ℂ) : Fin Ne → ℂ :=
fun m => u m * (transferMatrix R γ T *ᵥ u) m
/-- Eq. (10), Section II.B, PDF p. 3: the gradient matrix
`∇_u M̂(Γ, u) = diag(H u) + diag(u) H`. -/
def forwardGradient (R : Matrix (Fin Ne) (Fin Ns) ℂ) (γ : Fin Ns → ℂ)
(T : Matrix (Fin Ne) (Fin Ns) ℂ) (u : Fin Ne → ℂ) : Matrix (Fin Ne) (Fin Ne) ℂ :=
diagonal (transferMatrix R γ T *ᵥ u) + diagonal u * transferMatrix R γ T
/-- Eq. (13b), Section II.B, PDF p. 4: the augmented unknown `(u | 1)ᵀ` of length `Ne + 1`,
whose last entry is `1`. -/
def augment (u : Fin Ne → ℂ) : Fin (Ne + 1) → ℂ :=
fun j => if h : (j : ℕ) < Ne then u ⟨j, h⟩ else 1
/-- Eq. (13a), Section II.B, PDF p. 4: the `Ne × (Ne + 1)` forward operator
`K(Γ, u₀) = (∇_u M̂(Γ, u₀) | M̂(Γ, u₀) - ∇_u M̂(Γ, u₀) u₀)`: the first `Ne` columns are the
gradient at `u₀`, the last column is `M̂(Γ, u₀) - ∇_u M̂(Γ, u₀) u₀`. -/
def linearOperator (R : Matrix (Fin Ne) (Fin Ns) ℂ) (γ : Fin Ns → ℂ)
(T : Matrix (Fin Ne) (Fin Ns) ℂ) (u₀ : Fin Ne → ℂ) : Matrix (Fin Ne) (Fin (Ne + 1)) ℂ :=
fun m j => if h : (j : ℕ) < Ne then forwardGradient R γ T u₀ m ⟨j, h⟩
else forwardModel R γ T u₀ m - (forwardGradient R γ T u₀ *ᵥ u₀) m
/-- Supplemental materials C, eq. (35), PDF p. 17: the `n × n` second-difference matrix `D₂`,
with first row `(-1, 1, 0, …)`, interior rows `(…, 1, -2, 1, …)` centred on the diagonal, and
last row `(…, 0, -1, 1)`. (The printed pattern is consistent for `n ≥ 2`; statements use
`n = Ne + 1` with `Ne ≥ 1`.) -/
def secondDiffMatrix (n : ℕ) : Matrix (Fin n) (Fin n) ℝ :=
fun i j =>
if (i : ℕ) = 0 then
(if (j : ℕ) = 0 then -1 else if (j : ℕ) = 1 then 1 else 0)
else if (i : ℕ) + 1 = n then
(if (j : ℕ) + 2 = n then -1 else if (j : ℕ) + 1 = n then 1 else 0)
else
(if (j : ℕ) + 1 = (i : ℕ) then 1 else if (j : ℕ) = (i : ℕ) then -2
else if (j : ℕ) = (i : ℕ) + 1 then 1 else 0)
/-- The squared Euclidean norm `‖v‖² = ∑_i |v_i|²` of a complex vector, used in eq. (14). -/
def sqNorm {ι : Type*} [Fintype ι] (v : ι → ℂ) : ℝ :=
∑ i, Complex.normSq (v i)
/-- Eq. (14), Section II.C, PDF p. 4: the Tikhonov-regularized least-squares objective
`‖s - K v‖² + α ‖L v‖²` for a forward operator `K`, a real regularization matrix `L`, a
regularization parameter `α` and a measured signal `s`. -/
def tikhonovObjective {ι : Type*} [Fintype ι] {p : ℕ} (K : Matrix ι (Fin p) ℂ)
(L : Matrix (Fin p) (Fin p) ℝ) (α : ℝ) (s : ι → ℂ) (v : Fin p → ℂ) : ℝ :=
sqNorm (s - K *ᵥ v) + α * sqNorm (L.map (fun x : ℝ => (x : ℂ)) *ᵥ v)
/-- Eq. (15), Section II.C, PDF p. 4: the normal matrix `K† K + α Lᵀ L`, with `K†` the
conjugate transpose. -/
def normalMatrix {ι : Type*} [Fintype ι] {p : ℕ} (K : Matrix ι (Fin p) ℂ)
(L : Matrix (Fin p) (Fin p) ℝ) (α : ℝ) : Matrix (Fin p) (Fin p) ℂ :=
Kᴴ * K + (α : ℂ) • ((L.map (fun x : ℝ => (x : ℂ)))ᵀ * L.map (fun x : ℝ => (x : ℂ)))
/-- Eq. (15), Section II.C, PDF p. 4: the closed-form estimate
`û = (K† K + α Lᵀ L)⁻¹ K† s`. -/
def tikhonovSolution {ι : Type*} [Fintype ι] {p : ℕ} (K : Matrix ι (Fin p) ℂ)
(L : Matrix (Fin p) (Fin p) ℝ) (α : ℝ) (s : ι → ℂ) : Fin p → ℂ :=
(normalMatrix K L α)⁻¹ *ᵥ (Kᴴ *ᵥ s)
variable {Nθ : ℕ}
/-- Eq. (16), Section II.D, PDF p. 4: the transmission operator for transmit angle `θ`,
`T_θ = T ∘ A(θ)`, with per-element transmit phase `A_n(ω₀, θ) = exp(i ω₀ τ_n(θ))`. -/
def angleTransmit (T : Matrix (Fin Ne) (Fin Ns) ℂ) (ω₀ : ℝ) (τ : Fin Nθ → Fin Ne → ℝ)
(θ : Fin Nθ) : Matrix (Fin Ne) (Fin Ns) ℂ :=
fun n s => T n s * Complex.exp (Complex.I * (ω₀ : ℂ) * (τ θ n : ℂ))
/-- Section II.D, PDF p. 4: the vectorized multi-angle model signal; its entry `(θ, m)` is the
forward model (6) for transmit operator `T_θ` and the angle-independent aberration `u`. -/
def multiAngleSignal (R : Matrix (Fin Ne) (Fin Ns) ℂ) (γ : Fin Ns → ℂ)
(T : Matrix (Fin Ne) (Fin Ns) ℂ) (ω₀ : ℝ) (τ : Fin Nθ → Fin Ne → ℝ) (u : Fin Ne → ℂ) :
Fin Nθ × Fin Ne → ℂ :=
fun x => forwardModel R γ (angleTransmit T ω₀ τ x.1) u x.2
/-- Eq. (18), Section II.D, PDF p. 4: the stacked operator `K_θ(Γ, u₀)`, whose block for angle
`θ` is the operator (13a) built with `T_θ`. Rows are indexed by pairs `(θ, m)`. -/
def multiAngleOperator (R : Matrix (Fin Ne) (Fin Ns) ℂ) (γ : Fin Ns → ℂ)
(T : Matrix (Fin Ne) (Fin Ns) ℂ) (ω₀ : ℝ) (τ : Fin Nθ → Fin Ne → ℝ) (u₀ : Fin Ne → ℂ) :
Matrix (Fin Nθ × Fin Ne) (Fin (Ne + 1)) ℂ :=
fun x j => linearOperator R γ (angleTransmit T ω₀ τ x.1) u₀ x.2 j
end Arxiv2401_10389
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Unaberrated signal. Fix natural numbers and , either of which may be . Take two complex matrices and and a complex vector . The definition produces a vector whose entry for each index is
The inner sum over runs over all rows of and involves no weighting other than itself. If , every entry is . If , the output is the empty vector.
Aberrated signal. Take the same data and , together with a complex vector . The definition produces the vector in with entries
The same vector multiplies both the receive index and the summed index . No constraint is placed on : for example, it need not have unit-modulus entries, and is allowed.
Transfer matrix. Given and , the transfer matrix is the complex matrix
Here is the plain transpose, with no complex conjugation. does not involve any vector . If , then is the zero matrix.
Forward model. Given , and , let be the transfer matrix above. The forward model is the vector in with entries
In words, it is the entrywise (Hadamard) product . Expanded, it coincides entry by entry with the aberrated-signal formula above. The file does not state this coincidence as a theorem.
Forward "gradient". Given as above and , this is defined as the complex matrix
This is a bare definition. Nothing in the code asserts that is a derivative, Jacobian or gradient of the forward model in any sense.
Augmentation. Given , its augmentation is the vector given by
That is, . When , it is the one-entry vector .
Linearized operator. Given , and a base point , the linearized operator is the complex matrix . Here and are the "gradient" matrix and forward model defined above, both built from . Its entries are
So the first columns are , and the last column is . The code makes no statement relating times the augmented vector to , whether exact or approximate.
"Second-difference" matrix. For each natural number (including and ), this is a real matrix . Rows and columns are indexed , and the rules below are applied in this order.
- Row : , (when column exists), and all other entries are .
- Last row: for a row with , , , and all other entries are .
- Interior rows: for , , , , and all other entries are .
So the first and last rows are first differences, and , and the interior rows are . The small cases are:
- gives the empty matrix.
- gives the matrix , because row takes precedence.
- gives , which has two identical rows.
For every , each row sums to , so sends the all-ones vector to .
Squared norm. For a vector with complex entries indexed by any finite set ,
a nonnegative real number. When is empty, the value is .
Tikhonov objective. The inputs are:
- a finite index set and a natural number ;
- a complex matrix with rows indexed by and columns;
- a real matrix ;
- a real number , with no sign restriction, so and are allowed;
- a complex vector indexed by ;
- a complex vector .
The objective is the real number
where is the sum of squared moduli and is applied to after its real entries are viewed as complex numbers.
Normal matrix. Given (complex, rows indexed by a finite set , columns), a real matrix and a real number (any sign), the normal matrix is the complex matrix
Here is the conjugate transpose of , and is computed after viewing 's real entries as complex numbers. Since is real, conjugating it makes no difference. Nothing is asserted about the invertibility of .
Tikhonov solution. Given , and as for the normal matrix, together with a complex vector indexed by , the Tikhonov solution is the vector in
The inverse is the total matrix inverse: if , then is defined to be the zero matrix, and in that case . The code makes no claim that minimizes, or is a critical point of, the Tikhonov objective.
Angle-dependent transmit operator. The inputs are:
- natural numbers , and , the last being the number of angles, possibly ;
- a complex matrix ;
- a real number ;
- a real array for and ;
- an angle index .
The definition is the complex matrix
The phase factor depends only on the row and the angle , not on . No relation between and any geometric angle is imposed.
Multi-angle signal. Given , , , delays and a single vector that is the same for all angles, this is the complex vector indexed by pairs , with and , given by
In other words, it is the forward model built with the angle-dependent transmit matrix in place of . When , the vector is empty.
Multi-angle operator. Given as above and a base point , this is the complex matrix with rows indexed by pairs and columns. Its entry is the entry of the linearized operator built from , and the angle-dependent . Explicitly, with as in the multi-angle signal and ,
The rows are indexed by the pair ; the code fixes no particular linear ordering of the blocks. When , the matrix has no rows.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.