k-Wave Toolbox |

# makeTransducer

Create k-Wave ultrasound transducer

## Syntax

    transducer = makeTransducer(kgrid, settings)

## Description

`makeTransducer` creates an object of the `kWaveTransducer` class which can be substituted for the source or sensor inputs when using `kspaceFirstOrder3D`. For additional information, see the Defining An Ultrasound Transducer Example.

Note: This function will not work with older versions of MATLAB in which custom class definitions are not supported.

## Inputs

`kgrid` | k-Wave grid structure returned by `makeGrid`
`settings` | input structure used to define the properties of the transducer (see below)

The following parameters can be appended as fields to the `settings` input structure. These parameters are fixed when the transducer is initialised (they cannot be changed without re-creating the transducer). All the settings are optional and are given their default values if not defined by the user.

Property | Description | Default
--- | --- | ---
`number_elements` | total number of transducer elements | `128`
`element_width` | width of each element in grid points | `1`
`element_length` | length of each element in grid points | `10`
`element_spacing` | spacing (kerf width) between the transducer elements in grid points | `0`
`position` | position of the corner of the transducer within the grid in grid points | `[1, 1, 1]`
`radius` | radius of curvature of the transducer [m] (currently only `inf` is supported) | `inf`
`input_signal` | signal used to drive the ultrasound transducer (where the sampling rate is defined by `kgrid.dt` or `kgrid.t_array`) | `[]`

The following parameters can also be appended as fields to the `settings` input structure, and can additionally be modified after the transducer has been initialised.

Property | Description | Default
--- | --- | ---
`active_elements` | transducer elements that are currently active elements | (all elements)
`elevation_focus_distance` | focus depth in the elevation direction [m] | `inf`
`transmit_apodization` | transmit apodization - can be set to any of the window shapes supported by `getWin`, or given as a vector the same length as `number_elements` | `'Rectangular'`
`receive_apodization` | receive apodization - can be set to any of the window shapes supported by `getWin`, or given as a vector the same length as `number_elements` | `'Rectangular'`
`sound_speed` | sound speed used to calculate beamforming delays [m/s] | `1540`
`focus_distance` | focus distance used to calculate beamforming delays [m] | `inf`
`steering_angle` | steering angle used to calculate beamforming delays [deg] | `0`
`beamforming_delay_offset` | beamforming delay offset (used to force beamforming delays to be positive) | `'auto'`

## Outputs

`transducer` | k-Wave transducer object which can be used to replace the `source` or `sensor` inputs of `kspaceFirstOrder3D`

In addition to the input parameters given above (which are also accessible after the transducer has been created), the `kWaveTransducer` object has a number dependent properties and methods.

Property | Description
--- | ---
`mask` | binary mask of the active transducer elements
`transducer_width` | total width of the transducer in grid points
`number_active_elements` | current number of active transducer elements
`input_signal` | user defined input signal appended and prepended with additional zeros depending on the values of `focus_distance`, `elevation_focus_distance`, and `steering_angle`
Method | Description
`all_elements_mask` | return a binary mask of all the transducer elements (both active and inactive)
`active_elements_mask` | return a binary mask of the active transducer elements (identical to `mask`)
`indexed_elements_mask` | return a mask of all the transducer elements (both active and inactive), where the mask values indicate which transducer element each grid point corresponds to
`indexed_active_elements_mask` | return a mask of the active transducer elements, where the mask values indicate which transducer element each grid point corresponds to
`beamforming_delays` | return a vector of the beam forming delays (in units of time samples) for each active element based on the focus and steering angle settings
`elevation_beamforming_delays` | return a vector of the elevation beam forming delays (in units of time samples) for each active element based on the elevation focus setting
`delay_mask` | return a mask of the active transducer elements, where the mask values contain the beamforming delays (an integer input can also be given to control the beamforming delays used, where 1: both delays, 2: elevation only, 3: azimuth only)
`transmit_apodization_mask` | return a mask of the active transducer elements, where the mask values contain the apodization weights
`plot` | plot the transducer using `voxelPlot`
`expandGrid` | increase the size of the computational grid to accomodate an external PML
`retractGrid` | reduce the size of the computational grid after simulation
`gridSize` | return the size of the computational grid
`get_transmit_apodization` | return the transmit apodization
`get_receive_apodization` | return the receive apodization
`properties` | print a list of the transducer properties to the command line

For example, running the following commands at the command line

    kgrid = makeGrid(128, 1e-3, 128, 1e-3, 128, 1e-3);
    kgrid.t_array = makeTime(kgrid, 1500);
    settings.number_elements = 72;
    settings.active_elements = zeros(72, 1);
    settings.active_elements(1:16) = 1;
    transducer = makeTransducer(kgrid, settings);
    transducer.properties

will produce the following output:

    k-Wave Transducer Properties
      transducer position: [1  1  1]
      transducer width: 72mm (72 grid points)
      number of elements: 72
      number of active elements: 16 (elements 1 to 16)
      element width: 1mm (1 grid points)
      element spacing (kerf): 0ym (0 grid points)
      element pitch: 1mm (1 grid points)
      element length: 20mm (20 grid points)
      sound speed: 1540m/s
      focus distance: infinite
      elevation focus distance: infinite
      steering angle: 0 degrees

## Examples

- Defining An Ultrasound Transducer
- Simulating Ultrasound Beam Patterns
- Using An Ultrasound Transducer As A Sensor
- Simulating B-mode Ultrasound Images

## See Also

`makeGrid`, `kspaceFirstOrder3D`

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