mrpro.utils.pad_or_crop

mrpro.utils.pad_or_crop(data: Tensor, new_shape: Sequence[int] | Size, dim: None | Sequence[int] = None, value: float = 0.0) Tensor[source]

Change shape of data by center cropping or symmetric padding.

Parameters:
  • data (Tensor) – Data to pad or crop.

  • new_shape (Sequence[int] | Size) – Desired shape of data.

  • dim (None | Sequence[int], default: None) – Dimensions the new_shape corresponds to. None is interpreted as last len(new_shape) dimensions.

  • value (float, default: 0.0) – value to use for padding.

Returns:

Data zero padded or cropped to shape.