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: Generate spatial coordinates for sampling.
  
  Values in ``win_sizes`` could be different --
  for example in a segmentation network ``win_sizes`` could be
  ``{'training_image_spatial_window': (32, 32, 10),
     'Manual_label_spatial_window': (16, 16, 10)}``
  (the network reduces x-y plane spatial resolution).
  
  This function handles this situation by first find the largest
  window across these window definitions, and generate the coordinates.
  These coordinates are then adjusted for each of the
  smaller window sizes (the output windows are almost concentric).
code: def _spatial_coordinates_generator(
      self, subject_id, data, img_sizes, win_sizes, n_samples=1
  ):
      """
      Generate spatial coordinates for sampling.
  
      Values in ``win_sizes`` could be different --
      for example in a segmentation network ``win_sizes`` could be
      ``{'training_image_spatial_window': (32, 32, 10),
         'Manual_label_spatial_window': (16, 16, 10)}``
      (the network reduces x-y plane spatial resolution).
  
      This function handles this situation by first find the largest
      window across these window definitions, and generate the coordinates.
      These coordinates are then adjusted for each of the
      smaller window sizes (the output windows are almost concentric).
      """
  
      assert data is not None, (
          "No input from image reader. Please check"
          "the configuration file."
      )
  
      # infer the largest spatial window size and check image spatial shapes
      img_spatial_size, win_spatial_size = _infer_spatial_size(
          img_sizes, win_sizes
      )
  
      sampling_prior_map = None
      try:
          sampling_prior_map = data.get("sampler", None)
      except AttributeError:
          pass
  
      n_samples = max(n_samples, 1)
      window_centres = self.window_centers_sampler(
          n_samples,
          img_spatial_size,
          win_spatial_size,
          sampling_prior_map,
      )
      assert window_centres.shape == (n_samples, N_SPATIAL), (
          "the coordinates generator should return "
          "{} samples of rank {} locations".format(n_samples, N_SPATIAL)
      )
  
      # adjust spatial coordinates based on each mod spatial window size
      all_coordinates = {}
      for mod in list(win_sizes):
          win_size = np.asarray(win_sizes[mod][:N_SPATIAL])
          half_win = np.floor(win_size / 2.0).astype(int)
  
          # Make starting coordinates of the window
          spatial_coords = np.zeros(
              (n_samples, N_SPATIAL * 2), dtype=np.int32
          )
          spatial_coords[:, :N_SPATIAL] = np.maximum(
              window_centres[:, :N_SPATIAL] - half_win[:N_SPATIAL], 0
          )
  
          # Make the opposite corner of the window is
          # just adding the mod specific window size
          spatial_coords[:, N_SPATIAL:] = (
              spatial_coords[:, :N_SPATIAL] + win_size[:N_SPATIAL]
          )
          assert np.all(
              spatial_coords[:, N_SPATIAL:] <= img_spatial_size
          ), "spatial coords: out of bounds."
  
          # include subject id as the 1st column of all_coordinates values
          subject_id = (
              np.ones((n_samples,), dtype=np.int32) * subject_id
          )
          spatial_coords = np.append(
              subject_id[:, None], spatial_coords, axis=1
          )
          all_coordinates[mod] = spatial_coords
  
      return all_coordinates
  
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 3 for calling the UniformSampler obj's underlying member method code with example usage: obj._spatial_coordinates_generator(subject_id, data, img_sizes, win_sizes, n_samples) and returns: all_coordinates