k-Wave Toolbox |

## Modelling Sensor Directivity in 3D Example

On this page…
Overview Defining a large element detector Defining a collection of point sources Running simulations for each point source Plotting

### Overview

This example demonstrates how the sensitivity of a large single element detector varies with the angular position of a point-like source. It is a 3D version of the Modelling Sensor Directivity in 2D example.

- open the file in the MATLAB Editor
- run the file in MATLAB

Back to Top

### Defining a large element detector

A large area detector is defined as a rectangle and stored in `sensor.mask`.

    % define a large area detector
    sensor.mask = zeros(Nx, Ny, Nz);
    sensor.mask(Nx/2+1, (Ny/2-9):(Ny/2+11),(Nz/2-9):(Nz/2+11)) = 1;

Back to Top

### Defining a collection of point sources

Equi-spaced point sources are defined at a fixed distance from the centre of the detector face. To do this, the Cartesian coordinates of the points are calculated using `makeCartCircle` and then a binary source mask corresponding to these Cartesian points is calculated using `cart2grid`. The indices of the matrix elements for which the binary mask is equal to 1 (the source points) are found using `find`.

    % define equally spaced point sources lying on a circle centred at the
    % centre of the detector face
    Nangles = 11;
    circle = makeCartCircle(25*dx, Nangles, [0,0], pi);
    circle = [circle; zeros(1,Nangles)];

    % find the binary sensor mask most closely corresponding to the cartesian
    % points coordinates from makeCartCircle
    circle3D = cart2grid(kgrid,circle);

    % find the indices of the sources in the binary source mask
    source_positions = find(circle3D == 1);

A time varying pressure source is defined to drive the point sources.

    % define a time varying sinusoidal source
    source_freq = 0.25e6;
    source_mag = 1;
    source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);

    % smooth the source
    source.p = filterTimeSeries(kgrid, medium, source.p);

Back to Top

### Running simulations for each point source

For each point source, a binary source mask is set to one at the point corresponding to that source, and the simulation is run. When each simulation has finished, the calculated time series (one for each grid poing of the detector) are summed together to mimic the fact that in this example the grid points together define one single large measuring element. (This is in contrast to when each grid point is treated as a element of an array, see Steering A Linear Array Example.)

    for source_loop = 1:length(source_positions)

        % select a point source
        source.p_mask = zeros(Nx,Ny,Nz);
        source.p_mask(source_positions(source_loop)) = 1;

        % create a display mask to display the transducer
        display_mask = source.p_mask + sensor.mask;

        % run the simulation
        input_args = {'PMLSize', 10, 'DisplayMask', display_mask, 'PlotScale', [-0.2 0.2], 'PlotFreq', 50,  'DataCast', 'single'};
        sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});

        % average the data recorded for each pixel to simulate the measured signal
        % from a large aperture, single element, detector
        single_element_data(:,source_loop) = sum(sum(sensor_data,1),1);

    end

Back to Top

### Plotting

Finally, the maxima of the time series, one per point source, are plotted as a function of the angle between the detector plane and a line joining the point source and the centre of the detector face. 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-2012 Bradley Treeby and Ben Cox.