make_random_mask

make_random_mask#

pypulseqpp.make_random_mask()[source]#

Generate a uniform-random Cartesian sampling mask with a calibration region.

mask[y, z] is True when the view (y, z) is acquired. The mask holds round(n_y * n_z / accel) views: the centred calibration block, and the remainder drawn uniformly without replacement from the other views. If the calibration block alone exceeds that number, the mask is the calibration block.

Parameters:
  • shape (tuple of int) – Mask shape (n_y, n_z).

  • accel (float) – Target acceleration factor, greater than one.

  • calib (tuple of int, default=(0, 0)) – Extent of the fully sampled calibration block centred on (n_y // 2, n_z // 2).

  • seed (int or None, default=None) – Seed of the random draw.

Returns:

Boolean support mask of shape shape. It encodes no acquisition order.

Return type:

numpy.ndarray

Raises:

ValueError – If the acceleration is not greater than one.

See also

make_poisson_disc_mask

variable-density draw with a minimum distance.

make_caipirinha_mask

deterministic lattice for parallel imaging.

make_linear_order

echo-train ordering of views taken from a mask with np.argwhere and centred.

Examples

>>> import numpy as np
>>> import pypulseqpp as pp
>>> mask = pp.make_random_mask((6, 6), 3.0, calib=(2, 2), seed=0)
>>> mask.dtype, mask.shape, int(mask.sum())
(dtype('bool'), (6, 6), 12)
>>> bool(mask[2:4, 2:4].all())
True

np.argwhere lists the acquired views as (y, z) coordinates:

>>> np.argwhere(mask)[:4].tolist()
[[0, 0], [0, 1], [0, 2], [1, 1]]