How andyleow/ultrasound_image_reconstruction works
File Structure Analysis
• Top-Level Directories & Files
• src/
– cpuDAS, cpuFBF: MATLAB‐callable .m wrappers around CPU algorithms
– gpuDAS, gpuFBF: CUDA/C++ source (.cu/.cuh), mex build artifacts (.mexa64/.mexw64), and nvcc build config (xml)
• util/
– help_func: MATLAB beamforming helpers (CPU/GPU, Fourier/DAS)
– matlab-serialization-master: C++/MATLAB serialization library for data I/O
– savefast: fast MATLAB .mat writer
• examples/
– Offline: pure MATLAB demos calling mex functions
– Vantage: live scanner integration scripts
• makefile.m: top-level MATLAB build script
• README.md: usage, build instructions, requirements
README Insights
• Technology stack: MATLAB 2017b+, CUDA Toolkit 9.0, Visual Studio 2015 (Win) or GCC (Linux)
• Build process: mex commands invoking nvcc via xml configs
• Usage modes:
a) Offline reconstruction (batch)
b) Real-time pipeline (Vantage scanner → mex GPU kernels → MATLAB display)
a. Main Components
1. MATLAB Frontend
• User scripts & GUIs (examples/Offline & examples/Vantage)
2. MEX Gateway
• mexFunction entry points in cu*.cu / .cuh
3. CPU Beamformer Module
• DAS_CPU_Func.m, FBF_CPU_Func.m
4. GPU Beamformer Module
• cuDAS_*.cu(u), cuFBF_*.cu(u) kernels & helper functions
5. Utilities Layer
• helper MATLAB functions (util/help_func)
• serialization (util/matlab-serialization-master)
• fast save (util/savefast)
6. Hardware & External Services
• Host CPU / MATLAB runtime
• GPU device (CUDA)
• Vantage ultrasound scanner API
b. Relationships & Data Flow
1. Data Acquisition
• Offline: load raw IQ data via serialization library
• Real-time: Vantage scanner SDK streams raw data into MATLAB
2. Invocation
• MATLAB calls mex wrappers → dispatch to CPU or GPU kernels
3. Processing
• CPU: delay-and-sum or Fourier beamforming in pure MATLAB or via CPU MEX
• GPU: raw echo data transferred to GPU memory → CUDA kernels execute beamforming
4. Result
• Beamformed image passed back to MATLAB workspace → visualization
5. Persistence (offline mode)
• Optionally save results using savefast
c. Architectural Patterns & Principles
• Layered/pipeline architecture (acquisition → processing → visualization)
• Plugin-style native modules (mex functions as extension points)
• Clear host/device separation (CPU vs. GPU implementations)
• Reusable utility libraries for serialization and I/O
d. Key Technologies & Frameworks
• MATLAB mex API
• CUDA C/C++ (nvcc, xml build configs)
• Visual Studio (Windows) / GCC (Linux)
• Custom MATLAB scripts for build orchestration (makefile.m)
• Third-party serialization and fast-save libraries