test_images = list_folders(path_test_cs) # all test cases cnt=0 path_test = path_test_cs for case in test_images: path_timepoints = jp(path_test, case) list_images = get_dictionary_with_paths_cs([case], path_test, eval(parameters_dict['input_data'])) list_rois = get_dictionary_with_paths_cs([case], path_test, [parameters_dict['brain_mask']]) patch_half = tuple([idx // 2 for idx in eval(parameters_dict['patch_size'])]) timepoints = list_folders(path_timepoints) # get candidate voxels all_infer_patches, all_coordenates = get_inference_patches( path_test=path_test, case = case, input_data=eval(parameters_dict['input_data']), roi=parameters_dict['brain_mask'], patch_shape=eval(parameters_dict['patch_size']), step=eval(parameters_dict['sampling_step']), normalize=eval(parameters_dict['normalize']), mode = "cs" ) for tp in range(len(timepoints)): cls() print("Fold: ", f) print("Patient", cnt+1, "/", len(test_images)) print("Timepoint ", tp+1) infer_patches = all_infer_patches[tp] coordenates = all_coordenates[tp]
#Evaluate all test images columns = ['Case', 'DSC', 'HD'] df = pd.DataFrame(columns=columns) test_images = list_folders(path_test) i_row = 0 cnt = 0 for case in test_images: print(cnt + 1, "/", len(test_images)) scan_path = jp(path_test, case) infer_patches, coordenates = get_inference_patches( scan_path=scan_path, input_data=options['input_data'], roi="T1_bet_mask.nii.gz", patch_shape=options['patch_size'], step=options['sampling_step'], normalize=options['normalize']) batch_size = options['batch_size'] lesion_out = build_image(infer_patches, lesion_model, device, 2, options) scan_numpy = nib.load(jp(scan_path, "FLAIR_masked.nii.gz")).get_fdata() all_probs = np.zeros( (scan_numpy.shape[0], scan_numpy.shape[1], scan_numpy.shape[2], 2)) for i in range(options['num_classes']): all_probs[:, :, :, i] = reconstruct_image(lesion_out[:, i], coordenates,