class_docstr: This class generates samples by uniformly sampling each input volume
  currently the coordinates are randomised for spatial dims only,
  i.e., the first three dims of image.
  
  This layer can be considered as a "random cropping" layer of the
  input image.
docstr: This function generates sampling windows to the input buffer
  image data are from ``self.reader()``
  
  It first completes window shapes based on image data,
  then finds random coordinates based on the window shapes
  finally extract window with the coordinates and output
  a dictionary (required by input buffer).
  
  :return: output data dictionary
      ``{image_modality: data_array, image_location: n_samples * 7}``
code: def layer_op(self, idx=None):
      """
      This function generates sampling windows to the input buffer
      image data are from ``self.reader()``
  
      It first completes window shapes based on image data,
      then finds random coordinates based on the window shapes
      finally extract window with the coordinates and output
      a dictionary (required by input buffer).
  
      :return: output data dictionary
          ``{image_modality: data_array, image_location: n_samples * 7}``
      """
      image_id, data, _ = self.reader(idx=idx, shuffle=True)
      image_shapes = dict(
          (name, data[name].shape) for name in self.window.names
      )
      static_window_shapes = self.window.match_image_shapes(
          image_shapes
      )
  
      # find random coordinates based on window and image shapes
      coordinates = self._spatial_coordinates_generator(
          subject_id=image_id,
          data=data,
          img_sizes=image_shapes,
          win_sizes=static_window_shapes,
          n_samples=self.window.n_samples,
      )
  
      # initialise output dict, placeholders as dictionary keys
      # this dictionary will be used in
      # enqueue operation in the form of: `feed_dict=output_dict`
      output_dict = {}
      # fill output dict with data
      for name in list(data):
          coordinates_key = LOCATION_FORMAT.format(name)
          image_data_key = name
  
          # fill the coordinates
          location_array = coordinates[name]
          output_dict[coordinates_key] = location_array
  
          # fill output window array
          image_array = []
          for window_id in range(self.window.n_samples):
              (
                  x_start,
                  y_start,
                  z_start,
                  x_end,
                  y_end,
                  z_end,
              ) = location_array[window_id, 1:]
              try:
                  image_window = data[name][
                      x_start:x_end, y_start:y_end, z_start:z_end, ...
                  ]
                  image_array.append(image_window[np.newaxis, ...])
              except ValueError:
                  tf.logging.fatal(
                      "dimensionality miss match in input volumes, "
                      "please specify spatial_window_size with a "
                      "3D tuple and make sure each element is "
                      "smaller than the image length in each dim. "
                      "Current coords %s",
                      location_array[window_id],
                  )
                  raise
          if len(image_array) > 1:
              output_dict[image_data_key] = np.concatenate(
                  image_array, axis=0
              )
          else:
              output_dict[image_data_key] = image_array[0]
      # the output image shape should be
      # [enqueue_batch_size, x, y, z, time, modality]
      # where enqueue_batch_size = windows_per_image
      return output_dict
  
file_path: NiftyNet/niftynet/engine/sampler_uniform_v2.py
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import tensorflow
  from niftynet.engine.image_window_dataset import ImageWindowDataset
  from niftynet.engine.image_window import N_SPATIAL, LOCATION_FORMAT
label_desc: Use image node_id 2 for calling the UniformSampler obj's underlying member method code with example usage: obj.layer_op(idx) and returns: output_dict