esdiva 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. esdiva-0.1.0/.gitignore +46 -0
  2. esdiva-0.1.0/LICENSE +28 -0
  3. esdiva-0.1.0/PKG-INFO +212 -0
  4. esdiva-0.1.0/README.md +183 -0
  5. esdiva-0.1.0/pyproject.toml +150 -0
  6. esdiva-0.1.0/src/esdiva/__init__.py +142 -0
  7. esdiva-0.1.0/src/esdiva/attenuation/__init__.py +17 -0
  8. esdiva-0.1.0/src/esdiva/attenuation/attenuation.py +376 -0
  9. esdiva-0.1.0/src/esdiva/beamforming/__init__.py +15 -0
  10. esdiva-0.1.0/src/esdiva/beamforming/das.py +619 -0
  11. esdiva-0.1.0/src/esdiva/emission/__init__.py +7 -0
  12. esdiva-0.1.0/src/esdiva/emission/emission.py +981 -0
  13. esdiva-0.1.0/src/esdiva/emission/sir_to_pressure.py +268 -0
  14. esdiva-0.1.0/src/esdiva/hsir/__init__.py +9 -0
  15. esdiva-0.1.0/src/esdiva/hsir/farfield_rect_patch.py +368 -0
  16. esdiva-0.1.0/src/esdiva/hsir/helpers.py +201 -0
  17. esdiva-0.1.0/src/esdiva/hsir/transducer_sir_pe_sdi.py +1266 -0
  18. esdiva-0.1.0/src/esdiva/io/__init__.py +6 -0
  19. esdiva-0.1.0/src/esdiva/io/hdf5.py +98 -0
  20. esdiva-0.1.0/src/esdiva/io/rf_dataset.py +399 -0
  21. esdiva-0.1.0/src/esdiva/plotting/__init__.py +66 -0
  22. esdiva-0.1.0/src/esdiva/plotting/export_utils.py +174 -0
  23. esdiva-0.1.0/src/esdiva/plotting/plane_utils.py +383 -0
  24. esdiva-0.1.0/src/esdiva/plotting/plotting2D.py +946 -0
  25. esdiva-0.1.0/src/esdiva/plotting/plotting3D.py +674 -0
  26. esdiva-0.1.0/src/esdiva/plotting/plotting_pyvista.py +669 -0
  27. esdiva-0.1.0/src/esdiva/plotting/pyvista_functions.py +284 -0
  28. esdiva-0.1.0/src/esdiva/plotting/validators.py +61 -0
  29. esdiva-0.1.0/src/esdiva/py.typed +0 -0
  30. esdiva-0.1.0/src/esdiva/reception/__init__.py +6 -0
  31. esdiva-0.1.0/src/esdiva/reception/base.py +1277 -0
  32. esdiva-0.1.0/src/esdiva/reception/conventional.py +721 -0
  33. esdiva-0.1.0/src/esdiva/reception/reception.py +1074 -0
  34. esdiva-0.1.0/src/esdiva/simulation_base.py +95 -0
  35. esdiva-0.1.0/src/esdiva/transducers/__init__.py +137 -0
  36. esdiva-0.1.0/src/esdiva/transducers/base.py +954 -0
  37. esdiva-0.1.0/src/esdiva/transducers/circular.py +870 -0
  38. esdiva-0.1.0/src/esdiva/transducers/custom.py +302 -0
  39. esdiva-0.1.0/src/esdiva/transducers/fieldii_compat.py +482 -0
  40. esdiva-0.1.0/src/esdiva/transducers/geometry_utils.py +214 -0
  41. esdiva-0.1.0/src/esdiva/transducers/linear.py +614 -0
  42. esdiva-0.1.0/src/esdiva/transducers/matrix.py +424 -0
  43. esdiva-0.1.0/src/esdiva/transducers/saved_transducers.py +72 -0
  44. esdiva-0.1.0/src/esdiva/transducers/validators.py +306 -0
  45. esdiva-0.1.0/src/esdiva/utilities/__init__.py +31 -0
  46. esdiva-0.1.0/src/esdiva/utilities/bg_atlas.py +374 -0
  47. esdiva-0.1.0/src/esdiva/utilities/helper_functions.py +752 -0
  48. esdiva-0.1.0/src/esdiva/utilities/matlab.py +91 -0
  49. esdiva-0.1.0/src/esdiva/utilities/phantom.py +84 -0
  50. esdiva-0.1.0/src/esdiva/utilities/surface_subdivision.py +504 -0
