class_docstr: Class that performs the reading of the csv_input and select the lines
  according to the subject id if available
class_docstr_tok: ["Class","that","performs","the","reading","of","the","csv_input","and","select","the","lines","according","to","the","subject","id","if","available"]
docstr: this function takes in a data_param specifying the name of the source and the location of
  the csv data. Three input modes are supported:
  - 'label' - expects a csv with header subject_id,label.
  - 'features' - expects a csv with header subject_id,<name of feature 1>,<name of feature 2>
  e.g.::
  
       data_param = {'label': {'csv_data_file': 'path/to/some_data.csv', 'to_ohe': False}}
       
  :param data_param: dictionary of input sections
  :param task_param: Namespace object
  :param file_list: a dataframe generated by ImagePartitioner
  :param sample_per_volume: number of samples taken per volume (useful
  to know how much to tile the csv output
      for cross validation, so
      that the reader only loads files in training/inference phases.
docstr_tok: ["this","function","takes","in","a","data_param","specifying","the","name","of","the","source","and","the","location","of","the","csv","data",".","Three","input","modes","are","supported",":","-","'label","'","-","expects","a","csv","with","header","subject_id",",","label",".","-","'features","'","-","expects","a","csv","with","header","subject_id",",","<","name","of","feature","1",">",",","<","name","of","feature","2",">","e.g",".",":",":","data_param","=","{","'label","'",":","{","'csv_data_file","'",":","'path\/to\/some_data.csv","'",",","'to_ohe","'",":","False","}","}",":","param","data_param",":","dictionary","of","input","sections",":","param","task_param",":","Namespace","object",":","param","file_list",":","a","dataframe","generated","by","ImagePartitioner",":","param","sample_per_volume",":","number","of","samples","taken","per","volume","(","useful","to","know","how","much","to","tile","the","csv","output","for","cross","validation",",","so","that","the","reader","only","loads","files","in","training\/inference","phases","."]
code: def initialise(
      self,
      data_param,
      task_param=None,
      file_list=None,
      sample_per_volume=1,
  ):
      """
      this function takes in a data_param specifying the name of the source and the location of
      the csv data. Three input modes are supported:
      - 'label' - expects a csv with header subject_id,label.
      - 'features' - expects a csv with header subject_id,<name of feature 1>,<name of feature 2>
      e.g.::
  
           data_param = {'label': {'csv_data_file': 'path/to/some_data.csv', 'to_ohe': False}}
  
      :param data_param: dictionary of input sections
      :param task_param: Namespace object
      :param file_list: a dataframe generated by ImagePartitioner
      :param sample_per_volume: number of samples taken per volume (useful
      to know how much to tile the csv output
          for cross validation, so
          that the reader only loads files in training/inference phases.
      """
      assert self.names is not None
      data_param = param_to_dict(data_param)
      self.n_samples_per_id = sample_per_volume
      print(data_param)
      if not task_param:
          task_param = {mod: (mod,) for mod in list(data_param)}
      try:
          if not isinstance(task_param, dict):
              task_param = vars(task_param)
      except ValueError:
          tf.logging.fatal(
              "To concatenate multiple input data arrays,\n"
              "task_param should be a dictionary in the form:\n"
              "{'new_modality_name': ['modality_1', 'modality_2',...]}."
          )
          raise
      self.task_param = task_param
      valid_names = [
          name for name in self.names if self.task_param.get(name, None)
      ]
      if not valid_names:
          tf.logging.fatal(
              "CSVReader requires task input keywords %s, but "
              "not exist in the config file.\n"
              "Available task keywords: %s",
              self.names,
              list(self.task_param),
          )
          raise ValueError
      self.names = valid_names
      self.data_param = data_param
      self._dims = None
      self._indexable_output = {}
      self.file_list = file_list
      self.subject_ids = self.file_list["subject_id"].values
  
      self._input_sources = dict(
          (name, self.task_param.get(name)) for name in self.names
      )
      self.df_by_task = {}
      self.valid_by_task = {}
      self.pad_by_task = {}
      self.dims_by_task = {}
      self.type_by_task = {}
  
      for name in valid_names:
          df_fin, _indexable_output, _dims = self._parse_csv(
              path_to_csv=data_param[name].get("csv_data_file", None),
              to_ohe=data_param[name].get("to_ohe", False),
          )
          self.df_by_task[name] = df_fin
          self.dims_by_task[name] = _dims
          self._indexable_output[name] = _indexable_output
          self.valid_by_task[name] = -1 * np.ones(
              [self.df_by_task[name].shape[0]]
          )  # -1 means they have not been checked
  
          self.pad_by_task[name] = np.zeros(
              [self.df_by_task[name].shape[0], 2 * _dims]
          )
          if df_fin.shape[0] > len(set(self.subject_ids)):
              self.type_by_task[name] = "multi"
          else:
              self.type_by_task[name] = "mono"
      # Converts Dictionary of Lists to List of Dictionaries
      # self._indexable_output = pd.DataFrame(
      # self._indexable_output).to_dict('records')
      assert file_list is not None
      return self
  
imports: import random
  import numpy
  import pandas
  import tensorflow
  from tensorflow.python.data.util import nest
  from niftynet.layer.base_layer import Layer
  from niftynet.io.image_reader import param_to_dict
label_desc: Use image node_id 2 for calling the CSVReader obj's underlying member method code with example usage: obj.initialise(data_param, task_param, file_list, sample_per_volume) and returns: self