k-Wave Toolbox |
![]() ![]() |
3D time-domain simulation of wave propagation
sensor_data = kspaceFirstOrder3D(p0, kgrid, c, rho, t_array, sensor_mask) sensor_data = kspaceFirstOrder3D(p0, kgrid, c, rho, t_array, sensor_mask, ...)
kspaceFirstOrder3D
simulates the time-domain propagation of linear compressional waves through a three-dimensional homogeneous or heterogeneous acoustic medium defined by c
and rho
given the initial pressure distribution p0
. The size and discretisation of the acoustic domain are defined by the k-space grid structure kgrid
. At each time-step the pressure at the positions defined by sensor_mask
are recorded and stored.
The computation is based on a first-order k-space model which allows a heterogeneous sound speed and density. An absorbing boundary condition (in this case a perfectly matched layer) 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 (PML). 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 p0
) 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 setting the optional input 'TimeRev'
to true
. This enforces the pressure given by p0
as a time varying Dirichlet boundary condition over the sensor mask. In this mode, the input pressure p0
must be indexed as p0(sensor position, time)
. If sensor_mask
is given as a set of Cartesian coordinates then p0
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 p0
must be given as an array ordered using MATLAB's standard column-wise linear matrix indexing.
Note To run the inverse crime, the |
|
map of the initial pressure within the medium over the discretisation given by (or the time varying pressure across the sensor mask if |
|
k-space grid structure returned by |
|
sound speed within the acoustic medium [m/s] |
|
density within the acoustic medium [kg/m^3] |
|
evenly spaced array of time values [s] ( |
|
binary grid or a set of Cartesian points where the pressure is recorded at each time-step |
Note For heterogeneous medium parameters, |
Optional 'string', value pairs that may be used to modify the default computational settings.
Input | Valid Settings | Default | Description |
---|---|---|---|
|
(numeric scalar) |
|
Adaptive boundary condition threshold used when |
|
|
|
Interpolation mode used to extract the pressure when a Cartesian sensor mask is given. If set to |
|
(string of data type) |
|
String input of the data type that variables are cast to before computation. For example, setting to |
|
(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 three 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 or three element vector) |
|
Boolean controlling whether |
|
(boolean scalar or integer numeric scalar) |
|
Boolean controlling whether the code is used in time-reversal mode. If set to |
|
array of pressure time-series recorded at the sensor positions given by |
fftn
, ifftn
, imagesc
, kspaceFirstOrder1D
, kspaceFirstOrder2D
, makeGrid
, makeTime
, smooth
, unmaskSensorData
![]() |
kspaceFirstOrder2D | kspaceLineRecon | ![]() |
© 2009 Bradley Treeby and Ben Cox.