k-Wave Toolbox Previous   Next

Focussed 2D Array with Directional Elements Example

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 voxels. (The next release of k-Wave will contain functions that enable arrays consisting of elements made up from groups of pixels - such as this one - to be constructed easily.)

 Back to Top

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; % [pixels]
arc = makeCircle(Nx, Nz, Nx/2, Nz/2, semicircle_radius, pi);

The voxels making up this curved array are divided up between a number of elements. This is achieved by calculating the angles from each voxel to the focus of the array and grouping the voxels with similar angles.

% find total number and indices of the voxels constituting the semicircle
arc_indices = find(arc == 1);
Nv = length(arc_indices);

% calculate angles between voxels in the arc and the centre of the grid
arc_angles = atan((kgrid.x(arc_indices))./kgrid.z(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(Nz,Nx);
for loop = 1:Ne
    
    % the indices of the voxels belonging to one element.
    % (There is a two voxel gap between the elements.)
    voxel_indices = sorted_arc_indices(floor((loop-1)*Nv/Ne)+2:floor(loop*Nv/Ne)-1);
    
    % add the element to the sensor.mask
    sensor.mask(voxel_indices) = 1;
    
end

 Back to Top

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 streches across the domain.

source.p_mask = zeros(Nz,Nx);
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', [0 4], 'DisplayMask', display_mask, 'PlotScale', [-0.75 0.75]};

 Back to Top

Running the simulation

The simulation is run and the time series are measured for every non-zero pixel 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 voxels, between the elements
element_data = zeros(Ne,Nt);
for loop = 1:Ne
    
    % the indices of the sensor voxels in the sensor mask
    sensor_indices = find(sensor.mask==1);
    
    % the indices of the voxels belonging to one element.
    voxel_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(voxel_indices),1);
    for loop2 = 1:length(voxel_indices)
        data_indices(loop2) = find(sensor_indices == voxel_indices(loop2));
    end    

    % for one element per loop, average the time series from each of the
    % element's voxels 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.

 Back to Top


© 2009, 2010, 2011 Bradley Treeby and Ben Cox.