code: def __init__(self, server_env=None):
      #########################
      #    Preprocessing      #
      #########################
  
      self.root_dir = "/home/gregor/datasets/toy_mdt"
  
      #########################
      #         I/O           #
      #########################
  
      # one out of [2, 3]. dimension the model operates in.
      self.dim = 2
  
      # one out of ['mrcnn', 'retina_net', 'retina_unet', 'detection_unet', 'ufrcnn', 'detection_unet'].
      self.model = "mrcnn"
  
      DefaultConfigs.__init__(self, self.model, server_env, self.dim)
  
      # int [0 < dataset_size]. select n patients from dataset for prototyping.
      self.select_prototype_subset = None
      self.hold_out_test_set = True
      # including val set. will be 3/4 train, 1/4 val.
      self.n_train_val_data = 1500
  
      # choose one of the 3 toy experiments described in https://arxiv.org/pdf/1811.08661.pdf
      # one of ['donuts_shape', 'donuts_pattern', 'circles_scale'].
      toy_mode = "donuts_shape_noise"
  
      # path to preprocessed data.
      self.input_df_name = "info_df.pickle"
      self.pp_name = os.path.join(toy_mode, "train")
      self.pp_data_path = os.path.join(self.root_dir, self.pp_name)
      self.pp_test_name = os.path.join(toy_mode, "test")
      self.pp_test_data_path = os.path.join(
          self.root_dir, self.pp_test_name
      )
  
      # settings for deployment in cloud.
      if server_env:
          # path to preprocessed data.
          pp_root_dir = "/datasets/datasets_ramien/toy_exp/data"
          self.pp_name = os.path.join(toy_mode, "train")
          self.pp_data_path = os.path.join(pp_root_dir, self.pp_name)
          self.pp_test_name = os.path.join(toy_mode, "test")
          self.pp_test_data_path = os.path.join(
              pp_root_dir, self.pp_test_name
          )
          self.select_prototype_subset = None
  
      #########################
      #      Data Loader      #
      #########################
  
      # select modalities from preprocessed data
      self.channels = [0]
      self.n_channels = len(self.channels)
  
      # patch_size to be used for training. pre_crop_size is the patch_size before data augmentation.
      self.pre_crop_size_2D = [320, 320]
      self.patch_size_2D = [320, 320]
  
      self.patch_size = (
          self.patch_size_2D if self.dim == 2 else self.patch_size_3D
      )
      self.pre_crop_size = (
          self.pre_crop_size_2D
          if self.dim == 2
          else self.pre_crop_size_3D
      )
  
      # ratio of free sampled batch elements before class balancing is triggered
      # (>0 to include "empty"/background patches.)
      self.batch_sample_slack = 0.2
  
      # set 2D network to operate in 3D images.
      self.merge_2D_to_3D_preds = False
  
      # feed +/- n neighbouring slices into channel dimension. set to None for no context.
      self.n_3D_context = None
      if self.n_3D_context is not None and self.dim == 2:
          self.n_channels *= self.n_3D_context * 2 + 1
  
      #########################
      #      Architecture      #
      #########################
  
      self.start_filts = 48 if self.dim == 2 else 18
      self.end_filts = (
          self.start_filts * 4
          if self.dim == 2
          else self.start_filts * 2
      )
      self.res_architecture = "resnet50"  # 'resnet101' , 'resnet50'
      self.norm = None  # one of None, 'instance_norm', 'batch_norm'
      self.weight_decay = 0
  
      # one of 'xavier_uniform', 'xavier_normal', or 'kaiming_normal', None (=default = 'kaiming_uniform')
      self.weight_init = None
  
      #########################
      #  Schedule / Selection #
      #########################
  
      self.num_epochs = 24
      self.num_train_batches = 100 if self.dim == 2 else 200
      self.batch_size = 20 if self.dim == 2 else 8
  
      self.do_validation = True
      # decide whether to validate on entire patient volumes (like testing) or sampled patches (like training)
      # the former is morge accurate, while the latter is faster (depending on volume size)
      self.val_mode = (
          "val_patient"  # one of 'val_sampling' , 'val_patient'
      )
      if self.val_mode == "val_patient":
          self.max_val_patients = (
              None  # if 'None' iterates over entire val_set once.
          )
      if self.val_mode == "val_sampling":
          self.num_val_batches = 50
  
      #########################
      #   Testing / Plotting  #
      #########################
  
      # set the top-n-epochs to be saved for temporal averaging in testing.
      self.save_n_models = 5
      self.test_n_epochs = 5
  
      # set a minimum epoch number for saving in case of instabilities in the first phase of training.
      self.min_save_thresh = 0 if self.dim == 2 else 0
  
      self.report_score_level = [
          "patient",
          "rois",
      ]  # choose list from 'patient', 'rois'
      self.class_dict = {
          1: "benign",
          2: "malignant",
      }  # 0 is background.
      self.patient_class_of_interest = (
          2  # patient metrics are only plotted for one class.
      )
      self.ap_match_ious = [
          0.1
      ]  # list of ious to be evaluated for ap-scoring.
  
      self.model_selection_criteria = [
          "benign_ap",
          "malignant_ap",
      ]  # criteria to average over for saving epochs.
      self.min_det_thresh = 0.1  # minimum confidence value to select predictions for evaluation.
  
      # threshold for clustering predictions together (wcs = weighted cluster scoring).
      # needs to be >= the expected overlap of predictions coming from one model (typically NMS threshold).
      # if too high, preds of the same object are separate clusters.
      self.wcs_iou = 1e-5
  
      self.plot_prediction_histograms = True
      self.plot_stat_curves = False
  
      #########################
      #   Data Augmentation   #
      #########################
  
      self.da_kwargs = {
          "do_elastic_deform": True,
          "alpha": (0.0, 1500.0),
          "sigma": (30.0, 50.0),
          "do_rotation": True,
          "angle_x": (0.0, 2 * np.pi),
          "angle_y": (0.0, 0),
          "angle_z": (0.0, 0),
          "do_scale": True,
          "scale": (0.8, 1.1),
          "random_crop": False,
          "rand_crop_dist": (
              self.patch_size[0] / 2.0 - 3,
              self.patch_size[1] / 2.0 - 3,
          ),
          "border_mode_data": "constant",
          "border_cval_data": 0,
          "order_data": 1,
      }
  
      if self.dim == 3:
          self.da_kwargs["do_elastic_deform"] = False
          self.da_kwargs["angle_x"] = (0, 0.0)
          self.da_kwargs["angle_y"] = (0, 0.0)  # must be 0!!
          self.da_kwargs["angle_z"] = (0.0, 2 * np.pi)
  
      #########################
      #   Add model specifics #
      #########################
  
      {
          "detection_unet": self.add_det_unet_configs,
          "mrcnn": self.add_mrcnn_configs,
          "ufrcnn": self.add_mrcnn_configs,
          "ufrcnn_surrounding": self.add_mrcnn_configs,
          "retina_net": self.add_mrcnn_configs,
          "retina_unet": self.add_mrcnn_configs,
          "prob_detector": self.add_mrcnn_configs,
      }[self.model]()
  
file_path: medicaldetectiontoolkit/experiments/toy_exp/configs.py
imports: import sys
  import os
  import numpy
  from default_configs import DefaultConfigs
label_desc: Use image node_id 1 to create a new configs object from inherited base classes: DefaultConfigs with example: obj = configs(server_env)