class_docstr: This class represents the application logic for evaluating a set of
  results inferred within NiftyNet (or externally generated)
docstr: This is the main application logic for evaluation.
  Computation of all metrics for all subjects is delegated to an
  Evaluator objects owned by the application object. The resulting
  metrics are aggregated as defined by the evaluation classes and
  output to one or more csv files (based on their 'group_by' headings).
  For example, per-subject metrics will be in one file, per-label-class
  metrics will be in another and per-subject-per-class will be in a
  third.
  :return:
docstr_tok: ["This","is","the","main","application","logic","for","evaluation",".","Computation","of","all","metrics","for","all","subjects","is","delegated","to","an","Evaluator","objects","owned","by","the","application","object",".","The","resulting","metrics","are","aggregated","as","defined","by","the","evaluation","classes","and","output","to","one","or","more","csv","files","(","based","on","their","'group_by","'","headings",")",".","For","example",",","per-subject","metrics","will","be","in","one","file",",","per-label-class","metrics","will","be","in","another","and","per-subject-per-class","will","be","in","a","third",".",":","return",":"]
code: def run(self, application):
      """
      This is the main application logic for evaluation.
      Computation of all metrics for all subjects is delegated to an
      Evaluator objects owned by the application object. The resulting
      metrics are aggregated as defined by the evaluation classes and
      output to one or more csv files (based on their 'group_by' headings).
      For example, per-subject metrics will be in one file, per-label-class
      metrics will be in another and per-subject-per-class will be in a
      third.
      :return:
      """
      start_time = time.time()
      try:
          if not os.path.exists(self.eval_param.save_csv_dir):
              os.makedirs(self.eval_param.save_csv_dir)
          # iteratively run the graph
          all_results = application.evaluator.evaluate()
          for group_by, data_frame in all_results.items():
              if group_by == (None,):
                  csv_id = ""
              else:
                  csv_id = "_".join(group_by)
  
              with open(
                  os.path.join(
                      self.eval_param.save_csv_dir,
                      "eval_" + csv_id + ".csv",
                  ),
                  "w",
              ) as csv:
                  csv.write(
                      data_frame.reset_index().to_csv(index=False)
                  )
      except KeyboardInterrupt:
          tf.logging.warning("User cancelled application")
      except RuntimeError:
          import sys
          import traceback
  
          exc_type, exc_value, exc_traceback = sys.exc_info()
          traceback.print_exception(
              exc_type, exc_value, exc_traceback, file=sys.stdout
          )
      finally:
          tf.logging.info("Cleaning up...")
          tf.logging.info(
              "%s stopped (time in second %.2f).",
              type(application).__name__,
              (time.time() - start_time),
          )
  
file_path: NiftyNet/niftynet/evaluation/evaluation_application_driver.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import time
  import itertools
  import pandas
  import tensorflow
  from niftynet.engine.application_factory import ApplicationFactory
  from niftynet.io.misc_io import touch_folder
  from niftynet.io.image_sets_partitioner import ImageSetsPartitioner
label_desc: Use image node_id 3 for calling the EvaluationApplicationDriver obj's underlying member method code with example usage: obj.run(application) without return types