code: def rand_spatial_coordinates(
      n_samples, img_spatial_size, win_spatial_size, sampler_map
  ):
      """
      Generate spatial coordinates from a discrete uniform distribution.
  
      :param n_samples: number of random coordinates to generate
      :param img_spatial_size: input image size
      :param win_spatial_size: input window size
      :param sampler_map: sampling prior map (not in use)
      :return: (n_samples, N_SPATIAL) coordinates representing sampling
                window centres relative to img_spatial_size
      """
      tf.logging.debug("uniform sampler, prior %s ignored", sampler_map)
  
      # Sample coordinates at random
      half_win = np.floor(np.asarray(win_spatial_size) / 2.0).astype(
          np.int32
      )
      max_coords = np.zeros((n_samples, N_SPATIAL), dtype=np.int32)
      for idx, (img, win) in enumerate(
          zip(
              img_spatial_size[:N_SPATIAL], win_spatial_size[:N_SPATIAL]
          )
      ):
          max_coords[:, idx] = np.random.randint(
              0, max(img - win + 1, 1), n_samples
          )
      max_coords[:, :N_SPATIAL] = (
          max_coords[:, :N_SPATIAL] + half_win[:N_SPATIAL]
      )
      return max_coords
  
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 1 for calling a global function with example usage: rand_spatial_coordinates(n_samples, img_spatial_size, win_spatial_size, sampler_map) and returns: max_coords