class_docstr: This class generates samples using the coordinates of the centre as
  extracted from a csv file
  
  This layer can be considered as a "guided cropping" layer of the
  input image based on preselected input.
class_docstr_tok: ["This","class","generates","samples","using","the","coordinates","of","the","centre","as","extracted","from","a","csv","file","This","layer","can","be","considered","as","a","``","guided","cropping","''","layer","of","the","input","image","based","on","preselected","input","."]
code: def check_csv_sampler_valid(self, subject_id, img_sizes, win_sizes):
      print("Checking if csv_sampler valid is updated")
      reject = False
      if self.mode_correction != "pad":
          reject = True
      idx_multi, csv_data, _ = self.csv_reader(
          subject_id=subject_id, idx=None, mode="multi", reject=reject
      )
  
      windows_centres = csv_data["sampler"]
      # print("Windows extracted", windows_centres)
      numb = windows_centres.shape[0]
      if windows_centres.shape[0] > 0:
          checked = self.csv_reader.valid_by_task["sampler"][
              idx_multi["sampler"]
          ]
          print(np.sum(checked), "is sum of checked")
          min_checked = np.min(checked)
          numb_valid = np.sum(checked)
      else:
          min_checked = 0
          numb_valid = 0
      if min_checked >= 0:
          print("Already checked, no need for further analysis")
          return numb, numb - numb_valid
      else:
          transformed_centres = self.transform_centres(
              subject_id, img_sizes, windows_centres
          )
  
          img_spatial_size, win_spatial_size = _infer_spatial_size(
              img_sizes, win_sizes
          )
          tf.logging.warning(
              "Need to checked validity of samples for "
              "subject %s" % subject_id
          )
          checked = np.ones([numb])
          pad = np.zeros([numb, 2 * N_SPATIAL])
          print(list(win_sizes))
          for mod in list(win_sizes):
              print("mod is %s" % mod)
              print(img_spatial_size)
              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(
                  (numb, N_SPATIAL * 2), dtype=np.int32
              )
              half_win_tiled = np.tile(half_win[:N_SPATIAL], [numb, 1])
              reshaped_windows = np.reshape(
                  transformed_centres[:, :N_SPATIAL],
                  half_win_tiled.shape,
              )
              spatial_coords[:, :N_SPATIAL] = (
                  reshaped_windows - half_win_tiled
              )
  
              min_spatial_coords = np.max(-1 * spatial_coords, 1)
              checked = np.asarray(
                  np.where(
                      min_spatial_coords > 0,
                      np.zeros_like(checked),
                      checked,
                  )
              )
              pad = np.maximum(-1 * spatial_coords, pad)
              # Make the opposite corner of the window is
              # just adding the mod specific window size
              spatial_coords[:, N_SPATIAL:] = spatial_coords[
                  :, :N_SPATIAL
              ] + np.tile(win_size[:N_SPATIAL], [numb, 1])
  
              max_spatial_coords = np.max(
                  spatial_coords[:, N_SPATIAL:]
                  - np.tile(img_spatial_size, [numb, 1]),
                  axis=1,
              )
              diff_spatial_size = spatial_coords[
                  :, N_SPATIAL:
              ] - np.tile(img_spatial_size, [numb, 1])
              checked = np.asarray(
                  np.where(
                      max_spatial_coords > 0,
                      np.zeros_like(checked),
                      checked,
                  )
              )
              pad[:, N_SPATIAL:] = np.maximum(
                  diff_spatial_size, pad[:, N_SPATIAL:]
              )
  
              tf.logging.warning(
                  "to discard or pad is %d out of %d for mod "
                  "%s" % (numb - np.sum(checked), numb, mod)
              )
  
          idx_discarded = []
          for i in range(0, len(checked)):
              self.csv_reader.valid_by_task["sampler"][
                  idx_multi["sampler"][i]
              ] = checked[i]
              self.csv_reader.pad_by_task["sampler"][
                  idx_multi["sampler"][i]
              ] = pad[i]
              if checked[i] == 0:
                  idx_discarded.append(idx_multi["sampler"][i])
          # self.csv_reader.valid_by_task['sampler'][np.asarray(idx_multi[
          #     'sampler'])] = checked
          print("Updated check")
          if np.sum(checked) < numb:
              tf.logging.warning(
                  "The following indices are not valid for "
                  "%s %s "
                  % (subject_id, " ".join(map(str, idx_discarded)))
              )
          print(
              "updated valid part of csv_reader for subject %s"
              % subject_id
          )
          return numb, numb - np.sum(checked)
  
file_path: NiftyNet/niftynet/contrib/csv_reader/sampler_csvpatch.py
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import tensorflow
  from niftynet.contrib.csv_reader.sampler_csv_rows import ImageWindowDatasetCSV
  from niftynet.engine.image_window import N_SPATIAL, LOCATION_FORMAT
  from niftynet.io.misc_io import do_reorientation_idx, do_resampling_idx
label_desc: Use image node_id 5 for calling the CSVPatchSampler obj's underlying member method code with example usage: obj.check_csv_sampler_valid(subject_id, img_sizes, win_sizes) and returns: numb,  unknown, numb,  unknown