code: def main():
      system_param, input_data_param = user_parameters_parser.run()
      if util.has_bad_inputs(system_param):
          return -1
  
      # print all parameters to txt file for future reference
      all_param = {}
      all_param.update(system_param)
      all_param.update(input_data_param)
  
      # Set up path for niftynet model_root
      # (rewriting user input with an absolute path)
      system_param["SYSTEM"].model_dir = resolve_module_dir(
          system_param["SYSTEM"].model_dir,
          create_new=system_param["SYSTEM"].action == TRAIN,
      )
  
      # writing all params for future reference
      txt_file = "settings_{}.txt".format(system_param["SYSTEM"].action)
      txt_file = os.path.join(
          system_param["SYSTEM"].model_dir, txt_file
      )
      try:
          util.print_save_input_parameters(all_param, txt_file)
      except IOError:
          tf.logging.fatal(
              "Unable to write %s,\nplease check "
              "model_dir parameter, current value: %s",
              txt_file,
              system_param["SYSTEM"].model_dir,
          )
          raise
  
      # keep all commandline outputs to model_root
      log_file_name = os.path.join(
          system_param["SYSTEM"].model_dir,
          "{}_{}".format(all_param["SYSTEM"].action, "niftynet_log"),
      )
      set_logger(file_name=log_file_name)
  
      # set up all model folder related parameters here
      # see https://cmiclab.cs.ucl.ac.uk/CMIC/NiftyNet/issues/168
      # 1. resolve mapping file:
      try:
          if system_param["NETWORK"].histogram_ref_file:
              system_param[
                  "NETWORK"
              ].histogram_ref_file = to_absolute_path(
                  input_path=system_param["NETWORK"].histogram_ref_file,
                  model_root=system_param["SYSTEM"].model_dir,
              )
      except (AttributeError, KeyError):
          pass
      # 2. resolve output file:
      try:
          if system_param["INFERENCE"].save_seg_dir:
              system_param["INFERENCE"].save_seg_dir = to_absolute_path(
                  input_path=system_param["INFERENCE"].save_seg_dir,
                  model_root=system_param["SYSTEM"].model_dir,
              )
      except (AttributeError, KeyError):
          pass
      # 3. resolve dataset splitting file:
      try:
          if system_param["SYSTEM"].dataset_split_file:
              system_param[
                  "SYSTEM"
              ].dataset_split_file = to_absolute_path(
                  input_path=system_param["SYSTEM"].dataset_split_file,
                  model_root=system_param["SYSTEM"].model_dir,
              )
      except (AttributeError, KeyError):
          pass
  
      # 4. resolve evaluation dir:
      try:
          if system_param["EVALUATION"].save_csv_dir:
              system_param[
                  "EVALUATION"
              ].save_csv_dir = to_absolute_path(
                  input_path=system_param["EVALUATION"].save_csv_dir,
                  model_root=system_param["SYSTEM"].model_dir,
              )
      except (AttributeError, KeyError):
          pass
  
      # start application
      driver_table = {
          TRAIN: ApplicationDriver,
          INFER: ApplicationDriver,
          EVAL: EvaluationApplicationDriver,
      }
      app_driver = driver_table[system_param["SYSTEM"].action]()
      app_driver.initialise_application(system_param, input_data_param)
      app_driver.run(app_driver.app)
  
      if tf.get_default_session() is not None:
          tf.get_default_session().close()
      tf.reset_default_graph()
      close_logger()
  
      return 0
  
file_path: NiftyNet/niftynet/__init__.py
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import unicode_literals
  from niftynet.utilities.versioning import get_niftynet_version_string
  import os
  from tensorflow.python.util import deprecation
  from niftynet.io.misc_io import set_logger, close_logger
  from niftynet.utilities.util_import import require_module
  from tensorflow.python.util import deprecation
  from niftynet.engine.signal import TRAIN, INFER, EVAL
  import niftynet.utilities.util_common
  import niftynet.utilities.user_parameters_parser
  from niftynet.engine.application_driver import ApplicationDriver
  from niftynet.evaluation.evaluation_application_driver import EvaluationApplicationDriver
  from niftynet.io.misc_io import touch_folder
  from niftynet.io.misc_io import resolve_module_dir
  from niftynet.io.misc_io import to_absolute_path
label_desc: Use image node_id 1 for calling a global function with example usage: main() and returns: int, unknown