|
| 1 | +Time Reversal Reconstruction |
| 2 | +======================== |
| 3 | + |
| 4 | +The :class:`TimeReversal` class provides functionality for time reversal reconstruction in photoacoustic imaging. |
| 5 | +It handles the reconstruction of initial pressure distributions from recorded sensor data. |
| 6 | + |
| 7 | +.. tip:: |
| 8 | + **Migration from Legacy Time Reversal** |
| 9 | + |
| 10 | + Previous versions used ``sensor.time_reversal_boundary_data`` directly with ``kspaceFirstOrder2D/3D``. |
| 11 | + This approach is now deprecated. Instead, use the new :class:`TimeReversal` class: |
| 12 | + |
| 13 | + .. code-block:: python |
| 14 | +
|
| 15 | + # Old approach (deprecated) |
| 16 | + sensor.time_reversal_boundary_data = sensor_data |
| 17 | + p0_recon = kspaceFirstOrder2D(kgrid, source, sensor, medium, simulation_options, execution_options) |
| 18 | +
|
| 19 | + # New approach |
| 20 | + sensor.recorded_pressure = sensor_data # Store recorded data |
| 21 | + tr = TimeReversal(kgrid, medium, sensor) |
| 22 | + p0_recon = tr(kspaceFirstOrder2D, simulation_options, execution_options) |
| 23 | +
|
| 24 | +Class Documentation |
| 25 | +----------------- |
| 26 | + |
| 27 | +.. autoclass:: kwave.reconstruction.time_reversal.TimeReversal |
| 28 | + :members: |
| 29 | + :undoc-members: |
| 30 | + :show-inheritance: |
| 31 | + |
| 32 | +Key Features |
| 33 | +----------- |
| 34 | + |
| 35 | +- Automatic compensation for half-plane recording |
| 36 | +- Support for both 2D and 3D reconstructions |
| 37 | +- Input validation and error checking |
| 38 | +- Clean interface separating data recording from reconstruction |
| 39 | + |
| 40 | +Example Usage |
| 41 | +------------ |
| 42 | + |
| 43 | +Here's a complete example showing forward simulation and time reversal reconstruction: |
| 44 | + |
| 45 | +.. code-block:: python |
| 46 | +
|
| 47 | + import numpy as np |
| 48 | + from kwave import * |
| 49 | +
|
| 50 | + # Setup grid and medium |
| 51 | + kgrid = kWaveGrid([64, 64], [0.1e-3, 0.1e-3]) |
| 52 | + medium = kWaveMedium(sound_speed=1500) |
| 53 | + kgrid.makeTime(medium.sound_speed) |
| 54 | +
|
| 55 | + # Create initial pressure |
| 56 | + source = kSource() |
| 57 | + source.p0 = np.zeros(kgrid.N) |
| 58 | + source.p0[32, 32] = 1 |
| 59 | +
|
| 60 | + # Setup sensor |
| 61 | + sensor = kSensor() |
| 62 | + sensor.mask = np.zeros(kgrid.N) |
| 63 | + sensor.mask[0, :] = 1 # Line sensor |
| 64 | +
|
| 65 | + # Forward simulation |
| 66 | + sensor_data = kspaceFirstOrder2D(kgrid, source, sensor, medium, |
| 67 | + simulation_options, execution_options) |
| 68 | + sensor.recorded_pressure = sensor_data["p"].T |
| 69 | +
|
| 70 | + # Time reversal reconstruction |
| 71 | + tr = TimeReversal(kgrid, medium, sensor) |
| 72 | + p0_recon = tr(kspaceFirstOrder2D, simulation_options, execution_options) |
| 73 | +
|
| 74 | +Notes |
| 75 | +----- |
| 76 | + |
| 77 | +- The compensation factor (default=2.0) accounts for energy loss when recording over a half-plane |
| 78 | +- The time array must be explicitly defined (not 'auto') for time reversal |
| 79 | +- The sensor mask must have at least one active point |
| 80 | +- The sensor mask shape must match the grid dimensions |
0 commit comments