k-Wave Toolbox |

## Sensor Element Directivity Example

On this page…
Overview Defining directional detectors Running the simulation

### Overview

This example shows how to attribute a directional response to a single-element sensor, or individual elements of a multi-element sensor array. It builds on the Simulating Transducer Field Patterns and Sensor Element Directivity examples.

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

Back to Top

### Defining directional detectors

When using a binary sensor mask, the directionality of each sensor element (defined by the 1's within `sensor.mask`) can be set by assigning a directivity angle to the corresponding elements within an Nz by Nx matrix assigned to `sensor.directivity_angle`. This angle defines the direction of greatest sensitivity for each element. For waves incident from other angles, the sensitivity will be reduced. In this example, a line of spaced single element sensors is assigned to a binary sensor mask with each given a different directionality. A directivity angle of 0 (or pi) results in the element being most sensitive to waves travelling in the z (up/down) direction. A directivity of pi/2 (or -pi/2) results in the element being most sensitive to waves travelling in the x (left/right) direction. The magnitude of the directionality can be adjusted by defining the `sensor.directivity_size` (this value is assigned to all elements). For a plane wave incindent on a parallel linear detector, this value is equivalent to the size of sensor that each element averages across. If this field is not set, it defaults to `10*kgrid.dx` (i.e., 10 times the width of a single pixel).

    % define a line of single-element sensors
    sensor.mask = zeros(Nz,Nx);
    sensor.mask(24,2:2:63) = 1;

    % define the angle of max directivity for each single-element sensor
    % 0 = max sensitivity in z direction (up/down)
    % pi/2 or -pi/2 = max sensitivity in x direction (left/right)
    sensor.directivity_angle = zeros(Nz,Nx);
    sensor.directivity_angle(24,2:2:63) = (-1:1/15:1)*pi/2;

    % define the directivity size
    sensor.directivity_size = 16*kgrid.dx;

A visualisation of the sensor mask and the directivity of each element is shown below. Note that including many different directivity angles in a single simulation can increase the computation time. However, line arrays in which all the elements have the same directionality will run almost as fast as the default omni-directional case.

Back to Top

### Running the simulation

The computation is invoked by running `kspaceFirstOrder2D` with the inputs defined above. To ensure the plane wave source (defined as a single line within `source.p_mask`) is not perturbed by the perfectly matched layer, the layer perpendicular to the propagation direction is turned off by setting the optional input `'PMLAlpha'` to `[0 4]` (see Controlling The Absorbing Boundary Layer).

    % run the simulation
    sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, 'PMLAlpha', [0 4]);

The maxima of the time series recorded by each sensor element are plotted below on Cartesian and polar plots where the characteristic side lobes associated with spatial averaging detectors can be seen.

Back to Top

© 2009, 2010 Bradley Treeby and Ben Cox.