## Image Reconstruction Scripts The repository includes all necessary scripts to reconstruct the received ultrasound data for the in-vivo datasets presented in the paper as well as the raw data from those recordings. The various functions and scripts are: 1) output_map.m - Generates the output data mapping from each coarse uBF such that the data stream can be mapped to the correct coarse uBF within the array 2) grid_gen.m - Generates the imaging grid for DAS reconstruction. It uses a polar grid with radii starting from the virtual center of the array for maximum sector angle all the way to the maximum imaged depth, and then transforms this into a Cartesian grid 3) delay_gen.m - Generates ASIC delays for transmit to utilize them in determining the TX delay for the array. It can generate delays for both XZ centric and YZ centric imaging 4) file_rename.m - Splits the data input into per beam datsets, either as files or structs. It supports older data formats including CSVs and per-beam output files for backward compatibility 5) channel_reorder.m - Rearranges the data input into per pixel data from top-left of the array to bottom-right by compressing the N_outxN_bypass input data into N_pixelxN_pixel columns per beam. This involves replicating the data by sqrt(N_bypass)xsqrt(N_bypass) to make up for reduced channel count. It also removes the data for unused elements and zero-pads by the T/R switch delay to ensure correct time indices. It supports older data formats including CSVs and per-beam output files for backward compatibility 6) traumas_das.m - Performs the delay-and-sum beamforming for the imaged data onto the reconstruction grid using linear interpolation. It involves determining both TX and RX distance, converting them into a return time and then a time index and interpolating the echo from each point in the grid using the received data from all channels based on this time index 7) traumas_das_3d.m - Same as traumas_das but extended to 3D 8) image_recon_rt.m - Takes raw ultrasound real-time 2-D data (`*_rt_raw.zip` in directory datasets_lung) and uses DAS to generate real-time image frames. The script handles unzipping and file handling if necessary and outputs a `.mat` file which contains the reconstruction grid coordinates and corresponding B-Mode values. It also optionally generates a video that contains the B-Mode slices 9) image_recon_3d.m - Takes raw ultrasound 3-D data (`*_3d_raw.zip` in directory datasets_neck) and uses DAS to generate volumetric B-Mode data. The script handles unzipping and file handling if necessary. The parameter `orthogonal` determines if the reconstruction is done along the direction orthogonal to the acquisition plane. It outputs a `.mat` file which contains the reconstruction grid coordinates and corresponding B-Mode values. It also optionally generates a video that contains the B-Mode slices 10) bmode_image_plot.m - Plots 2-D and 3-D reconstructed B-mode data in `*_3d_recon.mat` files generated by image_recon_3d.m 11) multiframe_bmode_plot.m - Plots real-time 2-D reconstructed B-mode data in `*_rt_recon.mat` files generated by image_recon_rt.m 12) lung_seashore_plot.m - Generates M-Mode Seashore plots from real-time recordings of pleural region from files `*_rt_recon.mat` for B-Mode data 13) lung_motion_brightness.m - Tracks brightness on real-time recordings of pleural region. This script uses files `*_rt_recon.mat` for B-Mode data and `*_motion.csv` for chest height information. Requires MATLAB Image Processing Toolbox. 14) lung_chest_position.py - Python script for extracting chest motion from video recording of the subject breathing. This script also adds markers to the video tracking the chest position. Requires the following packages: OpenCV (cv2), NumPy, SciPy Signal Processing (scipy.signal), PyPlot (matplotlib) and the module sys. Raw data for image reconstruction is available on [Zenodo](https://zenodo.org/records/20738352) -- DOI 10.5281/zenodo.20738351