class_docstr: generate randomised elastic deformations
  along each dim for data augmentation
docstr: Apply randomised transformation to 2D or 3D image
  
  :param image: 2D or 3D array
  :param interp_order: order of interpolation
  :return: the transformed image
code: def _apply_bspline_transformation(self, image, interp_order=3):
      """
      Apply randomised transformation to 2D or 3D image
  
      :param image: 2D or 3D array
      :param interp_order: order of interpolation
      :return: the transformed image
      """
      resampler = sitk.ResampleImageFilter()
      if interp_order > 1:
          resampler.SetInterpolator(sitk.sitkBSpline)
      elif interp_order == 1:
          resampler.SetInterpolator(sitk.sitkLinear)
      elif interp_order == 0:
          resampler.SetInterpolator(sitk.sitkNearestNeighbor)
      else:
          return image
  
      squeezed_image = np.squeeze(image)
      while squeezed_image.ndim < self.spatial_rank:
          # pad to the required number of dimensions
          squeezed_image = squeezed_image[..., None]
      sitk_image = sitk.GetImageFromArray(squeezed_image)
  
      resampler.SetReferenceImage(sitk_image)
      resampler.SetDefaultPixelValue(0)
      resampler.SetTransform(self._bspline_transformation)
      out_img_sitk = resampler.Execute(sitk_image)
      out_img = sitk.GetArrayFromImage(out_img_sitk)
      return out_img.reshape(image.shape)
  
file_path: NiftyNet/niftynet/layer/rand_elastic_deform.py
imports: from __future__ import absolute_import, print_function
  import warnings
  import numpy
  from niftynet.layer.base_layer import RandomisedLayer
  from niftynet.utilities.util_import import require_module
label_desc: Use image node_id 4 for calling the RandomElasticDeformationLayer obj's underlying member method code with example usage: obj._apply_bspline_transformation(image, interp_order) and returns: out_img, image