Artifact2ArtifactSplittingMaskGenerator#

class deepinv.physics.generator.Artifact2ArtifactSplittingMaskGenerator(tensor_size: Tuple[int], split_size: int | Tuple[int] = 2, device: device = 'cpu', rng: Generator | None = None)[source]#

Bases: Phase2PhaseSplittingMaskGenerator

Artifact2Artifact splitting mask generator for dynamic data.

To be exclusively used with deepinv.loss.Artifact2ArtifactLoss. Randomly selects a chunk from dynamic data (i.e. data of shape (B, C, T, H, W)) in the T dimension and puts zeros in the rest of the mask.

When step called with persist_prev, the selected chunk will be different from the previous time it was called. This is used so input chunk is compared to a different output chunk.

Artifact2Artifact was introduced in RARE: Image Reconstruction using Deep Priors Learned without Ground Truth for free-breathing MRI.

If input_mask not passed, a blank input mask is used instead.

Parameters:
  • tensor_size (tuple[int]) – size of the tensor to be masked without batch dimension of shape (C, T, H, W)

  • split_size (int, tuple[int]) – time-length of chunk. Must divide tensor_size[1] exactly. If tuple, one is randomly selected each time.

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

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

batch_step(input_mask: Tensor | None = None, persist_prev: bool = False) dict[source]#

Create one batch of splitting mask.

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. Batch dimension should not be included in shape.