class_docstr: generate randomised bias field transformation for data augmentation
class_docstr_tok: ["generate","randomised","bias","field","transformation","for","data","augmentation"]
docstr: Create the bias field map using a linear combination polynomial
  functions and the coefficients previously sampled
  :param shape: shape of the image in order to create the polynomial
      functions
  :return: bias field map to apply
docstr_tok: ["Create","the","bias","field","map","using","a","linear","combination","polynomial","functions","and","the","coefficients","previously","sampled",":","param","shape",":","shape","of","the","image","in","order","to","create","the","polynomial","functions",":","return",":","bias","field","map","to","apply"]
code: def _generate_bias_field_map(self, shape):
      """
      Create the bias field map using a linear combination polynomial
      functions and the coefficients previously sampled
      :param shape: shape of the image in order to create the polynomial
          functions
      :return: bias field map to apply
      """
      spatial_rank = len(shape)
      x_range = np.arange(-shape[0] / 2, shape[0] / 2)
      y_range = np.arange(-shape[1] / 2, shape[1] / 2)
      bf_map = np.zeros(shape)
      i = 0
      if spatial_rank == 3:
          z_range = np.arange(-shape[2] / 2, shape[2] / 2)
          x_mesh, y_mesh, z_mesh = np.asarray(
              np.meshgrid(x_range, y_range, z_range), dtype=float
          )
          x_mesh /= float(np.max(x_mesh))
          y_mesh /= float(np.max(y_mesh))
          z_mesh /= float(np.max(z_mesh))
          for order_x in range(self.order + 1):
              for order_y in range(self.order + 1 - order_x):
                  for order_z in range(
                      self.order + 1 - (order_x + order_y)
                  ):
                      rand_coeff = self._bf_coeffs[i]
                      new_map = (
                          rand_coeff
                          * np.power(x_mesh, order_x)
                          * np.power(y_mesh, order_y)
                          * np.power(z_mesh, order_z)
                      )
                      bf_map += np.transpose(new_map, (1, 0, 2))
                      i += 1
      if spatial_rank == 2:
          x_mesh, y_mesh = np.asarray(
              np.meshgrid(x_range, y_range), dtype=float
          )
          x_mesh /= np.max(x_mesh)
          y_mesh /= np.max(y_mesh)
          for order_x in range(self.order + 1):
              for order_y in range(self.order + 1 - order_x):
                  rand_coeff = self._bf_coeffs[i]
                  new_map = (
                      rand_coeff
                      * np.power(x_mesh, order_x)
                      * np.power(y_mesh, order_y)
                  )
                  bf_map += np.transpose(new_map, (1, 0))
                  i += 1
      return np.exp(bf_map)
  
file_path: NiftyNet/niftynet/layer/rand_bias_field.py
imports: from __future__ import absolute_import, print_function
  import numpy
  from niftynet.layer.base_layer import RandomisedLayer
label_desc: Use image node_id 6 for calling the RandomBiasFieldLayer obj's underlying member method code with example usage: obj._generate_bias_field_map(shape) and returns: np