zea.beamform.pixelgrid

Pixel grid calculation for ultrasound beamforming.

Functions

cartesian_pixel_grid(xlims, zlims[, ylims, ...])

Generate a Cartesian pixel grid.

check_for_aliasing(scan)

Checks if the scan class parameters will cause spatial aliasing due to a too low pixel density.

polar_pixel_grid(polar_limits, zlims, ...[, ...])

Generate a polar grid.

radial_pixel_grid(rlims, dr, oris, dirs)

Generate a focused pixel grid based on input parameters.

zea.beamform.pixelgrid.cartesian_pixel_grid(xlims, zlims, ylims=(0.0, 0.0), grid_size_x=None, grid_size_y=None, grid_size_z=None, dx=None, dy=None, dz=None)[source]

Generate a Cartesian pixel grid.

Behaviour:
  • If ylims has zero extent (abs(ymax - ymin) < eps) the function returns a 2D grid with shape (nz, nx, 3) that contains (x, y=0, z) per-pixel (y omitted as a dimension).

  • If ylims has non-zero extent the function returns a 3D grid with shape (nz, nx, ny, 3) containing (x, y, z) per-voxel.

Parameters:
  • xlims (tuple) – [xmin, xmax]

  • ylims (tuple) – [ymin, ymax] — if ymax == ymin (within tol) treated as “no y extent”

  • zlims (tuple) – [zmin, zmax]

  • grid_size_x (int) – number of samples along each axis. For 2D (no y extent) only grid_size_x and grid_size_z are required if using sizes.

  • grid_size_y (int) – number of samples along each axis. For 2D (no y extent) only grid_size_x and grid_size_z are required if using sizes.

  • grid_size_z (int) – number of samples along each axis. For 2D (no y extent) only grid_size_x and grid_size_z are required if using sizes.

  • dx (float) – spacings along axes. For 2D, only dx and dz are required if using spacings.

  • dy (float) – spacings along axes. For 2D, only dx and dz are required if using spacings.

  • dz (float) – spacings along axes. For 2D, only dx and dz are required if using spacings.

Returns:

  • 2D: shape (nz, nx, 3) with per-pixel [x, y, z] (y will be zeros)

  • 3D: shape (nz, nx, ny, 3) with per-voxel [x, y, z]

Return type:

np.ndarray

zea.beamform.pixelgrid.check_for_aliasing(scan)[source]

Checks if the scan class parameters will cause spatial aliasing due to a too low pixel density. If so, a warning is printed with a suggestion to increase the pixel density by either increasing the number of pixels, or decreasing the pixel spacing, depending on which parameter was set by the user.

zea.beamform.pixelgrid.polar_pixel_grid(polar_limits, zlims, num_radial_pixels, num_polar_pixels, distance_to_apex=0.0)[source]

Generate a polar grid.

Uses radial_pixel_grid but based on parameters that are present in the scan class. Currently only 2D grids (no elevation steering) are supported.

Parameters:
  • polar_limits (tuple) – Polar limits of pixel grid ([polar_min, polar_max])

  • zlims (tuple) – Depth limits of pixel grid ([zmin, zmax])

  • num_radial_pixels (int) – Number of depth pixels.

  • num_polar_pixels (int) – Number of polar pixels.

  • distance_to_apex (float) – Distance from transducer to apex of pixel grid.

Returns:

Pixel grid of size (num_radial_pixels, num_polar_pixels, 3) in Cartesian coordinates (x, y, z)

Return type:

grid (np.ndarray)

zea.beamform.pixelgrid.radial_pixel_grid(rlims, dr, oris, dirs)[source]

Generate a focused pixel grid based on input parameters.

To accommodate the multitude of ways of defining a focused transmit grid, we define pixel “rays” or “lines” according to their origins (oris) and directions (dirs). The position along the ray is defined by its limits (rlims) and spacing (dr).

Parameters:
  • rlims (tuple) – Radial limits of pixel grid ([rmin, rmax]) with respect to each ray origin

  • dr (float) – Pixel spacing in radius

  • oris (np.ndarray) – Origin of each ray in Cartesian coordinates (x, y, z) with shape (nrays, 3)

  • dirs (np.ndarray) – Steering direction of each ray in azimuth, in units of radians (nrays, 2)

Returns:

Pixel grid of size (nr, nrays, 3) in

Cartesian coordinates (x, y, z), with nr being the number of radial pixels.

Return type:

grid (np.ndarray)