mrpro.utils.zero_pad_or_crop

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

Change shape of data by center cropping or symmetric zero-padding.

Parameters:
  • data (Tensor) – data

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

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

Returns:

data zero padded or cropped to shape