GaussianSplittingMaskGenerator#

class deepinv.physics.generator.GaussianSplittingMaskGenerator(img_size, split_ratio, pixelwise=True, std_scale=4.0, center_block=(8, 8), device=torch.device('cpu'), rng=None, *args, **kwargs)[source]#

Bases: BernoulliSplittingMaskGenerator

Randomly generate Gaussian splitting/inpainting masks.

Generates binary masks with an approximate given split ratio, where samples are weighted according to a spatial Gaussian distribution, where pixels near the center are less likely to be kept. This mask is used for measurement splitting for MRI in Yaman et al.[1].

Can be used either for generating random inpainting masks for deepinv.physics.Inpainting, or random splitting masks for deepinv.loss.SplittingLoss.

Optional pass in input_mask to subsample this mask given the split ratio.

Handles both 2D mask (i.e. [C, H, W] from Yaman et al.[1] and 2D+time dynamic mask (i.e. [C, T, H, W] from Acar et al.[2] generation. Does not handle 1D data (e.g. of shape [C, M])


Examples:

Randomly split input mask using Gaussian weighting

>>> from deepinv.physics.generator import GaussianSplittingMaskGenerator
>>> from deepinv.physics import Inpainting
>>> physics = Inpainting((1, 3, 3), 0.9)
>>> gen = GaussianSplittingMaskGenerator((1, 3, 3), split_ratio=0.6, center_block=0)
>>> gen.step(batch_size=2, input_mask=physics.mask)["mask"].shape
torch.Size([2, 1, 3, 3])
Parameters:
  • img_size (tuple[int]) – size of the tensor to be masked without batch dimension e.g. of shape (C, H, W) or (C, T, H, W)

  • split_ratio (float) – ratio of values to be kept (i.e. ones).

  • pixelwise (bool) – Apply the mask in a pixelwise fashion, i.e., zero all channels in a given pixel simultaneously.

  • std_scale (float) – scale parameter of 2D Gaussian, in pixels.

  • center_block (int, tuple[int]) – size of block in image center that is always kept for MRI autocalibration signal. Either int for square block or 2-tuple (h, w)

  • device (str, torch.device) – device where the tensor is stored (default: ‘cpu’).

  • rng (torch.Generator) – random number generator.

  • dtype (torch.dtype) – the data type of the generated parameters


References:

batch_step(input_mask=None)[source]#

Create one batch of splitting mask using Gaussian distribution.

Adapted from byaman14/SSDU from SSDU Yaman et al.[1].

Parameters:

input_mask (torch.Tensor, None) – optional mask to be split. If None, all pixels are considered. If not None, only pixels where mask==1 are considered. No batch dim in shape.


References:

get_pdf(shape)[source]#

Generate a Gaussian distribution.

Parameters:

shape (tuple) – (nx, ny) dimensions.

Returns:

Gaussian Tensor of shape (nx, ny)

Examples using GaussianSplittingMaskGenerator:#

Self-supervised learning with measurement splitting

Self-supervised learning with measurement splitting