@@ -0,0 +1,46 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ *.mp4
5
+ build/
6
+ dist/
7
+ wheels/
8
+ results/
9
+ out/
10
+ log/
11
+ site/
12
+ *.mp4
13
+ *.pth
14
+ # *.npz
15
+ *.egg-info
16
+ pressure_fields/
17
+ test_models/
18
+
19
+
20
+ # Virtual environments
21
+ .venv
22
+ .cache
23
+
24
+ # Coverage reports
25
+ htmlcov/
26
+ nul
27
+ coverage.xml
28
+ *.cover
29
+ .coverage
30
+ .coverage.*
31
+
32
+ # Precommit files
33
+ precommit_full.txt
34
+
35
+ # Specific files (too heavy)
36
+ Linear_nsubx1_nsuby10_fs200_P359601_M1280_T2634_pulsed.mat
37
+ Linear_nsubx1_nsuby10_fs200_P90201_M1280_T2634_pulsed.mat
38
+
39
+ # graphify non-crucial temporal/cache data (regenerated by `graphify update .`).
40
+ # Keep only the crucial outputs tracked: graph.json, graph.html, GRAPH_REPORT.md,
41
+ # manifest.json. Everything below is local cache/state and must not be committed.
42
+ graphify-out/cache/
43
+ graphify-out/cost.json
44
+ graphify-out/.graphify_labels.json
45
+ graphify-out/.graphify_root
46
+ graphify-out/.graphify_python
esdiva-0.1.0/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Deyver Esteban Rivera
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
esdiva-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: esdiva
3
+ Version: 0.1.0
4
+ Summary: eSDIva — Efficient Sparse Delta Integration for Vectorized Acoustics. A friendly, fast, exact ultrasound pressure-field simulator for any transducer geometry.
5
+ Project-URL: Homepage, https://estebanrivera08.github.io/eSDIva/
6
+ Project-URL: Documentation, https://estebanrivera08.github.io/eSDIva/
7
+ Project-URL: Repository, https://github.com/EstebanRivera08/eSDIva
8
+ Project-URL: Issues, https://github.com/EstebanRivera08/eSDIva/issues
9
+ Author-email: Deyver Esteban Rivera <113285895+EstebanRivera08@users.noreply.github.com>
10
+ License-Expression: BSD-3-Clause
11
+ License-File: LICENSE
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Topic :: Scientific/Engineering
15
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
16
+ Classifier: Topic :: Scientific/Engineering :: Physics
17
+ Requires-Python: <3.13,>=3.11
18
+ Requires-Dist: brainglobe-atlasapi>=2.2.1
19
+ Requires-Dist: brainglobe-space>=1.0.3
20
+ Requires-Dist: h5py>=3.13.0
21
+ Requires-Dist: imageio-ffmpeg>=0.6.0
22
+ Requires-Dist: imageio>=2.37.3
23
+ Requires-Dist: matplotlib>=3.10.1
24
+ Requires-Dist: numba>=0.61
25
+ Requires-Dist: numpy>=2.1.2
26
+ Requires-Dist: pyvista[jupyter]>=0.45.0
27
+ Requires-Dist: scipy>=1.15.2
28
+ Description-Content-Type: text/markdown
29
+
30
+ <h1 align="center">🌊 eSDIva</h1>
31
+ <p align="center"><b>Efficient Sparse Delta Integration for Vectorized Acoustics.</b></p>
32
+ <p align="center">
33
+ A friendly acoustic field simulator — your probe into ultrasound fields: <b>fast and exact</b>.
34
+ </p>
35
+
36
+ [![PyPI version](https://img.shields.io/pypi/v/esdiva)](https://pypi.org/project/esdiva/)
37
+ [![Python versions](https://img.shields.io/pypi/pyversions/esdiva)](https://pypi.org/project/esdiva/)
38
+ [![DOI]()]()
39
+ [![codecov](https://codecov.io/gh/EstebanRivera08/eSDIva/graph/badge.svg)](https://codecov.io/gh/EstebanRivera08/eSDIva)
40
+ [![Docs](https://img.shields.io/badge/docs-online-blue)](https://estebanrivera08.github.io/eSDIva/)
41
+
42
+ 📖 **Documentation:** <https://estebanrivera08.github.io/eSDIva/>
43
+
44
+ > [!WARNING]
45
+ > eSDIva is currently under development. The API is subject to change, and some features may be incomplete or unstable.
46
+
47
+ eSDIva is an open‑source Spatial Impulse Response (SIR) and pressure‑field simulation library that supports arbitrary transducer geometries composed of small rectangular patches with apodization and delays.
48
+ eSDIva implements both the Fully Sampled Trapezoid (FST) and the Sparse Delta Integration (SDI) methods for computing SIRs following the Tupholme–Stepanishen formulation.
49
+ FST reproduces the classic Field II approach, while SDI is a new, algorithmically and mathematically improved method that computes the same SIRs — under identical assumptions — but substantially faster; an automatic mode picks the best method for each simulation.
50
+
51
+ > [!NOTE]
52
+ > eSDIva is designed as complementary material to the work presented in [https://arxiv.org/abs/2608.26891]. Its goal is to provide fundamental building blocks that researchers can inspect, reuse, contribute to, or adapt. It also leaves room for community‑driven extensions that integrate naturally with the broader scientific Python ecosystem.
53
+ > Utilities such as the integration with the BrainGlobe atlas may still evolve to improve robustness.
54
+
55
+ ### Main Features
56
+
57
+ - **Transducer objects** — Tools to create and assemble common transducer types: linear arrays, convex arrays, matrix arrays, flat/concave/focused circular transducers, and arbitrary custom arrays. These utilities compute geometric focal laws, generate apodization windows for specified F/D ratios, and more.
58
+
59
+ - **SIR simulation** — The `H_sir` module computes discrete spatial impulse responses \( h(r, t) \) produced by apertures discretized into rectangular patches. It includes naïve, SDI, and automatic methods implemented with Numba‑accelerated kernels for field‑point‑parallel execution.
60
+
61
+ - **Emission simulation** — Converts time‑domain SIRs into acoustic pressure fields via the `Emission` class. Supports monochromatic fields (spatial‑only, CW amplitude at `fc`) and broadband transient simulations with defined excitation pulses (spatio‑temporal pressure matrices), with global or per‑element excitation.
62
+
63
+ - **Pulse‑echo reception** — The `Reception` class simulates pulse‑echo RF from scatterers using a fast closed‑form PE‑SDI spectral kernel (plus conventional Tupholme–Stepanishen and pedagogic reference backends). Generates PSFs, focused B‑mode lines, plane‑wave / diverging‑wave event sequences, and full‑matrix / synthetic‑aperture (FMC) acquisitions, with crash‑safe checkpointing of long runs.
64
+
65
+ - **Beamforming** — Numba‑accelerated 3‑D delay‑and‑sum (`das_volume`, `das_rca_volume`) and focused scanline (`DAS_focused_scanline`) reconstructors for plane‑wave, diverging‑wave, focused, and row‑column sequences, with optional coherence weighting and envelope/log‑compression helpers.
66
+
67
+ - **Attenuation** — Causal power‑law (frequency‑dependent) attenuation transfer functions applicable per patch in both emission and reception.
68
+
69
+ - **Phantoms & I/O** — Random‑scatterer phantom generation with echogenicity maps, and a checkpointed on‑disk RF store (`RFDataset`, `.npz`) with HDF5 export (UFF‑compatible fields) for MATLAB/USTB interchange.
70
+
71
+ - **Brain Atlas Integration** — Maps pressure simulations onto standard brain atlases (via BrainGlobe) for neuro‑ultrasound research.
72
+
73
+ - **Visualization** — Rich plotting utilities using Matplotlib and PyVista for visualizing transducers, pressure fields, pulse‑echo setups, and brain atlases.
74
+
75
+ ## Gallery
76
+
77
+ <table>
78
+ <tr>
79
+ <td width="50%"><img src="docs/examples/assets/ex03_matrix_array_field.png" width="100%" alt="Focused pressure field"><br><sub><b>Focused CW field</b> — matrix array</sub></td>
80
+ <td width="50%"><img src="docs/examples/assets/ex05_matrix_pw_3d.gif" width="100%" alt="Steered plane-wave transient"><br><sub><b>Steered plane wave</b> — 3-D transient</sub></td>
81
+ </tr>
82
+ <tr>
83
+ <td width="50%"><img src="docs/examples/assets/ex13_rat_brain_zones.png" width="100%" alt="Transcranial targeting"><br><sub><b>Transcranial targeting</b> — rat-brain atlas</sub></td>
84
+ <td width="50%"><img src="docs/examples/assets/ex21_zeus10_volume_3d.png" width="100%" alt="3-D B-mode volume"><br><sub><b>3-D B-mode volume</b> — Zeus matrix, fast RF + DAS</sub></td>
85
+ </tr>
86
+ </table>
87
+
88
+ ---
89
+
90
+ ## Installation
91
+
92
+ ### 1. Set up a virtual environment
93
+
94
+ We recommend installing eSDIva in a virtual environment to avoid dependency conflicts with other Python packages. Using [uv](https://docs.astral.sh/uv/guides/install-python/), you can create a new project folder with a virtual environment as follows:
95
+
96
+ ```bash
97
+ uv init new_project
98
+ ```
99
+
100
+ If you already have a project folder, create a virtual environment with:
101
+
102
+ ```bash
103
+ uv venv
104
+ ```
105
+
106
+ ### 2. Install eSDIva
107
+
108
+ To install the latest development version from GitHub:
109
+
110
+ ```bash
111
+ uv add git+https://github.com/EstebanRivera08/eSDIva.git
112
+ ```
113
+
114
+ eSDIva will soon be available on PyPI.
115
+
116
+ ### 3. Check installation
117
+
118
+ Check that eSDIva is correctly installed by opening a Python interpreter and
119
+ importing the package:
120
+
121
+ ```python
122
+ import esdiva
123
+ ```
124
+
125
+ If no error is raised, you have installed eSDIva correctly.
126
+
127
+ ---
128
+
129
+ ## Quick Start
130
+
131
+ ```python
132
+ import esdiva as diva
133
+
134
+ # Define transducer (mm units; no_sub_x/no_sub_y are keyword-only)
135
+ tx = diva.transducers.LinearArrayTransducer(
136
+ n_elements=64,
137
+ element_width_mm=0.25,
138
+ element_height_mm=12.0,
139
+ kerf_mm=0.05,
140
+ no_sub_x=2,
141
+ no_sub_y=4,
142
+ frequency_Hz=5e6,
143
+ )
144
+ tx.compute_delays(focus_mm=[0, 0, 30])
145
+ tx.compute_apodization(focus_mm=[0, 0, 30], FoverD=2.0)
146
+
147
+ # Define field grid
148
+ field_points = {
149
+ "x_extent": [-5, 5],
150
+ "y_extent": [-0.5, 0.5],
151
+ "z_extent": [5, 55],
152
+ "dx": 0.1,
153
+ "dy": 1.0,
154
+ "dz": 0.2,
155
+ }
156
+
157
+ # Run a monochromatic (CW) simulation → pressure amplitude at fc
158
+ sim = diva.Emission(tx, monochromatic=True)
159
+ p, coords = sim(field_points, method="auto")
160
+
161
+ # Visualize
162
+ diva.plot2D_pressure_slices(p, coords=coords, db_scale=True, vmin=-40)
163
+ ```
164
+
165
+ From the project folder you can also run the bundled examples directly:
166
+
167
+ ```bash
168
+ uv run examples/example03_multielements_monochromatic_CW.py
169
+ uv run examples/example04_lineararray_excitation_DW.py
170
+ uv run examples/example01_transducer_gallery.py
171
+ ```
172
+
173
+ ---
174
+
175
+
176
+ ## Citing eSDIva
177
+
178
+ If you use eSDIva in your research, please cite it using the following reference:
179
+
180
+ ```bibtex
181
+ @misc{rivera2026sparsedeltaintegrationmethod,
182
+ title={Sparse Delta Integration method for the calculation of spatiotemporal pressure fields of arbitrary ultrasound transducer geometries},
183
+ author={Deyver E. Rivera and Charlie Demene and Mickael Tanter},
184
+ year={2026},
185
+ eprint={2608.26891},
186
+ archivePrefix={arXiv},
187
+ primaryClass={physics.med-ph},
188
+ url={https://arxiv.org/abs/2608.26891},
189
+ }
190
+ ```
191
+
192
+
193
+ ## References
194
+
195
+ These works underpin the theory and helped as inspiration for the methods implemented in eSDIva (far-field trapezoid SIR for rectangular apertures, pulse‑echo modelling, power‑law attenuation, and related simulators).
196
+
197
+ 1. B. T. Cox, S. Kara, S. R. Arridge, and P. C. Beard, "k‑space propagation models for acoustically heterogeneous media: Application to biomedical photoacoustics," *The Journal of the Acoustical Society of America*, vol. 121, no. 6, pp. 3453–3464, Jun. 2007. [Online]. Available: <https://pubs.aip.org/jasa/article/121/6/3453/537252/>
198
+ 2. G. Pinton, J. Dahl, S. Rosenzweig, and G. Trahey, "A heterogeneous nonlinear attenuating full‑wave model of ultrasound," *IEEE Trans. Ultrason., Ferroelect., Freq. Contr.*, vol. 56, no. 3, pp. 474–488, Mar. 2009. [Online]. Available: <http://ieeexplore.ieee.org/document/4816057/>
199
+ 3. E. Bossy, M. Talmant, and P. Laugier, "Three‑dimensional simulations of ultrasonic axial transmission velocity measurement on cortical bone models," *The Journal of the Acoustical Society of America*, vol. 115, no. 5, pp. 2314–2324, May 2004. [Online]. Available: <https://pubs.aip.org/jasa/article/115/5/2314/546299/>
200
+ 4. B. E. Treeby and B. T. Cox, "k‑Wave: MATLAB toolbox for the simulation and reconstruction of photoacoustic wave fields," *J. Biomed. Opt.*, vol. 15, no. 2, p. 021314, 2010. [Online]. Available: <http://biomedicaloptics.spiedigitallibrary.org/article.aspx?doi=10.1117/1.3360308>
201
+ 5. J. A. Jensen, "FIELD: A program for simulating ultrasound systems," *Medical & Biological Engineering & Computing*, vol. 34, no. Supplement 1, Part 1, pp. 351–352, Jan. 1996.
202
+ 6. G. E. Tupholme, "Generation of acoustic pulses by baffled plane pistons," *Mathematika*, vol. 16, no. 2, pp. 209–224, Dec. 1969. [Online]. Available: <https://onlinelibrary.wiley.com/doi/abs/10.1112/S0025579300008184>
203
+ 7. P. R. Stepanishen, "Transient Radiation from Pistons in an Infinite Planar Baffle," *Journal of the Acoustical Society of America*, vol. 49, pp. 1629–1638, Mar. 1971. [Online]. Available: <https://doi.org/10.1121/1.1912541>
204
+ 8. P. R. Stepanishen, "The Time‑Dependent Force and Radiation Impedance on a Piston in a Rigid Infinite Planar Baffle," *Journal of the Acoustical Society of America*, vol. 49, pp. 841–849, Mar. 1971. [Online]. Available: <https://doi.org/10.1121/1.1912424>
205
+ 9. J. Jensen and N. Svendsen, "Calculation of pressure fields from arbitrarily shaped, apodized, and excited ultrasound transducers," *IEEE Trans. Ultrason., Ferroelect., Freq. Contr.*, vol. 39, no. 2, pp. 262–267, Mar. 1992. [Online]. Available: <http://ieeexplore.ieee.org/document/139123/>
206
+ 10. D. Garcia, "SIMUS: An open‑source simulator for medical ultrasound imaging. Part I: Theory & examples," *Computer Methods and Programs in Biomedicine*, vol. 218, p. 106726, May 2022. [Online]. Available: <https://linkinghub.elsevier.com/retrieve/pii/S0169260722001122>
207
+ 11. A. Cigier, F. Varray, and D. Garcia, "SIMUS: An open‑source simulator for medical ultrasound imaging. Part II: Comparison with four simulators," *Computer Methods and Programs in Biomedicine*, vol. 220, p. 106774, 2022. [Online]. Available: <https://www.sciencedirect.com/science/article/pii/S0169260722001602>
208
+ 12. G. S. Kino, *Acoustic waves: devices, imaging, and analog signal processing*, ser. Prentice‑Hall signal processing series. Englewood Cliffs: Prentice‑Hall, 1987.
209
+ 13. J. Jensen, D. Gandhi, and W. O'Brien, Jr., "Ultrasound fields in an attenuating medium," in *1993 Proceedings IEEE Ultrasonics Symposium*, Baltimore, MD, USA: IEEE, 1993, pp. 943–946 vol.2. [Online]. Available: <https://ieeexplore.ieee.org/document/5727212/>
210
+ 14. J. A. Jensen, "A model for the propagation and scattering of ultrasound in tissue," *The Journal of the Acoustical Society of America*, vol. 89, no. 1, pp. 182–190, Jan. 1991. [Online]. Available: <https://pubs.aip.org/jasa/article/89/1/182/678841/>
211
+ 15. B. A. J. Angelsen, "A Theoretical Study of the Scattering of Ultrasound from Blood," *IEEE Transactions on Biomedical Engineering*, vol. BME‑27, no. 2, pp. 61–67, Feb. 1980.
212
+ 16. J. Jensen and I. Nikolov, "Fast simulation of ultrasound images," in *2000 IEEE Ultrasonics Symposium. Proceedings*, vol. 2, San Juan, Puerto Rico: IEEE, 2000, pp. 1721–1724. [Online]. Available: <http://ieeexplore.ieee.org/document/921654/>
esdiva-0.1.0/README.md ADDED
@@ -0,0 +1,183 @@
1
+ <h1 align="center">🌊 eSDIva</h1>
2
+ <p align="center"><b>Efficient Sparse Delta Integration for Vectorized Acoustics.</b></p>
3
+ <p align="center">
4
+ A friendly acoustic field simulator — your probe into ultrasound fields: <b>fast and exact</b>.
5
+ </p>
6
+
7
+ [![PyPI version](https://img.shields.io/pypi/v/esdiva)](https://pypi.org/project/esdiva/)
8
+ [![Python versions](https://img.shields.io/pypi/pyversions/esdiva)](https://pypi.org/project/esdiva/)
9
+ [![DOI]()]()
10
+ [![codecov](https://codecov.io/gh/EstebanRivera08/eSDIva/graph/badge.svg)](https://codecov.io/gh/EstebanRivera08/eSDIva)
11
+ [![Docs](https://img.shields.io/badge/docs-online-blue)](https://estebanrivera08.github.io/eSDIva/)
12
+
13
+ 📖 **Documentation:** <https://estebanrivera08.github.io/eSDIva/>
14
+
15
+ > [!WARNING]
16
+ > eSDIva is currently under development. The API is subject to change, and some features may be incomplete or unstable.
17
+
18
+ eSDIva is an open‑source Spatial Impulse Response (SIR) and pressure‑field simulation library that supports arbitrary transducer geometries composed of small rectangular patches with apodization and delays.
19
+ eSDIva implements both the Fully Sampled Trapezoid (FST) and the Sparse Delta Integration (SDI) methods for computing SIRs following the Tupholme–Stepanishen formulation.
20
+ FST reproduces the classic Field II approach, while SDI is a new, algorithmically and mathematically improved method that computes the same SIRs — under identical assumptions — but substantially faster; an automatic mode picks the best method for each simulation.
21
+
22
+ > [!NOTE]
23
+ > eSDIva is designed as complementary material to the work presented in [https://arxiv.org/abs/2608.26891]. Its goal is to provide fundamental building blocks that researchers can inspect, reuse, contribute to, or adapt. It also leaves room for community‑driven extensions that integrate naturally with the broader scientific Python ecosystem.
24
+ > Utilities such as the integration with the BrainGlobe atlas may still evolve to improve robustness.
25
+
26
+ ### Main Features
27
+
28
+ - **Transducer objects** — Tools to create and assemble common transducer types: linear arrays, convex arrays, matrix arrays, flat/concave/focused circular transducers, and arbitrary custom arrays. These utilities compute geometric focal laws, generate apodization windows for specified F/D ratios, and more.
29
+
30
+ - **SIR simulation** — The `H_sir` module computes discrete spatial impulse responses \( h(r, t) \) produced by apertures discretized into rectangular patches. It includes naïve, SDI, and automatic methods implemented with Numba‑accelerated kernels for field‑point‑parallel execution.
31
+
32
+ - **Emission simulation** — Converts time‑domain SIRs into acoustic pressure fields via the `Emission` class. Supports monochromatic fields (spatial‑only, CW amplitude at `fc`) and broadband transient simulations with defined excitation pulses (spatio‑temporal pressure matrices), with global or per‑element excitation.
33
+
34
+ - **Pulse‑echo reception** — The `Reception` class simulates pulse‑echo RF from scatterers using a fast closed‑form PE‑SDI spectral kernel (plus conventional Tupholme–Stepanishen and pedagogic reference backends). Generates PSFs, focused B‑mode lines, plane‑wave / diverging‑wave event sequences, and full‑matrix / synthetic‑aperture (FMC) acquisitions, with crash‑safe checkpointing of long runs.
35
+
36
+ - **Beamforming** — Numba‑accelerated 3‑D delay‑and‑sum (`das_volume`, `das_rca_volume`) and focused scanline (`DAS_focused_scanline`) reconstructors for plane‑wave, diverging‑wave, focused, and row‑column sequences, with optional coherence weighting and envelope/log‑compression helpers.
37
+
38
+ - **Attenuation** — Causal power‑law (frequency‑dependent) attenuation transfer functions applicable per patch in both emission and reception.
39
+
40
+ - **Phantoms & I/O** — Random‑scatterer phantom generation with echogenicity maps, and a checkpointed on‑disk RF store (`RFDataset`, `.npz`) with HDF5 export (UFF‑compatible fields) for MATLAB/USTB interchange.
41
+
42
+ - **Brain Atlas Integration** — Maps pressure simulations onto standard brain atlases (via BrainGlobe) for neuro‑ultrasound research.
43
+
44
+ - **Visualization** — Rich plotting utilities using Matplotlib and PyVista for visualizing transducers, pressure fields, pulse‑echo setups, and brain atlases.
45
+
46
+ ## Gallery
47
+
48
+ <table>
49
+ <tr>
50
+ <td width="50%"><img src="docs/examples/assets/ex03_matrix_array_field.png" width="100%" alt="Focused pressure field"><br><sub><b>Focused CW field</b> — matrix array</sub></td>
51
+ <td width="50%"><img src="docs/examples/assets/ex05_matrix_pw_3d.gif" width="100%" alt="Steered plane-wave transient"><br><sub><b>Steered plane wave</b> — 3-D transient</sub></td>
52
+ </tr>
53
+ <tr>
54
+ <td width="50%"><img src="docs/examples/assets/ex13_rat_brain_zones.png" width="100%" alt="Transcranial targeting"><br><sub><b>Transcranial targeting</b> — rat-brain atlas</sub></td>
55
+ <td width="50%"><img src="docs/examples/assets/ex21_zeus10_volume_3d.png" width="100%" alt="3-D B-mode volume"><br><sub><b>3-D B-mode volume</b> — Zeus matrix, fast RF + DAS</sub></td>
56
+ </tr>
57
+ </table>
58
+
59
+ ---
60
+
61
+ ## Installation
62
+
63
+ ### 1. Set up a virtual environment
64
+
65
+ We recommend installing eSDIva in a virtual environment to avoid dependency conflicts with other Python packages. Using [uv](https://docs.astral.sh/uv/guides/install-python/), you can create a new project folder with a virtual environment as follows:
66
+
67
+ ```bash
68
+ uv init new_project
69
+ ```
70
+
71
+ If you already have a project folder, create a virtual environment with:
72
+
73
+ ```bash
74
+ uv venv
75
+ ```
76
+
77
+ ### 2. Install eSDIva
78
+
79
+ To install the latest development version from GitHub:
80
+
81
+ ```bash
82
+ uv add git+https://github.com/EstebanRivera08/eSDIva.git
83
+ ```
84
+
85
+ eSDIva will soon be available on PyPI.
86
+
87
+ ### 3. Check installation
88
+
89
+ Check that eSDIva is correctly installed by opening a Python interpreter and
90
+ importing the package:
91
+
92
+ ```python
93
+ import esdiva
94
+ ```
95
+
96
+ If no error is raised, you have installed eSDIva correctly.
97
+
98
+ ---
99
+
100
+ ## Quick Start
101
+
102
+ ```python
103
+ import esdiva as diva
104
+
105
+ # Define transducer (mm units; no_sub_x/no_sub_y are keyword-only)
106
+ tx = diva.transducers.LinearArrayTransducer(
107
+ n_elements=64,
108
+ element_width_mm=0.25,
109
+ element_height_mm=12.0,
110
+ kerf_mm=0.05,
111
+ no_sub_x=2,
112
+ no_sub_y=4,
113
+ frequency_Hz=5e6,
114
+ )
115
+ tx.compute_delays(focus_mm=[0, 0, 30])
116
+ tx.compute_apodization(focus_mm=[0, 0, 30], FoverD=2.0)
117
+
118
+ # Define field grid
119
+ field_points = {
120
+ "x_extent": [-5, 5],
121
+ "y_extent": [-0.5, 0.5],
122
+ "z_extent": [5, 55],
123
+ "dx": 0.1,
124
+ "dy": 1.0,
125
+ "dz": 0.2,
126
+ }
127
+
128
+ # Run a monochromatic (CW) simulation → pressure amplitude at fc
129
+ sim = diva.Emission(tx, monochromatic=True)
130
+ p, coords = sim(field_points, method="auto")
131
+
132
+ # Visualize
133
+ diva.plot2D_pressure_slices(p, coords=coords, db_scale=True, vmin=-40)
134
+ ```
135
+
136
+ From the project folder you can also run the bundled examples directly:
137
+
138
+ ```bash
139
+ uv run examples/example03_multielements_monochromatic_CW.py
140
+ uv run examples/example04_lineararray_excitation_DW.py
141
+ uv run examples/example01_transducer_gallery.py
142
+ ```
143
+
144
+ ---
145
+
146
+
147
+ ## Citing eSDIva
148
+
149
+ If you use eSDIva in your research, please cite it using the following reference:
150
+
151
+ ```bibtex
152
+ @misc{rivera2026sparsedeltaintegrationmethod,
153
+ title={Sparse Delta Integration method for the calculation of spatiotemporal pressure fields of arbitrary ultrasound transducer geometries},
154
+ author={Deyver E. Rivera and Charlie Demene and Mickael Tanter},
155
+ year={2026},
156
+ eprint={2608.26891},
157
+ archivePrefix={arXiv},
158
+ primaryClass={physics.med-ph},
159
+ url={https://arxiv.org/abs/2608.26891},
160
+ }
161
+ ```
162
+
163
+
164
+ ## References
165
+
166
+ These works underpin the theory and helped as inspiration for the methods implemented in eSDIva (far-field trapezoid SIR for rectangular apertures, pulse‑echo modelling, power‑law attenuation, and related simulators).
167
+
168
+ 1. B. T. Cox, S. Kara, S. R. Arridge, and P. C. Beard, "k‑space propagation models for acoustically heterogeneous media: Application to biomedical photoacoustics," *The Journal of the Acoustical Society of America*, vol. 121, no. 6, pp. 3453–3464, Jun. 2007. [Online]. Available: <https://pubs.aip.org/jasa/article/121/6/3453/537252/>
169
+ 2. G. Pinton, J. Dahl, S. Rosenzweig, and G. Trahey, "A heterogeneous nonlinear attenuating full‑wave model of ultrasound," *IEEE Trans. Ultrason., Ferroelect., Freq. Contr.*, vol. 56, no. 3, pp. 474–488, Mar. 2009. [Online]. Available: <http://ieeexplore.ieee.org/document/4816057/>
170
+ 3. E. Bossy, M. Talmant, and P. Laugier, "Three‑dimensional simulations of ultrasonic axial transmission velocity measurement on cortical bone models," *The Journal of the Acoustical Society of America*, vol. 115, no. 5, pp. 2314–2324, May 2004. [Online]. Available: <https://pubs.aip.org/jasa/article/115/5/2314/546299/>
171
+ 4. B. E. Treeby and B. T. Cox, "k‑Wave: MATLAB toolbox for the simulation and reconstruction of photoacoustic wave fields," *J. Biomed. Opt.*, vol. 15, no. 2, p. 021314, 2010. [Online]. Available: <http://biomedicaloptics.spiedigitallibrary.org/article.aspx?doi=10.1117/1.3360308>
172
+ 5. J. A. Jensen, "FIELD: A program for simulating ultrasound systems," *Medical & Biological Engineering & Computing*, vol. 34, no. Supplement 1, Part 1, pp. 351–352, Jan. 1996.
173
+ 6. G. E. Tupholme, "Generation of acoustic pulses by baffled plane pistons," *Mathematika*, vol. 16, no. 2, pp. 209–224, Dec. 1969. [Online]. Available: <https://onlinelibrary.wiley.com/doi/abs/10.1112/S0025579300008184>
174
+ 7. P. R. Stepanishen, "Transient Radiation from Pistons in an Infinite Planar Baffle," *Journal of the Acoustical Society of America*, vol. 49, pp. 1629–1638, Mar. 1971. [Online]. Available: <https://doi.org/10.1121/1.1912541>
175
+ 8. P. R. Stepanishen, "The Time‑Dependent Force and Radiation Impedance on a Piston in a Rigid Infinite Planar Baffle," *Journal of the Acoustical Society of America*, vol. 49, pp. 841–849, Mar. 1971. [Online]. Available: <https://doi.org/10.1121/1.1912424>
176
+ 9. J. Jensen and N. Svendsen, "Calculation of pressure fields from arbitrarily shaped, apodized, and excited ultrasound transducers," *IEEE Trans. Ultrason., Ferroelect., Freq. Contr.*, vol. 39, no. 2, pp. 262–267, Mar. 1992. [Online]. Available: <http://ieeexplore.ieee.org/document/139123/>
177
+ 10. D. Garcia, "SIMUS: An open‑source simulator for medical ultrasound imaging. Part I: Theory & examples," *Computer Methods and Programs in Biomedicine*, vol. 218, p. 106726, May 2022. [Online]. Available: <https://linkinghub.elsevier.com/retrieve/pii/S0169260722001122>
178
+ 11. A. Cigier, F. Varray, and D. Garcia, "SIMUS: An open‑source simulator for medical ultrasound imaging. Part II: Comparison with four simulators," *Computer Methods and Programs in Biomedicine*, vol. 220, p. 106774, 2022. [Online]. Available: <https://www.sciencedirect.com/science/article/pii/S0169260722001602>
179
+ 12. G. S. Kino, *Acoustic waves: devices, imaging, and analog signal processing*, ser. Prentice‑Hall signal processing series. Englewood Cliffs: Prentice‑Hall, 1987.
180
+ 13. J. Jensen, D. Gandhi, and W. O'Brien, Jr., "Ultrasound fields in an attenuating medium," in *1993 Proceedings IEEE Ultrasonics Symposium*, Baltimore, MD, USA: IEEE, 1993, pp. 943–946 vol.2. [Online]. Available: <https://ieeexplore.ieee.org/document/5727212/>
181
+ 14. J. A. Jensen, "A model for the propagation and scattering of ultrasound in tissue," *The Journal of the Acoustical Society of America*, vol. 89, no. 1, pp. 182–190, Jan. 1991. [Online]. Available: <https://pubs.aip.org/jasa/article/89/1/182/678841/>
182
+ 15. B. A. J. Angelsen, "A Theoretical Study of the Scattering of Ultrasound from Blood," *IEEE Transactions on Biomedical Engineering*, vol. BME‑27, no. 2, pp. 61–67, Feb. 1980.
183
+ 16. J. Jensen and I. Nikolov, "Fast simulation of ultrasound images," in *2000 IEEE Ultrasonics Symposium. Proceedings*, vol. 2, San Juan, Puerto Rico: IEEE, 2000, pp. 1721–1724. [Online]. Available: <http://ieeexplore.ieee.org/document/921654/>
@@ -0,0 +1,150 @@
1
+ [project]
2
+ name = "esdiva"
3
+ version = "0.1.0"
4
+ description = "eSDIva — Efficient Sparse Delta Integration for Vectorized Acoustics. A friendly, fast, exact ultrasound pressure-field simulator for any transducer geometry."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Deyver Esteban Rivera", email = "113285895+EstebanRivera08@users.noreply.github.com" }
8
+ ]
9
+ requires-python = ">=3.11,<3.13"
10
+ license = "BSD-3-Clause"
11
+ license-files = ["LICENSE"]
12
+ classifiers = [
13
+ "Programming Language :: Python",
14
+ "Intended Audience :: Science/Research",
15
+ "Topic :: Scientific/Engineering",
16
+ "Topic :: Scientific/Engineering :: Physics",
17
+ "Topic :: Scientific/Engineering :: Medical Science Apps.",
18
+ ]
19
+ dependencies = [
20
+ "brainglobe-atlasapi>=2.2.1",
21
+ "brainglobe-space>=1.0.3",
22
+ "h5py>=3.13.0",
23
+ "imageio>=2.37.3",
24
+ "imageio-ffmpeg>=0.6.0",
25
+ "matplotlib>=3.10.1",
26
+ "numba>=0.61",
27
+ "numpy>= 2.1.2",
28
+ "pyvista[jupyter]>=0.45.0",
29
+ "scipy>=1.15.2",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://estebanrivera08.github.io/eSDIva/"
34
+ Documentation = "https://estebanrivera08.github.io/eSDIva/"
35
+ Repository = "https://github.com/EstebanRivera08/eSDIva"
36
+ Issues = "https://github.com/EstebanRivera08/eSDIva/issues"
37
+
38
+ [tool.ruff]
39
+ exclude = []
40
+
41
+ [project.scripts]
42
+ esdiva = "esdiva:main"
43
+
44
+ [build-system]
45
+ # Pin < 1.28: hatchling 1.28+ emits Metadata 2.5, which twine 6.2 rejects on
46
+ # upload (its metadata-version allowlist stops at 2.4). 2.4 already carries the
47
+ # SPDX license-expression we need.
48
+ requires = ["hatchling<1.28"]
49
+ build-backend = "hatchling.build"
50
+
51
+ # Keep the sdist lean: ship source, license, and readme — not the docs gifs,
52
+ # example figures, or graphify artefacts (those bloated it to 63 MB).
53
+ [tool.hatch.build.targets.sdist]
54
+ only-include = ["src", "README.md", "LICENSE", "CITATION.cff", "pyproject.toml"]
55
+
56
+ # torch not currently used — uncomment this index + the `torch` dep + source below to re-enable.
57
+ # [[tool.uv.index]]
58
+ # name = "pytorch"
59
+ # url = "https://download.pytorch.org/whl/cu126"
60
+ # default = false
61
+
62
+ [dependency-groups]
63
+ dev = [
64
+ "zensical>=0.0.28",
65
+ "ipykernel>=6.29.5",
66
+ "ipympl>=0.9.7",
67
+ "ipython>=9.1.0",
68
+ "ipyvtklink>=0.2.3",
69
+ "ruff>=0.12.0",
70
+ # "torch>=2.6.0", # unused for now; CUDA-only index breaks macOS sync. Re-enable with index above.
71
+ "pytest>=8.4.2",
72
+ "pytest-cov>=6.0.0",
73
+ "ty>=0.0.10",
74
+ "pytest-pyvista>=0.3.2",
75
+ "mkdocstrings[python]>=1.0.3",
76
+ "prek>=0.2.0",
77
+ "vtk>=9.2.2",
78
+ "pytest-mpl>=0.16.0",
79
+ "tqdm<=4.66.5",
80
+ "codespell>=2.3.0",
81
+ "numpydoc>=1.9.0",
82
+ "pandas>=2.2.3",
83
+ "openpyxl>=3.1.5",
84
+ "twine>=6.1",
85
+ "packaging>=24.2",
86
+ ]
87
+
88
+ # [tool.uv.sources]
89
+ # torch = {index = "pytorch"}
90
+
91
+ # --------------------------------------------------------------------------- #
92
+ # pytest
93
+ # --------------------------------------------------------------------------- #
94
+ [tool.pytest.ini_options]
95
+ minversion = "8.0"
96
+ testpaths = ["tests"]
97
+ python_files = ["test_*.py"]
98
+ python_classes = ["Test*"]
99
+ python_functions = ["test_*"]
100
+ addopts = [
101
+ "-ra",
102
+ "--strict-markers",
103
+ "--strict-config",
104
+ "--showlocals",
105
+ ]
106
+ filterwarnings = [
107
+ "error",
108
+ "ignore::DeprecationWarning",
109
+ "ignore:The active matplotlib backend.*is non-interactive:UserWarning",
110
+ "ignore:FigureCanvasAgg is non-interactive:UserWarning",
111
+ ]
112
+
113
+ # --------------------------------------------------------------------------- #
114
+ # coverage
115
+ # --------------------------------------------------------------------------- #
116
+ [tool.coverage.run]
117
+ source = ["esdiva"]
118
+ omit = ["*/examples/*"]
119
+
120
+ [tool.coverage.report]
121
+ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]
122
+
123
+ # --------------------------------------------------------------------------- #
124
+ # codespell
125
+ # --------------------------------------------------------------------------- #
126
+ [tool.codespell]
127
+ skip = "*.ipynb,*.lock,examples/*,.git"
128
+ ignore-words-list = "ser,hsi,nd,mear,apod,fo,te,bu"
129
+
130
+ # --------------------------------------------------------------------------- #
131
+ # numpydoc
132
+ # --------------------------------------------------------------------------- #
133
+
134
+ [tool.numpydoc_validation]
135
+ exclude = [
136
+ '\.__init__$',
137
+ '\._.*$',
138
+
139
+ '^\.examples/.*',
140
+
141
+ ]
142
+ checks = [
143
+ "all", # Report on all checks, except the below
144
+ "GL01",
145
+ "ES01",
146
+ "SA01",
147
+ "EX01",
148
+ ]
149
+ numpydoc_validation_checks = ["all", "GL01", "ES01", "SA01", "EX01"]
150
+