class_docstr: Unit test for GPUImageResampling defined in python_wrapper.cpp
class_docstr_tok: ["Unit","test","for","GPUImageResampling","defined","in","python_wrapper.cpp"]
code: def _make_constant_displacement_image(self, u, axis, image_data):
      nof_dims = len(image_data.shape)
      displacement_shape = (
          list(image_data.shape) + [1] * (3 - nof_dims) + [nof_dims]
      )
  
      displacement_data = np.zeros(displacement_shape)
      displacement_data[..., axis] = u
      for dd in range(nof_dims):
          idcs = np.arange(displacement_data.shape[dd])
          idcs = idcs.reshape(
              [1] * dd
              + [displacement_shape[dd]]
              + [1] * (nof_dims - dd - 1)
          )
  
          tile_dim = (
              list(displacement_shape[:dd])
              + [1]
              + list(displacement_shape[dd + 1 : nof_dims])
          )
  
          idcs = np.tile(idcs, tile_dim)
          if len(idcs.shape) < 3:
              idcs = idcs.reshape(list(idcs.shape) + [1])
  
          displacement_data[..., dd] += idcs
  
      return displacement_data
  
file_path: NiftyNet/niftynet/contrib/niftyreg_image_resampling/tests/test_resampler.py
imports: from glob import glob
  import math
  import os.path
  import nibabel
  import numpy
  import copy
  import tensorflow
  import tensorflow.test
  from niftynet.contrib.niftyreg_image_resampling.niftyreg_module_loader import get_niftyreg_module
label_desc: Use image node_id 4 for calling the ResamplerTest obj's underlying member method code with example usage: obj._make_constant_displacement_image(u, axis, image_data) and returns: displacement_data