Skip to content

Commit 1cd4312

Browse files
Fix metrics initialization in compute_validation_metrics for proper label handling
1 parent 670ff15 commit 1cd4312

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

monai/nvflare/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ def compute_validation_metrics(gt_folder, pred_folder, n_labels=1):
378378
{
379379
"prediction_file": os.path.join(pred_folder, file),
380380
"metrics": {
381-
"1": {}
382381
}
383382
}
384383
)
@@ -408,6 +407,7 @@ def compute_validation_metrics(gt_folder, pred_folder, n_labels=1):
408407
)
409408
dice = dice_fn(to_onehot(pred_array[None])[None], to_onehot(gt_array[None])[None])
410409
for label_id in range(1,1+n_labels):
410+
summary['metric_per_case'][idx]["metrics"][str(label_id)] = {}
411411
summary['metric_per_case'][idx]["metrics"][str(label_id)]["HD95"] = hd_95[label_id-1][0].item()
412412
summary['metric_per_case'][idx]["metrics"][str(label_id)]["ASD"] = asd[label_id-1][0].item()
413413
summary['metric_per_case'][idx]["metrics"][str(label_id)]["Dice"] = dice[label_id-1][0].item()

0 commit comments

Comments
 (0)