code: def resample(
      img, hdr, target_spacing, bspline_order=3, mode="constant"
  ):
      """
      Re-sample an image to a new voxel-spacing.
  
      Parameters
      ----------
      img : array_like
          The image.
      hdr : object
          The image header.
      target_spacing : number or sequence of numbers
          The target voxel spacing to achieve. If a single number, isotropic spacing is assumed.
      bspline_order : int
          The bspline order used for interpolation.
      mode : str
          Points outside the boundaries of the input are filled according to the given mode ('constant', 'nearest', 'reflect' or 'wrap'). Default is 'constant'.
  
      Warning
      -------
      Voxel-spacing of input header will be modified in-place!
  
      Returns
      -------
      img : ndarray
          The re-sampled image.
      hdr : object
          The image header with the new voxel spacing.
      """
      if isinstance(target_spacing, numbers.Number):
          target_spacing = [target_spacing] * img.ndim
  
      # compute zoom values
      zoom_factors = [
          old / float(new)
          for new, old in zip(
              target_spacing, header.get_pixel_spacing(hdr)
          )
      ]
  
      # zoom image
      img = zoom(img, zoom_factors, order=bspline_order, mode=mode)
  
      # set new voxel spacing
      header.set_pixel_spacing(hdr, target_spacing)
  
      return img, hdr
  
file_path: medpy/medpy/filter/image.py
imports: import itertools
  import numbers
  import math
  import numpy
  from scipy.ndimage import convolve, gaussian_filter, minimum_filter
  from scipy.ndimage._ni_support import _get_output
  from scipy.ndimage import zoom
  from .utilities import pad, __make_footprint
  from ..io import header
label_desc: Use image node_id 7 for calling a global function with example usage: resample(img, hdr, target_spacing, bspline_order, mode) and returns: img,  hdr