k-Wave
A MATLAB toolbox for the time-domain
simulation of acoustic wave fields
- Getting Started
- Examples
- Initial Value Problems
- Example: Homogenous Propagation Medium
- Example: Using A Binary Sensor Mask
- Example: Defining A Sensor Mask By Opposing Corners
- Example: Loading External Image Maps
- Example: Heterogeneous Propagation Medium
- Example: Saving Movie Files
- Example: Recording The Particle Velocity
- Example: Defining A Gaussian Sensor Frequency Response
- Example: Comparison Of Modelling Functions
- Example: Setting An Initial Pressure Gradient
- Example: Simulations In One Dimension
- Example: Simulations In Three Dimensions
- Example: Photoacoustic Waveforms in 1D, 2D and 3D
- Time Varying Source Problems
- Example: Monopole Point Source In A Homogeneous Propagation Medium
- Example: Dipole Point Source In A Homogeneous Propagation Medium
- Example: Simulating Transducer Field Patterns
- Example: Steering A Linear Array
- Example: Snell's Law And Critical Angle Reflection
- Example: The Doppler Effect
- Example: Diffraction Through A Slit
- Example: Simulations In Three-Dimensions
- Sensor Directivity
- Example: Focussed Detector in 2D
- Example: Focussed Detector in 3D
- Example: Modelling Sensor Directivity in 2D
- Example: Modelling Sensor Directivity in 3D
- Example: Sensor Element Directivity in 2D
- Example: Focussed 2D Array with Directional Elements
- Photoacoustic Image Reconstruction
- Example: 2D FFT Reconstruction For A Line Sensor
- Example: 3D FFT Reconstruction For A Planar Sensor
- Example: 2D Time Reversal For A Line Sensor
- Example: 2D Time Reversal For A Circular Sensor
- Example: 3D Time Reversal For A Planar Sensor
- Example: 3D Time Reversal For A Spherical Sensor
- Example: Image Reconstruction With Directional Sensors
- Example: Image Reconstruction With Bandlimited Sensors
- Example: Iterative Image Improvement Using Time Reversal
- Example: Attenuation Compensation Using Time Reversal
- Example: Attenuation Compensation Using Time Variant Filtering
- Example: Automatic Sound Speed Selection
- Diagnostic Ultrasound Simulation
- Example: Defining An Ultrasound Transducer
- Example: Simulating Ultrasound Beam Patterns
- Example: Using An Ultrasound Transducer As A Sensor
- Example: Simulating B-mode Ultrasound Images
- Example: Simulating B-mode Images Using A Phased Array
- Numerical Analysis
- Example: Controlling The Absorbing Boundary Layer
- Example: Source Smoothing
- Example: Filtering A Delta Function Input Signal
- Example: Modelling Power Law Absorption
- Example: Modelling Nonlinear Wave Propagation
- Example: Optimising k-Wave Performance
- Using The C++ Code
- Elastic Wave Propagation
- Example: Explosive Source In A Layered Medium
- Example: Plane Wave Absorption
- Example: Shear Waves And Critical Angle Reflection
- Example: Simulations In Three Dimensions
- Functions - By Category
- Functions - Alphabetical List
- Release Notes
- License
k-Wave Toolbox |
Using A Binary Sensor Mask Example
On this page… |
---|
Overview
This example demonstrates how to use a binary sensor mask for the detection of the pressure field generated by an initial pressure distribution within a two-dimensional homogeneous propagation medium. It builds on the Homogeneous Propagation Medium Example.
Defining a binary sensor mask
In the Homogeneous Propagation Medium Example, the sensor mask (which defines where the pressure field is recorded at each time-step) is defined as a 2 x N matrix of Cartesian points. It is also possible to define the sensor mask as binary matrix (i.e., a matrix of 1's and 0's) representing the grid points within the computational domain that will collect the data. In this case, the sensor mask must have the same dimensions as the computational grid (i.e., it must have Nx
rows and Ny
columns). Here makeCircle
is used (instead of makeCartCircle
) to define a binary sensor mask of an arc created using the midpoint circle algorithm. It is also possible to explicitly create an arbitrary binary sensor mask, or to load one from an external image map (see the Loading External Image maps Example).
% define a binary sensor mask sensor_x_pos = Nx/2; % [grid points] sensor_y_pos = Ny/2; % [grid points] sensor_radius = Nx/2 - 22; % [grid points] sensor_arc_angle = 3*pi/2; % [radians] sensor.mask = makeCircle(Nx, Ny, sensor_x_pos, sensor_y_pos, sensor_radius, sensor_arc_angle);
A plot of the initial pressure distribution and the sensor mask is given below.
Running the simulation
The computation is again started by calling kspaceFirstOrder2D
. For a Cartesian sensor mask (as in the Homogeneous Propagation Medium Example), the returned time-series are ordered the same way as the set of Cartesian sensor points. For a binary sensor mask (as in this example), the time-series are instead returned using MATLAB's standard column-wise linear matrix index ordering. As an example, if the sensor mask is defined as
0 1 0 1 0 1 1 0 1 0 1 0the ordering of the recorded time series will be
0 3 0 1 0 5 2 0 6 0 4 0For both Cartesian and binary sensor masks, the data is indexed as
sensor_data(sensor_point_index, time_index)
. A visualisation of the recorded time data is given below. The data ordering is clearly visible; the data is returned column-wise from top to bottom, and left to right.
For 2D simulations, it is possible to reorder the sensor data returned by a binary sensor mask based on the angle that each sensor point makes with the grid origin using reorderSensorData
. The angles are defined from the upper left quadrant or negative y-axis in the same way as within makeCircle
and makeCartCircle
% reorder the simulation data sensor_data_reordered = reorderSensorData(kgrid, sensor, sensor_data);
The recorded data at a particular time step can also be restored to its original position in the grid using unmaskSensorData
.
Homogeneous Propagation Medium | Defining A Sensor Mask By Opposing Corners |
© 2009-2014 Bradley Treeby and Ben Cox.