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"]
code: def _parse_csv(self, path_to_csv, to_ohe):
      tf.logging.warning(
          "This method will read your entire csv into memory"
      )
      df_init = pd.read_csv(path_to_csv, index_col=0, header=None)
  
      df_init.index = df_init.index.map(str)
  
      if set(df_init.index) != set(self.subject_ids):
          print(
              "probably different because of split file - drop not "
              "relevant ones"
          )
          df_fin = df_init.drop(
              index=[
                  s
                  for s in set(df_init.index)
                  if s not in set(self.subject_ids)
              ]
          )
          # df.reset_index(drop=True, inplace=True)
  
          if set(df_fin.index) != set(self.subject_ids):
              print(set(self.subject_ids) - set(df_fin.index))
              tf.logging.fatal(
                  "csv file provided at: {} does not have "
                  "all the subject_ids".format(path_to_csv)
              )
              raise Exception
      else:
          df_fin = df_init.copy()
      if to_ohe and len(df_fin.columns) == 1:
          _dims = len(list(df_fin[1].unique()))
          _indexable_output = self.to_ohe(df_fin[1].values, _dims)
          return df_fin, _indexable_output, _dims
      elif not to_ohe and len(df_fin.columns) == 1:
          _dims = 1
          _indexable_output = self.to_categorical(
              df_fin[1].values, np.sort(df_fin[1].unique())
          )
          return df_fin, _indexable_output, _dims
      elif not to_ohe:
          _dims = len(df_fin.columns)
          _indexable_output = list(df_fin.values)
          return df_fin, _indexable_output, _dims
      tf.logging.fatal(
          "Unrecognised input format for {}".format(path_to_csv)
      )
      raise Exception(
          "Unrecognised input format for {}".format(path_to_csv)
      )
  
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 3 for calling the CSVReader obj's underlying member method code with example usage: obj._parse_csv(path_to_csv, to_ohe) and returns: df_fin,  _indexable_output,  _dims, df_fin,  _indexable_output,  _dims, df_fin,  _indexable_output,  _dims