BaseMaskGenerator#

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

Bases: PhysicsGenerator

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.

sample_mask(mask: Tensor) Tensor[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)

step(batch_size=1, seed: int | None = None, **kwargs) dict[source]#

Create a mask of vertical lines.

Parameters:
  • batch_size (int) – batch_size.

  • seed (int) – the seed for the random number generator.

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

Self-supervised MRI reconstruction with Artifact2Artifact

Self-supervised MRI reconstruction with Artifact2Artifact