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 |
Focussed 2D Array with Directional Elements Example
On this page… |
---|
Define a focussed array of directional elements |
Overview
This example demonstrates the use of k-Wave to compute the outputs from a curved detector array which consists of several elements, each of which consists of a number of grid points.
Define a focussed array of directional elements
To start with, a curved detector array is defined using the makeCircle
function.
% define a semicircular sensor centered on the grid semicircle_radius = 65; % [grid points] arc = makeCircle(Nx, Ny, Nx/2, Ny/2, semicircle_radius, pi);
The grid points making up this curved array are divided up between a number of elements. This is achieved by calculating the angles from each grid point to the focus of the array and grouping the grid points with similar angles.
% find total number and indices of the grid points constituting the % semicircle arc_indices = find(arc == 1); Nv = length(arc_indices); % calculate angles between grid points in the arc and the centre of the grid arc_angles = atan((kgrid.y(arc_indices))./kgrid.x(arc_indices)); % sort the angles into ascending order, and adjust the indices accordingly [sorted_arc_angles,sorted_index] = sort(arc_angles); sorted_arc_indices = arc_indices(sorted_index); % divide the semicircle into Ne separate sensor elements Ne = 13; sensor.mask = zeros(Nx,Ny); for loop = 1:Ne % the indices of the grid points belonging to one element. % (There is a two grid point gap between the elements.) grid point_indices = sorted_arc_indices(floor((loop-1)*Nv/Ne)+2:floor(loop*Nv/Ne)-1); % add the element to the sensor.mask sensor.mask(grid point_indices) = 1; end
Using an infinitely wide line source
To model a plane wave source parallel to one of the grid dimensions, two
steps are necessary. First, source.p_mask
is set so that it
stretches across the domain.
source.p_mask = zeros(Nx,Ny); source.p_mask(140,:) = 1;
Secondly, the inputs to the simulation are set so that the perfectly matched
layer is turned off on the two sides that source.p_mask
meets.
input_args = {'PMLAlpha', [2 0], 'DisplayMask', display_mask, 'PlotScale', [-0.75 0.75]};
Running the simulation
The simulation is run and the time series are measured for every non-zero
grid point in sensor.mask
. These time series are then allocated to
their relevant elements, and averaged together.
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:}); % split up the data, recorded on all the grid points, between the elements element_data = zeros(Ne,Nt); for loop = 1:Ne % the indices of the sensor grid points in the sensor mask sensor_indices = find(sensor.mask==1); % the indices of the grid points belonging to one element. grid point_indices = sorted_arc_indices(floor((loop-1)*Nv/Ne)+2:floor(loop*Nv/Ne)-1); % indices of sensor_data that refer to the data for this element data_indices = zeros(length(grid point_indices),1); for loop2 = 1:length(grid point_indices) data_indices(loop2) = find(sensor_indices == grid point_indices(loop2)); end % for one element per loop, average the time series from each of the % element's grid points to give one time series for the whole element element_data(loop,:) = mean(sensor_data(data_indices,:),1); end
The time series corresponding to the different elements are plotted. The directionality introduced by the large size of the detector (because it averages the incoming wave over its area) is clearly seen.
Sensor Element Directivity in 2D | Photoacoustic Image Reconstruction |
© 2009-2014 Bradley Treeby and Ben Cox.