GaussianSplittingMaskGenerator#

class deepinv.physics.generator.GaussianSplittingMaskGenerator(tensor_size: Tuple[int], split_ratio: float, pixelwise: bool = True, std_scale: float = 4.0, center_block: Tuple[int] | int = (8, 8), device: device = device(type='cpu'), rng: Generator | None = 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 SSDU.

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 SSDU) and 2D+time dynamic mask (i.e. [C, T, H, W] from Acar et al.) 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:
  • tensor_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.

batch_step(input_mask: Tensor | None = None) dict[source]#

Create one batch of splitting mask using Gaussian distribution.

Adapted from byaman14/SSDU from SSDU.

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.

Examples using GaussianSplittingMaskGenerator:#

Self-supervised learning with measurement splitting

Self-supervised learning with measurement splitting