class TestWrapper:
    def __init__(self, wa, cv_stage, epoch):
        self.wa = wa
        self.cv_stage = cv_stage
        self.epoch = epoch
        self.label = str_label(wa, cv_stage, epoch)

    def run(self, r_rand=0.5, stage=0):
        path2model = label2model(self.wa, self.cv_stage,
                                 self.epoch)['path2model']
        self.test = SimpleTest(paths2model=[path2model],
                               r_rand=r_rand,
                               stage=stage)

    def eval_metrics(self):
        result = run_test(self.test, mode='froc', left=-1, thr_number=10)
        self.mc = FROCMetricsCalculator(result, label=self.label)

    def load(self, subfolder=None):
        self.mc = FROCMetricsCalculator(label=self.label)
        subfolder = '' if subfolder is None else subfolder
        load_path = opjoin(subfolder, self.label)
        self.mc.load(load_path + '.npy')

    def save(self, subfolder):
        self.mc.save(subfolder)
 def eval_metrics(self):
     baseline_result = run_test(self.test, mode='froc', left=-1, thr_number=10, net_number=0)
     augmented_result = run_test(self.test, mode='froc', left=-1, thr_number=10, net_number=1)
     self.baseline_mc = FROCMetricsCalculator(baseline_result, label=self.baseline_label)
     self.augmented_mc = FROCMetricsCalculator(augmented_result, label=self.augmented_label)
     second_baseline_result = run_test(self.test, mode='froc', left=-1, thr_number=10, net_number=2)
     second_baseline_mc = FROCMetricsCalculator(second_baseline_result, label='label')
     self.baseline_mc.roc_result = np.add(self.baseline_mc.roc_result, second_baseline_mc.roc_result)
    def load(self, subfolder=None):
        self.baseline_mc = FROCMetricsCalculator(label=self.baseline_label)
        subfolder = '' if subfolder is None else subfolder
        baseline_load_path = opjoin(subfolder, self.baseline_label)
        self.baseline_mc.load(baseline_load_path + '.npy')

        self.augmented_mc = FROCMetricsCalculator(label=self.augmented_label)
        aug_load_path = opjoin(subfolder, self.augmented_label)
        self.augmented_mc.load(aug_load_path + '.npy')
class DoubleTestWrapper:
    def __init__(self, cv_stage, baseline_epoch, augmented_epoch, all_tta=False):
        self.cv_stage = cv_stage
        self.baseline_epoch = baseline_epoch
        self.augmented_epoch = augmented_epoch
        self.baseline_label = str_label(False, cv_stage, baseline_epoch)
        self.augmented_label = str_label(True, cv_stage, augmented_epoch)
        self.all_tta = all_tta

    def run(self, r_rand=0.5, stage=0):
        path2baseline = label2model(False, self.cv_stage, self.baseline_epoch)['path2model']
        path2augmented = label2model(True, self.cv_stage, self.augmented_epoch)['path2model']
        self.test = SimpleTest(paths2model=[path2baseline, path2augmented], r_rand=r_rand, stage=stage, all_tta=self.all_tta)

    def eval_metrics(self):
        baseline_result = run_test(self.test, mode='froc', left=-1, thr_number=10, net_number=0)
        augmented_result = run_test(self.test, mode='froc', left=-1, thr_number=10, net_number=1)
        self.baseline_mc = FROCMetricsCalculator(baseline_result, label=self.baseline_label)
        self.augmented_mc = FROCMetricsCalculator(augmented_result, label=self.augmented_label)

    def load(self, subfolder=None):
        self.baseline_mc = FROCMetricsCalculator(label=self.baseline_label)
        subfolder = '' if subfolder is None else subfolder
        baseline_load_path = opjoin(subfolder, self.baseline_label)
        self.baseline_mc.load(baseline_load_path + '.npy')

        self.augmented_mc = FROCMetricsCalculator(label=self.augmented_label)
        aug_load_path = opjoin(subfolder, self.augmented_label)
        self.augmented_mc.load(aug_load_path + '.npy')

    def save(self, subfolder):
        self.baseline_mc.save(subfolder)
        self.augmented_mc.save(subfolder)
 def load(self, subfolder=None):
     self.mc = FROCMetricsCalculator(label=self.label)
     subfolder = '' if subfolder is None else subfolder
     load_path = opjoin(subfolder, self.label)
     self.mc.load(load_path + '.npy')
 def eval_metrics(self):
     result = run_test(self.test, mode='froc', left=-1, thr_number=10)
     self.mc = FROCMetricsCalculator(result, label=self.label)
 def eval_metrics(self, left=-1, thr_number=10):
     result = run_test(self.test, mode=self.mode, left=left, thr_number=thr_number)
     self.mc = FROCMetricsCalculator(result, label=self.label) if self.mode == 'froc' else MetricsCalculator(result)