BaseMaskGenerator#

class deepinv.physics.generator.BaseMaskGenerator(img_size, acceleration=4, center_fraction=None, rng=None, device='cpu', *args, **kwargs)[source]#

Bases: PhysicsGenerator, ABC

Base generator for MRI acceleration masks.

Generate a mask of vertical lines for MRI acceleration with fixed sampling in low frequencies (center of k-space) and undersampling in the high frequencies.

The type of undersampling is determined by the child class. The mask is repeated across channels and randomly varies across batch dimension.

Parameters:
  • img_size (Tuple) – image size, either (H, W) or (C, H, W) or (C, T, H, W), where optional C is channels, and optional T is number of time-steps

  • acceleration (int) – acceleration factor, defaults to 4

  • center_fraction (float) – fraction of lines to sample in low frequencies (center of k-space). If 0, there is no fixed low-freq sampling. Defaults to None.

  • rng (torch.Generator) – torch random generator. Defaults to None.

abstract sample_mask(mask)[source]#

Given empty mask, sample lines according to child class sampling strategy.

This must be implemented in child classes. Time dimension is specified but can be ignored if needed.

Parameters:

mask (torch.Tensor) – empty mask of shape (B, C, T, H, W)

Return torch.Tensor:

sampled mask of shape (B, C, T, H, W)

Return type:

Tensor

step(batch_size=1, seed=None, img_size=None, **kwargs)[source]#

Create a mask of vertical lines.

Parameters:
  • batch_size (int) – batch_size.

  • seed (int) – optional: the seed for the random number generator, to reseed on-the-fly.

  • img_size (tuple) – optionally reset the 2D image size on-the-fly, must be of form (H, W).

Returns:

dictionary with key ‘mask’: tensor of size (batch_size, C, H, W) or (batch_size, C, T, H, W) with values in {0, 1}.

Return type:

dict

Examples using BaseMaskGenerator:#

A tour of forward sensing operators

A tour of forward sensing operators

Tour of MRI functionality in DeepInverse

Tour of MRI functionality in DeepInverse

Self-supervised MRI reconstruction with Artifact2Artifact

Self-supervised MRI reconstruction with Artifact2Artifact