} with open(args.save_dir + '/eval_experiment_{}.txt'.format(args.save_exp_code), 'w') as f: print(settings, file=f) f.close() print(settings) if args.task == 'task_1_tumor_vs_normal': args.n_classes = 2 dataset = Generic_MIL_Dataset( csv_path='dataset_csv/tumor_vs_normal_dummy_clean.csv', data_dir=os.path.join(args.data_root_dir, 'tumor_vs_normal_resnet_features'), shuffle=False, print_info=True, label_dict={ 'normal_tissue': 0, 'tumor_tissue': 1 }, patient_strat=False, ignore=[]) elif args.task == 'task_2_tumor_subtyping': args.n_classes = 3 dataset = Generic_MIL_Dataset( csv_path='dataset_csv/tumor_subtyping_dummy_clean.csv', data_dir=os.path.join(args.data_root_dir, 'tumor_subtyping_resnet_features'), shuffle=False, print_info=True, label_dict={
settings.update({ 'bag_weight': args.bag_weight, 'inst_loss': args.inst_loss, 'B': args.B }) print('\nLoad Dataset') if args.task == 'camelyon_40x_cv': args.n_classes = 2 dataset = Generic_MIL_Dataset(csv_path='dataset_csv/camelyon_clean.csv', data_dir=os.path.join( args.data_root_dir, 'camelyon_feat_resnet'), shuffle=False, seed=args.seed, print_info=True, label_dict={ 'normal_tissue': 0, 'tumor_tissue': 1 }, patient_strat=False, ignore=[]) elif args.task == 'tcga_kidney_cv': args.n_classes = 3 dataset = Generic_MIL_Dataset(csv_path='dataset_csv/tcga_kidney_clean.csv', data_dir=os.path.join( args.data_root_dir, 'tcga_kidney_resnet_features'), shuffle=False, seed=args.seed,
'bag_weight': args.bag_weight, 'inst_loss': args.inst_loss, 'B': args.B }) print('\nLoad Dataset') if args.task == 'task_1_tumor_vs_normal': args.n_classes = 2 dataset = Generic_MIL_Dataset( csv_path='dataset_csv/tumor_vs_normal_dummy_clean.csv', data_dir=os.path.join(args.data_root_dir, 'tumor_vs_normal_resnet_features'), shuffle=False, seed=args.seed, print_info=True, label_dict={ 'normal_tissue': 0, 'tumor_tissue': 1 }, patient_strat=False, ignore=[]) elif args.task == 'task_2_tumor_subtyping': args.n_classes = 3 dataset = Generic_MIL_Dataset( csv_path='dataset_csv/tumor_subtyping_dummy_clean.csv', data_dir=os.path.join(args.data_root_dir, 'tumor_subtyping_resnet_features'), shuffle=False, seed=args.seed,
} with open(args.save_dir + '/eval_experiment_{}.txt'.format(args.save_exp_code), 'w') as f: print(settings, file=f) f.close() print(settings) if args.task == 'camelyon_40x_cv': args.n_classes = 2 dataset = Generic_MIL_Dataset(csv_path='dataset_csv/camelyon_clean.csv', data_dir=os.path.join( args.data_root_dir, 'camelyon_40x_resnet_features'), shuffle=False, print_info=True, label_dict={ 'normal_tissue': 0, 'tumor_tissue': 1 }, patient_strat=False, ignore=[]) elif args.task == 'tcga_kidney_cv': args.n_classes = 3 dataset = Generic_MIL_Dataset(csv_path='dataset_csv/tcga_kidney_clean.csv', data_dir=os.path.join( args.data_root_dir, 'tcga_kidney_resnet_features'), shuffle=False, print_info=True, label_dict={
'model_size': args.model_size, "use_drop_out": args.drop_out, 'weighted_sample': args.weighted_sample, 'opt': args.opt } print('\nLoad Dataset') if args.task == 'camelyon_40x_cv': args.n_classes = 2 dataset = Generic_MIL_Dataset(csv_path='dataset_csv/camelyon_clean.csv', data_dir=os.path.join( args.data_root_dir, 'camelyon_feat_resnet'), shuffle=False, seed=args.seed, print_info=True, label_dict={ 'normal_tissue': 0, 'tumor_tissue': 1 }, patient_strat=False, ignore=[]) elif args.task == 'colon_cancer': args.n_classes = 2 dataset = Generic_MIL_Dataset( csv_path='dataset_csv/label_information_colon.csv', data_dir=os.path.join(args.data_root_dir, 'resnet_features_colon'), shuffle=False, seed=args.seed, print_info=True,
'subtype_1': 0, 'subtype_2': 1, 'subtype_3': 2 }, patient_strat=True, patient_voting='maj', ignore=[]) elif args.task == 'hpa': args.n_classes = 19 dataset = Generic_MIL_Dataset(csv_path='/content/label_df.csv', data_dir='/content/feature', shuffle=False, seed=args.seed, print_info=True, label_dict={i: i for i in range(19)}, patient_strat=False, ignore=[], hpa=True) else: raise NotImplementedError num_slides_cls = np.array( [len(cls_ids) for cls_ids in dataset.patient_cls_ids]) val_num = np.round(num_slides_cls * args.val_frac).astype(int) test_num = np.round(num_slides_cls * args.test_frac).astype(int) if __name__ == '__main__': if args.label_frac > 0: