RyoMurakami commited on
Commit
55b0cc0
·
verified ·
1 Parent(s): 15c074e

8th: add reviewer verification PNGs (own DAS vs zea reconstruct.py)

Browse files
verification/coarse_pitch_0p3__point_z080_r4__own_das.png ADDED

Git LFS Details

  • SHA256: 94e9f0b9581bf496f1479a05fbbc9a5d23cf813facb339da119843df36a8b26f
  • Pointer size: 130 Bytes
  • Size of remote file: 52.7 kB
verification/coarse_pitch_0p3__point_z080_r4__zea_reconstruct.png ADDED

Git LFS Details

  • SHA256: 414d526081cf2432888cb16083c9e8d682f64187481810b16ab122e95545faa9
  • Pointer size: 130 Bytes
  • Size of remote file: 99.7 kB
verification/own_das_reconstruct.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ own_das_reconstruct.py — reconstruct one rotation frame of an acquisition with
4
+ the authors' ORIGINAL in-plane DAS beamformer (sim/beamform.py of the generation
5
+ codebase, vendored below as `das_planewave`), independent of the zea pipeline.
6
+
7
+ Produced for reviewer verification (Tristan, 2026-07-17): the same frame of the
8
+ same acquisition is also reconstructed with the package's reconstruct.py (zea
9
+ Pipeline: demodulate -> delay_and_sum -> envelope -> normalize -> log-compress);
10
+ comparing the two PNGs confirms the raw RF channel data is correct and intended.
11
+
12
+ Only numpy / scipy / h5py / matplotlib are needed (no zea).
13
+
14
+ Usage:
15
+ python own_das_reconstruct.py [--input ../data/coarse_pitch_0p3__point_z080_r4.hdf5]
16
+ """
17
+ import argparse
18
+ import os
19
+ from pathlib import Path
20
+
21
+ import h5py
22
+ import matplotlib
23
+
24
+ matplotlib.use("Agg")
25
+ import matplotlib.pyplot as plt
26
+ import numpy as np
27
+ from scipy.signal import hilbert
28
+
29
+ HERE = Path(__file__).parent
30
+ DEFAULT_INPUT = HERE.parent / "data" / "coarse_pitch_0p3__point_z080_r4.hdf5"
31
+
32
+
33
+ def das_planewave(rf, t0, xe, c, fs, z_mm, x_mm, apod=True):
34
+ """Vectorized in-plane DAS for one normal plane-wave transmit
35
+ (verbatim logic of the authors' sim/beamform.py).
36
+
37
+ rf: (n_ax, n_el) channel data; xe: (n_el,) element x positions [m].
38
+ Returns beamformed image (nz, nx)."""
39
+ n_ax, n_el = rf.shape
40
+ xg = x_mm * 1e-3
41
+ zg = z_mm * 1e-3
42
+ win = np.hanning(n_el) if apod else np.ones(n_el)
43
+
44
+ X = xg[None, :, None]
45
+ Z = zg[:, None, None]
46
+ XE = xe[None, None, :]
47
+ delay = (Z + np.sqrt((X - XE) ** 2 + Z**2)) / c # (nz, nx, n_el)
48
+ idx = np.round((delay - t0) * fs).astype(np.int64)
49
+ ok = (idx >= 0) & (idx < n_ax)
50
+ idx_c = np.clip(idx, 0, n_ax - 1)
51
+ el = np.arange(n_el)[None, None, :]
52
+ gathered = rf[idx_c, el] * ok * win[None, None, :]
53
+ return gathered.sum(axis=2)
54
+
55
+
56
+ def main():
57
+ ap = argparse.ArgumentParser(description=__doc__)
58
+ ap.add_argument("--input", type=Path, default=DEFAULT_INPUT)
59
+ ap.add_argument("--output", type=Path, default=None)
60
+ ap.add_argument("--frame-index", type=int, default=None)
61
+ args = ap.parse_args()
62
+
63
+ with h5py.File(args.input, "r") as f:
64
+ scan = f["tracks/track_0/scan"]
65
+ fs = float(scan["sampling_frequency"][()])
66
+ c = float(scan["sound_speed"][()])
67
+ t0 = float(np.asarray(scan["initial_times"]).ravel()[0])
68
+ xe = np.asarray(f["probe/probe_geometry"])[:, 0] # element x [m]
69
+ rot_deg = np.degrees(np.asarray(f["metadata/probe_pose/rotation"])[:, 2])
70
+ raw = f["tracks/track_0/data/raw_data"] # (n_fr, 1, n_ax, n_el, 1)
71
+ frame = args.frame_index
72
+ if frame is None: # same default as reconstruct.py: ~90 deg rotation magnitude
73
+ frame = int(np.argmin(np.abs(np.abs(rot_deg) - 90.0)))
74
+ rf = np.asarray(raw[frame, 0, :, :, 0], dtype=np.float64)
75
+
76
+ n_ax = rf.shape[0]
77
+ dz = c / (2 * fs) * 1e3 # mm per RF sample
78
+ z_max_mm = (t0 + n_ax / fs) * c / 2 * 1e3
79
+ z_mm = np.arange(0.0, z_max_mm, dz)
80
+ x_mm = xe * 1e3 # one beam per element
81
+
82
+ img = das_planewave(rf, t0, xe, c, fs, z_mm, x_mm)
83
+ env = np.abs(hilbert(img, axis=0))
84
+ env /= env.max()
85
+ bmode_db = 20 * np.log10(env + 1e-12)
86
+
87
+ out = args.output or HERE / (args.input.stem + "__own_das.png")
88
+ fig, ax = plt.subplots(figsize=(5, 8))
89
+ im = ax.imshow(bmode_db, cmap="gray", vmin=-40, vmax=0, aspect="equal",
90
+ extent=[x_mm[0], x_mm[-1], z_mm[-1], z_mm[0]])
91
+ ax.set_xlabel("lateral [mm]")
92
+ ax.set_ylabel("depth [mm]")
93
+ ax.set_title(f"{args.input.name}\nauthors' own DAS (sim/beamform.py), "
94
+ f"frame {frame} ({rot_deg[frame]:.0f}°), DR −40 dB")
95
+ fig.colorbar(im, ax=ax, label="dB")
96
+ fig.tight_layout()
97
+ fig.savefig(out, dpi=150)
98
+ print(f"frame {frame} @ {rot_deg[frame]:.1f} deg -> {out}")
99
+
100
+
101
+ if __name__ == "__main__":
102
+ main()