Algorithmresearch
Delay-multiply-and-sum beamforming
Also called DMAS.
A nonlinear beamformer that sums the signed square roots of the products of all pairs of delayed channel samples. It rewards channels that agree, and a square of sums makes it O(M) per pixel.
- Solves
- Beamforming
- Time
- O(M n^2) worst
- Space
- O(M) extra
- Where
- M = the number of array elements; n = the number of pixels along one side of the image
- Model
- Real RAM
- Properties
- deterministicexactnot linear in dataiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Giulia Matrone, Alessandro Stuart Savoia, Giosue Caliano, Giovanni Magenes, 2015
Delay-multiply-and-sum (DMAS) is a nonlinear combiner for beamforming. It uses the same delayed channel samples as delay-and-sum (DAS), but in place of the sum it adds the products of all pairs, each with a signed square root so that the output keeps the units of the input: . A pair contributes a positive value when the two channels agree in sign and a negative value when they do not, so the output is large only where many channels agree. DAS is linear and treats a strong echo on a few channels the same as a weak echo on all of them; DMAS favors the second case. With the signed roots , the pair sum is , so DMAS costs per pixel, not .
In plain words
After the delays, each element of the array holds one number for the point you want to see. The usual method adds them up. DMAS instead takes every pair of elements and asks whether they agree. Two elements that agree add to the score, two that disagree take away from it. An echo that truly comes from the point is seen the same way by all elements, so all pairs agree and the score is high. Noise and echoes from other places are seen differently by different elements, so the pairs cancel. A square root on each product keeps the result at the same scale as a plain sum.
The problem
The input of the combiner is a real vector : the RF samples of the channels after the focusing delays of one pixel, as in dynamic receive focusing. The output is the real number above. For an image, the combiner is applied at every pixel of an grid; the RF image is then band-pass filtered, envelope detected and log compressed as in B-mode image formation.
The algorithm
DMAS(s_1 … s_M) ▷ returns the pair sum y- 1
r_i ← sign(s_i) √|s_i| for i = 1 … M ▷ signed square roots - 2
R ← Σ_i r_i - 3
E ← Σ_i |s_i| ▷ equals Σ_i r_i² - 4
return (R² - E) / 2
Line L4 is the square of the sum minus the diagonal, which leaves twice the sum over the pairs . In an image, a pixel loop computes the delayed samples (by interpolation of the RF traces at the two-way time) and calls DMAS in place of the plain sum.
Example
For , line L1 gives , line L2 gives , line L3 gives , and line L4 gives . The six pairs give , the same value. DAS gives . The channel with the value disagrees with the other three, and in DMAS it takes away from three pairs.
The tests simulate elements with pitch 0.3 mm, a plane wave at normal incidence, one scatterer of amplitude 1 at mm, MHz, MHz and a Gaussian envelope with us. The lateral profile is the largest modulus of the RF output over depths from 5.9 to 6.1 mm, normalized to its peak:
| combiner | peak | value at x = 0.3 mm | largest side lobe at abs(x) at least 0.6 mm |
|---|---|---|---|
| DAS | 15.11 | 0.329 | 0.131 |
| DMAS | 113.33 | 0.095 | 0.029 |
At the scatterer the 16 delayed samples are almost equal, so DMAS is close to times one sample, and . These are measurements on this simulation without noise and without the band-pass filter; they depend on the array, the pulse and the scene.
Correctness
Line L4 equals the pair sum because each signed product is and . With , the output lies between and , and the upper bound holds only when all delayed samples are equal: by the Cauchy-Schwarz inequality, DMAS measures how well the channels agree. The output is homogeneous of degree one in the magnitude, , so it loses the sign: for equal channels it is a rectified copy of the signal, with its spectrum at and . This is a theorem, and it explains the band-pass filter at of filtered DMAS. The proofs are in proofs/correctness.md.
Proof: The O(M) form of delay-multiply-and-sum equals the pair sum, is bounded by the channel energy, and rectifies the signalfull
We prove five facts about the combiner on the main page (lines L1 to L4). The input is a real vector of delayed RF samples at one pixel. Let (line L1), (line L2) and (line L3). The definition of DMAS is
Theorem 1 (the O(M) form). , which is line L4.
Proof. For every pair, and , so each term is . This also holds when or , because both sides are then . Expand the square: , and , so . Solve for the pair sum.
The test compares the two forms on 300 random vectors with some zero entries.
Theorem 2 (bounds). . The lower bound holds with equality if and only if . The upper bound holds with equality if and only if all are equal, that is, all are equal.
Proof. gives the lower bound, with equality exactly when . By the Cauchy-Schwarz inequality, , with equality if and only if is a multiple of . Then . The map is one-to-one, so equal means equal .
So, for a fixed channel energy , DMAS is largest when all delayed channels agree exactly in value and sign, and for equal samples it returns . The test checks this value for and . For the same equal samples, delay-and-sum gives , which grows like and keeps the sign. DMAS grows like for agreeing channels, and it can be negative (down to ) when the signed roots cancel, which happens at a pixel where the channels disagree in sign.
Theorem 3 (homogeneity). For every real , .
Proof. . Each product is multiplied by .
So the output keeps the dimension of the input (the square root undoes the product), which is the purpose of the signed square root, but it does not keep the sign: .
Theorem 4 (rectification). Let all channels carry the same delayed signal, for all . Then . For a constant this is periodic with period , so its spectrum lies at and at the multiples of , and has nothing at .
Proof. Theorem 2 with equal entries gives the first formula. The function has period , so has period , and a periodic function has a Fourier series on the multiples of its base frequency.
This is why the filtered DMAS of Matrone et al. (2015) applies a band-pass filter around to the output before envelope detection: the DC part is removed and the second harmonic band is kept. For channels that differ, the output is no longer a pure rectified signal; the statement about the band at is then a heuristic for narrow-band data, not a theorem.
Theorem 5 (cost). Lines L1 to L4 cost per pixel, against for the pair sum. An image costs , the same order as delay-and-sum.
Proof. Lines L1 and L3 touch each entry once, line L2 is one sum and line L4 is .
Complexity
In the real-RAM model, lines L1 to L4 cost per pixel, so an image costs , the same order as DAS, with extra space for the delayed samples. The defining pair sum costs per pixel. The square root in L1 is one more operation per channel; on hardware the products and the filter cost more than the sum of DAS.
Properties
- Nonlinear: the output of a sum of two scenes is not the sum of the outputs, so cross terms between scatterers appear.
- Homogeneous of degree one in the magnitude, even in the sign: .
- Gain for perfectly aligned channels, against for DAS, and a negative output where the channels cancel.
- The signed square root is a design choice that keeps the units; other exponents give other trade-offs between contrast and speckle. Treat it as tuned, not as derived.
- Matrone et al. (2015) explain the narrower main lobe by the pairwise products, which act like the autocorrelation of the receive aperture and so like a wider virtual aperture. This is a heuristic argument; the side-lobe and resolution gains are measurements.
Variants and improvements
- Filtered DMAS (F-DMAS). A band-pass filter around on the RF image removes the DC part of the rectified output before envelope detection (Matrone et al. 2015).
- Short-lag DMAS. Only the pairs with up to a lag enter the sum, which trades resolution for less speckle variance.
- Synthetic aperture and plane waves. DMAS can combine the channels of TFM or plane-wave compounding data, over elements, angles or both.
- Other adaptive weights. The coherence factor also rewards agreement, but as a weight on the DAS output; the Capon beamformer solves for data-dependent linear weights.
When to use it
Use DMAS when contrast and lateral resolution matter more than a linear, well-understood speckle pattern, and the channel data are available after the delays. It is a research method: its nonlinearity changes the speckle statistics and the relation between echo strength and pixel value, so quantitative methods that assume a linear beamformer, such as Doppler and backscatter estimation, should use DAS.
Pitfalls
- Using the defining double loop. It costs per pixel; use the square of sums of L4.
- No band-pass filter. The raw output has a strong DC part; envelope detection at on it gives a wrong image. Filter around first.
- Sampling. The output has energy at , so the RF sampling must keep that band, or it aliases.
- IQ data. The signed square root is defined for real samples. For complex baseband data the sign must be replaced, for example by the phase, and the result is a different method.
- Linear expectations. Two equal scatterers do not give twice the output of one, and weak targets near strong ones are suppressed more than with DAS.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/delay-multiply-and-sum/. The authors are listed in prov/SF6EBZ.jsonl.
"""Delay-multiply-and-sum (DMAS) beamforming (Matrone et al. 2015).
The input of the combiner is the vector s_1, ..., s_M of real RF channel
samples after the focusing delays of one pixel. DMAS returns
y = sum over pairs i < j of sign(s_i s_j) sqrt(|s_i s_j|).
With the signed square roots r_i = sign(s_i) sqrt(|s_i|), each term is r_i r_j,
so y = ((sum r_i)^2 - sum r_i^2) / 2, which costs O(M) in place of O(M^2).
The image part uses a plane wave at normal incidence and a linear array on
z = 0, in millimetres, microseconds and megahertz (1540 m/s is 1.54 mm/us).
"""
import math
SOUND_SPEED = 1.54 # mm per microsecond
def signed_sqrt(v):
"""sign(v) sqrt(|v|), with the value 0 at 0."""
return math.copysign(math.sqrt(abs(v)), v) if v != 0 else 0.0
def dmas(samples):
"""DMAS of one delayed channel vector in O(M), by the square of the sum."""
r = [signed_sqrt(s) for s in samples] # @line L1
total = sum(r) # @line L2
energy = sum(abs(s) for s in samples) # @line L3
return (total * total - energy) / 2 # @line L4
def dmas_pairs(samples):
"""DMAS by the defining double sum over the pairs i < j, in O(M^2)."""
m = len(samples)
y = 0.0
for i in range(m):
for j in range(i + 1, m):
p = samples[i] * samples[j]
y += math.copysign(math.sqrt(abs(p)), p) if p != 0 else 0.0
return y
def das(samples):
"""Delay-and-sum of the same delayed samples, for comparison."""
return sum(samples)
def element_positions(m_count, pitch):
"""x positions of a linear array, centered at x = 0."""
return [(j - (m_count - 1) / 2) * pitch for j in range(m_count)]
def simulate_rf(elements, scatterers, f0, sigma_t, fs, t0, ns, c=SOUND_SPEED):
"""Real RF traces for a plane wave at normal incidence and point scatterers (x, z, amp).
The pulse is g(t) cos(2 pi f0 t) with a Gaussian envelope g of standard
deviation sigma_t, delayed by z / c + |p - e_j| / c.
"""
data = []
for xj in elements:
tr = [0.0] * ns
for (sx, sz, amp) in scatterers:
tau = sz / c + math.hypot(sx - xj, sz) / c
lo = max(0, math.ceil((tau - 5 * sigma_t - t0) * fs))
hi = min(ns - 1, math.floor((tau + 5 * sigma_t - t0) * fs))
for q in range(lo, hi + 1):
dt = t0 + q / fs - tau
tr[q] += amp * math.exp(-dt * dt / (2 * sigma_t * sigma_t)) * math.cos(2 * math.pi * f0 * dt)
data.append(tr)
return data
def delayed_samples(data, elements, px, pz, t0, fs, c=SOUND_SPEED):
"""The RF sample of each channel at the two-way time of the pixel, by linear interpolation."""
out = []
for xj, tr in zip(elements, data):
t = pz / c + math.hypot(px - xj, pz) / c
u = (t - t0) * fs
q = math.floor(u)
if q < 0 or q + 1 >= len(tr):
out.append(0.0)
continue
phi = u - q
out.append((1 - phi) * tr[q] + phi * tr[q + 1])
return out
def beamform(data, elements, xs, zs, t0, fs, combiner, c=SOUND_SPEED):
"""The RF image combiner(delayed samples) on the grid; rows follow zs."""
return [[combiner(delayed_samples(data, elements, px, pz, t0, fs, c)) for px in xs] for pz in zs]
test_delay_multiply_and_sum.py 67 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/delay-multiply-and-sum/. The authors are listed in prov/SF6EBZ.jsonl.
import random
from delay_multiply_and_sum import (beamform, das, dmas, dmas_pairs, element_positions, signed_sqrt,
simulate_rf)
F0, SIGMA, FS, T0, NS = 5.0, 0.1, 40.0, 7.0, 120
ELEMENTS = element_positions(16, 0.3)
XS = [round(-1.5 + 0.1 * k, 10) for k in range(31)]
ZS = [round(6.0 + 0.01 * k, 10) for k in range(-10, 11)]
def test_page_example() -> None:
s = [4.0, 1.0, -1.0, 9.0]
assert dmas_pairs(s) == 5.0
assert dmas(s) == 5.0
assert das(s) == 13.0
def test_fast_form_equals_the_pair_sum() -> None:
rng = random.Random(3105)
for _ in range(300):
m = rng.randint(1, 24)
s = [rng.uniform(-5, 5) for _ in range(m)]
if rng.random() < 0.2:
s[rng.randrange(m)] = 0.0
assert abs(dmas(s) - dmas_pairs(s)) <= 1e-9 * (1 + sum(abs(v) for v in s) * m)
def test_identical_channels_give_the_rectified_value() -> None:
for v in (2.25, -2.25, 0.0):
for m in (1, 2, 5, 16):
assert abs(dmas([v] * m) - m * (m - 1) / 2 * abs(v)) < 1e-12
def test_homogeneous_of_degree_one_in_the_magnitude() -> None:
rng = random.Random(3106)
s = [rng.uniform(-3, 3) for _ in range(10)]
for a in (4.0, 0.25, -1.0, -9.0):
assert abs(dmas([a * v for v in s]) - abs(a) * dmas(s)) < 1e-9
def test_signed_sqrt() -> None:
assert signed_sqrt(9.0) == 3.0 and signed_sqrt(-9.0) == -3.0 and signed_sqrt(0.0) == 0.0
def _profile(combiner):
data = simulate_rf(ELEMENTS, [(0.0, 6.0, 1.0)], F0, SIGMA, FS, T0, NS)
img = beamform(data, ELEMENTS, XS, ZS, T0, FS, combiner)
prof = [max(abs(img[i][j]) for i in range(len(ZS))) for j in range(len(XS))]
peak = max(prof)
return [v / peak for v in prof], peak
def test_point_target_peak_and_lower_sidelobes_than_das() -> None:
p_das, peak_das = _profile(das)
p_dmas, peak_dmas = _profile(dmas)
assert p_das.index(1.0) == XS.index(0.0) and p_dmas.index(1.0) == XS.index(0.0)
# at the peak all 16 aligned samples are close to equal, so DMAS is close to 120 times one of them
assert abs(peak_dmas - 120 * peak_das / 16) < 0.02 * peak_dmas
side_das = max(v for x, v in zip(XS, p_das) if abs(x) >= 0.6)
side_dmas = max(v for x, v in zip(XS, p_dmas) if abs(x) >= 0.6)
assert side_dmas < 0.5 * side_das
i3 = XS.index(0.3)
assert p_dmas[i3] < p_das[i3]
History
Lim, Nhung, Li and Thang (2008) introduced delay-multiply-and-sum to reconstruct images in confocal microwave imaging for the detection of breast cancer. Matrone, Savoia, Caliano and Magenes (2015) brought it to medical ultrasound B-mode imaging with the signed square root and a band-pass filter at the second harmonic, and reported better contrast and resolution than DAS on phantoms and simulations. Many later papers combine it with synthetic aperture and plane-wave imaging.
References
- Giulia Matrone, Alessandro Stuart Savoia, Giosue Caliano and Giovanni Magenes, The delay multiply and sum beamforming algorithm in ultrasound B-mode medical imaging, IEEE Transactions on Medical Imaging 34(4), 2015, 940 to 949, the definition with signed square roots, the O(M) computation, the band-pass filtered version at 2 f0, and the comparison with delay-and-sum (general locator)
- Hooi Been Lim, Nguyen Thi Tuyet Nhung, Er-Ping Li and Nguyen Duc Thang, Confocal microwave imaging for breast cancer detection: delay-multiply-and-sum image reconstruction algorithm, IEEE Transactions on Biomedical Engineering 55(6), 2008, 1697 to 1704, the original pairwise product algorithm for microwave imaging (general locator)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag SF6EBZ Edit this page History Report an error Markdown