code: def recover_img(
      image,
      affine,
      ori_shape,
      image_shape,
      init_shape=(256, 256, 256),
      voxsize=None,
      scale=2,
  ):
      r"""
      Function to recover image back to its original shape
  
      Parameters
      ----------
      image : np.ndarray
          Image to recover
      affine : np.ndarray
          Affine matrix provided from transform_img
      ori_shape : np.ndarray (3,)
          Original shape of isotropic image
      image_shape : tuple (3,)
          Original shape of actual image
      init_shape : tuple (3,), optional
          Initial shape to transform the image to
          Default is (256, 256, 256)
      voxsize : np.ndarray (3,), optional
          Voxel size of the original image
      scale : float, optional
          Scale that was used in transform_img
          Default is 2
  
      Returns
      -------
      recovered_img : np.ndarray
      """
      new_image, _ = reslice(
          image, np.eye(4), (scale, scale, scale), (1, 1, 1)
      )
      recovered_img = affine_transform(
          new_image, affine, output_shape=ori_shape
      )
      affine[:3, 3] += np.array(
          [init_shape[0] // 2, init_shape[1] // 2, init_shape[2] // 2]
      )
      if voxsize is not None and np.any(voxsize != np.ones(3)):
          kwargs = {
              "order": 1,
              "mode": "constant",
              "matrix": voxsize,
              "output_shape": image_shape,
          }
          recovered_img = np.round(
              affine_transform(recovered_img, **kwargs)
          )
      return recovered_img
  
file_path: dipy/dipy/nn/utils.py
imports: import numpy
  from scipy.ndimage import affine_transform, label
  from dipy.align.reslice import reslice
label_desc: Use image node_id 5 for calling a global function with example usage: recover_img(image, affine, ori_shape, image_shape, init_shape, voxsize, scale) and returns: recovered_img