k-Wave Toolbox |
![]() ![]() |
On this page… |
---|
This example demonstrates how to record the particle velocity using a Cartesian or binary sensor mask. It builds on the Homogeneous Propagation Medium and Heterogeneous Propagation Medium examples.
By default, the first order simulation functions return the pressure field recorded at the positions denoted by sensor.mask
directly to the output argument sensor_data
. The particle velocity at these positions can also be returned by setting the optional input parameter 'ReturnVelocity'
to true
. In this case, the output argument sensor_data
is returned as a structure with the pressure and particle velocity appended as separate fields. In two dimensions, these fields are given by sensor_data.p
, sensor_data.ux
, and sensor_data.uz
(similarly for other dimensions).
The final pressure and velocity can similarly be stored by using the second output argument field_final
. Here the final pressure and velocity fields are assigned as field_final.p
, field_final.ux
, and field_final.uz
.
The simulation is invoked in the same way as in previous examples. Here four sensor points are defined centered about the position of the source. kspaceFirstOrder2D
is then called with the optional input parameter 'ReturnVelocity'
set to true
. A plot of the initial pressure distribution and the sensor mask is given below.
% define four sensor points centered about source.p0 sensor_radius = 40; % pixels sensor.mask = zeros(Nz, Nx); sensor.mask(Nz/2 + sensor_radius, Nx/2) = 1; sensor.mask(Nz/2 - sensor_radius, Nx/2) = 1; sensor.mask(Nz/2, Nx/2 + sensor_radius) = 1; sensor.mask(Nz/2, Nx/2 - sensor_radius) = 1; % run the simulation sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, 'ReturnVelocity', true);
The pressure and velocity recorded at the four sensor positions is shown below (these are indexed left to right, top to bottom). The recorded pressure signals are shown in the left column. As the sensor points are all equidistance from the center of the source, the signals appear the same. The recorded particle velocity signals in the x-direction are shown in the central column. The signals from the first and fourth sensor points are mirrored as the wave at these points is travelling in opposite directions. The signals at the second and third sensor points are almost zero because the wave at these positions is travelling in the z-direction. The recorded particle velocity signals in the z-direction are shown in the right column. The signals from the second and third sensor points are mirrored as the wave at these points is travelling in opposite directions. The signals at the first and fourth sensor points are almost zero because the wave at these positions is travelling in the x-direction.
![]() |
Saving Movie Files | Defining A Gaussian Sensor Frequency Response | ![]() |
© 2009, 2010, 2011 Bradley Treeby and Ben Cox.