class_docstr: This class generators 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.
class_docstr_tok: ["This","class","generators","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 a function, the function will be used
  to replace the random coordinate generated in UniformSampler
  
  This wrapper is created in order to use self.properties
  directly in the generator.
  
  :return: a spatial coordinates generator function
docstr_tok: ["this","function","generates","a","function",",","the","function","will","be","used","to","replace","the","random","coordinate","generated","in","UniformSampler","This","wrapper","is","created","in","order","to","use","self.properties","directly","in","the","generator",".",":","return",":","a","spatial","coordinates","generator","function"]
code: def selective_spatial_coordinates(self):
      """
      this function generates a function, the function will be used
      to replace the random coordinate generated in UniformSampler
  
      This wrapper is created in order to use self.properties
      directly in the generator.
  
      :return: a spatial coordinates generator function
      """
      print("self rand samples is ", self.n_samples_rand)
  
      def spatial_coordinates_function(
          subject_id,
          data,
          img_sizes,
          win_sizes,
          n_samples=1,
          n_samples_rand=0,
      ):
          """
          this function first find a set of feasible locations,
          based on discrete labels and randomly choose n_samples
          from the feasible locations.
  
          :param subject_id:
          :param data:
          :param img_sizes:
          :param win_sizes:
          :param n_samples: total number of samples
          :param n_samples_rand: number of totally random samples apart
          from selected ones
          :return:
          """
          candidates, proba_cand = candidate_indices(
              win_sizes["label"], data["label"], self.constraint
          )
          print("feasible locations found")
          if np.sum(candidates) < self.window.n_samples:
              print("Constraints not fulfilled for this case")
              # return something here...
  
          # find random coordinates based on window, potential
          # candidates and image shapes
  
          coordinates = rand_choice_coordinates(
              subject_id,
              img_sizes,
              win_sizes,
              candidates,
              proba_cand,
              n_samples,
              n_samples_rand,
          )
          return coordinates
  
      return spatial_coordinates_function
  
file_path: NiftyNet/niftynet/contrib/segmentation_selective_sampler/sampler_selective.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import tensorflow
  from scipy import ndimage
  from scipy.signal import fftconvolve
  from niftynet.engine.image_window import N_SPATIAL
  from niftynet.engine.sampler_uniform_v2 import UniformSampler
label_desc: Use image node_id 2 for calling the SelectiveSampler obj's underlying member method code with example usage: obj.selective_spatial_coordinates() and returns: spatial_coordinates_function, coordinates