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 – data

  • new_shape – desired shape of data

  • dim – dimensions the new_shape corresponds to. None (default) is interpreted as last len(new_shape) dimensions.

Return type:

data zero padded or cropped to shape