region_centroids = RegionCentroids(134) region_centroids.update_barycentres(ds_testing.vx, pred_wo_centroids) # Generate and evaluate the dataset start_time = time.clock() dices = np.zeros((n_files, 134)) errors = np.zeros((n_files,)) pred_functions = {} for atlas_id in xrange(n_files): print "Atlas: {}".format(atlas_id) ls_vx = [] ls_pred = [] brain_batches = data_gen.generate_single_atlas(atlas_id, None, region_centroids, batch_size, True) vx_all, pred_all = net.predict_from_generator(brain_batches, scaler, pred_functions) # Construct the predicted image img_true = data_gen.atlases[atlas_id][1] img_pred = create_img_from_pred(vx_all, pred_all, img_true.shape) # Compute the dice coefficient and the error non_zo = img_pred.nonzero() or img_true.nonzero() pred = img_pred[non_zo] true = img_true[non_zo] dice_regions = compute_dice(pred, true, n_out) err_global = error_rate(pred, true) end_time = time.clock()
region_centroids.update_barycentres(ds_testing.vx, pred_wo_centroids) # Generate and evaluate the dataset start_time = time.clock() dices = np.zeros((n_files, 134)) errors = np.zeros((n_files, )) pred_functions = {} for atlas_id in xrange(n_files): print "Atlas: {}".format(atlas_id) ls_vx = [] ls_pred = [] brain_batches = data_gen.generate_single_atlas(atlas_id, None, region_centroids, batch_size, True) vx_all, pred_all = net.predict_from_generator(brain_batches, scaler, pred_functions) # Construct the predicted image img_true = data_gen.atlases[atlas_id][1] img_pred = create_img_from_pred(vx_all, pred_all, img_true.shape) # Compute the dice coefficient and the error non_zo = img_pred.nonzero() or img_true.nonzero() pred = img_pred[non_zo] true = img_true[non_zo] dice_regions = compute_dice(pred, true, n_out) err_global = error_rate(pred, true)
# region_centroids = RegionCentroids(134) # region_centroids.update_barycentres(ds_testing.vx, pred_wo_centroids) # Generate and evaluate the dataset dices = np.zeros((n_files, 134)) errors = np.zeros((n_files, )) pred_functions = {} # for atlas_id in xrange(n_files): for atlas_id in xrange(1): start_time = time.clock() print "Atlas: {}".format(atlas_id) ls_vx = [] ls_pred = [] brain_batches = data_gen.generate_single_atlas(atlas_id, None, None, batch_size, True) vx_all, pred_all = net.predict_from_generator(brain_batches, scaler, pred_functions) # Construct the predicted image img_true = data_gen.atlases[atlas_id][1] img_pred = create_img_from_pred(vx_all, pred_all, img_true.shape) # Compute the dice coefficient and the error non_zo = img_pred.nonzero() or img_true.nonzero() pred = img_pred[non_zo] true = img_true[non_zo] dice_regions = net.compute_dice(pred, true, n_out) err_global = error_rate(pred, true)