k-Wave Toolbox |
![]() ![]() |
3D time-domain simulation of wave propagation
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor) sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, ...) [sensor_data p_final] = kspaceFirstOrder3D(kgrid, medium, source, sensor) [sensor_data p_final] = kspaceFirstOrder3D(kgrid, medium, source, sensor, ...)
kspaceFirstOrder3D
simulates the time-domain propagation of linear compressional waves through a three-dimensional homogeneous or heterogeneous acoustic medium given four input structures: kgrid
, medium
, source
, and sensor
. The computation is based on a first-order k-space model which allows a heterogeneous sound speed and density and power law absorption. At each time-step (defined by kgrid.t_array
), the pressure at the positions defined by sensor.mask
are recorded and stored. If kgrid.t_array
is set to 'auto'
, this array is automatically generated using makeTime
. An absorbing boundary condition called a perfectly matched layer (PML) is implemented to prevent waves that leave one side of the domain being reintroduced from the opposite side (a consequence of using the FFT to compute the spatial derivatives in the wave equation). This allows infinite domain simulations to be computed using small computational grids.
For a homogeneous medium the formulation is exact and the time-steps are only limited by the effectiveness of the perfectly matched layer. For a heterogeneous medium, the solution represents a leap-frog pseudospectral method with a Laplacian correction that improves the accuracy of computing the temporal derivatives. This allows larger time-steps to be taken without instability compared to conventional pseudospectral time-domain methods. The computational grids are staggered both spatially and temporally.
The pressure is returned as an array of time-series at the sensor locations defined by sensor.mask
. This can be given either as a binary grid (i.e., a matrix of 1's and 0's the same size as the grid defined by kgrid
) representing the pixels within the computational grid that will collect the data, or as a series of arbitrary Cartesian coordinates within the grid at which the pressure values are calculated at each time-step via interpolation. The Cartesian points must be given as a 3 by N matrix corresponding to the x, y, and z positions, respectively.
If sensor.mask
is given as a set of Cartesian coordinates, the computed sensor_data
is returned in the same order. If sensor.mask
is given as a binary grid, sensor_data
is returned using MATLAB's standard column-wise linear matrix index ordering. In both cases, the recorded data is indexed as sensor_data(sensor position, time)
. For a binary sensor mask, the pressure values at a particular time can be restored to the sensor positions within the computation grid using unmaskSensorData
.
The code may also be used for time-reversal image reconstruction by assigning the boundary data to the input field sensor.time_reversal_boundary_data
. This data is then enforced as a time varying Dirichlet boundary condition over the sensor mask. The boundary data must be indexed as sensor.time_reversal_boundary_data(sensor position, time)
. If sensor.mask
is given as a set of Cartesian coordinates then the boundary data must be given in the same order. An equivalent binary sensor mask (computed using nearest neighbour interpolation) is then used to place the pressure values into the computational grid at each time-step. If sensor.mask
is given as a binary grid of sensor points then the boundary data must be given as an array ordered using MATLAB's standard column-wise linear matrix indexing.
Note To run a simple reconstruction example using time reversal
(that commits the 'inverse crime' of using the same numerical parameters and model for data
simulation and image reconstruction), the |
The fields that are required for a photoacoustic forward simulation are marked with a *.
|
k-space grid structure returned by |
|
evenly spaced array of time values [s] (set to |
  |
  |
|
sound speed distribution within the acoustic medium [m/s] |
|
density distribution within the acoustic medium [kg/m^3] |
|
power law absorption exponent [dB/(MHz^y cm)] |
|
power law absorption coefficient [dB/(MHz^y cm)] |
  |
  |
|
initial pressure within the acoustic medium |
|
time varying pressure at each of the source positions given by |
|
binary grid specifying the positions of the time varying pressure source distribution |
  |
  |
|
binary grid or a set of Cartesian points where the pressure is recorded at each time-step |
|
time varying pressure enforced as a Dirichlet boundary condition over |
|
adaptive boundary condition threshold |
Note For heterogeneous medium parameters, |
Optional 'string', value pairs that may be used to modify the default computational settings.
Input | Valid Settings | Default | Description |
---|---|---|---|
|
|
|
Interpolation mode used to extract the pressure when a Cartesian sensor mask is given. If set to |
|
(boolean scalar) |
|
Boolean controlling whether the command line output is saved using the diary function with a date and time stamped filename. |
|
(string of data type) |
|
String input of the data type that variables are cast to before computation. For example, setting to |
|
(binary matrix) |
|
Binary matrix overlayed onto the animated simulation display. Elements set to 1 within the display mask are set to black within the display. |
|
(string) |
|
Name of the movie produced when |
|
(string cell array) |
|
Settings for |
|
(integer numeric scalar) |
|
The number of iterations which must pass before the simulation plot is updated. |
|
(boolean scalar) |
|
Boolean controlling whether a three plots are produced of the initial simulation layout (initial pressure, sound speed, density). |
|
(numeric two element vector) |
|
[min, max] values used to control the scaling for |
|
(boolean scalar) |
|
Boolean controlling whether the simulation iterations are progressively plotted. |
|
(numeric scalar or two element vector) |
|
Attenuation in Nepers per m of the absorption within the perfectly matched layer. |
|
(boolean scalar) |
|
Boolean controlling whether the perfectly matched layer is inside or outside the grid. Currently only |
|
(integer numeric scalar or three element vector) |
|
Size of the perfectly matched layer in pixels. By default, the PML is added evenly to all sides of the grid, however, both |
|
(boolean scalar) |
|
Boolean controlling whether the displayed image frames are captured using |
|
(boolean scalar or three element vector) |
|
Boolean controlling whether |
|
array of pressure time-series recorded at the sensor positions given by |
|
final pressure field |
fftn
, ifftn
, imagesc
, kspaceFirstOrder1D
, kspaceFirstOrder2D
, makeGrid
, makeTime
, smooth
, unmaskSensorData
![]() |
kspaceFirstOrder2D | kspaceLineRecon | ![]() |
© 2009, 2010 Bradley Treeby and Ben Cox.