RandomMaskGenerator
- class deepinv.physics.generator.RandomMaskGenerator(img_size: Tuple, acceleration: int = 4, center_fraction: float | None = None, rng: Generator | None = None, device='cpu', *args, **kwargs)[source]
Bases:
BaseMaskGenerator
Generator for MRI Cartesian acceleration masks using random uniform undersampling.
Generate a mask of vertical lines for MRI acceleration with fixed sampling in low frequencies (center of k-space) and random uniform undersampling in the high frequencies.
Supports k-t sampling, where the mask is selected randomly across time.
The mask is repeated across channels and randomly varies across batch dimension.
For parameter descriptions see
deepinv.physics.generator.mri.BaseMaskGenerator
- Examples:
Random k-t mask generator for a 8x64x64 video:
>>> from deepinv.physics.generator import RandomMaskGenerator >>> generator = RandomMaskGenerator((2, 8, 64, 64), acceleration=8, center_fraction=0.04) # C, T, H, W >>> params = generator.step(batch_size=1) >>> mask = params["mask"] >>> mask.shape torch.Size([1, 2, 8, 64, 64])
- get_pdf() Tensor [source]
Create one-dimensional uniform probability density function across columns, ignoring any fixed sampling columns.
- Return torch.Tensor:
unnormalised 1D vector representing pdf evaluated across mask columns.
- 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)
Examples using RandomMaskGenerator
:
A tour of forward sensing operators
Self-supervised MRI reconstruction with Artifact2Artifact